結果

問題 No.2408 Lakes and Fish
ユーザー vjudge1
提出日時 2024-05-02 00:05:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,396 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 197,540 KB
最終ジャッジ日時 2025-02-21 10:06:42
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 1 MLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

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