제출 #894366

#제출 시각아이디문제언어결과실행 시간메모리
894366raul2008487거래 (IZhO13_trading)C++17
100 / 100
170 ms26944 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define eb emplace_back #define vl vector<ll> #define fi first #define se second #define in insert #define mpr make_pair #define lg(x) __lg(x) #define bpc(x) __builtin_popcount(x) #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const ll sz = 3e5+5; const int mod = 998244353; const ll inf = 1000000000000000; ll res[sz]; vl st(sz<<2); bool inran(ll x, ll l, ll r){ return x <= r && x >= l; } void push(ll v, ll tl, ll tr){ if(tl == tr || (!st[v])){return ;} ll tm = (tl + tr)>>1; st[v*2] = max(st[v*2], st[v]); st[v*2+1] = max(st[v*2+1], st[v] + tm - tl + 1); st[v] = 0; } void update(ll v, ll tl, ll tr, ll l, ll r, ll val){ if(tl > r || tr < l){return ;} if(tl >= l && tr <= r){ ll nl = val + tl - l; st[v] = max(st[v], nl); if(st[v]){ //cout << tl << ' ' << tr << ' ' << st[v] << endl; } //push(v, tl, tr); return ; } push(v, tl, tr); ll tm = (tl + tr)>>1; update(v*2, tl, tm, l, r, val); update(v*2+1, tm+1, tr, l, r, val); } void trav(ll v, ll l, ll r){ if(l == r){ res[l] = st[v]; return ; } push(v, l, r); ll m = (l + r)>>1; trav(v*2, l, m); trav(v*2+1, m+1, r); } void solve() { ll n, m, i, j; cin>>n>>m; vl l(m), r(m), x(m); for(i=0;i<m;i++){ cin>>l[i]>>r[i]>>x[i]; update(1, 1, n, l[i], r[i], x[i]); } trav(1, 1, n); for(i=1;i<=n;i++){ cout << res[i] << ' '; }cout << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //precomp(); ll tst=1; //cin>>tst; while(tst--){ solve(); } } /* 4 6 5 4 3 2 1 0 3 2 1 0 8 2 3 6 7 0 1 4 5 1 0 */

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

trading.cpp: In function 'void solve()':
trading.cpp:58:17: warning: unused variable 'j' [-Wunused-variable]
   58 |     ll n, m, i, j;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...