제출 #783687

#제출 시각아이디문제언어결과실행 시간메모리
783687Cookie지구 온난화 (NOI13_gw)C++14
0 / 40
17 ms3152 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; ifstream fin("FEEDING.INP"); ofstream fout("FEEDING.OUT"); #define sz(a) (int)a.size() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> const ld PI = 3.14159265359; using u128 = __uint128_t; const int x[4] = {1, -1, 0, 0}; const int y[4] = {0, 0, 1, -1}; const ll mod = 1e9 + 7, inf = 1e16; const int mxn = 1e5 + 5; int cnt = 0; int n; int h[mxn + 1]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; vt<pii>comp; forr(i, 0, n){ cin >> h[i]; comp.pb({h[i], i}); } sort(comp.begin(), comp.end()); vt<bool>ok(n + 1); int ans = 0; for(int i = 0; i < sz(comp);){ int r = i + 1; while(r < sz(comp) && comp[r].fi == comp[i].fi)r++; for(int j = i; j < r; j++){ int id = comp[j].second; cnt++; if(id && ok[id - 1])cnt--; if(id < n && ok[id + 1])cnt--; ok[id] = 1; } int val = cnt; if(ok[0])val--; if(ok[n - 1])val--; ans = max(ans, val); i = r; } cout << ans; 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...