답안 #897217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897217 2024-01-02T17:48:17 Z AndrijaM 지구 온난화 (NOI13_gw) C++14
0 / 40
1000 ms 35956 KB
#include <bits/stdc++.h>

using namespace std;

const long long maxn=1e4+10;
const long long mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    vector<pair<int,int>>v;
    bool vis[n];
    vector<int>og;
    for(int i=0;i<n;i++)
    {
        vis[i]=0;
        int h;
        cin>>h;
        v.push_back({h,i});
        og.push_back(h);
    }
    int ans=1;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++)
    {
        int j=i-1;
        while(j+1<n && v[j+1].first==v[i].first)
        {
            j++;
            if(vis[v[j].second]==true)continue;
            int l=v[j].second;
            int r=v[j].second;
            vis[l]=true;
                while(l-1>=0)
                {
                    if(l-1>=0 && og[l-1]==v[j].first && vis[l-1]!=true)
                    {
                        vis[l-1]=true;
                    }
                    if(vis[l-1]==true)
                    {
                        l--;
                    }
                    else
                    {
                        break;
                    }
                }
            while(r+1<n)
            {
                if(r+1<n && og[r+1]==v[j].first && vis[r+1]!=true)
                    {
                        vis[r+1]=true;
                    }
                    if(vis[r+1]==true)
                    {
                        r++;
                    }
                    else
                    {
                        break;
                    }
            }
            if(l-1>=0 && r+1<n)
            {
                if(vis[l-1]==0 && vis[r+1]==0)
                {
                    ans++;
                }
            }
            cout<<i<<" "<<v[j].first<<" "<<v[j].second<<" "<<ans<<endl;
        }
        i=j;
    }
    cout<<ans<<endl;
    return 0;
}
/*
10
3
2
3
5
10
8
2
5
3
8
*/

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 120 ms 3652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 157 ms 4828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1044 ms 35956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1020 ms 35864 KB Time limit exceeded
2 Halted 0 ms 0 KB -