QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278630 | #7750. Revenge on My Boss | KomejiNora | WA | 377ms | 8600kb | C++14 | 1.1kb | 2023-12-07 18:45:10 | 2023-12-07 18:45:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
int n,a[N],b[N],c[N],B;
int d[N],e[N];
int p[N];
bool cmp(int x,int y) {
if(d[x]<0&&d[y]<0) return e[x]>e[y];
if(d[x]<0) return 1;
if(d[y]<0) return 0;
if(d[x]+e[x]!=d[y]+e[y]) return d[x]+e[x]<d[y]+e[y];
return e[x]<e[y];
}
bool check(int t) {
for(int i=1;i<=n;i++) {
p[i]=i;
d[i]=a[i]-b[i];
e[i]=t/c[i]-a[i]-B;
}
sort(p+1,p+n+1,cmp);
int sum=0;
for(int i=1;i<=n;i++) {
int x=p[i];
if(sum>e[x]) return false;
sum+=d[x];
}
return true;
}
signed main() {
int T;scanf("%lld",&T);
while(T--) {
scanf("%lld",&n);B=0;
for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&a[i],&b[i],&c[i]),B+=b[i];
int l=0,r=1e9,ans,mid;
while(l<=r) {
mid=(l+r)>>1;
if(check(mid)) {
ans=mid;
l=mid+1;
}
else r=mid-1;
}
check(ans);
for(int i=1;i<=n;i++) printf("%lld ",p[i]);puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5968kb
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 2 1 4 3 8 4 2 5 9 7 1 6
result:
ok correct
Test #2:
score: 0
Accepted
time: 377ms
memory: 8480kb
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: 0
Accepted
time: 363ms
memory: 8600kb
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 24934 97468 58044 16598 54398 41611 25297 90410 54385 14754 38513 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:
ok correct
Test #4:
score: -100
Wrong Answer
time: 360ms
memory: 8528kb
input:
1 100000 361850 684411 2 188930 167748 2 676274 449963 1 970095 784305 1 412379 854673 1 208323 612179 1 296548 633970 1 560983 633064 2 848966 248363 2 741057 340814 1 393854 435721 2 302707 834494 1 229770 235051 2 875992 747523 2 314215 448795 1 531181 809914 2 786505 95721 1 86557 773136 1 44527...
output:
16321 7131 95323 35939 17982 39108 40409 6682 52183 74664 70501 41441 84223 56736 85313 14964 28720 78033 67062 57534 70472 11374 94854 66622 93668 48920 28893 22168 52514 29910 91864 76382 77675 53874 4818 16590 14329 99654 33902 81051 8212 93812 4065 34961 84790 47118 54934 27805 33368 77685 23450...
result:
wrong answer Wrong Answer on Case#1