結果

問題 No.2221 Set X
ユーザー 鴨志田卓鴨志田卓
提出日時 2023-02-19 14:34:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 164,852 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 20:38:34
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 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,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 84 ms
4,380 KB
testcase_17 AC 29 ms
4,376 KB
testcase_18 AC 99 ms
4,376 KB
testcase_19 AC 26 ms
4,380 KB
testcase_20 AC 55 ms
4,380 KB
testcase_21 AC 105 ms
4,376 KB
testcase_22 AC 152 ms
4,376 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 98 ms
4,376 KB
testcase_25 AC 57 ms
4,380 KB
testcase_26 AC 188 ms
4,380 KB
testcase_27 AC 237 ms
4,376 KB
testcase_28 AC 238 ms
4,376 KB
testcase_29 AC 183 ms
4,380 KB
testcase_30 AC 192 ms
4,380 KB
testcase_31 AC 229 ms
4,380 KB
testcase_32 AC 164 ms
4,376 KB
testcase_33 AC 197 ms
4,380 KB
testcase_34 AC 182 ms
4,380 KB
testcase_35 AC 168 ms
4,380 KB
testcase_36 AC 181 ms
4,376 KB
testcase_37 AC 185 ms
4,376 KB
testcase_38 AC 181 ms
4,380 KB
testcase_39 AC 196 ms
4,380 KB
testcase_40 AC 222 ms
4,376 KB
testcase_41 AC 206 ms
4,376 KB
testcase_42 AC 202 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

int n, a[N];

int getNext(int x, int p) {
    int l = p, r = n + 1;
    while(l + 1 < r) {
        int mid = (l + r) / 2;
        if(a[mid] / x > a[p] / x) r = mid;
        else l = mid;
    }
    return r;
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    
    int x = 1, fx = 2 * n;
    for(int i = 2; i < 2 * n; i ++) {
        int cnt = 0;
        for(int j = 1; j <= n; ) {
            j = getNext(i, j);
            cnt ++;
            if(cnt * (i + 1) >= fx) break;
        }
        if(cnt * (i + 1) < fx) {
            x = i;
            fx = cnt * (i + 1);
        }
    }
    cout << x << "\n" << fx;
}
0