結果
問題 | No.1279 Array Battle |
ユーザー | 🍮かんプリン |
提出日時 | 2020-11-06 21:35:17 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 1,079 bytes |
コンパイル時間 | 1,506 ms |
コンパイル使用メモリ | 173,520 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-29 18:19:55 |
合計ジャッジ時間 | 2,349 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 2 ms
4,380 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 12 ms
4,376 KB |
testcase_16 | AC | 12 ms
4,380 KB |
testcase_17 | AC | 11 ms
4,380 KB |
testcase_18 | AC | 11 ms
4,380 KB |
testcase_19 | AC | 12 ms
4,380 KB |
ソースコード
/** * @FileName a.cpp * @Author kanpurin * @Created 2020.11.06 21:35:02 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int bitpopcount(ll n) { int res = 0; while (n) { if (n & 1) res++; n >>= 1; } return res; } int main() { int n;cin >> n; vector<pair<int,int>> a(n); vector<int> b(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } for (int i = 0; i < n; i++) { cin >> b[i]; } sort(a.begin(), a.end()); int m = 0; do { int sum = 0; for (int i = 0; i < n; i++) { sum += max(0,a[i].first-b[i]); } m = max(m,sum); } while(next_permutation(a.begin(), a.end())); sort(a.begin(), a.end()); int ans = 0; do { int sum = 0; for (int i = 0; i < n; i++) { sum += max(0,a[i].first-b[i]); } if (sum == m) { ans++; } } while(next_permutation(a.begin(), a.end())); cout << ans << endl; return 0; }