結果

問題 No.1279 Array Battle
ユーザー yansi819
提出日時 2024-03-23 20:19:39
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 656 bytes
コンパイル時間 4,201 ms
コンパイル使用メモリ 250,384 KB
最終ジャッジ日時 2025-02-20 13:28:18
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

int N, a[10], b[10], c[10], sum, res = -1, cnt;

int main() {
  cin >> 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++) c[i] = i;
  do {
    sum = 0;
    for (int i = 0; i < N; i++) {
      sum += max(a[c[i]] - b[i], 0);
    }
    //cout << sum << ' ' << res << endl;
    if (sum > res) {
      res = sum;
      cnt = 1;
    } else if (sum == res) {
      cnt++;
    }
  } while (next_permutation(c, c + N));
  cout << cnt << endl;
  return 0;
}
0