Submission #21906534


Source Code Expand

#include <iostream>
#define rep(i, n) for (std::uint32_t i = 0; i < (n); ++i)

using ll = std::uint64_t;

template<class T, class U, typename std::enable_if_t<std::is_convertible<U, T>::value, nullptr_t>* = nullptr>
void chmin(T &a, const U &b) {
  if (a > T(b)) a = T(b);
}

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

  int res = 10000;
  rep(i, 10000) rep(j, 10000) {
    ll value = ll(i) * a + ll(j) * b;
    if (n < value || (n - value) % c != 0) continue;
    chmin(res, i + j + (n - value) / c);
  }
  std::cout << res << std::endl;;
}

Submission Info

Submission Time
Task 016 - Minimum Coins(★3)
User kichi2004_
Language C++ (GCC 9.2.1)
Score 3
Code Size 585 Byte
Status AC
Exec Time 754 ms
Memory 3636 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:18:11: warning: comparison of integer expressions of different signedness: ‘int’ and ‘ll’ {aka ‘long unsigned int’} [-Wsign-compare]
   18 |     if (n < value || (n - value) % c != 0) continue;
      |         ~~^~~~~~~

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 360 ms 3436 KiB
rand_02.txt AC 324 ms 3440 KiB
rand_03.txt AC 438 ms 3396 KiB
rand_04.txt AC 340 ms 3580 KiB
rand_05.txt AC 340 ms 3572 KiB
rand_06.txt AC 334 ms 3516 KiB
rand_07.txt AC 428 ms 3536 KiB
rand_08.txt AC 449 ms 3424 KiB
rand_09.txt AC 338 ms 3560 KiB
rand_10.txt AC 456 ms 3584 KiB
rand_large_abc_1.txt AC 106 ms 3512 KiB
rand_large_abc_2.txt AC 104 ms 3512 KiB
rand_large_abc_3.txt AC 754 ms 3512 KiB
sample_1.txt AC 106 ms 3556 KiB
sample_2.txt AC 171 ms 3560 KiB
sample_3.txt AC 145 ms 3616 KiB
sample_4.txt AC 425 ms 3432 KiB
small_1.txt AC 431 ms 3560 KiB
small_2.txt AC 109 ms 3636 KiB
small_3.txt AC 105 ms 3396 KiB
small_4.txt AC 106 ms 3384 KiB