結果

問題 No.1160 Strange Bowling
ユーザー t98slider
提出日時 2022-12-14 23:38:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 166,356 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 16:06:48
合計ジャッジ時間 3,198 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, p, v;
    cin >> n;
    array<int, 2> dp = {0, -(1 << 30)};
    for(int i = 0; i < n; i++){
        cin >> p >> v;
        array<int, 2> ndp{};
        for(int j = 0; j < 2; j++){
            for(int k = 0; k < 2; k++){
                ndp[k] = max(ndp[k], (1 + (j & 1)) * (k & 1 ? v : p) + dp[j]);
            }
        }
        swap(dp, ndp);
    }
    cout << dp[0] << '\n';
}
0