結果
| 問題 |
No.3363 Two Closest Numbers
|
| コンテスト | |
| ユーザー |
rurun
|
| 提出日時 | 2025-10-27 23:41:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 626 bytes |
| コンパイル時間 | 3,400 ms |
| コンパイル使用メモリ | 283,688 KB |
| 実行使用メモリ | 10,788 KB |
| 最終ジャッジ日時 | 2025-11-17 20:33:47 |
| 合計ジャッジ時間 | 7,514 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 52 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 998244353;
const lint INF = (1LL<<60);
lint solve(int N, vector<int> c) {
sort(c.begin(), c.end());
lint ans = INF;
do {
for (lint i = 0; i < (1<<N); i++) {
lint a = 0, b = 0;
for (lint j = 0; j < N; j++) {
if ((1<<j)&i) a = a*10+c[j];
else b = b*10+c[j];
}
ans = min(ans, abs(a-b));
}
} while (next_permutation(c.begin(), c.end()));
return ans;
}
int main() {
int N;
cin >> N;
vector<int> c(N);
for (int i = 0; i < N; i++) cin >> c[i];
cout << solve(N, c) << endl;
}
rurun