# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
336325 | 2020-12-15T04:44:45 Z | beepbeepsheep | 지구 온난화 (NOI13_gw) | C++17 | 214 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 (int 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 (int 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 (int 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
# | 결과 | 실행 시간 | 메모리 | 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 2920 KB | Output is correct |
2 | Correct | 13 ms | 2920 KB | Output is correct |
3 | Correct | 14 ms | 2920 KB | Output is correct |
4 | Correct | 16 ms | 2920 KB | Output is correct |
5 | Correct | 13 ms | 2920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 4204 KB | Output is correct |
2 | Correct | 18 ms | 3948 KB | Output is correct |
3 | Correct | 21 ms | 4204 KB | Output is correct |
4 | Correct | 18 ms | 4204 KB | Output is correct |
5 | Correct | 19 ms | 4076 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 214 ms | 34132 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 213 ms | 33532 KB | Memory limit exceeded |
2 | Halted | 0 ms | 0 KB | - |