結果
問題 |
No.2221 Set X
|
ユーザー |
![]() |
提出日時 | 2023-02-17 23:29:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 853 ms |
コンパイル使用メモリ | 95,072 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 14:41:08 |
合計ジャッジ時間 | 2,859 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); for (auto &x : A) cin >> x; int best = 2 * N; int argbest = 1; for (int x = 2; x < N * 2; ++x) { int cnt = 0; for (int i = 0; i < N and cnt < best; i = lower_bound(begin(A) + i + 1, end(A), A[i] + x - A[i] % x) - begin(A)) { if (cnt + (N - i + x - 1) / x * (x + 1) >= best) { cnt = best; break; } cnt += x + 1; } if (best > cnt) best = cnt, argbest = x; } cout << argbest << '\n' << best << '\n'; }