QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#266333 | #7750. Revenge on My Boss | mendicillin2# | WA | 1ms | 5468kb | C++17 | 980b | 2023-11-26 13:03:53 | 2023-11-26 13:03:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+5;
int n;
int a[N],b[N],c[N];
struct node{
int id,a,b,s;
}re[N];
inline bool cmp(node x,node y)
{
return x.a+y.b<x.b+y.a;
}
int pre[N],suf[N];
inline bool check(int x)
{
for(int i=1;i<=n;i++) re[i].id=i, re[i].a=a[i], re[i].b=b[i], re[i].s=x/c[i];
sort(re+1,re+n+1,cmp);
pre[0]=suf[n+1]=0;
for(int i=1;i<=n;i++) pre[i]=pre[i-1]+re[i].a;
for(int i=n;i>=1;i--) suf[i]=suf[i+1]+re[i].b;
for(int i=1;i<=n;i++)
if(pre[i]+suf[i]-re[i].s>0)
return false;
return true;
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int T;
cin>>T;
while(T--)
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
int lef=0, rig=1e18;
while(lef<rig)
{
int mid=(lef+rig)>>1;
if(check(mid)) rig=mid;
else lef=mid+1;
}
check(lef);
for(int i=1;i<=n;i++) cout<<re[i].id<<" ";
cout<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5468kb
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 4 2 2 3 8 4 6 9 1 5 7
result:
wrong answer Wrong Answer on Case#1