Submission #856430

# Submission time Handle Problem Language Result Execution time Memory
856430 2023-10-03T13:16:13 Z overwatch9 Sails (IOI07_sails) C++17
40 / 100
1000 ms 2884 KB
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    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;
    priority_queue <ll> pq;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            for (int j = 1; j <= updates[i].first; j++)
                pq.push(0);
        } else {
            for (int j = updates[i-1].first+1; j <= updates[i].first; j++)
                pq.push(0);
        }
        vector <ll> to_add(updates[i].second);
        for (int j = 0; j < updates[i].second; j++) {
            ll x = pq.top();
            pq.pop();
            ans += (-x);
            to_add[j] = x - 1;
        }
        for (auto i : to_add)
            pq.push(i);
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 488 KB Output is correct
2 Correct 138 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1026 ms 2884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 1392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 1432 KB Time limit exceeded
2 Halted 0 ms 0 KB -