結果

問題 No.1163 I want to be a high achiever
ユーザー kotatsugamekotatsugame
提出日時 2020-09-09 20:09:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 68,288 KB
実行使用メモリ 260,216 KB
最終ジャッジ日時 2023-08-22 09:37:03
合計ジャッジ時間 7,769 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
15,696 KB
testcase_01 AC 9 ms
15,620 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 9 ms
15,708 KB
testcase_04 AC 249 ms
260,072 KB
testcase_05 AC 253 ms
260,216 KB
testcase_06 AC 209 ms
259,988 KB
testcase_07 AC 208 ms
260,204 KB
testcase_08 AC 191 ms
259,876 KB
testcase_09 AC 197 ms
259,984 KB
testcase_10 AC 189 ms
260,064 KB
testcase_11 AC 194 ms
260,072 KB
testcase_12 AC 195 ms
259,872 KB
testcase_13 AC 203 ms
260,000 KB
testcase_14 AC 204 ms
259,872 KB
testcase_15 AC 198 ms
259,932 KB
testcase_16 AC 198 ms
259,872 KB
testcase_17 AC 195 ms
260,076 KB
testcase_18 AC 195 ms
259,876 KB
testcase_19 AC 193 ms
260,004 KB
testcase_20 AC 193 ms
259,872 KB
testcase_21 AC 196 ms
259,856 KB
testcase_22 AC 194 ms
259,920 KB
testcase_23 AC 192 ms
259,928 KB
testcase_24 AC 192 ms
259,876 KB
testcase_25 AC 192 ms
259,856 KB
testcase_26 AC 192 ms
259,872 KB
testcase_27 AC 9 ms
15,616 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 197 ms
259,932 KB
testcase_30 AC 4 ms
7,712 KB
testcase_31 AC 4 ms
7,560 KB
testcase_32 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,X,A[505];
int B[505],dp[505][1<<17];
const int off=1<<16;
main()
{
	for(int i=0;i<1<<17;i++)dp[0][i]=1e9;
	dp[0][off]=0;
	cin>>N>>X;
	bool out=true;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		if(A[i]>=X)out=false;
	}
	if(out)
	{
		cout<<-1<<endl;
		return 0;
	}
	for(int i=0;i<N;i++)cin>>B[i];
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<1<<17;j++)dp[i+1][j]=dp[i][j]+B[i];
		int di=A[i]-X;
		for(int j=0;j<1<<17;j++)
		{
			if(j+di<1<<17&&j+di>=0)
			{
				dp[i+1][j+di]=min(dp[i+1][j+di],dp[i][j]);
			}
		}
	}
	int ans=1e9;
	for(int j=off;j<1<<17;j++)ans=min(ans,dp[N][j]);
	cout<<ans<<endl;
}
0