結果
| 問題 |
No.2890 Chiffon
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2024-09-13 21:43:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 871 ms / 2,000 ms |
| コード長 | 2,516 bytes |
| コンパイル時間 | 2,263 ms |
| コンパイル使用メモリ | 201,060 KB |
| 最終ジャッジ日時 | 2025-02-24 07:25:29 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 53 |
ソースコード
#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;
}
Rubikun