#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 = 1e6 + 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 + 1;
if(ok[0])val--;
if(ok[n - 1])val--;
ans = max(ans, val);
i = r;
}
cout << ans;
return(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
1748 KB |
Output is correct |
2 |
Correct |
14 ms |
1748 KB |
Output is correct |
3 |
Correct |
14 ms |
1748 KB |
Output is correct |
4 |
Correct |
18 ms |
1748 KB |
Output is correct |
5 |
Correct |
14 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
1748 KB |
Output is correct |
2 |
Correct |
12 ms |
1748 KB |
Output is correct |
3 |
Correct |
16 ms |
1748 KB |
Output is correct |
4 |
Correct |
15 ms |
1748 KB |
Output is correct |
5 |
Correct |
14 ms |
1748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
18572 KB |
Output is correct |
2 |
Correct |
169 ms |
21508 KB |
Output is correct |
3 |
Correct |
177 ms |
21496 KB |
Output is correct |
4 |
Correct |
172 ms |
21452 KB |
Output is correct |
5 |
Correct |
160 ms |
20888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
195 ms |
18076 KB |
Output is correct |
2 |
Correct |
174 ms |
20776 KB |
Output is correct |
3 |
Correct |
173 ms |
20796 KB |
Output is correct |
4 |
Correct |
164 ms |
14944 KB |
Output is correct |
5 |
Correct |
148 ms |
15012 KB |
Output is correct |