結果

問題 No.2488 Mod Sum Maximization
ユーザー CyanmondCyanmond
提出日時 2023-09-29 15:34:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 1,854 ms
コンパイル使用メモリ 199,932 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 20:59:47
合計ジャッジ時間 5,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 86 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 82 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 83 ms
4,376 KB
testcase_09 AC 67 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 4 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 52 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 69 ms
4,380 KB
testcase_20 AC 74 ms
4,380 KB
testcase_21 AC 71 ms
4,384 KB
testcase_22 AC 82 ms
4,376 KB
testcase_23 AC 82 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 3 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 43 ms
4,380 KB
testcase_28 AC 43 ms
4,380 KB
testcase_29 AC 45 ms
4,380 KB
testcase_30 AC 28 ms
4,380 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 67 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 78 ms
4,376 KB
testcase_35 AC 27 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 2 ms
4,376 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using i64 = std::int64_t;

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for (auto &e : A) std::cin >> e;

    i64 ans = 0;
    {
        i64 sum = 0;
        for (int i = 0; i < N; ++i) {
            sum += A[i] % A[(i + 1) % N];
        }
        ans = std::max(ans, sum);
    }
    {
        i64 baseScore = ans;
        for (int i = 1; i < N - 1; ++i) {
            i64 diff = -(A[i - 1] % A[i]) + -(A[i] % A[i + 1]);
            diff += A[i - 1] % A[i + 1];
            diff -= A[N - 1] % A[0];
            diff += A[N - 1] % A[i];
            diff += A[i] % A[0];
            ans = std::max(ans, baseScore + diff);
        }
    }
    std::cout << ans << std::endl;
}
0