Submission #936558

# Submission time Handle Problem Language Result Execution time Memory
936558 2024-03-02T07:43:51 Z Warinchai Global Warming (NOI13_gw) C++14
29 / 40
188 ms 34704 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;
    for(int i=0;i<n;){
        auto x=v[i];
        add[x.second]=1;
        int 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){
            auto x=v[i];
            add[x.second]=1;
            int 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;
}
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 15 ms 7060 KB Output is correct
2 Correct 16 ms 7124 KB Output is correct
3 Correct 15 ms 7300 KB Output is correct
4 Correct 15 ms 7308 KB Output is correct
5 Correct 15 ms 7124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 6868 KB Output is correct
2 Correct 11 ms 6868 KB Output is correct
3 Correct 22 ms 7056 KB Output is correct
4 Correct 17 ms 7000 KB Output is correct
5 Correct 17 ms 6868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 176 ms 32176 KB Output is correct
2 Correct 175 ms 31664 KB Output is correct
3 Correct 176 ms 31848 KB Output is correct
4 Correct 177 ms 31696 KB Output is correct
5 Correct 169 ms 31916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 32048 KB Output is correct
2 Correct 181 ms 31984 KB Output is correct
3 Correct 188 ms 31700 KB Output is correct
4 Correct 161 ms 31776 KB Output is correct
5 Runtime error 157 ms 34704 KB Memory limit exceeded
6 Halted 0 ms 0 KB -