QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#620674 | #7750. Revenge on My Boss | xinlengweishang | TL | 0ms | 0kb | C++20 | 1.1kb | 2024-10-07 20:18:49 | 2024-10-07 20:18:52 |
answer
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000010
using namespace std;
struct node{
ll a,b,c,d,e;
ll num;
}w[maxn];
bool cmp(node x,node y){
if(x.d<=0&&y.d<=0)
return x.e>y.e;
else if(x.d<=0||y.d<=0)
return x.d<y.d;
else
return x.d+x.e<y.d+y.e;
}
void slove(){
ll n,B=0;
scanf("%lld",&n);
for(ll i=1;i<=n;i++){
scanf("%lld%lld%lld",&w[i].a,&w[i].b,&w[i].c);
w[i].d=w[i].a-w[i].b;
B+=w[i].b;
w[i].num=i;
}
ll P;
ll l=1,r=1000000000000000000ll;
while(l+1<r){
int temp=0;
ll sumd=0;
for(int i=1;i<=n;i++){
if(sumd>w[i].e){
temp=1;
break;
}
sumd+=w[i].d;
}
if(temp) l=P;
else r=P;
// printf("%lld %lld %lld\n",P,l,r);
}
// printf("%lld\n",P);
P=(l+r)/2;
for(int i=1;i<=n;i++){
w[i].e=P/w[i].c-B-w[i].a;
// printf("%d %lld %lld %lld %lld %lld\n",i,w[i].a,w[i].b,w[i].c,w[i].d,w[i].e);
}
sort(w+1,w+n,cmp);
for(int i=1;i<=n;i++){
printf("%lld ",w[i].num);
}
printf("\n");
return ;
}
int main(){
int T;
scanf("%d",&T);
while(T--){
slove();
}
return 0;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
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