USACO月赛2018年12月铜组

T1 Mixing Milk
#include <iostream>
using namespace std;

int main() {
	int c[3], m[3];
	for (int i = 0; i < 3; i ++) cin >> c[i] >> m[i];
	
	for (int i = 0; i < 100; i ++) {
		int x = i % 3;
		int y = (i+1) % 3;
		
		if (m[x] >= c[y]-m[y]) m[x] -= c[y]-m[y], m[y] = c[y];
		else m[y] += m[x], m[x] = 0;
	}

	for (int i = 0; i < 3; i ++) cout << m[i] << endl;

	return 0;
}
T2 The Bucket List
#include <iostream>
using namespace std;

const int N = 1005;
int n, a[N], sum[N];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		int s, t, b;
		cin >> s >> t >> b;
		
		a[s] += b;
		a[t+1] -= b;
	}

	int ans = 0;
	for (int i = 1; i <= 1000; i ++) {
		sum[i] = sum[i-1] + a[i];
		ans = max(ans, sum[i]);
	}	
	cout << ans << endl;

	return 0;
}
T3 Back and Forth
#include <iostream>
using namespace std;

int a[30], ttl = 1000;
bool b[30], mt[2010];

void dfs(int x) {
	if (x == 6) {
		mt[ttl] = true;
		return;
	}
	
	for (int i = 1; i <= 20; i ++) {
		if (x%2==0 && !b[i]) {
			ttl -= a[i];
			b[i] = true;
			dfs(x+1);
			b[i] = false;
			ttl += a[i];
		}
		else if (x%2==1 && b[i]) {
			ttl += a[i];
			b[i] = false;
			dfs(x+1);
			b[i] = true;
			ttl -= a[i];
		}
	}	
}

int main() {
	for (int i = 1; i <= 10; i ++) {
		cin >> a[i];
		b[i] = false;
	}
	for (int i = 11; i <= 20; i ++) {
		cin >> a[i];
		b[i] = true;
	}

	dfs(2);

	int cnt = 0;
	for (int i = 0; i <= 2000; i ++) {
		if (mt[i]) cnt ++;
	}
	cout << cnt;

	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值