Submission #783687

# Submission time Handle Problem Language Result Execution time Memory
783687 2023-07-15T08:31:00 Z Cookie Global Warming (NOI13_gw) C++14
0 / 40
17 ms 3152 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("FEEDING.INP");
ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
const int x[4] = {1, -1, 0, 0};
const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 7, inf = 1e16;
const int mxn = 1e5 + 5;
int cnt = 0;

int n;
int h[mxn + 1];
signed main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    vt<pii>comp;
    forr(i, 0, n){
        cin >> h[i]; comp.pb({h[i], i});
    }
    sort(comp.begin(), comp.end());
    vt<bool>ok(n + 1);
    int ans = 0;
    for(int i = 0; i < sz(comp);){
        int r = i + 1;
        while(r < sz(comp) && comp[r].fi == comp[i].fi)r++;
        for(int j = i; j < r; j++){
            int id = comp[j].second;
            cnt++;
            if(id && ok[id - 1])cnt--;
            if(id < n && ok[id + 1])cnt--;
            ok[id] = 1;
        }
        int val = cnt;
        if(ok[0])val--;
        if(ok[n - 1])val--;
        ans = max(ans, val);
        i = r;
    }
    cout << ans;
    return(0);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 1680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 3152 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 3152 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -