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;
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 |
---|
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... |