結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 14 ms
4,952 KB
testcase_23 AC 16 ms
5,168 KB
testcase_24 WA -
testcase_25 AC 16 ms
5,152 KB
testcase_26 AC 13 ms
4,904 KB
testcase_27 AC 19 ms
5,564 KB
testcase_28 WA -
testcase_29 AC 20 ms
5,720 KB
testcase_30 AC 17 ms
5,408 KB
testcase_31 AC 18 ms
5,532 KB
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 = 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