/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Accepted 1ms 320.0 KiB
#5 Accepted 1ms 460.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 324.0 KiB
#9 Accepted 1ms 324.0 KiB
#10 Accepted 1ms 532.0 KiB
#11 Accepted 1ms 324.0 KiB

Code

/*CODED BY mahmudulsakib2019
  DATE:-4/3/2024;TIME:-23:05 pm
  BANGALDESH , SYLHET*/

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int X, a, b, c, N;
    cin >> X >> a >> b >> c >> N;
    vector<int> dp(N + 1, 1e9);
    dp[X] = 0;
    for (int i = X; i <= N; ++i) {
        if (i + a <= N) dp[i + a] = min(dp[i + a], dp[i] + 1);
        if (i + b <= N) dp[i + b] = min(dp[i + b], dp[i] + 1);
        if (i + c <= N) dp[i + c] = min(dp[i + c], dp[i] + 1);
    }
    if (dp[N] == 1e9) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        cout << dp[N] << endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1028 Magical box and spell
Contest
Brain booster #2
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-06 16:41:03
Judged At
2024-11-11 03:41:13
Judged By
Score
100
Total Time
1ms
Peak Memory
536.0 KiB