You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
890 B
C++
39 lines
890 B
C++
#include <cstdio>
|
|
#include <cctype>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
void getint(int &x)
|
|
{
|
|
int ch = x = 0;
|
|
while (!isdigit(ch = getchar()))
|
|
;
|
|
for (; isdigit(ch); ch = getchar())
|
|
x = x * 10 + ch - '0';
|
|
}
|
|
const int M = 1e3 + 5;
|
|
struct Int
|
|
{
|
|
int s, e, x;
|
|
} Ints[M];
|
|
bool operator<(const Int &lhs, const Int &rhs)
|
|
{
|
|
return lhs.s < rhs.s;
|
|
}
|
|
int f[M];
|
|
int main()
|
|
{
|
|
int n, m, r;
|
|
getint(n), getint(m), getint(r);
|
|
for (int i = 0; i < m; i++)
|
|
getint(Ints[i].s), getint(Ints[i].e), getint(Ints[i].x), Ints[i].e += r;
|
|
sort(Ints, Ints + m);
|
|
for (int i = 0; i < m; i++)
|
|
{
|
|
f[i] = Ints[i].e;
|
|
for (int j = 0; j < i; j++)
|
|
if (Ints[j].e <= Ints[i].s)
|
|
f[i] = max(f[i], f[j] + Ints[i].x);
|
|
}
|
|
printf("%d", *max_element(f, f + m));
|
|
return 0;
|
|
} |