結果

問題 No.2408 Lakes and Fish
ユーザー vjudge1vjudge1
提出日時 2024-05-02 00:05:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,396 bytes
コンパイル時間 2,472 ms
コンパイル使用メモリ 203,244 KB
実行使用メモリ 817,232 KB
最終ジャッジ日時 2024-05-02 00:05:49
合計ジャッジ時間 5,012 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    int T;
    cin >> T;

    while (T--) {
        int N, M;
        cin >> N >> M;

        vector<int> L(N);
        for (int i = 0; i < N; ++i) {
            cin >> L[i];
        }

        vector<int> F(M), B(M), W(M);
        for (int i = 0; i < M; ++i) {
            cin >> F[i];
        }
        for (int i = 0; i < M; ++i) {
            cin >> B[i];
        }
        for (int i = 0; i < M; ++i) {
            cin >> W[i];
        }

        long long sun_strength = 0, total_moves = 0;
        for (int i = 0; i < M; ++i) {
            if (F[i] <= L[0]) {
                sun_strength += B[i];
            } else {
                sun_strength += W[i];
            }
        }

        long long max_magic = sun_strength;
        for (int i = 1; i < N; ++i) {
            long long new_sun_strength = sun_strength;
            for (int j = 0; j < M; ++j) {
                if (F[j] <= L[i]) {
                    new_sun_strength += B[j];
                } else {
                    new_sun_strength += W[j];
                }
            }

            long long moves = abs(L[i] - L[i - 1]);
            max_magic = max(max_magic, new_sun_strength - moves);
            sun_strength = new_sun_strength;
            total_moves += moves;
        }

        cout << max_magic - total_moves << endl;
    }

    return 0;
}

0