結果

問題 No.1279 Array Battle
ユーザー kpinkcatkpinkcat
提出日時 2023-08-31 15:53:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 110,164 KB
実行使用メモリ 5,096 KB
最終ジャッジ日時 2023-08-31 15:53:37
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include <algorithm>
#include<math.h>
#include <iomanip>
#include<set>
#include <numeric>
#include<string>
using namespace std;

int main()
{
    int n, cnt = 0;
    cin >> n;
    vector<int> a(n), b(n), sum1;
    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());
    do {
        int tsum = 0;
        for (int i = 0; i < n; i ++){
            if (a[i] > b[i]) tsum += (a[i] - b[i]);
        }
        sum1.push_back(tsum);
    }while (next_permutation(a.begin(), a.end()));
    sort(sum1.begin(), sum1.end(), greater());
    for (int i = 0; i < sum1.size(); i++){
        if (sum1[i] == sum1[0]) cnt++;
    }
    cout << cnt << endl;
}   
0