QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#664250 | #7750. Revenge on My Boss | beidiaodadejht | WA | 1ms | 6036kb | C++23 | 1.2kb | 2024-10-21 19:51:11 | 2024-10-21 19:51:12 |
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: 0
Wrong Answer
time: 1ms
memory: 6036kb
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:
1 3 2 4 2 4 8 3 5 9 7 1 6
result:
wrong answer Wrong Answer on Case#2