# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
739434 |
2023-05-10T12:56:36 Z |
MODDI |
Trading (IZhO13_trading) |
C++14 |
|
448 ms |
33440 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++){
sort(v[i].begin(), v[i].end());
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 |
5 ms |
7308 KB |
Output is correct |
4 |
Correct |
7 ms |
7380 KB |
Output is correct |
5 |
Correct |
6 ms |
7380 KB |
Output is correct |
6 |
Correct |
8 ms |
7492 KB |
Output is correct |
7 |
Correct |
248 ms |
20792 KB |
Output is correct |
8 |
Correct |
230 ms |
21920 KB |
Output is correct |
9 |
Correct |
262 ms |
23460 KB |
Output is correct |
10 |
Correct |
316 ms |
25468 KB |
Output is correct |
11 |
Correct |
339 ms |
24324 KB |
Output is correct |
12 |
Correct |
322 ms |
28176 KB |
Output is correct |
13 |
Correct |
366 ms |
26104 KB |
Output is correct |
14 |
Correct |
327 ms |
27636 KB |
Output is correct |
15 |
Correct |
377 ms |
30124 KB |
Output is correct |
16 |
Correct |
383 ms |
29428 KB |
Output is correct |
17 |
Correct |
360 ms |
29972 KB |
Output is correct |
18 |
Correct |
386 ms |
33200 KB |
Output is correct |
19 |
Correct |
393 ms |
30152 KB |
Output is correct |
20 |
Correct |
448 ms |
33440 KB |
Output is correct |