結果

問題 No.818 Dinner time
ユーザー milanis48663220milanis48663220
提出日時 2020-09-28 02:31:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,057 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 83,372 KB
実行使用メモリ 9,824 KB
最終ジャッジ日時 2023-09-13 13:29:42
合計ジャッジ時間 5,786 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll N, M;
ll A[100000], B[100000];
ll gain[100000][3];
ll dp[100000][3];

const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];

    for(int i = 0; i < N; i++){
        gain[i][0] = max({A[i]*M, A[i]*(M-1)+B[i], B[i]});
        gain[i][1] = max(A[i], B[i]);
        gain[i][2] = 0;

        cout << gain[i][0] << ' ' << gain[i][1] << ' ' << gain[i][2] << endl;
    }

    dp[0][0] = gain[0][0];
    dp[0][1] = B[0];
    dp[0][2] = B[0];

    for(int i = 1; i < N; i++){
        dp[i][0] = dp[i-1][0]+gain[i][0];
        dp[i][1] = max({dp[i-1][0]+gain[i][1], dp[i-1][1]+gain[i][1]});
        dp[i][2] = max({dp[i-1][0]+gain[i][2], dp[i-1][1]+gain[i][2], dp[i-1][2]+gain[i][2]});
    }
    cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
}
0