結果
| 問題 |
No.1279 Array Battle
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2020-11-08 17:04:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 674 bytes |
| コンパイル時間 | 1,077 ms |
| コンパイル使用メモリ | 75,896 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 15:18:31 |
| 合計ジャッジ時間 | 2,847 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <iostream>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main() {
int N; cin >> N;
vector<int> a(N), b(N), c(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;
int ans = 0;
int maxScore = -1;
do {
int s = 0;
for (int i = 0; i < N; i++) {
s += max(0, a[c[i]] - b[i]);
}
if (s > maxScore) {
maxScore = s;
ans = 0;
}
if (s == maxScore) ans++;
} while (next_permutation(c.begin(), c.end()));
cout << ans << endl;
}
norioc