# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053158 | SzymonKrzywda | Trading (IZhO13_trading) | C++17 | 200 ms | 10424 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |