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>
#define int long long
using namespace std;
int a[50013];
int h, w;
int id(int i, int j){
return i * w + j;
}
int32_t main(){
cin >> h >> w;
for(int i = 0; i < h * w; i++){
cin >> a[i];
}
int cnt = 1;
int st = 0;
int ans = 1;
for(int i = 1; i < w; i++){
if(a[i] > a[i - 1]){
if(st > 0){
cnt++;
}else{
cnt = 1;
}
ans += cnt + 1;
st = 1;
}else{
if(st < 0){
cnt++;
}else{
cnt = 1;
}
ans += cnt + 1;
st = -1;
}
}
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... |