/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 348.0 KiB
#3 Wrong Answer 1ms 532.0 KiB
#4 Wrong Answer 1ms 324.0 KiB

Code

#include <iostream>

using namespace std;

int main() {
    int X, a, b, c, N;
    cin >> X >> a >> b >> c >> N;

    int op = 0;
    bool possible = false;

    for (int i = 0; i <= N / a; ++i) {
        for (int j = 0; j <= N / b; ++j) {
            int r = N - (i * a + j * b);
            if (r >= 0 && r % c == 0 && r / c <= X) {
                possible = true;
                op = i + j + r / c;
                break;
            }
        }
        if (possible) {
            break;
        }
    }

    if (possible) {
        cout << "YES" << endl;
        cout << op-1 << endl;
    } else {
        cout << "NO" << 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:59:49
Judged At
2024-11-11 03:41:06
Judged By
Score
10
Total Time
1ms
Peak Memory
532.0 KiB