QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#649907#7750. Revenge on My BossLavender_FieldWA 760ms7372kbC++201.6kb2024-10-18 11:27:222024-10-18 11:27:26

Judging History

你现在查看的是最新测评结果

  • [2024-10-18 11:27:26]
  • 评测
  • 测评结果:WA
  • 用时:760ms
  • 内存:7372kb
  • [2024-10-18 11:27:22]
  • 提交

answer

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define ROF(i,a,b) for(int i = a; i >= b; --i)
typedef long long ll;
using namespace std;

inline int rd() {
	int r = 0; bool w = false; char ch = getchar();
	while( ch < '0' || ch > '9' ) w = !(ch^45), ch = getchar();
	while( ch >= '0' && ch <= '9' ) r = (r<<1) + (r<<3) + (ch^48), ch = getchar();
	return w ? -r : r;
}

#define MAXN 100000
const ll INF = 1e18;
int n;
int a[MAXN+5], b[MAXN+5], c[MAXN+5];
int otp[MAXN+5], out[MAXN+5];
ll B, sum;

struct node {
    double e;
    int d, id;
}arr[MAXN+5];
bool cmp(const node &a , const node &b) {
    if( (a.d > 0) ^ (b.d > 0) ) return (a.d > 0) < (b.d > 0);
    if( a.d <= 0 ) return  a.e - a.d > b.e - b.d;
    return a.e + a.d < b.e + b.d;
}


bool chk( ll x ) {
    ll now = 0;
    FOR(i,1,n) arr[i].e = x / c[i] - b[i] - B, arr[i].d = a[i] - b[i], arr[i].id = i;
    sort(arr+1, arr+1+n, cmp);
    FOR(i,1,n) {
        now += arr[i].d;
        if( now > arr[i].e ) return 0;
    }
    FOR(i,1,n) otp[i] = arr[i].id;
    return 1;
}
void solve() {
    B = 0, sum = 0;
    n = rd();
    FOR(i,1,n) a[i] = rd(), b[i] = rd(), c[i] = rd(), B += b[i], sum += a[i] - b[i];
    ll l = 0, r = INF, ans = 0;
    while( l <= r ) {
        ll mid = (l + r) >> 1;
        if( chk(mid) ) {
            r = mid - 1;
            ans = mid;
            FOR(i, 1, n) out[i] = otp[i];
        } else l = mid + 1;
    }
    // printf("%lld\n", ans);
    FOR(i,1,n) printf("%d ",out[i]);
    putchar('\n');
}

int main() {
    int T = rd(); while( T-- ) solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5832kb

input:

2
4
1 1 4
5 1 5
1 9 1
9 8 1
9
3 1 4
1 5 9
2 6 5
3 5 8
9 7 9
3 2 3
8 4 6
2 6 8
3 2 7

output:

3 1 2 4 
3 8 4 2 5 9 7 1 6 

result:

ok correct

Test #2:

score: 0
Accepted
time: 760ms
memory: 7372kb

input:

1
100000
581297 102863 1
742857 42686 1
676710 233271 1
443055 491162 1
442056 28240 1
769277 331752 1
8608 369730 1
495112 525554 1
787449 938154 1
441186 850694 1
84267 925450 1
740811 32385 1
834021 37680 1
257878 564126 1
90618 914340 1
239641 463103 1
40687 343062 1
587737 458554 1
103684 48666...

output:

70717 6151 48237 28851 35679 19561 94252 73342 13089 34865 69194 82763 50242 22597 3745 24913 97923 53671 77581 47428 82224 93567 61401 50007 4886 54152 28731 91278 99937 6691 26840 6048 46204 66044 60735 44469 20513 45842 18701 46818 27203 9261 50507 8020 72391 54368 86201 18839 64763 61758 40939 3...

result:

ok correct

Test #3:

score: -100
Wrong Answer
time: 750ms
memory: 7356kb

input:

1
99999
30245 831673 1
495617 185056 1
53028 422589 1
503558 778900 1
636981 480008 1
966864 78785 1
644954 303138 1
153080 225499 1
876411 832264 1
758904 549009 1
945000 441995 1
83780 789901 1
883282 832556 1
300776 548075 1
806599 108342 1
354979 831549 1
152110 819163 1
613891 812479 1
856259 6...

output:

42779 26176 16432 93736 36110 21022 69840 33300 88899 48735 97468 24934 58044 16598 54398 41611 25297 90410 54385 38513 14754 7374 40518 45724 3741 95478 36354 5270 92123 87433 5901 57489 42968 40570 60847 61715 65894 68944 27887 3727 38578 14748 15072 79314 41234 42830 79639 35429 60443 63782 12370...

result:

wrong answer Wrong Answer on Case#1