QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#261446 | #7750. Revenge on My Boss | Loging | WA | 0ms | 1532kb | C++20 | 1.1kb | 2023-11-22 21:49:15 | 2023-11-22 21:49:15 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#define M 100005
using namespace std;
int sign(long long x){
if(x<=0)return 0;
return 1;
}
struct node{
int id;
long long a,b,c,d;
double e;
bool operator <(const node &_)const{
if(sign(d)!=sign(_.d))return sign(d)<sign(_.d);
if(d<=0)return e<_.e;
return d+e<_.d+_.e;
}
}A[M];
int n;
long long sumB;
bool check(long long x){
for(int i=1;i<=n;i++)A[i].e=1.0*x/A[i].c-A[i].b-sumB;
sort(A+1,A+n+1);
long long sumd=0;
for(int i=1;i<=n;i++){
sumd+=A[i].d;
if(A[i].c*(sumB+sumd+A[i].b)>x)return false;
}
return true;
}
int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%lld%lld%lld",&A[i].a,&A[i].b,&A[i].c);
sumB=0;
for(int i=1;i<=n;i++){
A[i].id=i;
sumB+=A[i].b;
A[i].d=A[i].a-A[i].b;
}
long long L=0,R=1e18,res=1e18;
while(L<=R){
long long mid=(L+R)>>1;
if(check(mid)){
res=mid;
R=mid-1;
}else{
L=mid+1;
}
}
check(res);
// printf("res=%lld\n",res);
for(int i=1;i<=n;i++)printf("%d ",A[i].id);puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1532kb
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