답안 #1092101

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092101 2024-09-23T07:55:38 Z juicy 학교 설립 (IZhO13_school) C++17
20 / 100
81 ms 8788 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  int n, m, s; cin >> n >> m >> s;
  vector<array<int, 2>> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i][0] >> a[i][1];
  }  
  sort(a.rbegin(), a.rend());
  int p = m;
  priority_queue<int> x;
  priority_queue<array<int, 2>> y;
  long long res = 0;
  for (int i = 0; i < n; ++i) {
    if (i < m) {
      x.push(a[i][1] - a[i][0]);
      res += a[i][0];
    } else {
      y.push({a[i][1], i});
    }
  }
  vector<bool> used(n);
  while (s--) {
    if (!x.size()) {
      res += y.top()[0];
      y.pop();
    } else {
      while (y.size() && used[y.top()[1]]) {
        y.pop();
      }
      if (x.top() + a[p][0] > y.top()[0]) {
        res += x.top() + a[p][0];
        used[p++] = 1;
        x.pop();
      } else {
        auto [v, id] = y.top(); y.pop();
        res += v;
        used[id] = 1;
      }
    }
  }
  cout << res;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 0 ms 348 KB Output isn't correct
6 Incorrect 0 ms 452 KB Output isn't correct
7 Incorrect 1 ms 548 KB Output isn't correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Incorrect 2 ms 604 KB Output isn't correct
12 Incorrect 2 ms 604 KB Output isn't correct
13 Incorrect 7 ms 1244 KB Output isn't correct
14 Incorrect 19 ms 3028 KB Output isn't correct
15 Correct 39 ms 5632 KB Output is correct
16 Incorrect 58 ms 6016 KB Output isn't correct
17 Incorrect 63 ms 7248 KB Output isn't correct
18 Incorrect 71 ms 7508 KB Output isn't correct
19 Incorrect 71 ms 7860 KB Output isn't correct
20 Incorrect 81 ms 8788 KB Output isn't correct