QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#649901#7750. Revenge on My BossLavender_FieldWA 625ms7344kbC++201.6kb2024-10-18 11:25:102024-10-18 11:25:15

Judging History

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

  • [2024-10-18 11:25:15]
  • 评测
  • 测评结果:WA
  • 用时:625ms
  • 内存:7344kb
  • [2024-10-18 11:25:10]
  • 提交

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 > b.e;
    return a.e < b.e;
}


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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5828kb

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 4 8 2 5 9 7 1 6 

result:

ok correct

Test #2:

score: -100
Wrong Answer
time: 625ms
memory: 7344kb

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:

32063 35138 77895 37175 1117 78892 13855 93403 57307 43882 10790 40485 75847 86508 16681 30921 37548 74098 71155 60433 22241 74378 28602 30951 65092 98171 260 71472 73404 2098 26268 89359 83373 57 41825 24139 11373 63971 45598 22777 41079 27203 79576 94828 67086 63986 84460 6652 82720 32084 87144 88...

result:

wrong answer Wrong Answer on Case#1