QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#227371 | #3427. Getting Rid of Coins | Bashca# | WA | 0ms | 3352kb | C++23 | 924b | 2023-10-27 13:28:41 | 2023-10-27 13:28:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
int p;
int n[4];
cin>>p;
int v[4] = {1, 5, 10, 25};
for (int i=0; i<4; ++i) cin>>n[i];
int ans = 0;
for (int i = 0; i < 30; ++i) {
for (int j = 0; j < 10; ++j) {
for (int k = 0; k < 10; ++k) {
int t[4];
t[0] = max(0, n[0] - i);
t[1] = max(0, n[1] - j);
t[2] = max(0, n[2] - k);
t[3] = n[3];
int pp = p;
int lans = 0;
for (int d = 0; d < 4; ++d) {
int f = min(pp / v[d], t[0]);
lans += f;
pp -= f * v[d];
}
if (pp == 0) ans = max(ans, lans);
}
}
}
if (ans == 0) cout << "Impossible" << '\n';
else cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3352kb
input:
14 11 0 1 1
output:
10
result:
wrong answer 1st lines differ - expected: '5', found: '10'