Submission #580702

# Submission time Handle Problem Language Result Execution time Memory
580702 2022-06-21T17:04:46 Z snasibov05 Sails (IOI07_sails) C++14
25 / 100
1000 ms 6800 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    const int mx = 1e5 + 5;
    int n; cin >> n;
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;

    v.push_back({0, 0});
    sort(v.begin(), v.end());
    set<pair<int, int>> st;
    vector<int> avail(mx);
    vector<int> cnt(mx);
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= v[i].first; ++j) {
            if (avail[j] == 0) st.insert({cnt[j], j});
            avail[j]++;
        }
        for (int j = 0; j < v[i].second; ++j){
            auto it = st.begin();
            int k = it->first;
            int h = it->second;
            st.erase(it);
            cnt[h]++;
            avail[h]--;
            if (avail[h]) st.insert({k+1, h});
        }
    }

    int ans = 0;
    for (int i = 0; i < mx; ++i) ans += cnt[i] * (cnt[i] - 1) / 2;

    cout << ans << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 1068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1044 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 446 ms 1260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 1804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 2384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1048 ms 6800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 3092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 3484 KB Time limit exceeded
2 Halted 0 ms 0 KB -