結果

問題 No.1279 Array Battle
ユーザー noriocnorioc
提出日時 2020-11-08 16:56:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 77,920 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 21:19:02
合計ジャッジ時間 1,625 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];

    sort(a.begin(), a.end());
    int ans = 0;
    int maxScore = -1;
    do {
        int s = 0;
        for (int i = 0; i < N; i++) {
            s += max(0, a[i] - b[i]);
        }

        if (s > maxScore) {
            maxScore = s;
            ans = 0;
        }
        if (s == maxScore) ans++;
    } while (next_permutation(a.begin(), a.end()));

    cout << ans << endl;
}
0