Submission #734607

#TimeUsernameProblemLanguageResultExecution timeMemory
7346071075508020060209tcSandcastle 2 (JOI22_ho_t5)C++14
9 / 100
20 ms1876 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n;int m; int ar[200005]; int dp[200005]; int dp2[200005]; signed main(){ cin>>m>>n; for(int i=1;i<=n;i++){ cin>>ar[i]; } for(int i=n;i>=1;i--){ dp[i]=1; if(ar[i+1]<ar[i]){ dp[i]=dp[i+1]+1; } } reverse(ar+1,ar+n+1); for(int i=n;i>=1;i--){ dp2[i]=1; if(ar[i+1]<ar[i]){ dp2[i]=dp2[i+1]+1; } } int ans=0; for(int i=1;i<=n;i++){ ans+=dp[i]+dp2[i]; // cout<<dp[i]<<" "<<dp2[i]<<endl; } ans-=n; cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...