Submission #1067358

#TimeUsernameProblemLanguageResultExecution timeMemory
1067358DucNguyen2007Money (IZhO17_money)C++14
0 / 100
1 ms2396 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second const int maxN=1e6+5; const ll inf=2e18; int n,a[maxN+1]; ll dp[maxN+1]; int main() { //freopen("","r",stdin); //freopen("","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; dp[i]=inf; } dp[0]=0; for(int i=1;i<=n;i++) { int prev=a[i]; for(int j=i;j>=1;j--) { if(a[j]<=prev) { dp[i]=min(dp[i],dp[j-1]+1); prev=a[j]; } else break; } } cout<<dp[n]; } /*6 3 6 4 5 1 2*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...