比赛 4043级2023省选模拟赛5 评测结果 AAAAAAAAAAA
题目名称 Air Cownditioning II 最终得分 100
用户昵称 zxhhh 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2023-03-27 19:55:34
显示代码纯文本
#include <bits/stdc++.h>

using namespace std;
const int M = 15, N = 25;
int n, m, mv[M], s[N], t[N], c[N], a[M], b[M], p[M], ad[105];
int ans = 0x3f3f3f3f;

void dfs (int idx, int ss) {
	if (ss >= ans) return;
	if (idx > m) {
		for (int i = 1;i <= n;i++) {
			for (int j = s[i];j <= t[i];j++) if (ad[j] < c[i]) return;
		}
		ans = min(ans, ss);
	}
	dfs(idx+1, ss);
	for (int i = a[idx];i <= b[idx];i++) ad[i] += p[idx];
	dfs(idx+1, ss+mv[idx]);
	for (int i = a[idx];i <= b[idx];i++) ad[i] -= p[idx];
}

int main () {
	freopen("kongtiao.in", "r", stdin);
	freopen("kongtiao.out", "w", stdout);
	cin >> n >> m;
	for (int i = 1;i <= n;i++) cin >> s[i] >> t[i] >> c[i];
	for (int i = 1;i <= m;i++) cin >> a[i] >> b[i] >> p[i] >> mv[i];
	dfs(1, 0);
	cout << ans << endl;
//	system("pause");
	return 0;
}