# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532298 | devariaota | Money (IZhO17_money) | C++17 | 1534 ms | 5620 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |