제출 #1053194

#제출 시각아이디문제언어결과실행 시간메모리
1053194Szymon_PilipczukTrading (IZhO13_trading)C++17
100 / 100
300 ms41532 KiB
#include <iostream> #include <queue> #include <algorithm> using namespace std; int main() { int n,m; cin>>n>>m; vector <vector <int>> startq(m); vector <vector <int>> endq(m); int results[n]; int a,b,c; for(int i = 0;i<m;i++) { cin>>a>>b>>c; a--; b--; startq[i].push_back(a); startq[i].push_back(b); startq[i].push_back(c); endq[i].push_back(b); endq[i].push_back(a); endq[i].push_back(c); } priority_queue<int> mainq; priority_queue<int> stopq; sort(startq.begin(),startq.end()); sort(endq.begin(),endq.end()); startq.push_back(vector<int> {1000000,1000000,0}); endq.push_back(vector<int> {1000000,1000000,0}); int endi = 0; int starti = 0; for(int i = 0 ;i<n;i++) { while(startq[starti][0]==i) { mainq.push(startq[starti][2]-i); starti++; } while(endq[endi][0] == i) { stopq.push(endq[endi][2]-endq[endi][1]); endi++; } if (mainq.empty() == true) { results[i] = 0; cout<<0<<" "; continue; } results[i] = mainq.top()+i; cout<<results[i]<<" "; if (stopq.empty() == false) { while(mainq.top() == stopq.top()) { mainq.pop(); stopq.pop(); if(stopq.empty() == true) { break; } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...