結果
| 問題 |
No.2221 Set X
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-02-17 21:46:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 1,882 ms |
| コンパイル使用メモリ | 195,136 KB |
| 最終ジャッジ日時 | 2025-02-10 16:39:19 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
int xmin = 1;
int ans = 2 * n;
for (int x = 2; x < 2 * n; x++) {
int i = 0;
int cur = 0;
int last = 0;
while (cur < ans) {
int i = std::lower_bound(a.begin(), a.end(), last) - a.begin();
if (i == n) {
break;
}
last = a[i] / x * x + x;
cur += x + 1;
}
if (cur < ans) {
ans = cur;
xmin = x;
}
}
std::cout << xmin << "\n";
std::cout << ans << "\n";
return 0;
}