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;
#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<<ans<<endl;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |