結果

問題 No.2221 Set X
ユーザー t98slidert98slider
提出日時 2023-02-17 22:57:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 981 bytes
コンパイル時間 2,701 ms
コンパイル使用メモリ 166,584 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-26 20:19:54
合計ジャッジ時間 88,314 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

int main(){
    clock_t finish = clock() + CLOCKS_PER_SEC / 1000 * 1900;
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &&v:a)cin >> v;
    int pos = -1;
    int ans = 1 << 30;
    if(2 * n < ans){
        ans = 2 * n;
        pos = 1;
    }
    if(a.back() + 2 < ans){
        ans = a.back() + 2;
        pos = a.back() + 1;
    }
    int zi = 0;
    vector<int> b(n);
    auto f = [&](int v){
        int cnt = 1;
        while(zi < n && a[zi] < v) zi++;
        if(zi) b[zi - 1] = 0;
        for(int i = zi; i < n; i++){
            b[i] = a[i] / v;
            if(i >= 1 && b[i] != b[i - 1])cnt++;
        }
        return (ll)(cnt) * (v + 1);
    };
    for(int i = 1; clock() <= finish; i++){
        ll v = f(i);
        if(v < ans){
            ans = v;
            pos = i;
        }
    }
    cout << pos << '\n';
    cout << ans << '\n';
}
0