比赛 EYOI与SBOI开学欢乐赛2nd 评测结果 AWWWWE
题目名称 免费馅饼 最终得分 16
用户昵称 lihaoze 运行时间 0.230 s
代码语言 C++ 内存使用 1.10 MiB
提交时间 2022-09-02 21:46:30
显示代码纯文本
#include <bits/stdc++.h> 

int w, h;
int f[2010][110];
int pos[2010];

int calc(int bg, int x) {
	if ((h - 1) % x == 0) 
		return bg + (h - 1) / x;
	return 2001;
}

int main() {
	freopen("freepizza.in", "r", stdin);
	freopen("freepizza.out", "w", stdout);
	std::cin >> w >> h;
	int bg, x, v, rate;
	while (std::cin >> bg >> x >> v >> rate)
		f[calc(bg, v)][x] = rate;
	for (int i = 1; i <= 2000; ++ i)
		for (int j = 1; j <= 100; ++ j) {
			f[i][j] = std::max(f[i][j] + f[i - 1][j], f[i][j - 1]);
			if (f[i][j] > f[i][pos[i]]) pos[i] = j;
		}
	std::cout << f[2000][100] << '\n';
	pos[0] = w / 2 + 1;
	int ed;
	for (int i = 2000; i >= 1; -- i) 
		if (pos[i] - pos[i - 1]) {
			ed = i;
			break;
		}
	for (int i = 1; i <= ed; ++ i) 
		std::cout << pos[i] - pos[i - 1] << '\n';
	return 0;
}