結果
| 問題 | No.1279 Array Battle | 
| コンテスト | |
| ユーザー |  🍮かんプリン | 
| 提出日時 | 2020-11-06 21:35:17 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 16 ms / 2,000 ms | 
| コード長 | 1,079 bytes | 
| コンパイル時間 | 1,846 ms | 
| コンパイル使用メモリ | 174,092 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 12:21:07 | 
| 合計ジャッジ時間 | 2,582 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.11.06 21:35:02
**/
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;
int bitpopcount(ll n) {
    int res = 0;
    while (n) {
        if (n & 1) res++;
        n >>= 1;
    }
    return res;
}
int main() {
    int n;cin >> n;
    vector<pair<int,int>> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    sort(a.begin(), a.end());
    int m = 0;
    do {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += max(0,a[i].first-b[i]);
        }
        m = max(m,sum);
    } while(next_permutation(a.begin(), a.end()));
    
    sort(a.begin(), a.end());
    int ans = 0;
    do {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += max(0,a[i].first-b[i]);
        }
        if (sum == m) {
            ans++;
        }
    } while(next_permutation(a.begin(), a.end()));
    cout << ans << endl;
    return 0;
}
            
            
            
        