QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#258260 | #7750. Revenge on My Boss | ucup-team1321# | WA | 0ms | 3648kb | C++23 | 1.3kb | 2023-11-19 16:30:58 | 2023-11-19 16:30:59 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<numeric>
#include<algorithm>
using namespace std;
const int N=100005;
int n;
int a[N],b[N],c[N];
int d[N];
long long sa,sb;
long long lim[N];
int id[N];
bool check(long long x)
{
for(int i=1;i<=n;i++)
lim[i]=x/c[i]-b[i]-sb;
iota(id+1,id+n+1,1);
sort(id+1,id+n+1,[=](const int &x,const int &y)
{
if(d[x]<=0&&d[y]<=0) return lim[x]<lim[y];
else if(d[x]>0&&d[y]>0) return lim[x]+d[x]<lim[y]+d[y];
else return d[x]<d[y];
});
long long sd=0;
for(int i=1;i<=n;i++)
{
sd+=d[id[i]];
if(sd>lim[id[i]]) return false;
}
return true;
}
int ans[N];
void solve()
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i]>>b[i]>>c[i];
for(int i=1;i<=n;i++)
d[i]=a[i]-b[i];
sa=0,sb=0;
for(int i=1;i<=n;i++)
sa+=a[i],sb+=b[i];
long long l=1,r=(long long)*max_element(c+1,c+n+1)*max(sa,sb)*2;
while(l<=r)
{
long long mid=(l+r)/2;
if(check(mid))
{
for(int i=1;i<=n;i++)
ans[i]=id[i];
r=mid-1;
}
else l=mid+1;
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";
cout<<"\n";
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int T;
cin>>T;
while(T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3648kb
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 8 4 3 5 9 7 1 6
result:
wrong answer Wrong Answer on Case#2