답안 #936559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936559 2024-03-02T07:45:32 Z Warinchai 지구 온난화 (NOI13_gw) C++14
40 / 40
185 ms 31920 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int ar[1000005];
int add[1000005];
vector<pair<int,int> >v;
int cnt=0;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>ar[i];
        v.push_back({ar[i],i});
    }
    sort(v.begin(),v.end(),greater<pair<int,int>>());
    int mx=0;
    int temp=0;
    pair<int,int>x;
    for(int i=0;i<n;){
        x=v[i];
        add[x.second]=1;
        temp=0;
        if(add[x.second-1])temp++;
        if(add[x.second+1])temp++;
        if(temp==0)cnt++;
        if(temp==2)cnt--;
        i++;
        while(i<n&&x.first==v[i].first){
            x=v[i];
            add[x.second]=1;
            temp=0;
            if(add[x.second-1])temp++;
            if(add[x.second+1])temp++;
            if(temp==0)cnt++;
            if(temp==2)cnt--;
            i++;
        }
        mx=max(mx,cnt);
    }
    cout<<mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 6868 KB Output is correct
2 Correct 19 ms 7052 KB Output is correct
3 Correct 15 ms 6868 KB Output is correct
4 Correct 15 ms 6864 KB Output is correct
5 Correct 17 ms 6864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 6868 KB Output is correct
2 Correct 11 ms 6868 KB Output is correct
3 Correct 17 ms 7052 KB Output is correct
4 Correct 17 ms 6868 KB Output is correct
5 Correct 16 ms 6864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 174 ms 31792 KB Output is correct
2 Correct 176 ms 31700 KB Output is correct
3 Correct 175 ms 31700 KB Output is correct
4 Correct 171 ms 31660 KB Output is correct
5 Correct 166 ms 31752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 179 ms 31700 KB Output is correct
2 Correct 176 ms 31700 KB Output is correct
3 Correct 185 ms 31700 KB Output is correct
4 Correct 157 ms 31920 KB Output is correct
5 Correct 155 ms 31656 KB Output is correct