# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532296 | 2022-03-02T16:54:49 Z | andecaandeci | Money (IZhO17_money) | C++17 | 1 ms | 204 KB |
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 100; int arr[N],memo[N]; int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&arr[i]); } for(int i=0;i<n;i++){ memo[i] = i + 1; if(i) memo[i] = min(memo[i],memo[i-1] + 1); for(int j = i - 1;j >= 0;j--){ if(arr[j] < arr[j+1]) break; bool flag = 0; for(int k = 0;k < j;k++){ if(arr[k] > arr[j] && arr[k] < arr[i]){ flag = 1; break; } } if(!flag) memo[i] = min(memo[i], (j ? memo[j - 1] : 0 ) + 1); } } printf("%d",memo[n-1]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |