Submission #1010515

#TimeUsernameProblemLanguageResultExecution timeMemory
1010515ivopavTrading (IZhO13_trading)C++17
100 / 100
299 ms27952 KiB
#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)

trading.cpp: In function 'int main()':
trading.cpp:15:13: warning: operation on 'unos' may be undefined [-Wsequence-point]
   15 |         dog[--unos].push_back({0,unos3-unos});
      |             ^~~~~~
trading.cpp:15:13: warning: operation on 'unos' may be undefined [-Wsequence-point]
trading.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<bool, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (int j=0;j<dog[i].size();j++){
      |                      ~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...