結果
問題 | No.1279 Array Battle |
ユーザー |
|
提出日時 | 2020-11-07 02:20:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 1,862 ms |
コンパイル使用メモリ | 171,968 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 14:07:45 |
合計ジャッジ時間 | 2,671 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;constexpr char newl = '\n';int main() {cin.tie(nullptr);ios::sync_with_stdio(false);int n;cin >> n;vector<ll> a(n), b(n);for (int i = 0; i < n; i++) {cin >> a[i];}for (int i = 0; i < n; i++) {cin >> b[i];}ll ans = 0;ll max_score = -1;vector<int> ids(n, 0);iota(ids.begin(), ids.end(), 0);do {ll score = 0;for (int ii = 0; ii < n; ++ii) {int i = ids[ii];score += max(a[i] - b[ii], 0LL);}if (score > max_score) {ans = 1;max_score = score;} else if (score == max_score) ++ans;} while (next_permutation(ids.begin(), ids.end()));cout << ans << newl;return 0;}