제출 #739435

#제출 시각아이디문제언어결과실행 시간메모리
739435MODDI거래 (IZhO13_trading)C++14
100 / 100
464 ms27964 KiB
#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 timeMemoryGrader output
Fetching results...