QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#384552 | #6532. Trading | DDT | Compile Error | / | / | C++14 | 790b | 2024-04-10 01:34:35 | 2024-04-10 01:34:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
#define endl '\n'
#define x first
#define y second
typedef long long ll;
typedef pair<int,int> PII;
PII a[100010];
int n,cnt=0;
void solve()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a[i].x,&a[i].y);
cnt+=a[i].y;
}
sort(a+1,a+n+1);
int l=1,r=1;
ll ans=0
while(l<r)
{
int res=min(a[l].y,a[r].y);
a[l].y-=res;
a[r].y-=res;
ans+=(a[r].x-a[l].x)*res;
if(a[l].y==0)l++;
else r--;
}
printf("%d\n",ans);
//cout<<xs-cb<<endl;
}
/*
10 2
20 4
25
30 7
50 1
*/
int main()
{
//ios::sync_with_stdio(false);
//ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
int t;
scanf("%d",&t);
while(t--)
{
solve();
}
return 0;
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:25:9: error: expected ‘,’ or ‘;’ before ‘while’ 25 | while(l<r) | ^~~~~ answer.code:35:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 35 | printf("%d\n",ans); | ~^ ~~~ | | | | int ll {aka long long int} | %lld answer.code:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&n); | ~~~~~^~~~~~~~~ answer.code:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d%d",&a[i].x,&a[i].y); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%d",&t); | ~~~~~^~~~~~~~~