답안 #993461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993461 2024-06-05T17:09:52 Z AndrijaM 지구 온난화 (NOI13_gw) C++14
40 / 40
185 ms 26196 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int maxn=1e6+10;
const int mod=1e9+7;

struct st
{
    int val;
    int idx;
}v[maxn];

bool vis[maxn];

bool S(st x,st y)
{
    return x.val<y.val;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ///freopen("prieteni.in","r",stdin);
    ///freopen("prieteni.out","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i].val;
        v[i].idx=i;
    }
    vis[0]=vis[n+1]=1;
    sort(v+1,v+n+1,S);
    int ans=1;
    int sum=1;
    int i=1;
    while(i<=n)
    {
        int j=i-1;
        while(j+1<=n && v[j+1].val==v[i].val)
        {
            j++;
        }
        for(;i<=j;i++)
        {
            int ind=v[i].idx;
            if(vis[ind-1]==1 && vis[ind+1]==1)
            {
                sum--;
            }
            if(!vis[ind-1] && !vis[ind+1])
            {
                sum++;
            }
            vis[ind]=1;
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2520 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 9 ms 4440 KB Output is correct
2 Correct 10 ms 4700 KB Output is correct
3 Correct 10 ms 4696 KB Output is correct
4 Correct 11 ms 4700 KB Output is correct
5 Correct 10 ms 4828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 4444 KB Output is correct
2 Correct 11 ms 5212 KB Output is correct
3 Correct 16 ms 5412 KB Output is correct
4 Correct 16 ms 5468 KB Output is correct
5 Correct 16 ms 5340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 172 ms 16856 KB Output is correct
2 Correct 168 ms 16844 KB Output is correct
3 Correct 176 ms 26188 KB Output is correct
4 Correct 171 ms 26196 KB Output is correct
5 Correct 172 ms 25684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 185 ms 16848 KB Output is correct
2 Correct 184 ms 25672 KB Output is correct
3 Correct 170 ms 25536 KB Output is correct
4 Correct 99 ms 19800 KB Output is correct
5 Correct 98 ms 19740 KB Output is correct