結果

問題 No.1279 Array Battle
ユーザー hanyu
提出日時 2020-11-28 00:31:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 200,524 KB
最終ジャッジ日時 2025-01-16 08:53:39
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n), b(n), ord(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) ord[i] = i;
  
  map<int, int> mp;
  do {
    int keep = 0;
    for (int i = 0; i < n; i++) keep += max(a[ord[i]] - b[i], 0);
    mp[keep]++;
  } while (next_permutation(ord.begin(), ord.end()));
  
  cout << mp.rbegin()->second << '\n';
}
0