# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
777560 | 2023-07-09T10:41:32 Z | a_aguilo | Sails (IOI07_sails) | C++14 | 1000 ms | 4024 KB |
#include<bits/stdc++.h> using namespace std; int N; long long ans; const int maxN = 100002; const int maxH = 100002; pair<int, int> masts[maxN]; vector<int> merge(vector<int>& V1, vector<int>& V2){ int pos1 = 0; int pos2 = 0; vector<int> res; for(int i = 0; i < (V1.size() + V2.size()); ++i){ if(pos1 < V1.size() && pos2 < V2.size()){ if(V1[pos1] > V2[pos2]){ res.push_back(V1[pos1]); pos1++; }else{ res.push_back(V2[pos2]); pos2++; } }else if(pos1 < V1.size()){ res.push_back(V1[pos1]); pos1++; }else{ res.push_back(V2[pos2]); pos2++; } } return res; } int main(){ ans = 0; cin >> N; for(int i = 0; i < N; ++i) cin >> masts[i].first >> masts[i].second; vector<int> occupation; sort(masts, masts+N); for(int i = 0; i < N; ++i){ int h = masts[i].first; int k = masts[i].second; vector<int> prov; while(occupation.size() < h)occupation.push_back(0); for(int j = 0; j < k; ++j){ prov.push_back(occupation[occupation.size()-1] + 1); ans += occupation[occupation.size()-1]; occupation.pop_back(); } reverse(prov.begin(), prov.end()); occupation = merge(occupation, prov); } cout << ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 340 KB | Output is correct |
2 | Correct | 139 ms | 2092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 478 ms | 1072 KB | Output is correct |
2 | Correct | 326 ms | 980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1081 ms | 1252 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1075 ms | 1812 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1067 ms | 4024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1075 ms | 2596 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1072 ms | 2796 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |