提出 #48103325


ソースコード 拡げる

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pi pair<int, int>
#define mp make_pair

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

const int INF = (int)4e18;
const int MODa = 1e9 + 7;
const int MOD = 998244353;

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

void solve()
{
	int n, s, m, l;
	cin>>n>>s>>m>>l;

	vector<int> dp(115, INF);
	dp[0] = 0;

	int ps[] = {6, 8, 12};
	int pr[] = {s, m, l};

	for(int i=1; i<115; i++)
	{
		for(int j=0; j<3; j++)
		{
			if(i>=ps[j])
			{
				dp[i]=  min(dp[i], dp[i-ps[j]] + pr[j]);
			}
		}
	}

	for(int i=113; i; i--)
	{
		dp[i] = min(dp[i], dp[i+1]);
	}

	cout<<dp[n]<<"\n";
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;	
	//cin>>t;
	while(t--)
	{
		solve();
	}

	return 0;
}

提出情報

提出日時
問題 B - Buy One Carton of Milk
ユーザ ha___il
言語 C++ 23 (gcc 12.2)
得点 200
コード長 994 Byte
結果 AC
実行時間 1 ms
メモリ 3600 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 25
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 1 ms 3480 KiB
random_02.txt AC 1 ms 3456 KiB
random_03.txt AC 1 ms 3600 KiB
random_04.txt AC 1 ms 3468 KiB
random_05.txt AC 1 ms 3512 KiB
random_06.txt AC 1 ms 3524 KiB
random_07.txt AC 1 ms 3536 KiB
random_08.txt AC 1 ms 3480 KiB
random_09.txt AC 1 ms 3476 KiB
random_10.txt AC 1 ms 3376 KiB
random_11.txt AC 1 ms 3320 KiB
random_12.txt AC 1 ms 3380 KiB
random_13.txt AC 1 ms 3540 KiB
random_14.txt AC 1 ms 3480 KiB
random_15.txt AC 1 ms 3508 KiB
random_16.txt AC 1 ms 3432 KiB
random_17.txt AC 1 ms 3516 KiB
random_18.txt AC 1 ms 3476 KiB
random_19.txt AC 1 ms 3480 KiB
random_20.txt AC 1 ms 3324 KiB
random_21.txt AC 1 ms 3456 KiB
random_22.txt AC 1 ms 3540 KiB
sample_01.txt AC 1 ms 3480 KiB
sample_02.txt AC 1 ms 3544 KiB
sample_03.txt AC 1 ms 3460 KiB