POJ 1742 Coins 【DP】

tonyfang posted @ 2016年4月03日 15:27 in poj with tags C++ OI , 764 阅读


# include <stdio.h>
# include <string.h>
using namespace std;
int n, m, v[105], c[105], f[100005], times[100005];
int main() {
	while(1) {
		scanf("%d%d", &n, &m);
		if(n+m == 0) break;
		for (int i=1; i<=n; ++i) scanf("%d", &v[i]);
		for (int i=1; i<=n; ++i) scanf("%d", &c[i]);
		memset(f, 0, sizeof(f));
		int ans=0;
		for (int i=1; i<=n; ++i) {
			memset(times, 0, sizeof(times));
			for (int j=v[i]; j<=m; ++j)
				if(!f[j] && f[j-v[i]] && times[j-v[i]] < c[i]) f[j] = 1, times[j] = times[j-v[i]] + 1, ans++;
		printf("%d\n", ans);
	return 0;
BSNL Tune 说:
2022年8月09日 14:47

BSNL Personalized Ring Back Tone services, a mobile subscriber greet their callers with their favorite song as best choice, and this new My BSNL Tunes App service is an innovative service help the subscribers to express themselves, access information, entertainment and connect the other by greeting. BSNL Tune Most popular albums are vying for honor, but to find the best with codes or by names it is difficult, but now with this new launch of My BSNL Tunes App, each mobile user now have a chance to listen and activate their favorite songs of any language to set as BSNL caller tune on their mobiles.

登录 *

loading captcha image...
or Ctrl+Enter