結果

問題 No.2890 Chiffon
ユーザー RubikunRubikun
提出日時 2024-09-13 21:43:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 753 ms / 2,000 ms
コード長 2,516 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 206,144 KB
実行使用メモリ 182,972 KB
最終ジャッジ日時 2024-09-13 21:43:55
合計ジャッジ時間 12,995 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
15,712 KB
testcase_01 AC 5 ms
15,844 KB
testcase_02 AC 4 ms
15,840 KB
testcase_03 AC 5 ms
15,712 KB
testcase_04 AC 5 ms
15,840 KB
testcase_05 AC 4 ms
15,840 KB
testcase_06 AC 4 ms
15,972 KB
testcase_07 AC 4 ms
15,712 KB
testcase_08 AC 5 ms
15,840 KB
testcase_09 AC 5 ms
15,836 KB
testcase_10 AC 5 ms
15,968 KB
testcase_11 AC 5 ms
15,716 KB
testcase_12 AC 5 ms
15,712 KB
testcase_13 AC 5 ms
15,716 KB
testcase_14 AC 5 ms
15,972 KB
testcase_15 AC 4 ms
15,844 KB
testcase_16 AC 5 ms
15,840 KB
testcase_17 AC 5 ms
15,968 KB
testcase_18 AC 4 ms
15,840 KB
testcase_19 AC 5 ms
15,708 KB
testcase_20 AC 4 ms
15,716 KB
testcase_21 AC 5 ms
15,712 KB
testcase_22 AC 247 ms
182,872 KB
testcase_23 AC 327 ms
101,248 KB
testcase_24 AC 230 ms
80,384 KB
testcase_25 AC 622 ms
155,264 KB
testcase_26 AC 542 ms
164,608 KB
testcase_27 AC 18 ms
10,368 KB
testcase_28 AC 39 ms
20,352 KB
testcase_29 AC 332 ms
88,832 KB
testcase_30 AC 607 ms
176,896 KB
testcase_31 AC 488 ms
154,624 KB
testcase_32 AC 18 ms
13,184 KB
testcase_33 AC 209 ms
182,912 KB
testcase_34 AC 210 ms
182,824 KB
testcase_35 AC 209 ms
182,912 KB
testcase_36 AC 209 ms
182,840 KB
testcase_37 AC 210 ms
182,952 KB
testcase_38 AC 231 ms
182,828 KB
testcase_39 AC 209 ms
182,908 KB
testcase_40 AC 202 ms
182,892 KB
testcase_41 AC 209 ms
182,912 KB
testcase_42 AC 212 ms
182,912 KB
testcase_43 AC 212 ms
182,912 KB
testcase_44 AC 214 ms
182,912 KB
testcase_45 AC 213 ms
182,876 KB
testcase_46 AC 214 ms
182,912 KB
testcase_47 AC 239 ms
182,872 KB
testcase_48 AC 210 ms
182,916 KB
testcase_49 AC 211 ms
182,912 KB
testcase_50 AC 212 ms
182,912 KB
testcase_51 AC 213 ms
182,912 KB
testcase_52 AC 216 ms
182,972 KB
testcase_53 AC 753 ms
182,912 KB
testcase_54 AC 291 ms
182,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=1000005,INF=15<<26;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")


ll db[23][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K;cin>>N>>K;
    vl NG(2*N+3);
    for(int i=0;i<K;i++){
        int x;cin>>x;x--;
        NG[x]=true;
    }
    
    ll le=0,ri=N/K+3;
    while(ri-le>1){
        ll mid=(le+ri)/2;
        for(int t=0;t<22;t++) for(int i=0;i<2*N;i+=2) db[t][i]=-1;
        int j=1;
        int cn=0;
        for(int i=1;i<2*N;i+=2){
            while(j-i<2*mid||cn==0){
                if(NG[(j+1)%(2*N)]) cn++;
                j+=2;
            }
            db[0][i]=j-i;
            //cout<<mid<<" "<<j-i<<endl;
            if(NG[i+1]) cn--;
        }
        
        for(int t=1;t<=20;t++){
            for(int i=1;i<2*N;i+=2){
                if(db[t-1][i]>2*N){
                    db[t][i]=2*N+2;
                    continue;
                }
                int y=(i+db[t-1][i]);
                while(y>=2*N) y-=2*N;
                db[t][i]=db[t-1][i]+db[t-1][y];
            }
        }
        
        bool ok=false;
        
        for(int i=1;i<2*N;i+=2){
            ll now=i,sum=0;
            for(int t=20;t>=0;t--){
                if(K&(1<<t)){
                    sum+=db[t][now];
                    now=(now+db[t][now]);
                    while(now>=2*N) now-=2*N;
                }
                
                if(sum>2*N) break;
            }
            
            if(sum<=2*N) ok=true;
        }
        
        if(ok) le=mid;
        else ri=mid;
    }
    
    cout<<2*le<<endl;
}


0