結果

問題 No.1834 1D Gravity
ユーザー rianoriano
提出日時 2022-01-06 23:33:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,237 bytes
コンパイル時間 1,418 ms
コンパイル使用メモリ 167,336 KB
実行使用メモリ 6,280 KB
最終ジャッジ日時 2023-08-07 15:35:31
合計ジャッジ時間 3,122 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 23 ms
6,156 KB
testcase_02 AC 22 ms
6,164 KB
testcase_03 AC 22 ms
6,172 KB
testcase_04 AC 22 ms
6,212 KB
testcase_05 AC 22 ms
6,236 KB
testcase_06 AC 21 ms
6,280 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 25 ms
6,236 KB
testcase_14 AC 23 ms
5,888 KB
testcase_15 AC 22 ms
5,904 KB
testcase_16 AC 21 ms
6,264 KB
testcase_17 AC 21 ms
6,168 KB
testcase_18 AC 22 ms
6,232 KB
testcase_19 AC 22 ms
6,260 KB
testcase_20 AC 24 ms
6,164 KB
testcase_21 AC 22 ms
6,212 KB
testcase_22 AC 22 ms
6,240 KB
testcase_23 AC 21 ms
6,216 KB
testcase_24 AC 20 ms
6,000 KB
testcase_25 AC 21 ms
6,148 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(k,m) k = min(k,m)
#define chmax(k,m) k = max(k,m)
#define riano_ std::ios::sync_with_stdio(false);std::cin.tie(nullptr)

int main() {
    riano_; //ll ans = 0;
    ll N,M,K; cin >> N;
    vector<ll> a(N+2,0); vector<ll> b(N+2,0);
    rep(i,N) cin >> a[i+1];
    if(N==2){
        cout << 0 << " " << 1 << endl; return 0;
    }
    rep(i,N){
        if(a[i]>a[i+2]) chmax(b[i],a[i+1]);
        else chmax(b[i+2],a[i+1]);
    }

    ll tim = 0,cnt = 0;
    ll l = 0,r = 0,om = 0,em = 0,oi = 0,ei = 0;
    rep(i,N+2){
        if(b[i]==0){
            if(l!=0){
                ll m1 = min(oi,ei),m2 = max(oi,ei);
                ll tmp = 0;
                ll lw = m1-l,rw = r-m2,ct = m2-m1-1;
                tmp = max(lw,rw) + ct/2;
                cnt++; chmax(tim,tmp+1);
            }
            l = 0,r = 0,om = 0,em = 0;
        }
        else{
            if(l==0) l = i;
            r = i;
            if(i%2==0&&b[i]>em){
                em = b[i]; ei = i;
            }
            if(i%2==1&&b[i]>om){
                om = b[i]; oi = i;
            }
        }
    }

    cout << tim << " " << cnt << endl;
}
0