记录编号 |
415935 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[USACO Nov07] 挤奶时间 |
最终得分 |
100 |
用户昵称 |
kZime |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.006 s |
提交时间 |
2017-06-18 21:55:19 |
内存使用 |
0.58 MiB |
显示代码纯文本
# include <bits/stdc++.h>
# define MAXM 1024
using namespace std;
inline char getc() {
static char buf[1 << 18], *fs, * ft;
return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}
inline int gn() {
register int k = 0, f = 1;
register char c = getc();
for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
for(; isdigit(c); c = getc()) k = k * 10 + c - '0';
return f * k;
}
struct times {
int l, r, e;
bool operator <(const times &x) const {
return l < x.l;
}
}t[MAXM];
int n, m, r, dp[MAXM];
int main() {
freopen("milkprod.in", "r", stdin);
freopen("milkprod.out", "w", stdout);
n = gn(), m = gn(), r = gn();
for(int i = 1; i <= m; i++) {
times *b = &t[i];
b->l = gn(), b->r = gn(), b->e = gn();
}
sort(t + 1, t + 1 + m);
int ans = 0;
for(int i = 1; i <= m; i++) {
dp[i] = t[i].e;
for(int j = 1; j < i; j++) {
if(t[j].r + r <= t[i].l) {
dp[i] = max(dp[i], dp[j] + t[i].e);
ans = max(dp[i], ans);
}
}
}
printf("%d\n", ans);
}