QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141065 | #6532. Trading | cy1999 | WA | 0ms | 3376kb | C++20 | 748b | 2023-08-17 08:35:53 | 2023-08-17 08:35:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct node{
int a,b;
friend bool operator<(node a,node b){
return a.a<b.a;
}
}p[1000005];
int n,t,sum,r1,r2,nw;
signed main(){
return 0;
cin>>t;
while(t--){
cin>>n;sum=0;
for(int i=1;i<=n;i++){
scanf("%lld%lld",&p[i].a,&p[i].b);
sum+=p[i].b;
}
sort(p+1,p+n+1);nw=0;r1=r2=0;
for(int i=1;i<=n;i++){
if(p[i].b+nw<=sum/2){
nw+=p[i].b;
r1+=p[i].a*p[i].b;
}else{
r1+=(sum/2-nw)*p[i].a;
break;
}
}
nw=0;
for(int i=n;i>=1;i--){
if(p[i].b+nw<=sum/2){
nw+=p[i].b;
r2+=p[i].a*p[i].b;
}else{
r2+=(sum/2-nw)*p[i].a;
break;
}
}
printf("%lld\n",r2-r1);
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3376kb
input:
2 4 10 2 30 7 20 4 50 1 2 1 100 1 1000
output:
result:
wrong answer Answer contains longer sequence [length = 2], but output contains 0 elements