結果

問題 No.818 Dinner time
ユーザー kyort0nkyort0n
提出日時 2019-04-19 21:47:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 944 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 167,448 KB
実行使用メモリ 5,116 KB
最終ジャッジ日時 2023-10-24 01:22:26
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 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 1 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 17 ms
5,060 KB
testcase_18 AC 12 ms
4,564 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 13 ms
4,476 KB
testcase_23 AC 15 ms
4,620 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 12 ms
4,444 KB
testcase_27 WA -
testcase_28 AC 15 ms
4,652 KB
testcase_29 AC 19 ms
4,988 KB
testcase_30 AC 16 ms
4,780 KB
testcase_31 AC 18 ms
4,864 KB
testcase_32 AC 15 ms
4,680 KB
権限があれば一括ダウンロードができます

ソースコード

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];

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