結果

問題 No.1279 Array Battle
ユーザー yamakeyamake
提出日時 2020-11-06 21:55:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,068 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 89,072 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 18:40:24
合計ジャッジ時間 1,868 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define debug(output) cout<<#output<<"= "<<output<<endl

using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> b(n);
  vector<P> a(n);
  rep(i,n){
    cin>>a[i].first;
    a[i].second=i;
  }
  rep(i,n)cin>>b[i];
  sort(a.begin(),a.end());
  lint mx=0;
  do{
    lint buf=0;
    rep(i,n){
      if(a[i].first>b[i])buf+=a[i].first-b[i];
    }
    mx=max(mx,buf);
  }while(next_permutation(a.begin(),a.end()));
  int cnt=0;
  sort(a.begin(),a.end());
  do{
    lint buf=0;
    rep(i,n){
      if(a[i].first>b[i])buf+=a[i].first-b[i];
    }
    if(buf==mx)++cnt;
  }while(next_permutation(a.begin(),a.end()));
  cout<<cnt<<"\n";
  return 0;
}
0