Submission #59029774


Source Code Expand

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef modint1000000007 mi;

int main(){
	ll n,a,b,c;cin>>n>>a>>b>>c;

	ll ans=100000;

	for(int i=0;i<10000;i++){
		for (int j=0;j<=i;j++){
			if(n-(i-j)*a-j*b>=0&&(n-(i-j)*a-j*b)%c==0){
				ans=min(ans,i+(n-(i-j)*a-j*b)/c);
			}
		}
	}
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task 016 - Minimum Coins(★3)
User Rho17
Language C++ 20 (gcc 12.2)
Score 3
Code Size 431 Byte
Status AC
Exec Time 145 ms
Memory 3712 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 3 / 3
Status
AC × 4
AC × 21
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt
All rand_01.txt, rand_02.txt, rand_03.txt, rand_04.txt, rand_05.txt, rand_06.txt, rand_07.txt, rand_08.txt, rand_09.txt, rand_10.txt, rand_large_abc_1.txt, rand_large_abc_2.txt, rand_large_abc_3.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt
Case Name Status Exec Time Memory
rand_01.txt AC 116 ms 3648 KiB
rand_02.txt AC 107 ms 3708 KiB
rand_03.txt AC 141 ms 3536 KiB
rand_04.txt AC 113 ms 3588 KiB
rand_05.txt AC 112 ms 3528 KiB
rand_06.txt AC 110 ms 3628 KiB
rand_07.txt AC 142 ms 3496 KiB
rand_08.txt AC 141 ms 3536 KiB
rand_09.txt AC 111 ms 3524 KiB
rand_10.txt AC 145 ms 3504 KiB
rand_large_abc_1.txt AC 31 ms 3444 KiB
rand_large_abc_2.txt AC 31 ms 3708 KiB
rand_large_abc_3.txt AC 145 ms 3584 KiB
sample_1.txt AC 32 ms 3452 KiB
sample_2.txt AC 54 ms 3524 KiB
sample_3.txt AC 45 ms 3496 KiB
sample_4.txt AC 145 ms 3580 KiB
small_1.txt AC 124 ms 3472 KiB
small_2.txt AC 33 ms 3524 KiB
small_3.txt AC 31 ms 3712 KiB
small_4.txt AC 32 ms 3568 KiB