-
Notifications
You must be signed in to change notification settings - Fork 1
/
G.cpp
82 lines (67 loc) · 1.36 KB
/
G.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define sl(val) scanf("%lld", &val)
struct node {
ll s;
ll d;
ll c;
ll id;
} ara[109];
bool check[109], ch2 = 0, cm[109];
bool cmp(node a, node b)
{
return a.d < b.d;
}
ll ans[109];
int main()
{
ll n, m;
cin >> n >> m;
for(ll i = 1; i <= m; i++) {
sl(ara[i].s), sl(ara[i].d), sl(ara[i].c);
ara[i].id = i;
if( check[ ara[i].d ] )
ch2 = 1;
check[ ara[i].d ] = 1;
}
if(ch2) {
printf("-1\n");
return 0;
}
sort(ara + 1, ara + m + 1, cmp);
bool chk = 1;
for(ll i = 1; i <= n; i++) {
for(ll j = 1; j <= m; j++) {
if(i == ara[j].d) {
ans[i] = m + 1;
break;
}
if(i >= ara[j].s && !cm[j] && i < ara[j].d) {
ans[i] = ara[j].id;
ara[j].c--;
if(ara[j].c == 0)
cm[j] = 1;
break;
}
}
}
for(ll j = 1; j <= m; j++) {
if(!cm[j])
chk = 0;
}
if(!chk) {
printf("-1\n");
return 0;
}
else {
for(ll i = 1; i <= n; i++) {
if(i != 1)
printf(" ");
printf("%lld", ans[i]);
}
}
cout << endl;
return 0;
}