标签:force class name ++ puts pre iostream can put
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 5005;
int n, m, a[maxn];
int op[maxn], l[maxn], r[maxn], d[maxn];
int maxval[maxn], add[maxn];
int main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++)
maxval[i] = 1e9;
for (int i = 1; i <= m; i++) {
scanf("%d %d %d %d", &op[i], &l[i], &r[i], &d[i]);
if (op[i] == 1) {
for (int j = l[i]; j <= r[i]; j++)
add[j] += d[i];
} else {
for (int j = l[i]; j <= r[i]; j++)
maxval[j] = min(maxval[j], d[i] - add[j]);
}
}
for (int i = 1; i <= n; i++)
a[i] = maxval[i];
for (int i = 1; i <= m; i++) {
if (op[i] == 1) {
for (int j = l[i]; j <= r[i]; j++)
a[j] += d[i];
} else {
int minn = -1e9;
for (int j = l[i]; j <= r[i]; j++)
minn = max(minn, a[j]);
if (minn != d[i]) return puts("NO");
}
}
puts("YES");
for (int i = 1; i <= n; i++)
printf("%d ", maxval[i]);
}
标签:force class name ++ puts pre iostream can put
原文地址:https://www.cnblogs.com/AlphaWA/p/11123913.html