# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010515 | ivopav | Trading (IZhO13_trading) | C++17 | 299 ms | 27952 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;
int main(){
int n;
int m;
cin >> n >> m;
vector<vector<pair<bool,int>>> dog(n+3,vector<pair<bool,int>>{});
for (int i=0;i<m;i++){
int unos;
int unos2;
int unos3;
cin >> unos >> unos2 >> unos3;
dog[--unos].push_back({0,unos3-unos});
dog[unos2].push_back({1,unos3-unos});
}
multiset<int> tra={};
for (int i=0;i<n;i++){
for (int j=0;j<dog[i].size();j++){
if (dog[i][j].first==0){
tra.insert(dog[i][j].second);
}
else {
tra.erase(tra.find(dog[i][j].second));
}
}
if (tra.size()==0){
cout << "0 ";
}
else {
cout << (*(tra.rbegin()))+i << " ";
}
}
cout << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |