# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739435 |
2023-05-10T12:57:03 Z |
MODDI |
Trading (IZhO13_trading) |
C++14 |
|
464 ms |
27964 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vector<pll> v[300100];
multiset<ll> st;
int main(){
cin>>n>>m;
for(int i = 0; i < m; i++){
ll l, r, d;
cin>>l>>r>>d;
v[l].pb(mp(1, d-l));
v[r+1].pb(mp(0, d-l));
}
int ans[n+1];
for(int i = 1; i <= n; i++){
for(auto t : v[i]){
if(t.first == 1) st.insert(t.second);
else st.erase(st.find(t.second));
}
if(st.size()==0) ans[i] = 0;
else ans[i] = *st.rbegin() + i;
}
for(int i = 1; i <= n; i++)
cout<<ans[i]<<" ";
cout<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7252 KB |
Output is correct |
2 |
Correct |
4 ms |
7252 KB |
Output is correct |
3 |
Correct |
4 ms |
7252 KB |
Output is correct |
4 |
Correct |
5 ms |
7380 KB |
Output is correct |
5 |
Correct |
5 ms |
7372 KB |
Output is correct |
6 |
Correct |
6 ms |
7508 KB |
Output is correct |
7 |
Correct |
205 ms |
17944 KB |
Output is correct |
8 |
Correct |
250 ms |
18752 KB |
Output is correct |
9 |
Correct |
252 ms |
20092 KB |
Output is correct |
10 |
Correct |
281 ms |
21796 KB |
Output is correct |
11 |
Correct |
277 ms |
20492 KB |
Output is correct |
12 |
Correct |
386 ms |
24004 KB |
Output is correct |
13 |
Correct |
316 ms |
21840 KB |
Output is correct |
14 |
Correct |
325 ms |
23396 KB |
Output is correct |
15 |
Correct |
378 ms |
25284 KB |
Output is correct |
16 |
Correct |
368 ms |
24352 KB |
Output is correct |
17 |
Correct |
393 ms |
24976 KB |
Output is correct |
18 |
Correct |
406 ms |
27964 KB |
Output is correct |
19 |
Correct |
364 ms |
25120 KB |
Output is correct |
20 |
Correct |
464 ms |
27392 KB |
Output is correct |