結果

問題 No.2221 Set X
ユーザー otoshigootoshigo
提出日時 2023-02-18 19:31:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,515 bytes
コンパイル時間 2,151 ms
コンパイル使用メモリ 207,240 KB
実行使用メモリ 71,948 KB
最終ジャッジ日時 2023-09-27 09:42:41
合計ジャッジ時間 10,568 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 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 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 855 ms
61,680 KB
testcase_17 AC 186 ms
19,080 KB
testcase_18 AC 1,082 ms
71,948 KB
testcase_19 AC 158 ms
15,856 KB
testcase_20 AC 439 ms
39,520 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
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];
    vector<vector<int>>V(N);
    rep(i,N){
        int b=1;
        while(b*b<=A[i]){
            if((A[i]+b)/(b+1)+(A[i]%(b+1)==0)<2*N)V[i].push_back((A[i]+b)/(b+1)+(A[i]%(b+1)==0));
            if(b<2*N)V[i].push_back(b);
            b++;
        }
        if(A[i]+1<2*N)V[i].push_back(A[i]+1);
        sort(all(V[i]));
        V[i].erase(unique(all(V[i])),V[i].end());
    }
    vector<int>S(2*N+1);
    rep(i,N-1){
        vector<int>X;
        for(auto x:V[i])X.push_back(x);
        for(auto x:V[i+1])X.push_back(x);
        X.push_back(2*N);
        sort(all(X));
        X.erase(unique(all(X)),X.end());
        int l=X.size();
        rep(j,l-1){
            int px=X[j],qx=X[j+1];
            if(A[i]/px<A[i+1]/px){
                S[px]++;
                S[qx]--;
            }
        }
    }
    int k=1;
    ll ans=2*N;
    rep(i,2*N)S[i+1]+=S[i];
    for(ll x=2;x<=2*N-1;x++){
        if(chmin(ans,(x+1)*(S[x]+1)))k=x;
    }
    cout<<k<<"\n";
    cout<<ans<<"\n";
}
0