제출 #21225

#제출 시각아이디문제언어결과실행 시간메모리
21225jjwdi0거래 (IZhO13_trading)C++11
100 / 100
293 ms20704 KiB
#include <bits/stdc++.h> using namespace std; struct Query { int s, e, v; Query() {} Query(int _s, int _e, int _v) { s = _s, e = _e, v = _v; } bool operator < (const Query &A) const { return v > A.v; } }T[300005]; int N, Q; int ans[300005]; set<int> s; int main() { scanf("%d %d", &N, &Q); for(int i=0; i<Q; i++) scanf("%d %d %d", &T[i].s, &T[i].e, &T[i].v), T[i].v -= T[i].s; sort(T, T+Q); for(int i=1; i<=N; i++) ans[i] = -i, s.insert(i); for(int i=0; i<Q; i++) { auto it1 = s.lower_bound(T[i].s), it2 = s.upper_bound(T[i].e); for(auto iter = it1; iter != it2; iter++) ans[*iter] = T[i].v; s.erase(it1, it2); } for(int i=1; i<=N; i++) printf("%d ", ans[i] + i); }

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

trading.cpp: In function 'int main()':
trading.cpp:16:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &N, &Q);
                           ^
trading.cpp:17:90: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0; i<Q; i++) scanf("%d %d %d", &T[i].s, &T[i].e, &T[i].v), T[i].v -= T[i].s;
                                                                                          ^

#Verdict Execution timeMemoryGrader output
Fetching results...