QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#141073 | #6532. Trading | cy1999 | WA | 1ms | 3612kb | C++ | 749b | 2023-08-17 08:38:16 | 2023-08-17 08:38:18 |
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(){
cin>>t;
while(t--){
return 0;
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: 1ms
memory: 3612kb
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