結果

問題 No.1279 Array Battle
ユーザー ytftytft
提出日時 2021-05-18 04:37:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 936 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 4,738 ms
コンパイル使用メモリ 340,868 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-07 19:46:45
合計ジャッジ時間 10,489 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mp;

int main(){
    int N;
    cin>>N;
    vector<int> a(N),b(N),ind(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
        ind[i]=i;
    }
    for(int i=0;i<N;i++){
        cin>>b[i];
    }
    int ans=0;
    int m=0;
    do{
        int temp=0;
        for(int i=0;i<N;i++){
            if(a[ind[i]]>b[i]){
                temp+=a[ind[i]]-b[i];
            }
        }
        if(m==temp){
            ++ans;
        }
        cerr<<temp<<endl;
        if(m<temp){
            m=temp;
            ans=1;
        }
    }while(next_permutation(ind.begin(),ind.end()));
    cout<<ans<<endl;
}
0