結果

問題 No.1279 Array Battle
ユーザー deuteridayo
提出日時 2020-11-23 21:00:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 1,920 ms
コンパイル使用メモリ 174,480 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-23 17:44:14
合計ジャッジ時間 2,743 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
long const mod = 1e9+7;
int main(){
    int n;
    cin >> n;
    long a[n];
    long b[n];
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];
    vector<int>per(n);
    for(int i=0;i<n;i++)per[i] = i;
    long maxx = 0;
    map<long,long>mapp;
    do{
        long tmp = 0;
        for(int i=0;i<n;i++){
            if(a[per[i]] > b[i]){
                tmp += a[per[i]] - b[i];
            }
        }
        mapp[tmp]++;
        maxx = max(maxx,tmp);
    }while(next_permutation(per.begin(),per.end()));

    cout << mapp[maxx] << endl;
}
0