Submission #532291

# Submission time Handle Problem Language Result Execution time Memory
532291 2022-03-02T16:53:12 Z christinelynn Money (IZhO17_money) C++17
Compilation error
0 ms 0 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;z++){
                if(arr[k] > arr[j] && arr[k] < arr[i]){
                    flag = 1;
                    break;
                }
            }
            if(!flag) memo[i] = min(memo[i], (j ? dp[j - 1] : 0 ) + 1);
        }
    }
    printf("%d",dp[n-1]);
    return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:17:33: error: 'z' was not declared in this scope
   17 |             for(int k = 0;k < j;z++){
      |                                 ^
money.cpp:23:51: error: 'dp' was not declared in this scope
   23 |             if(!flag) memo[i] = min(memo[i], (j ? dp[j - 1] : 0 ) + 1);
      |                                                   ^~
money.cpp:26:17: error: 'dp' was not declared in this scope
   26 |     printf("%d",dp[n-1]);
      |                 ^~
money.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
money.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         scanf("%d",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~