# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
393690 | 2021-04-24T09:17:52 Z | Qw3rTy | Rabbit Carrot (LMIO19_triusis) | C++11 | 1 ms | 332 KB |
#include <iostream> using namespace std; const int maxN = 2e5+5; int a[maxN]; int f[maxN]; int dif[maxN]; int ps[maxN]; int N,M; void testIO(){ freopen("../test.in","r",stdin); return; return; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); //testIO(); cin >> N >> M; for(int i = 1; i <= N; ++i)cin >> a[i]; int curHeight = M; //current height that can be reached int prevHeight = M; //maximum height that can be reached for(int i = 1; i <= N; ++i){ //Can jump onto the next pole if(a[i] <= curHeight){ dif[i] = 0; //Moves forward prevHeight = curHeight; curHeight = a[i] + M; } else{ dif[i] = 1; curHeight = max(prevHeight, curHeight); //Tries to go as high as possible } } for(int i = 1; i <= N; ++i)ps[i] = ps[i-1] + dif[i]; for(int i = 1; i <= N; ++i){ for(int j = 1; j < i; ++j){ if(a[j] + M < a[i]){ f[i] = max(f[i],f[j] + ps[i] - ps[j-1]); } } } int res = 0; for(int i = 1; i <= N; ++i)res = max(res,f[i]); cout << res << '\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |