社区讨论
WA+AC求条
B4071[GESP202412 五级] 武器强化参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mhjgupou
- 此快照首次捕获于
- 2025/11/04 02:21 4 个月前
- 此快照最后确认于
- 2025/11/04 02:21 4 个月前
CPP
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct node
{
int p,c;
}a[2001];
bool cmp(node x,node y)
{
return x.c<y.c;
}
priority_queue<int,vector<int>,less<int> >tot2;
int tong[2001];
signed main()
{
int n,m,tot1=0,ans=0;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>a[i].p>>a[i].c;
if(a[i].p==1)tot1++;
else tong[a[i].p]++;
}
for(int i=2;i<=n;i++){tot2.push(tong[i]);}
for(int i=1;i<=m;i++)
{
if(a[i].p!=1)
{
//cout<<tot2.top();
if(tot1<=tot2.top())
{
tot1++;
tot2.pop();
a[i].p=1;
ans+=a[i].c;
}
}
}
cout<<ans;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...