結果

問題 No.2221 Set X
ユーザー t98slidert98slider
提出日時 2023-02-17 23:09:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,193 bytes
コンパイル時間 3,528 ms
コンパイル使用メモリ 165,388 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-26 20:31:03
合計ジャッジ時間 4,110 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 14 ms
4,376 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 23 ms
4,380 KB
testcase_22 AC 29 ms
4,376 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 21 ms
4,380 KB
testcase_25 AC 14 ms
4,376 KB
testcase_26 AC 35 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 41 ms
4,376 KB
testcase_34 AC 41 ms
4,380 KB
testcase_35 AC 40 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;
using ll = long long;

int main(){
    clock_t finish = clock() + CLOCKS_PER_SEC / 1000 * 1920;
    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 = 0; i < 30 && clock() <= finish; i++){
        ll v = f(1 << i);
        if(v < ans){
            ans = v;
            pos = 1 << i;
        }
    }
    zi = 0;
    for(int i = 0; i < 30 && clock() <= finish; i++){
        ll v = f((1 << i) + 1);
        if(v < ans){
            ans = v;
            pos = (1 << i) + 1;
        }
    }
    cout << pos << '\n';
    cout << ans << '\n';
}
0