結果

問題 No.2542 Yokan for Two
ユーザー k82bk82b
提出日時 2023-11-24 21:55:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 466 ms / 2,000 ms
コード長 1,206 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 203,056 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-24 21:55:46
合計ジャッジ時間 17,233 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,676 KB
testcase_01 AC 17 ms
6,676 KB
testcase_02 AC 7 ms
6,676 KB
testcase_03 AC 161 ms
6,676 KB
testcase_04 AC 347 ms
6,676 KB
testcase_05 AC 245 ms
6,676 KB
testcase_06 AC 12 ms
6,676 KB
testcase_07 AC 411 ms
6,676 KB
testcase_08 AC 156 ms
6,676 KB
testcase_09 AC 401 ms
6,676 KB
testcase_10 AC 189 ms
6,676 KB
testcase_11 AC 254 ms
6,676 KB
testcase_12 AC 189 ms
6,676 KB
testcase_13 AC 222 ms
6,676 KB
testcase_14 AC 438 ms
6,676 KB
testcase_15 AC 435 ms
6,676 KB
testcase_16 AC 461 ms
6,676 KB
testcase_17 AC 435 ms
6,676 KB
testcase_18 AC 438 ms
6,676 KB
testcase_19 AC 466 ms
6,676 KB
testcase_20 AC 460 ms
6,676 KB
testcase_21 AC 463 ms
6,676 KB
testcase_22 AC 434 ms
6,676 KB
testcase_23 AC 438 ms
6,676 KB
testcase_24 AC 30 ms
6,676 KB
testcase_25 AC 47 ms
6,676 KB
testcase_26 AC 46 ms
6,676 KB
testcase_27 AC 51 ms
6,676 KB
testcase_28 AC 55 ms
6,676 KB
testcase_29 AC 112 ms
6,676 KB
testcase_30 AC 436 ms
6,676 KB
testcase_31 AC 435 ms
6,676 KB
testcase_32 AC 448 ms
6,676 KB
testcase_33 AC 438 ms
6,676 KB
testcase_34 AC 462 ms
6,676 KB
testcase_35 AC 435 ms
6,676 KB
testcase_36 AC 433 ms
6,676 KB
testcase_37 AC 461 ms
6,676 KB
testcase_38 AC 432 ms
6,676 KB
testcase_39 AC 433 ms
6,676 KB
testcase_40 AC 462 ms
6,676 KB
testcase_41 AC 433 ms
6,676 KB
testcase_42 AC 457 ms
6,676 KB
testcase_43 AC 435 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int=long long;
using Real=long double;
template<class T>inline bool chmin(T&A,T B){return(A>B?A=B,1:0);}
template<class T>inline bool chmax(T&A,T B){return(A<B?A=B,1:0);}
#define REP(i,n)for(int i=0;i<(n);++i)
#define REP1(i,n)for(int i=1;i<=(n);++i)
#define ALL(x)begin(x),end(x)
#define drop(x){cout<<x<<'\n';return;}
const int MOD=998244353;
int L,N;
int X[200],A[200];
bool dp[2][3<<17][2][2];
int zero=(3<<17)/2;
void sol()
{
	cin>>L>>N;
	REP(i,N)
	{
		cin>>X[i+1];
		A[i]=X[i+1]-X[i];
	}
	A[N]=L-X[N];
	int now=0;
	dp[now][zero-A[0]][0][0]=dp[now][zero+A[0]][1][0]=true;
	REP1(i,N)
	{
		int nxt=!now;
		REP(j,3<<17)REP(k,2)REP(l,2)dp[nxt][j][k][l]=false;
		REP(j,3<<17)REP(k,2)REP(l,2)
		{
			if(j-A[i]>=0)
			{
				dp[nxt][j-A[i]][0][(l+(k==1))%2]|=dp[now][j][k][l];
			}
			if(j+A[i]<3<<17)
			{
				dp[nxt][j+A[i]][1][(l+(k==0))%2]|=dp[now][j][k][l];
			}
		}
		now=nxt;
	}
	REP(i,1e9)
	{
		bool ok=false;
		REP(j,2)ok=ok||dp[now][zero-i][j][1]||dp[now][zero+i][j][1];
		if(ok)drop(i);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout<<fixed<<setprecision(16);
	int T=1;
	//cin>>T;
	while(T--)sol();
}
0