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>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector <vector<int>> vvi;
typedef vector<bool> vb;
typedef vector <vector<bool>> vvb;
typedef vector <string> vs;
typedef vector<char> vc;
typedef vector <vector<char>> vvc;
typedef pair<int, int> pii;
typedef vector <pii> vpii;
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define endl "\n"
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vi h(n);
set<int> sh;
for(int i = 0; i < n; i++) {
cin >> h[i];
sh.insert(h[i]);
}
vi orig_h(h);
int mx_islands = 0;
sh.insert(0);
for(int v : sh) {
int islands = 0;
for(int i = 0; i < n; i++) {
if(max(0, h[i]-v)>0 && (i==0 || max(0, h[i-1]-v)==0)) islands++;
}
mx_islands = max(mx_islands, islands);
h = orig_h;
}
cout << mx_islands << endl;
return 0;
}
# | 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... |