# Week11 作业 E - 选做题11-1 东东与 ATM POJ - 1276

N = 3，
n_1 = 10，D_1 = 100，
n_2 = 4，D_2 = 50，
n_3 = 5，D_3 = 10

Input

Output

Sample Input
735 3 4 125 6 5 3 350
633 4 500 30 6 100 1 5 0 1
735 0
0 3 10 100 10 50 10 10
Sample Output
735
630
0
0
Hint

#include<stdio.h>

int main() {
int money, n;
while (scanf("%d%d", &money, &n) != EOF) {
int w[100001];
int v[100001] = { 0 };
int total = 0;
for (int i = 0; i < n; i++) {
int a, b, remain;
scanf("%d%d", &a, &b);
remain = a;
for (int k = 1; k <= remain; k <<= 1) {
total++;
w[total] = k * b;
remain -= k;
}
if (remain > 0) {
total++;
w[total] = remain * b;
}
}
for (int i = 1; i <= total; i++) {
for (int j = money; j >= w[i]; j--) {
if (v[j - w[i]] + w[i] > v[j]) v[j] = v[j - w[i]] + w[i];
}
}
printf("%d\n", v[money]);
}
}

05-22 74

04-29 148

04-30 65

05-02 92

05-03 66

06-29

04-30 1081

05-17 7万+

01-12 1万+

01-18 1万+

07-18 1万+

03-19 83万+

04-14 62万+

03-13 16万+

03-01 14万+

03-07 1万+

03-08 5万+

03-08 8万+

03-10 14万+

03-10 20万+

#### MySQL数据库面试题（2020最新版）

©️2019 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客