QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662859 | #7750. Revenge on My Boss | beidiaodadejht | WA | 793ms | 8116kb | C++23 | 1.2kb | 2024-10-21 11:24:25 | 2024-10-21 11:24:25 |
Judging History
answer
#include<bits/stdc++.h>
#define pll pair<long long,long long>
#define M 100005
#define fi first
#define se second
using namespace std;
int n,T,p[M];
long long al,ans;
pll gu[M];
struct node{long long a,b,c;}e[M];
bool ck(pll a,pll b){
if(max(a.se,b.se)<=0) return a.fi>b.fi;
if(min(a.se,b.se)<=0) return a.se<=0;
return a.fi+a.se<b.fi+b.se;
}
bool ck(long long C){
for(int i=1;i<=n;++i) gu[i]=make_pair((C/e[i].c)-e[i].a-al,e[i].a-e[i].b);
sort(gu+1,gu+n+1,[](auto x,auto y){return ck(x,y);});
long long nw=0;
for(int i=1;i<=n;++i){if(nw>gu[i].fi) return 1;nw+=gu[i].se;}
return 0;
}
int main(){
scanf("%d",&T);
while(T--){
scanf("%d",&n);al=0;
for(int i=1;i<=n;++i) scanf("%lld%lld%lld",&e[i].a,&e[i].b,&e[i].c),al+=e[i].b;
long long l=1,r=1e18;
while(l<=r){
long long mid=(l+r)>>1;
if(ck(mid)) l=mid+1;
else r=mid-1,ans=mid;
// printf("%lld %lld\n",l,r);
}
for(int i=1;i<=n;++i) p[i]=i;
sort(p+1,p+n+1,[](int a,int b){return ck(make_pair(ans/e[a].c-e[a].c-al,e[a].a-e[a].b),make_pair(ans/e[b].c-e[b].c-al,e[b].a-e[b].b));});
for(int i=1;i<=n;++i) printf("%d ",p[i]);printf("\n");
}
return 0;
}
// (C/c[i])-a[i]-sum1~n(b[j])>=sum1~i-1(a[j]-b[j]);
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5928kb
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: 793ms
memory: 8116kb
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:
52669 52639 52640 52641 52642 52643 52644 52646 95794 52659 52660 52662 52663 52665 52666 95793 52637 52670 52672 52677 52678 52679 52680 52686 52687 52689 52691 52692 52695 52696 52698 52700 52611 52592 52593 52594 52595 52596 52597 52598 52599 95799 95798 95797 52603 52604 52605 52607 95790 52612 ...
result:
wrong answer Wrong Answer on Case#1