# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890424 | 2023-12-21T07:26:49 Z | Ghulam_Junaid | Sails (IOI07_sails) | C++17 | 1000 ms | 10684 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 1e5 + 10; ll n, p[N], initial_cost; vector<pair<ll, ll>> vec; int main(){ cin >> n; for (ll i=0; i<n; i++){ ll h, k; cin >> h >> k; if (h == k){ p[0]++; p[h]--; } else{ vec.push_back({h, k}); } } initial_cost = (p[0] * (p[0] - 1)) / 2; for (ll i=1; i<N; i++){ p[i] += p[i - 1]; initial_cost += (p[i] * (p[i] - 1)) / 2; } set<pair<ll, ll>> st; for (ll i = 0; i < N; i++) st.insert({p[i], -i}); ll cost = initial_cost; vector<ll> places; for (ll i=0; i<vec.size(); i++){ ll h = vec[i].first; ll k = vec[i].second; places.clear(); for (ll j = 0; j < k; j++){ places.push_back(-(*st.begin()).second); st.erase(st.begin()); } for (ll j=0; j<k; j++){ ll pos = places[j]; cost += p[pos]; p[pos]++; st.insert({p[pos], -pos}); } } cout << cost << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 7260 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 7508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 16 ms | 7256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 7260 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 432 ms | 7504 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1037 ms | 7768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1046 ms | 8464 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1082 ms | 9156 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1029 ms | 10248 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 10524 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1024 ms | 10684 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |