結果

問題 No.2221 Set X
ユーザー kuronikuroni
提出日時 2023-02-17 22:29:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,602 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 1,534 ms
コンパイル使用メモリ 167,972 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 19:46:05
合計ジャッジ時間 17,895 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 101 ms
4,376 KB
testcase_17 AC 28 ms
4,376 KB
testcase_18 AC 123 ms
4,376 KB
testcase_19 AC 23 ms
4,380 KB
testcase_20 AC 59 ms
4,376 KB
testcase_21 AC 540 ms
4,376 KB
testcase_22 AC 848 ms
4,380 KB
testcase_23 AC 16 ms
4,376 KB
testcase_24 AC 477 ms
4,376 KB
testcase_25 AC 244 ms
4,376 KB
testcase_26 AC 394 ms
4,380 KB
testcase_27 AC 395 ms
4,380 KB
testcase_28 AC 395 ms
4,376 KB
testcase_29 AC 602 ms
4,376 KB
testcase_30 AC 387 ms
4,376 KB
testcase_31 AC 397 ms
4,376 KB
testcase_32 AC 1,602 ms
4,376 KB
testcase_33 AC 1,579 ms
4,376 KB
testcase_34 AC 1,554 ms
4,376 KB
testcase_35 AC 1,527 ms
4,376 KB
testcase_36 AC 523 ms
4,376 KB
testcase_37 AC 459 ms
4,376 KB
testcase_38 AC 522 ms
4,376 KB
testcase_39 AC 355 ms
4,376 KB
testcase_40 AC 347 ms
4,376 KB
testcase_41 AC 394 ms
4,376 KB
testcase_42 AC 379 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) + 2;
    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(2 * d);
    for (int i = d + 1; i < 2 * n; i++) {
        for (int j = 1; j < 2 * 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;
}
0