1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <iostream>
using
namespace std;
struct
Node
{
int
l; int r; int val;
}node[11111];
int
cmp( const
Node &a, const
Node &b)
{
return
a.r<b.r;
}
int
main()
{
int
n,l,r,c;
while (cin>>n){
for ( int
i=0;i<n;i++){
cin>>l>>r>>c;
node[i].l=l;node[i].r=r;node[i].val=c;
}
sort(node,node+n,cmp); int
ans=0;
int
vis[1111]={0};
for ( int
i=0;i<n;i++){
for ( int
j=node[i].l;j<=node[i].r;j++){
if (vis[j]) node[i].val--;
}
int
gg=node[i].val;
for ( int
j=node[i].r;j>=node[i].l&&gg>0;j--){
if (!vis[j]){
vis[j]=1;ans++;gg--;
}
}
}
printf ( "%d\n" ,ans);
}
return
0;
}
|