Submission #580706

# Submission time Handle Problem Language Result Execution time Memory
580706 2022-06-21T17:06:45 Z snasibov05 Sails (IOI07_sails) C++14
30 / 100
1000 ms 7876 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;
    
    sort(v.begin(), v.end());
    set<pair<int, int>> st;
    vector<int> cnt(mx);
    for (int i = 0; i < n; ++i){
        for (int j = 1; j <= v[i].first; ++j) {
            st.insert({cnt[j], j});
        }
        for (int j = 0; j < v[i].second; ++j){
            auto it = st.begin();
            int h = it->second;
            st.erase(it);
            cnt[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 980 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 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1108 KB Output is correct
2 Correct 18 ms 1136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 515 ms 1356 KB Output is correct
2 Execution timed out 1084 ms 4560 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 2072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 2024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 2360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 7876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 2876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 3568 KB Time limit exceeded
2 Halted 0 ms 0 KB -