제출 #339818

#제출 시각아이디문제언어결과실행 시간메모리
339818beksultan04거래 (IZhO13_trading)C++14
100 / 100
223 ms18016 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); const int N = 1e5+12,INF=1e9+7; main(){ int n,m,i; scan2(n,m) deque <pair<pii,int> > v; while (m--){ int l,r,x; scan3(l,r,x) v.pb({{l,r},x-l}); } sort(all(v)); priority_queue <pair<int,pii> > q; int h=0; for (i=1;i<=n;++i){ while (!v.empty() && v[0].fr.fr <= i){ q.push({v[0].sc,{-v[0].fr.fr,v[0].fr.sc}}); v.pop_front(); } pair <int,pii> p ; if (q.empty()) p = {0,{-i,0}}; else p = q.top(); while (!q.empty() && p.sc.sc < i){ q.pop(); if (q.empty()) p = {0,{-i,0}}; else p = q.top(); } if (p.fr == 0)p.fr = -i; cout <<p.fr+i<<" "; } }

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

trading.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   21 | main(){
      |      ^
trading.cpp: In function 'int main()':
trading.cpp:32:9: warning: unused variable 'h' [-Wunused-variable]
   32 |     int h=0;
      |         ^
trading.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
trading.cpp:23:5: note: in expansion of macro 'scan2'
   23 |     scan2(n,m)
      |     ^~~~~
trading.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
trading.cpp:27:9: note: in expansion of macro 'scan3'
   27 |         scan3(l,r,x)
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...