結果

問題 No.1279 Array Battle
ユーザー platinum
提出日時 2020-11-03 17:00:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 77,812 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-22 08:59:59
合計ジャッジ時間 1,499 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
const int M = 100000000;

int main(){
  int N;
  cin >> N;
  assert(1 <= N and N <= 9);
  vector<int> a(N), b(N), p(N);
  rep(i,N) cin >> a[i];
  rep(i,N) assert(1 <= a[i] and a[i] <= M);
  rep(i,N) cin >> b[i];
  rep(i,N) assert(1 <= b[i] and b[i] <= M);
  rep(i,N) p[i] = i;
  vector<int> score;
  do{
  	int total = 0;
  	rep(i,N){
  		int A = a[p[i]], B = b[i];
  		int point = max(A - B, 0);
  		total += point;
  	}
  	score.push_back(total);
  }while(next_permutation(p.begin(),p.end()));
  sort(score.begin(),score.end(),greater<int>());
  int max_score = score[0];
  int ans = 0;
  rep(i,score.size()){
  	if(score[i] == max_score) ans++;
  	else break;
  }
  cout << ans << endl;

  return 0;
}
0