#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m; cin >> n >> m;
vector<array<int,3>> toAdd, toRem;
for(int i = 0; i < m; ++i){
int l, r, x; cin >> l >> r >> x;
toAdd.push_back({l,r,x-l});
toRem.push_back({r,l,x-l});
}
sort(toAdd.begin(), toAdd.end());
sort(toRem.begin(), toRem.end());
int cnl = 0, cnr = 0;
map<int,int> M;
for(int i = 1; i <= n; ++i){
while(toAdd[cnl][0] == i){
M[toAdd[cnl++][2]]++;
}
while(toRem[cnr][0] == i-1){
M[toRem[cnr][2]]--;
if(!M[toRem[cnr][2]]){
M.erase(toRem[cnr][2]);
}
cnr++;
}
if(M.empty()){
cout << "0 ";
}
else{
cout << prev(M.end())->first + i << " ";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
3 ms |
492 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
250 ms |
10044 KB |
Output is correct |
8 |
Correct |
277 ms |
10688 KB |
Output is correct |
9 |
Correct |
294 ms |
12148 KB |
Output is correct |
10 |
Correct |
312 ms |
14008 KB |
Output is correct |
11 |
Correct |
303 ms |
12232 KB |
Output is correct |
12 |
Correct |
366 ms |
16064 KB |
Output is correct |
13 |
Correct |
374 ms |
13624 KB |
Output is correct |
14 |
Correct |
378 ms |
15444 KB |
Output is correct |
15 |
Correct |
411 ms |
16464 KB |
Output is correct |
16 |
Correct |
420 ms |
15544 KB |
Output is correct |
17 |
Correct |
420 ms |
17028 KB |
Output is correct |
18 |
Correct |
444 ms |
19648 KB |
Output is correct |
19 |
Correct |
427 ms |
17092 KB |
Output is correct |
20 |
Correct |
515 ms |
19012 KB |
Output is correct |