Submission #90570

#TimeUsernameProblemLanguageResultExecution timeMemory
90570popovicirobertTrading (IZhO13_trading)C++14
100 / 100
474 ms34580 KiB
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long #define ld long double // 217 // 44 using namespace std; const int MAXN = (int) 3e5; int x[MAXN + 1], l[MAXN + 1], r[MAXN + 1]; struct Data { int pos; bool operator <(const Data &other) const { if(x[pos] - l[pos] == x[other.pos] - l[other.pos]) { return pos < other.pos; } return x[pos] - l[pos] > x[other.pos] - l[other.pos]; } }; multiset <Data> mst; vector <int> upd[MAXN + 1]; int main() { //ifstream cin("A.in"); //ofstream cout("A.out"); int i, n, m; ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> n >> m; for(i = 1; i <= m; i++) { cin >> l[i] >> r[i] >> x[i]; upd[l[i]].push_back(i); upd[r[i] + 1].push_back(-i); } for(i = 1; i <= n; i++) { for(auto it : upd[i]) { if(it < 0) { mst.erase(mst.find({-it})); } else { mst.insert({it}); } } if(mst.size() == 0) { cout << 0 << " "; } else { auto it = *mst.begin(); cout << x[it.pos] - l[it.pos] + i << " "; } } //cin.close(); //cout.close(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...