Submission #47576

#TimeUsernameProblemLanguageResultExecution timeMemory
47576fallingstarTrading (IZhO13_trading)C++17
100 / 100
685 ms31244 KiB
#include <iostream> #include <vector> #include <set> using namespace std; const int N = 3e5 + 2; int n, m; vector<pair<int, int> > begpoint[N], endpoint[N]; int main() { cin >> n >> m; for (int i = 0; i < m; ++i) { int l, r, x; cin >> l >> r >> x; begpoint[l].push_back({x - l, i}); endpoint[r].push_back({x - l, i}); } set<pair<int, int> > s; for (int i = 1; i <= n; ++i) { for (auto p: begpoint[i]) s.insert(p); if (!s.empty()) cout << i + prev(s.end())->first << ' '; else cout << 0 << ' '; for (auto p: endpoint[i]) s.erase(p); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...