P2073 STLset求调
  • 板块灌水区
  • 楼主mxdyzmx
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/8/14 16:56
  • 上次更新2023/11/3 03:50:44
查看原帖
P2073 STLset求调
575480
mxdyzmx楼主2023/8/14 16:56

rt,RE20pts

#include <bits/stdc++.h>
using u64 = long long;
using namespace std;
const int N = 1e5 + 10;
set<u64> s;
u64 cost[N];
u64 t, w, c, wst = 0, ans = 0;
int main()
{
    while(true)
    {
        scanf("%lld", &t);
        if(t == 1)
        {
            scanf("%lld%lld", &w, &c);
            if(s.count(c)) continue;
            s.insert(c);
            cost[c] = w;
        }
        if(t == 2) if(s.size() != 0) s.erase(--s.end());
        if(t == 3) if(s.size() != 0) s.erase(s.begin());
        if(t == -1) break;
    }
    set<u64>::iterator it;
    for(it = s.begin(); it != s.end(); it++)
    {
        ans += cost[*it];
        wst += *it;
    }
    printf("%lld %lld", ans, wst);
    return 0;
}
2023/8/14 16:56
加载中...