# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170352 |
2019-12-24T20:25:30 Z |
ngmh |
Global Warming (NOI13_gw) |
C++11 |
|
839 ms |
31292 KB |
#include <bits/stdc++.h>
using namespace std;
int n, a[1000000], h = 0, c = -1, t = 0, l = 0;
vector<pair<int, int> > pv, is;
int main(){
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i];
if(n > 1){
if(a[0] > a[1]) pv.push_back(make_pair(a[0], 1));
if(a[n-1] > a[n-2]) pv.push_back(make_pair(a[n-1], 1));
}
for(int i = 1; i < n-1; i++){
if(a[i-1] > a[i]){
while(a[i] == a[i+1]) i++;
if(a[i] < a[i+1]) pv.push_back(make_pair(a[i], -1));
} else if(a[i-1] < a[i]){
while(a[i] == a[i+1]) i++;
if(a[i] > a[i+1]) pv.push_back(make_pair(a[i], 1));
}
}
sort(pv.begin(), pv.end());
reverse(pv.begin(), pv.end());
for(int i = 0; i < pv.size(); i++){
if(pv[i].first == c) t += pv[i].second;
else {
if(c != -1) is.push_back(make_pair(c, t));
c = pv[i].first;
t = pv[i].second;
}
}
for(int i = 0; i < is.size(); i++){
l += is[i].second;
h = max(h, l);
}
cout << h;
}
Compilation message
gw.cpp: In function 'int main()':
gw.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < pv.size(); i++){
~~^~~~~~~~~~~
gw.cpp:32:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < is.size(); i++){
~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1652 KB |
Output is correct |
2 |
Correct |
36 ms |
1652 KB |
Output is correct |
3 |
Correct |
36 ms |
1652 KB |
Output is correct |
4 |
Correct |
36 ms |
1652 KB |
Output is correct |
5 |
Correct |
36 ms |
1652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
3732 KB |
Output is correct |
2 |
Correct |
64 ms |
3760 KB |
Output is correct |
3 |
Correct |
76 ms |
3680 KB |
Output is correct |
4 |
Correct |
80 ms |
3664 KB |
Output is correct |
5 |
Correct |
72 ms |
3564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
809 ms |
31192 KB |
Output is correct |
2 |
Correct |
839 ms |
31132 KB |
Output is correct |
3 |
Correct |
810 ms |
31292 KB |
Output is correct |
4 |
Correct |
809 ms |
31184 KB |
Output is correct |
5 |
Correct |
770 ms |
30576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
771 ms |
25856 KB |
Output is correct |
2 |
Correct |
773 ms |
25868 KB |
Output is correct |
3 |
Correct |
768 ms |
25884 KB |
Output is correct |
4 |
Correct |
364 ms |
15432 KB |
Output is correct |
5 |
Correct |
392 ms |
15452 KB |
Output is correct |