# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
114204 | 2019-05-31T09:27:13 Z | zubec | Sails (IOI07_sails) | C++14 | 1000 ms | 1532 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; vector <pair<int, int> > vec; int n; int kol[100100]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin >> n; for (int i = 1; i <= n; i++){ int h, k; cin >> h >> k; vec.push_back({h, k}); } sort(vec.begin(), vec.end()); int mxh = 0; for (int i = 0; i < vec.size(); i++){ if (mxh < vec[i].first){ kol[0] += vec[i].first-mxh; mxh = vec[i].first; } vector <pair<int, int> > vec2; for (int j = 0; j <= n && vec[i].second > 0; j++){ int mn = min(kol[j], vec[i].second); if (mn > 0){ vec[i].second -= mn; vec2.push_back({j, mn}); kol[j] -= mn; } } for (int j = 0; j < vec2.size(); j++){ kol[vec2[j].first+1] += vec2[j].second; } } ll ans = 0; for (int j = 0; j <= n; j++){ ans += kol[j]*1ll*j*(j-1)/2; } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 648 KB | Output is correct |
2 | Correct | 949 ms | 864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1053 ms | 1148 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1053 ms | 1140 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1076 ms | 1516 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1053 ms | 1532 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 1532 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |