# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890425 | 2023-12-21T07:27:51 Z | Ghulam_Junaid | Sails (IOI07_sails) | C++17 | 1000 ms | 5828 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; } vector<pair<ll, ll>> places; ll cost = initial_cost; for (ll i=0; i<vec.size(); i++){ ll h = vec[i].first; ll k = vec[i].second; places.clear(); for (ll j = h - 1; j >= 0; j--){ places.push_back({p[j], -j}); } sort(places.begin(), places.end()); for (ll j=0; j<k; j++){ ll pos = -places[j].second; cost += p[pos]; p[pos]++; } } cout << cost << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1116 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 1 ms | 1116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1116 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 227 ms | 1364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1016 ms | 1916 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1062 ms | 2284 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 3272 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1068 ms | 5224 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1095 ms | 5568 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1048 ms | 5828 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |