제출 #508187

#제출 시각아이디문제언어결과실행 시간메모리
508187ac2hu거래 (IZhO13_trading)C++14
0 / 100
17 ms29036 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n,m; int a[N]; struct tr{ int l,r,x; } tr[N]; vector<int> in[N],out[N]; signed main(){ iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); cin >> n >> m; for(int i = 0;i<n;i++){ cin >> tr[i].l >> tr[i].r >> tr[i].x; in[tr[i].l].push_back(i); out[tr[i].r].push_back(i); } set<pair<int,int>> se; for(int i = 1;i<=n;i++){ for(auto e : in[i]){ se.insert({tr[e].x - i,i}); } // for(auto e : se)cout << e << " "; // cout << endl; if(se.size() == 0) a[i - 1] = 0; else{ auto it = se.end(); --it; pair<int,int> temp = *it; a[i - 1] = temp.first+ i; } for(auto e : out[i]){ int val = tr[e].x - tr[e].l; // cerr << e << " " << val << endl; assert(se.find({val,tr[e].l}) != se.end()); se.erase(se.find({val,tr[e].l})); } } for(int i = 0;i<n;i++) cout << a[i] << " "; cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...