# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
228751 | 2020-05-02T13:17:55 Z | Rakhmand | Fire (JOI20_ho_t5) | C++14 | 1000 ms | 13176 KB |
// I feel still alive. // Created by existence on 18/04/2003. // Copyright © 2020 Rakhman. All rights reserved. #include <vector> #include <map> #include <set> #include <deque> #include <algorithm> #include <iostream> #include <cmath> #include <iterator> #define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0); #define S second #define F first #define nl '\n' const long long mxn = 1e6 + 10; const long long mod = 1e9 + 7; const long long inf = 1e18; typedef long long llong; using namespace std; void istxt(bool yes){ if(yes == 1){ freopen("balancing.in", "r", stdin); freopen("balancing.out", "w", stdout); }else{ freopen("/Users/rakhmanabdirashov/Desktop/folder/Programming/Road2Master/Road2Master/input.txt", "r", stdin); } } int n, Q, b[mxn], l[mxn], mx[mxn]; llong ans[mxn]; struct query{ int t, l, r, ind; }q[mxn]; bool cmp(query a, query b){ return a.t < b.t; } int main () { ios; //istxt(0); cin >> n >> Q; for(int i = 1; i <= n; i++){ cin >> b[i]; mx[i] = b[i]; l[i] = i; } for(int i = 1; i <= Q; i++){ cin >> q[i].t >> q[i].l >> q[i].r; q[i].ind = i; } sort(q + 1, q + Q + 1, cmp); for(int qq = 1; qq <= Q; qq++){ int last = q[qq].t - q[qq - 1].t; for(int i = 1; i <= n; i++){ for(int j = 1; j <= last; j++){ l[i]--; if(l[i] <= 0) break; mx[i] = max(mx[i], b[l[i]]); } } llong sum = 0; for(int i = q[qq].l; i <= q[qq].r; i++){ sum += mx[i]; } ans[q[qq].ind] = sum; } for(int i = 1; i <= n; i++){ cout << ans[i] << nl; } return 0; } /* 5 5 9 3 2 6 5 1 1 3 2 1 5 3 2 5 4 3 3 5 3 5 10 10 3 1 4 1 5 9 2 6 5 3 1 1 6 2 8 10 4 2 7 8 3 3 6 1 10 3 2 8 5 1 9 7 4 5 9 7 9 10 10 10 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Execution timed out | 1093 ms | 11384 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Execution timed out | 1093 ms | 13176 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1085 ms | 11356 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Incorrect | 5 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |