# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336326 | 2020-12-15T04:46:04 Z | beepbeepsheep | Global Warming (NOI13_gw) | C++17 | 221 ms | 34132 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const ll bignum=1e17; const int inf= 2e9; const int mod= 1e9+7; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll ele,n; cin>>n; vector<ll> arr; ll prev=-1; for (ll i=0;i<n;i++){ cin>>ele; if (ele!=prev){ arr.push_back(ele); } prev=ele; } if (arr.size()==1){ cout<<1; return 0; } vector<pair<ll,ll>> v; for (ll i=1;i<arr.size()-1;i++){ if (arr[i]>arr[i-1] && arr[i]>arr[i+1]){ v.push_back(make_pair(arr[i],1)); } if (arr[i]<arr[i-1] && arr[i]<arr[i+1]){ v.push_back(make_pair(arr[i],-1)); } } if (arr[0]>arr[1]) v.push_back(make_pair(arr[0],1)); if (arr[arr.size()-1]>arr[arr.size()-2]) v.push_back(make_pair(arr[arr.size()-1],1)); sort(v.rbegin(),v.rend()); ll ans=0,curr=0; for (ll i=0;i<v.size();i++){ curr+=v[i].second; if (i!=v.size()-1 && v[i+1].first==v[i].first) continue; ans=max(curr,ans); } cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 2664 KB | Output is correct |
2 | Correct | 13 ms | 2664 KB | Output is correct |
3 | Correct | 13 ms | 2664 KB | Output is correct |
4 | Correct | 13 ms | 2664 KB | Output is correct |
5 | Correct | 13 ms | 2664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 3308 KB | Output is correct |
2 | Correct | 18 ms | 3308 KB | Output is correct |
3 | Correct | 20 ms | 3308 KB | Output is correct |
4 | Correct | 20 ms | 3308 KB | Output is correct |
5 | Correct | 19 ms | 3308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 214 ms | 24840 KB | Output is correct |
2 | Runtime error | 221 ms | 34132 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 215 ms | 24788 KB | Output is correct |
2 | Runtime error | 216 ms | 33528 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |