結果

問題 No.818 Dinner time
ユーザー kyort0nkyort0n
提出日時 2019-04-19 22:41:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 1,941 ms
コンパイル使用メモリ 167,288 KB
実行使用メモリ 5,876 KB
最終ジャッジ日時 2023-10-24 05:55:58
合計ジャッジ時間 3,669 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, M;
ll A[100050];
ll B[100050];
ll before[100050];
ll beforemax = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    ll ans = 0;
    for(int i = 1; i <= N; i++) cin >> A[i] >> B[i];
    ll now = 0;
    for(int i = 1; i <= N; i++) {
        now += max(A[i], B[i]);
        ll delta = A[i] * (M - 1);
        if(A[i] < 0) {
            if(B[i] < A[i])
            delta = max(delta, B[i] - A[i]);
        }
        before[i] = before[i - 1] + delta;
        beforemax = max(beforemax, before[i]);
        ans = max(ans, beforemax + now);
    }
    cout << ans << endl;
    return 0;
}
0