Submission #532298

#TimeUsernameProblemLanguageResultExecution timeMemory
532298devariaotaMoney (IZhO17_money)C++17
45 / 100
1534 ms5620 KiB
#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)

money.cpp: In function 'int main()':
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]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...