Submission #529466

#TimeUsernameProblemLanguageResultExecution timeMemory
529466wiwihoSandcastle 2 (JOI22_ho_t5)C++14
9 / 100
5 ms908 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...