結果

問題 No.158 奇妙なお使い
ユーザー kotatsugamekotatsugame
提出日時 2020-02-13 01:36:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 69,776 KB
実行使用メモリ 8,008 KB
最終ジャッジ日時 2024-04-15 03:06:01
合計ジャッジ時間 1,932 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,816 KB
testcase_01 AC 7 ms
6,944 KB
testcase_02 AC 8 ms
6,940 KB
testcase_03 AC 7 ms
6,944 KB
testcase_04 AC 17 ms
8,008 KB
testcase_05 AC 6 ms
6,940 KB
testcase_06 AC 6 ms
6,944 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 7 ms
6,944 KB
testcase_09 AC 7 ms
6,944 KB
testcase_10 AC 7 ms
6,944 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 7 ms
6,940 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 7 ms
6,944 KB
testcase_15 AC 8 ms
6,940 KB
testcase_16 AC 8 ms
6,944 KB
testcase_17 AC 9 ms
7,372 KB
testcase_18 AC 10 ms
6,944 KB
testcase_19 AC 7 ms
6,944 KB
testcase_20 AC 8 ms
6,940 KB
testcase_21 AC 7 ms
6,944 KB
testcase_22 AC 6 ms
6,940 KB
testcase_23 AC 7 ms
6,940 KB
testcase_24 AC 7 ms
6,944 KB
testcase_25 AC 7 ms
6,944 KB
testcase_26 AC 7 ms
6,940 KB
testcase_27 AC 7 ms
6,944 KB
testcase_28 AC 7 ms
6,944 KB
testcase_29 AC 7 ms
6,944 KB
testcase_30 AC 8 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int dp[11][101][10001];
int D[2],B1[2],B2[2],B3[2];
main()
{
	int A1,A2,A3;
	cin>>A1>>A2>>A3;
	for(int i=0;i<2;i++)
	{
		cin>>D[i]>>B1[i]>>B2[i]>>B3[i];
	}
	dp[A1][A2][A3]=1;
	int ans=0;
	for(int all=10000;all>=0;all--)
	{
		for(int i=0;i*1000<=all;i++)for(int j=0;i*1000+j*100<=all;j++)
		{
			int k=all-i*1000-j*100;
			if(dp[i][j][k]==0)continue;
			ans=max(ans,dp[i][j][k]-1);
			for(int id=0;id<2;id++)
			{
				if(all>=D[id])
				{
					int rest=D[id];
					int I=min(i,rest/1000);
					rest-=I*1000;
					int J=min(j,rest/100);
					rest-=J*100;
					int K=rest;
					if(k>=K)
					{
						int ni=i-I+B1[id];
						int nj=j-J+B2[id];
						int nk=k-K+B3[id];
						dp[ni][nj][nk]=max(dp[ni][nj][nk],dp[i][j][k]+1);
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}
0