# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
412853 | aryan12 | Global Warming (NOI13_gw) | C++17 | 799 ms | 65540 KiB |
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;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
void Solve() {
int n;
cin >> n;
vector<int> a(n + 1);
vector<bool> isTaken(n + 3);
vector<vector<int> > positions(n + 1);
map<int, int> cc;
for(int i = 1; i <= n; i++) {
cin >> a[i];
cc[a[i]]++;
isTaken[i] = false;
}
isTaken[0] = true;
isTaken[n + 1] = true;
int cnt = 1;
for(auto i: cc) {
cc[i.first] = cnt++;
}
for(int i = 1; i <= n; i++) {
a[i] = cc[a[i]];
positions[a[i]].push_back(i);
}
int ans = 0, curr = 0;
for(int i = 1; i <= n; i++) {
for(int j = 0; j < positions[i].size(); j++) {
int curPosition = positions[i][j];
isTaken[curPosition] = true;
if(!isTaken[curPosition - 1] && !isTaken[curPosition + 1]) {
curr++;
}
else if(isTaken[curPosition - 1] && isTaken[curPosition + 1]) {
curr--;
}
}
ans = max(ans, curr);
}
cout << ans + 1 << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) {
Solve();
}
return 0;
}
Compilation message (stderr)
# | 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... |