結果
問題 |
No.1279 Array Battle
|
ユーザー |
![]() |
提出日時 | 2020-11-06 22:35:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 2,104 ms |
コンパイル使用メモリ | 202,680 KB |
最終ジャッジ日時 | 2025-01-15 21:03:12 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<int, int>> a(n); vector<int> b(n); for(int i = 0; i < n; ++i) { int x; cin >> x; a[i] = make_pair(i, x); } for(auto &e : b) cin >> e; sort(a.begin(), a.end()); int mx_score = -1, mx_cnt = 0; do { int score = 0; for(int i = 0; i < n; ++i) { score += abs(a[i].second - b[i]); } if(mx_score < score) { mx_score = score; mx_cnt = 1; } else if(mx_score == score) { mx_cnt++; } } while(next_permutation(a.begin(), a.end())); cout << mx_cnt << '\n'; return 0; }