Submission #580704

# Submission time Handle Problem Language Result Execution time Memory
580704 2022-06-21T17:05:24 Z snasibov05 Sails (IOI07_sails) C++14
35 / 100
1000 ms 8540 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
 
signed 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 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1876 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 592 ms 2144 KB Output is correct
2 Correct 513 ms 8136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 3068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 2724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 3104 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 8540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 3620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 4328 KB Time limit exceeded
2 Halted 0 ms 0 KB -