結果

問題 No.2221 Set X
ユーザー t98slidert98slider
提出日時 2023-02-17 22:33:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,115 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 166,252 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-26 19:53:39
合計ジャッジ時間 52,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 1,970 ms
4,380 KB
testcase_17 AC 766 ms
4,380 KB
testcase_18 AC 1,969 ms
4,376 KB
testcase_19 AC 604 ms
4,380 KB
testcase_20 AC 1,970 ms
4,380 KB
testcase_21 AC 1,971 ms
4,380 KB
testcase_22 AC 1,971 ms
4,376 KB
testcase_23 AC 93 ms
4,380 KB
testcase_24 AC 1,971 ms
4,376 KB
testcase_25 AC 1,971 ms
4,376 KB
testcase_26 AC 1,971 ms
4,380 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1,974 ms
4,380 KB
testcase_33 AC 1,971 ms
4,380 KB
testcase_34 AC 1,972 ms
4,376 KB
testcase_35 AC 1,972 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 * 1960;
    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;
    }
    vector<int> b(n);
    auto f = [&](int v){
        int cnt = 1;
        for(int i = 0; i < n; i++){
            b[i] = a[i] / v;
            if(i >= 1 && b[i] != b[i - 1])cnt++;
        }
        return cnt * (v + 1);
    };
    for(int i = 1; i <= 320 && clock() <= finish; i++){
        int v = f(i);
        if(v < ans){
            ans = v;
            pos = i;
        }
    }
    for(int i = upper_bound(a.begin(), a.end(), 320) - a.begin(); i < n && clock() <= finish; i++){
        int v = f(a[i] + 1);
        if(v < ans){
            ans = v;
            pos = a[i] + 1;
        }
    }
    cout << pos << '\n';
    cout << ans << '\n';
}
0