比赛 20251001国庆欢乐赛1 评测结果 AAWWAWWWWW
题目名称 有n种物品 最终得分 30
用户昵称 123 运行时间 0.190 s
代码语言 C++ 内存使用 3.88 MiB
提交时间 2025-10-01 09:17:35
显示代码纯文本
#include <bits/stdc++.h>
#define fi first
#define sd second
using namespace std;
priority_queue<pair<int,int> > q; 
int t,x,y,f=0;
long long ret[3];
int main() {
    freopen("nit.in","r",stdin);
    freopen("nit.out","w",stdout);
    cin>>t;
    while (t--)
    {
        scanf("%d%d",&x,&y);
        q.push({x-y,y});
    }
    while (!q.empty())
    {
        pair<int,int> t=q.top();q.pop();
        if (t.sd==0) ret[f]+=t.fi;
        else ret[f]+=t.fi+t.sd,q.push({t.sd,0});
        f^=1;
    }
    cout<<ret[0]-ret[1];
}