QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227372#3427. Getting Rid of CoinsBashca#AC ✓0ms3688kbC++23924b2023-10-27 13:30:182023-10-27 13:30:18

Judging History

你现在查看的是最新测评结果

  • [2023-10-27 13:30:18]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3688kb
  • [2023-10-27 13:30:18]
  • 提交

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[d]);
                    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: 100
Accepted
time: 0ms
memory: 3540kb

input:

14
11 0 1 1

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

30
5 0 3 1

output:

6

result:

ok single line: '6'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

12
6 6 0 4

output:

4

result:

ok single line: '4'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

783
15 51 39 14

output:

108

result:

ok single line: '108'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

6863
2862 155 210 67

output:

3267

result:

ok single line: '3267'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3684kb

input:

92573
26598 809 3704 1241

output:

32106

result:

ok single line: '32106'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

208823
317 912 6847 1288

output:

Impossible

result:

ok single line: 'Impossible'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

33876241
9888057 357603 843373 455010

output:

Impossible

result:

ok single line: 'Impossible'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

100000000
2937029 14974823 1234243 12631827

output:

19539947

result:

ok single line: '19539947'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

100000000
29837029 197823 291702 99185427

output:

32976823

result:

ok single line: '32976823'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

100000000
99999995 0 1 1

output:

99999991

result:

ok single line: '99999991'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

100000000
99999980 3 0 3

output:

99999976

result:

ok single line: '99999976'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

100000000
99999929 2 6 1

output:

99999932

result:

ok single line: '99999932'