結果

問題 No.2890 Chiffon
ユーザー kotatsugamekotatsugame
提出日時 2024-09-13 21:43:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 740 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 65,076 KB
実行使用メモリ 9,188 KB
最終ジャッジ日時 2024-09-13 21:43:54
合計ジャッジ時間 2,798 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 52 ms
9,188 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 22 ms
6,944 KB
testcase_34 AC 22 ms
7,848 KB
testcase_35 AC 22 ms
6,944 KB
testcase_36 AC 22 ms
6,944 KB
testcase_37 AC 22 ms
6,940 KB
testcase_38 AC 22 ms
6,944 KB
testcase_39 AC 22 ms
6,944 KB
testcase_40 AC 22 ms
7,164 KB
testcase_41 AC 22 ms
7,160 KB
testcase_42 AC 23 ms
6,944 KB
testcase_43 AC 22 ms
6,940 KB
testcase_44 AC 22 ms
7,160 KB
testcase_45 AC 23 ms
6,944 KB
testcase_46 AC 22 ms
6,944 KB
testcase_47 AC 22 ms
7,020 KB
testcase_48 AC 22 ms
6,944 KB
testcase_49 AC 22 ms
6,940 KB
testcase_50 AC 22 ms
6,940 KB
testcase_51 AC 22 ms
7,048 KB
testcase_52 AC 22 ms
6,940 KB
testcase_53 AC 3 ms
6,944 KB
testcase_54 AC 15 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
int N,K;
int A[1500000];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>K;
	for(int i=0;i<K;i++)
	{
		cin>>A[i],A[i]--;
		A[i+K]=A[i]+N+N;
		A[i+K+K]=A[i]+N+N+N+N;
	}
	int idx=-1;
	{
		int W=1e9;
		for(int i=0;i<K;i++)
		{
			int w=A[i+1]-A[i];
			if(W>w)W=w,idx=i;
		}
	}
	int l=0,r=N;
	while(r-l>1)
	{
		int m=(l+r)/2;
		bool ok=false;
		for(int s=A[idx]+1;s<A[idx+1];s+=2)
		{
			int u=s;
			bool now=true;
			for(int j=1;j<=K;j++)
			{
				int nu=max(u+m+m,A[idx+j]+1);
				if(nu>A[idx+j+1])
				{
					now=false;
					break;
				}
				u=nu;
			}
			if(now&&u<=s+N+N)
			{
				ok=true;
				break;
			}
		}
		if(ok)l=m;
		else r=m;
	}
	cout<<l+l<<endl;
}
0