Submission #1053158

#TimeUsernameProblemLanguageResultExecution timeMemory
1053158SzymonKrzywdaTrading (IZhO13_trading)C++17
100 / 100
200 ms10424 KiB
#include <bits/stdc++.h> using namespace std; struct trader{ int p,k,val; }; bool comp( trader& tr_1, trader& tr_2){ return tr_1.p < tr_2.p; } int main(){ int n,m; cin >> n >> m; vector<trader> tablica; for (int i=0; i<m; i++){ trader dod; cin >> dod.p >> dod.k >> dod.val; dod.p--;dod.k--; tablica.push_back(dod); } //posortuj sort(tablica.begin(),tablica.end(),comp); int akt = 0; priority_queue<pair<int,int>> kolejka; for (int i=0; i<n; i++){ while (akt<m && tablica[akt].p==i){ kolejka.push({ tablica[akt].val - (tablica[akt].p - 0) ,akt}); akt++; } while (!kolejka.empty() && tablica[kolejka.top().second].k < i) kolejka.pop(); if (kolejka.empty()) cout << 0 << " "; else cout << kolejka.top().first + tablica[kolejka.top().second].p + (i-tablica[kolejka.top().second].p) << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...