結果
| 問題 | No.1279 Array Battle | 
| コンテスト | |
| ユーザー |  milanis48663220 | 
| 提出日時 | 2020-11-06 21:24:54 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 13 ms / 2,000 ms | 
| コード長 | 962 bytes | 
| コンパイル時間 | 689 ms | 
| コンパイル使用メモリ | 85,832 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 12:04:28 | 
| 合計ジャッジ時間 | 1,366 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    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];
    vector<int> v(n);
    for(int i = 0; i < n; i++) v[i] = i;
    int ans = 0;
    do{
        int tmp = 0;
        for(int i = 0; i < n; i++){
            tmp += max(0, a[v[i]]-b[i]);
        }
        ans = max(ans, tmp);
    }while(next_permutation(v.begin(), v.end()));
    int cnt = 0;
    for(int i = 0; i < n; i++) v[i] = i;
    do{
        int tmp = 0;
        for(int i = 0; i < n; i++){
            tmp += max(0, a[v[i]]-b[i]);
        }
        if(tmp == ans) cnt++;
    }while(next_permutation(v.begin(), v.end()));
    cout << cnt << endl;
}
            
            
            
        