Submission #929213

#TimeUsernameProblemLanguageResultExecution timeMemory
929213KarootTrading (IZhO13_trading)C++17
100 / 100
241 ms36920 KiB
#include <iostream> #include <cmath> #include <unordered_map> #include <map> #include <set> #include <queue> #include <vector> #include <string> #include <iomanip> #include <algorithm> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using namespace std; typedef long long ll; ll linf = 1e15+1; inline void scoobydoobydoo(){ ios::sync_with_stdio(false); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } multiset<ll> ms; vector<ll> start[300001]; vector<ll> ende[300001]; int main(){ scoobydoobydoo(); int n, m; cin >> n >> m; for (int i = 0; i < m; i++){ int l, r, X; cin >> l >> r >> X; l--; r--; start[l].push_back(X-l); ende[r+1].push_back(X-l); } for (int i = 0; i < n; i++){ for (int x : start[i])ms.insert(x); for (int x : ende[i]){ auto it = ms.find(x); ms.erase(it); } if (ms.empty())cout << 0 << " "; else cout << *ms.rbegin()+i << " "; } cout << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...