Submission #856402

# Submission time Handle Problem Language Result Execution time Memory
856402 2023-10-03T11:58:59 Z overwatch9 Sails (IOI07_sails) C++17
5 / 100
46 ms 3780 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    priority_queue <pair <ll, int>> pq;
    for (int i = 1; i <= 5; i++)
        pq.push({0, i});
    vector <pair <int, int>> updates(n);
    for (int i = 0; i < n; i++)
        cin >> updates[i].first >> updates[i].second;
    sort(updates.begin(), updates.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        priority_queue <pair <ll, int>> tp;
        int done = 0;
        ll delta = 0;
        while (done < updates[i].second) {
            pair <ll, int> x = pq.top();
            pq.pop();
            if (x.second <= updates[i].first) {
                ans += -(x.first);
                delta += (-x.first);
                tp.push({x.first-1, x.second});
                done++;
            } else {
                tp.push(x);
            }
        }
        while (!tp.empty()) {
            pq.push(tp.top());
            tp.pop();
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 356 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1048 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 1368 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 23 ms 1872 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 37 ms 3780 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 2788 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 46 ms 3664 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -