#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int W=50005;
const int inf=1e9;
int h,w;
int a[W];
ll ans=0;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
cin >> h >> w;
for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin >> a[j];
int mx=inf,sz=0;
for(int i=1;i<=w;i++){
if(mx>a[i])sz=1;
else sz++;
mx=a[i];
ans+=sz;
}
mx=inf,sz=0;
for(int i=w;i>=1;i--){
if(mx>a[i])sz=1;
else sz++;
mx=a[i];
ans+=sz;
}
cout << ans-w << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
4 ms |
844 KB |
Output is correct |
3 |
Correct |
4 ms |
852 KB |
Output is correct |
4 |
Correct |
4 ms |
876 KB |
Output is correct |
5 |
Correct |
4 ms |
852 KB |
Output is correct |
6 |
Correct |
5 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |