# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311268 | 2020-10-09T19:47:02 Z | kimbj0709 | Global Warming (NOI13_gw) | C++14 | 265 ms | 25952 KB |
#include <bits/stdc++.h> using namespace std; #define f first #define s second int32_t main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n; int input; cin >> n; vector<int> h = {-1}; vector<int> vect1 = {-1}; for(int i=0;i<n;i++){ cin >> input; vect1.push_back(input); } for(int i=1;i<vect1.size();i++){ if(vect1[i]!=vect1[i-1]){ h.push_back(vect1[i]); } } h.push_back(-1); vector<pair<int,int> > sorted; for(int i=1;i<h.size()-1;i++){ sorted.push_back({h[i],i}); } sort(sorted.begin(),sorted.end()); reverse(sorted.begin(),sorted.end()); int curr = 0; int ans = 1; for(int i=0;i<sorted.size();){ int current = sorted[i].f; while(i<sorted.size()&&sorted[i].f==current){ int pos = sorted[i].s; if(h[pos-1]>current&&h[pos+1]>current){ curr--; } else if(h[pos-1]<current&&h[pos+1]<current){ curr++; } i++; } //cout << curr << "--\n"; ans = max(ans,curr); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 2556 KB | Output is correct |
2 | Correct | 21 ms | 2556 KB | Output is correct |
3 | Correct | 20 ms | 2556 KB | Output is correct |
4 | Correct | 20 ms | 2556 KB | Output is correct |
5 | Correct | 20 ms | 2556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 3196 KB | Output is correct |
2 | Correct | 17 ms | 2940 KB | Output is correct |
3 | Correct | 24 ms | 3196 KB | Output is correct |
4 | Correct | 23 ms | 3068 KB | Output is correct |
5 | Correct | 22 ms | 3068 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 260 ms | 25856 KB | Output is correct |
2 | Correct | 259 ms | 25828 KB | Output is correct |
3 | Correct | 255 ms | 25952 KB | Output is correct |
4 | Correct | 261 ms | 25824 KB | Output is correct |
5 | Correct | 248 ms | 25184 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 260 ms | 25232 KB | Output is correct |
2 | Correct | 265 ms | 25348 KB | Output is correct |
3 | Correct | 259 ms | 25188 KB | Output is correct |
4 | Correct | 223 ms | 19296 KB | Output is correct |
5 | Correct | 231 ms | 19464 KB | Output is correct |