# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
906244 | 2024-01-13T21:16:48 Z | Matjaz | Sails (IOI07_sails) | C++14 | 1000 ms | 3520 KB |
// // IOI2007Sails.cpp // // // Created by Matjaz Leonardis on 04/12/2023. // #include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; int INF = 100001; int main(){ int N; cin >> N; vector<int> H(N),K(N); for (int i=0;i<N;i++) cin >> H[i] >> K[i]; vector<pair<int,int> > p(N); for (int i=0;i<N;i++) p[i] = make_pair(H[i],K[i]); sort(p.begin(), p.end()); vector<int> S(100005); int prev = 0; for (int i=0;i<N;i++){ S[0] += p[i].first - prev; int k = p[i].second; int delayed_update = 0; for (int j=0;;j++){ if (k == 0) break; if (S[j] >= k){ S[j] -= k; S[j + 1] += k; k = 0; S[j] += delayed_update; } else { k -= S[j]; int tmp = S[j]; S[j] = delayed_update; delayed_update = tmp; } } prev = p[i].first; /*cout << p[i].first<< " " << p[i].second << endl; for (int j=0;j<5;j++) cout << S[j] << endl; cout << endl;*/ } long long total=0; for (int i=0;i<S.size();i++){ total += (((long long)i * (i - 1)) / 2) * S[i]; } cout << total << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 756 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 860 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 856 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 856 KB | Output is correct |
2 | Correct | 1 ms | 860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 856 KB | Output is correct |
2 | Correct | 175 ms | 1668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 231 ms | 1628 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 190 ms | 2144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 759 ms | 2896 KB | Output is correct |
2 | Correct | 387 ms | 2908 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1038 ms | 3152 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 665 ms | 3520 KB | Output is correct |
2 | Correct | 164 ms | 3408 KB | Output is correct |