답안 #339233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339233 2020-12-24T23:28:11 Z Ahmad_Hasan 지구 온난화 (NOI13_gw) C++17
40 / 40
527 ms 21768 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int> >vps(n);
    for(int i=0;i<n;i++){
        cin>>vps[i].first;
        vps[i].second=i;
    }

    sort(vps.begin(),vps.end());

    int vis[n]={0};
    int mx=1;
    int cr=0;
    for(int i=n-1;i>=0;i--){
        vis[vps[i].second]=1;
        if((vps[i].second-1>=0&&vis[vps[i].second-1])&&(vps[i].second+1<n&&vis[vps[i].second+1]))
            cr--;
        else if((vps[i].second-1<0||!vis[vps[i].second-1])&&(vps[i].second+1>=n||!vis[vps[i].second+1]))
            cr++;
        if(i==0||vps[i-1].first!=vps[i].first)
            mx=max(mx,cr);
    }

    cout<<mx<<'\n';

    return 0;
}
/****

1
8 4
3 1
4 3
1 8
8 7

1
100 9
1 100
2 1
3 2
4 3
5 4
100 99
99 98
98 97
97 96



19 3 6
3 12 9


2000000000 1000000000 1000000000
3 1000000000 1000000000

*/
# 결과 실행 시간 메모리 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 31 ms 1772 KB Output is correct
2 Correct 30 ms 1772 KB Output is correct
3 Correct 31 ms 1792 KB Output is correct
4 Correct 30 ms 1772 KB Output is correct
5 Correct 30 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 2416 KB Output is correct
2 Correct 36 ms 2156 KB Output is correct
3 Correct 48 ms 2284 KB Output is correct
4 Correct 47 ms 2284 KB Output is correct
5 Correct 45 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 527 ms 21404 KB Output is correct
2 Correct 519 ms 21484 KB Output is correct
3 Correct 526 ms 21392 KB Output is correct
4 Correct 520 ms 21768 KB Output is correct
5 Correct 495 ms 20972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 519 ms 20872 KB Output is correct
2 Correct 515 ms 20744 KB Output is correct
3 Correct 516 ms 20972 KB Output is correct
4 Correct 327 ms 14956 KB Output is correct
5 Correct 335 ms 14956 KB Output is correct