#include <bits/stdc++.h>
#define iter(a) a.begin(), a.end()
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
using namespace std;
typedef long long ll;
typedef long double ld;
using pii = pair<int, int>;
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
struct rect{
int u, d, l, r;
int cnt = 1;
int area(){
return (r - l + 1) * (d - u + 1);
}
};
rect merge(rect a, rect b){
rect c;
c.l = min(a.l, b.l);
c.r = max(a.r, b.r);
c.u = min(a.u, b.u);
c.d = max(a.d, b.d);
c.cnt = a.cnt + b.cnt;
return c;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<int> a(w + 2, INT_MAX);
for(int j = 1; j <= w; j++){
cin >> a[j];
}
vector<int> dpl(w + 2), dpr(w + 2);
for(int i = 1; i <= w; i++){
if(a[i - 1] < a[i]) dpl[i] = dpl[i - 1] + 1;
else dpl[i] = 1;
}
for(int i = w; i >= 1; i--){
if(a[i + 1] < a[i]) dpr[i] = dpr[i + 1] + 1;
else dpr[i] = 1;
}
ll ans = 0;
for(int i = 1; i <= w; i++){
ans += dpl[i] + dpr[i] - 1;
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
4 ms |
844 KB |
Output is correct |
3 |
Correct |
4 ms |
780 KB |
Output is correct |
4 |
Correct |
5 ms |
844 KB |
Output is correct |
5 |
Correct |
5 ms |
908 KB |
Output is correct |
6 |
Correct |
5 ms |
904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |