結果

問題 No.2221 Set X
ユーザー otoshigootoshigo
提出日時 2023-02-20 17:59:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 618 ms / 2,000 ms
コード長 1,104 bytes
コンパイル時間 1,171 ms
コンパイル使用メモリ 76,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 14:59:17
合計ジャッジ時間 14,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 142 ms
4,380 KB
testcase_17 AC 47 ms
4,376 KB
testcase_18 AC 166 ms
4,376 KB
testcase_19 AC 41 ms
4,376 KB
testcase_20 AC 91 ms
4,376 KB
testcase_21 AC 266 ms
4,376 KB
testcase_22 AC 378 ms
4,380 KB
testcase_23 AC 17 ms
4,380 KB
testcase_24 AC 242 ms
4,376 KB
testcase_25 AC 144 ms
4,380 KB
testcase_26 AC 339 ms
4,376 KB
testcase_27 AC 387 ms
4,376 KB
testcase_28 AC 389 ms
4,380 KB
testcase_29 AC 526 ms
4,380 KB
testcase_30 AC 444 ms
4,380 KB
testcase_31 AC 417 ms
4,380 KB
testcase_32 AC 583 ms
4,380 KB
testcase_33 AC 611 ms
4,376 KB
testcase_34 AC 614 ms
4,380 KB
testcase_35 AC 618 ms
4,376 KB
testcase_36 AC 514 ms
4,376 KB
testcase_37 AC 493 ms
4,380 KB
testcase_38 AC 515 ms
4,376 KB
testcase_39 AC 371 ms
4,376 KB
testcase_40 AC 391 ms
4,380 KB
testcase_41 AC 452 ms
4,376 KB
testcase_42 AC 440 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int ax=-1;
    ll ac=1LL<<60;
    for(int x=1;x<=2*n-1;x++){
        int d=0,at=0;
        bool flag=true;
        while(at<n){
            int ok=at,ng=n;
            while(ng-ok>1){
                int mid=(ok+ng)/2;
                if(a[at]/x==a[mid]/x)ok=mid;
                else ng=mid;
            }
            d++;
            at=ok+1;
            if((ll)(x+1)*d>2*n){
                flag=false;
                break;
            }
        }
        if(flag&&chmin(ac,(ll)(x+1)*d))ax=x;
    }
    cout<<ax<<"\n"<<ac<<"\n";
}
0