Submission #970449

#TimeUsernameProblemLanguageResultExecution timeMemory
970449jadai007Trading (IZhO13_trading)C++14
100 / 100
131 ms22968 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; int n, q; vector<pair<int, int>> vc[maxn]; int ans[maxn]; int main(){ cin.tie(nullptr)->sync_with_stdio(false); cin >> n >> q; for (int i = 1; i <= q; ++i){ int l, r, val; cin >> l >> r >> val; vc[l].push_back({r, val - l}); } priority_queue<pair<int, int>> pq; for (int i = 1; i <= n; ++i){ while (!pq.empty() && pq.top().second < i) pq.pop(); for (int j = 0; j < vc[i].size(); ++j) pq.push({vc[i][j].second, vc[i][j].first}); if (!pq.empty()) ans[i] = pq.top().first + i; else ans[i] = 0; cout << ans[i] << ' '; } return 0; }

Compilation message (stderr)

trading.cpp: In function 'int main()':
trading.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for (int j = 0; j < vc[i].size(); ++j) pq.push({vc[i][j].second, vc[i][j].first});
      |                         ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...