60pts 悬关求条
  • 板块P2073 送花
  • 楼主Epitome
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/10/21 15:19
  • 上次更新2024/10/21 18:36:40
查看原帖
60pts 悬关求条
994729
Epitome楼主2024/10/21 15:19
#include <iostream>

#include <set>

#include <map>

using namespace std;

long long n, sum1, sum2;

set<pair<int, int> > s;

int main() {
  ios :: sync_with_stdio(0), cin.tie(0);
  int op, x, y;
  while (cin >> op) {
    if (op == -1) break;
    if (op == 1) {
      cin >> x >> y;
      if ((*s.lower_bound({y, x})).first != y) {
        s.insert(make_pair(y, x));
      }
    } else if (op == 2) {
      if (!s.empty()) {
        s.erase(prev(s.end()));
      }
    } else {
      if (!s.empty()) {
        s.erase(s.begin());
      }
    }
  }
  for ( auto i : s ) {
    sum1 += i.first, sum2 += i.second;
  }
  cout << sum2 << " " << sum1;
  return 0;
}
2024/10/21 15:19
加载中...