結果

問題 No.2221 Set X
ユーザー kuronikuroni
提出日時 2023-02-17 22:24:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 167,704 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-26 19:41:00
合計ジャッジ時間 33,811 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 365 ms
4,380 KB
testcase_17 AC 92 ms
4,384 KB
testcase_18 AC 446 ms
4,384 KB
testcase_19 AC 76 ms
4,380 KB
testcase_20 AC 208 ms
4,388 KB
testcase_21 AC 563 ms
4,380 KB
testcase_22 AC 865 ms
4,384 KB
testcase_23 AC 17 ms
4,384 KB
testcase_24 AC 501 ms
4,380 KB
testcase_25 AC 263 ms
4,384 KB
testcase_26 AC 1,394 ms
4,384 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1,588 ms
4,384 KB
testcase_33 AC 1,587 ms
4,384 KB
testcase_34 AC 1,589 ms
4,380 KB
testcase_35 AC 1,589 ms
4,380 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

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) + 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(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