제출 #92658

#제출 시각아이디문제언어결과실행 시간메모리
92658SamAnd거래 (IZhO13_trading)C++17
100 / 100
443 ms22696 KiB
#include <iostream> #include <algorithm> #include <algorithm> #include <queue> #include <vector> using namespace std; const int N=300003; struct ban { int l,r,x; }; bool operator<(const ban& a,const ban& b) { int ansa,ansb; if(a.l<b.l) { ansb=b.x; ansa=a.x+(b.l-a.l); } else { ansb=b.x+(a.l-b.l); ansa=a.x; } return ansa<ansb; } int n, m; int a[N]; vector<ban> b[N]; int main() { //freopen("trading.in","r",stdin); //freopen("trading.out","w",stdout); cin>>n>>m; for(int i=0;i<m;++i) { ban t; cin>>t.l>>t.r>>t.x; b[t.l].push_back(t); } priority_queue<ban> q; for(int i=1;i<=n;++i) { ban t; for(int j=0;j<b[i].size();++j) { t=b[i][j]; q.push(t); } bool z=false; do { if(q.empty()) { z=true; break; } t=q.top(); if(t.r<i) q.pop(); else break; }while(1); if(z) { cout<<0<<' '; continue; } cout<<t.x+(i-t.l)<<' '; } cout<<endl; return 0; } /* 5 2 1 3 2 2 4 6 */

컴파일 시 표준 에러 (stderr) 메시지

trading.cpp: In function 'int main()':
trading.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<b[i].size();++j)
                     ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...