#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define debug(x) cout<<#x<<": "<<x<<"\n"
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("input.000","r",stdin);
// freopen("output.000","w",stdout);
// srand((unsigned)time(NULL));
// rand()
int n,i,a[50005],c,ans;
cin>>n>>n;
for (i=1;i<n+1;i++) cin>>a[i];
ans=0;
c=1;
for (i=2;i<n+1;i++)
if (a[i-1]>a[i]) c++;
else
{
ans += (c*(c+1))/2;
c=1;
}
ans += (c*(c+1))/2;
c=1;
for (i=n-1;i>0;i--)
if (a[i+1]>a[i]) c++;
else
{
ans += (c*(c+1))/2;
c=1;
}
ans += (c*(c+1))/2;
ans -= n;
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
704 KB |
Output is correct |
2 |
Correct |
9 ms |
972 KB |
Output is correct |
3 |
Correct |
8 ms |
972 KB |
Output is correct |
4 |
Correct |
5 ms |
980 KB |
Output is correct |
5 |
Correct |
5 ms |
980 KB |
Output is correct |
6 |
Correct |
7 ms |
1108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |