結果

問題 No.1279 Array Battle
ユーザー norioc
提出日時 2020-11-08 16:56:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 78,472 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-22 15:15:26
合計ジャッジ時間 1,722 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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