結果

問題 No.1279 Array Battle
ユーザー 👑 platinumplatinum
提出日時 2020-11-03 17:00:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 77,612 KB
実行使用メモリ 5,320 KB
最終ジャッジ日時 2023-09-29 14:48:50
合計ジャッジ時間 1,753 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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