제출 #47554

#제출 시각아이디문제언어결과실행 시간메모리
47554JohnTitor거래 (IZhO13_trading)C++11
100 / 100
365 ms33288 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, j, k) for(int i=(j); i<=(k); i++) #define FFOR(i, j, k) for(int i=(j); i<(k); i++) #define DFOR(i, j, k) for(int i=(j); i>=(k); i--) #define bug(x) cerr<<#x<<" = "<<(x)<<'\n' #define pb push_back #define mp make_pair #define setbit(s, i) (s|=(1LL<<(i))) #define bit(s, i) (((s)>>(i))&1LL) #define mask(i) ((1LL<<(i))) #define builtin_popcount __builtin_popcountll typedef long long ll; typedef long double ld; template <typename T> inline void read(T &x){ char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){ nega=1; c=getchar(); } x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x; } template <typename T> inline void writep(T x){ if(x>9) writep(x/10); putchar(x%10+48); } template <typename T> inline void write(T x){ if(x<0){ putchar('-'); x=-x; } writep(x); } template <typename T> inline void writeln(T x){ write(x); putchar('\n'); } #define taskname "H" int n, m; int l[300001]; int r[300001]; int x[300001]; vector <int> a[300002]; vector <int> b[300002]; multiset <int> s; int main(){ #ifdef Kanikou if(fopen(taskname".inp", "r")) freopen(taskname".inp", "r", stdin); #endif // Kanikou read(n); read(m); FOR(i, 1, m){ read(l[i]); read(r[i]); read(x[i]); x[i]-=l[i]; a[l[i]].pb(x[i]); b[r[i]+1].pb(x[i]); } FOR(i, 1, n){ for(int x: a[i]) s.insert(x); for(int x: b[i]) s.erase(s.find(x)); if(s.empty()) write(0); else write(*s.rbegin()+i); putchar(" \n"[i==n]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...