結果
問題 |
No.2221 Set X
|
ユーザー |
|
提出日時 | 2023-02-17 22:23:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 919 bytes |
コンパイル時間 | 1,610 ms |
コンパイル使用メモリ | 170,864 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 13:32:32 |
合計ジャッジ時間 | 20,653 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int d = sqrt(2 * n) + 1; pair<int, int> ans = {2 * n, 1}; for (int i = 2; i <= d; i++) { int cnt = 1; for (int j = 1; j < n; j++) { if (a[j] / i > a[j - 1] / i) { cnt++; } } ans = min(ans, {cnt * (i + 1), i}); } vector<int> pt(d + 1); for (int i = d + 1; i < 2 * n; i++) { for (int j = 1; j <= d; j++) { while (pt[j] < n && a[pt[j]] / i <= a[pt[j] - 1] / i) { pt[j]++; } if (pt[j] == n) { ans = min(ans, {j * (i + 1), i}); break; } } } cout << ans.second << '\n' << ans.first; }