結果
| 問題 | No.3363 Two Closest Numbers |
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-12-06 00:07:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 710 bytes |
| 記録 | |
| コンパイル時間 | 3,331 ms |
| コンパイル使用メモリ | 279,300 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-12-06 00:07:38 |
| 合計ジャッジ時間 | 8,023 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
vector<int> cnt(10, 0);
rep(i, n) cnt[a[i]]++;
rep(i, 10) cnt[i] %= 2;
vector<int> rem;
rep(i, 10) if (cnt[i]) rem.push_back(i);
int ans = 1e9;
do {
int x = 0, y = 0;
rep(i, rem.size()) {
if (i < rem.size() / 2)
x = x * 10 + rem[i];
else
y = y * 10 + rem[i];
}
ans = min(ans, abs(x - y));
} while (next_permutation(rem.begin(), rem.end()));
cout << ans << '\n';
return 0;
}
a01sa01to