답안 #783698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783698 2023-07-15T08:39:18 Z Cookie 지구 온난화 (NOI13_gw) C++14
19 / 40
31 ms 9676 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 = 3e5 + 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 + 1;
        if(ok[0])val--;
        if(ok[n - 1])val--;
        ans = max(ans, val);
        i = r;
    }
    cout << ans;
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1748 KB Output is correct
2 Correct 14 ms 2004 KB Output is correct
3 Correct 14 ms 2004 KB Output is correct
4 Correct 14 ms 2004 KB Output is correct
5 Correct 14 ms 2004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1748 KB Output is correct
2 Correct 10 ms 2388 KB Output is correct
3 Correct 16 ms 2520 KB Output is correct
4 Correct 16 ms 2520 KB Output is correct
5 Correct 15 ms 2400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 9676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 27 ms 9548 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -