Submission #897201

# Submission time Handle Problem Language Result Execution time Memory
897201 2024-01-02T17:30:35 Z AndrijaM Global Warming (NOI13_gw) C++14
0 / 40
204 ms 26420 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 && og[l-1]==v[j].first)
            {
                l--;
                vis[l]=true;
            }
            while(r+1<n && og[r+1]==v[j].first)
            {
                r++;
                vis[r]=true;
            }
            if(l-1>=0 && r+1<n)
            {
                if(vis[l-1]==0 && vis[r+1]==0)
                {
                    ans++;
                }
            }
            ///cout<<i<<" "<<ans<<endl;
        }
        i=j;
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 2388 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 172 ms 26420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 204 ms 26160 KB Output isn't correct
2 Halted 0 ms 0 KB -