結果

問題 No.818 Dinner time
ユーザー veqccveqcc
提出日時 2019-04-19 22:31:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 105,308 KB
実行使用メモリ 6,844 KB
最終ジャッジ日時 2023-10-24 05:19:23
合計ジャッジ時間 2,638 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 20 ms
6,844 KB
testcase_18 AC 14 ms
5,524 KB
testcase_19 AC 15 ms
5,524 KB
testcase_20 AC 19 ms
6,580 KB
testcase_21 AC 17 ms
6,052 KB
testcase_22 AC 14 ms
5,260 KB
testcase_23 AC 15 ms
5,788 KB
testcase_24 AC 22 ms
6,844 KB
testcase_25 AC 15 ms
5,788 KB
testcase_26 AC 13 ms
5,260 KB
testcase_27 AC 19 ms
6,316 KB
testcase_28 AC 16 ms
5,788 KB
testcase_29 AC 21 ms
6,580 KB
testcase_30 AC 18 ms
6,052 KB
testcase_31 AC 19 ms
6,316 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);

    ll n, m;
    cin >> n >> m;

    ll a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    vector <ll> opt(n+1, 0);
    vector <ll> mx(n+1, 0);
    for (int i = 0; i < n; i++) {
        opt[i+1] = max(a[i], b[i]) + opt[i];
        mx[i+1] = max(mx[i], opt[i+1]);
    }

    vector <ll> sm(n+1, 0);
    for (int i = 0; i < n; i++) {
        ll val = max({b[i], (m-1)*a[i] + b[i], m*a[i]});
        sm[i+1] = sm[i] + val;
    }

    ll ans = 0;
    for (int k = 0; k <= n; k++) {
        ans = max(ans, sm[k] + (mx[n] - mx[k]));
    }

    cout << ans << "\n";
    return 0;
}
0