結果

問題 No.1279 Array Battle
ユーザー iqueue02
提出日時 2020-11-06 22:21:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 202,436 KB
最終ジャッジ日時 2025-01-15 20:57:01
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  
  vector<int> id(n, 0);
  rep(i,n) id[i] = i;
  map<int, int> mp;
  int res = 0;
  int cur = -1;
  do {
    int tmp = 0;
    rep(i,n) tmp += max(0, a[id[i]] - b[i]);
    mp[tmp]++;
  } while (next_permutation(id.begin(), id.end()));
  for (auto e : mp) {
    if (cur < e.first) res = e.second;
  }
  cout << res << endl;
  return 0;
}
0