# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125264 | 2019-07-05T02:20:52 Z | dragonslayerit | Mountains (IOI17_mountains) | C++14 | 2 ms | 504 KB |
#include "mountains.h" #include <vector> #include <algorithm> #include <cstdio> int memo[2001][2001]; int last[2001][2001]; int solve(int begin,int end){ if(begin==end) return 0; if(end-begin==1) return 1; if(memo[begin][end]!=-1) return memo[begin][end]; int ans=solve(begin,last[begin][end-1])+solve(last[begin][end-1]+1,end); return memo[begin][end]=std::max(ans,solve(begin+1,end)); } int maximum_deevs(std::vector<int> y) { for(int i=0;i<=y.size();i++){ for(int j=0;j<=y.size();j++){ memo[i][j]=-1; } } for(int i=0;i<y.size();i++){ int k=i+1; for(int j=i+1;j<y.size();j++){ if((k-i)*(y[j]-y[i])>=(j-i)*(y[k]-y[i])){ k=j; } last[i][j]=k; } } return solve(0,y.size()); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 504 KB | Output is correct |
7 | Incorrect | 2 ms | 504 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 504 KB | Output is correct |
7 | Incorrect | 2 ms | 504 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 504 KB | Output is correct |
7 | Incorrect | 2 ms | 504 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 504 KB | Output is correct |
7 | Incorrect | 2 ms | 504 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |