Wrong Answer
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