You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
625 B
26 lines
625 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
const int V[6] = {1, 5, 10, 50, 100, 500};
|
|
int C[6];
|
|
int A; // 要组装的货币数量
|
|
/*
|
|
3 2 1 3 0 2
|
|
620
|
|
|
|
答案:
|
|
6
|
|
*/
|
|
int main() {
|
|
for (int i = 0; i < 6; i++) cin >> C[i];
|
|
cin >> A;
|
|
int ans = 0;
|
|
// 由大到小枚举
|
|
for (int i = 5; i >= 0; i--) {
|
|
int t = min(A / V[i], C[i]); // 能取多少,受两个条件限制:可以取的数量,包含的数量,两者取小
|
|
A -= t * V[i]; // 扣除掉
|
|
ans += t; // 维护结果
|
|
}
|
|
cout << ans << endl;
|
|
return 0;
|
|
} |