제출 #682312

#제출 시각아이디문제언어결과실행 시간메모리
682312smartmonky거래 (IZhO13_trading)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define int long long using namespace std; const int N = 3e5 + 1; int t[N * 4], add[N * 4], ans[N * 4]; int lg, rg, x; int n; void push(int v, int tl, int tr){ if(add[v] == 0)return; if(tl == tr){ t[v] = max(t[v], add[v]); add[v] = 0; return; } int mid = (tl + tr) >> 1; add[v * 2 + 1] = add[v] - tl + mid + 1; add[v * 2] = add[v]; add[v] = 0; } void update(int v = 1, int tl = 1, int tr = n){ push(v, tl, tr); if(tl > rg || tr < lg) return; if(tl >= lg && tr <= rg){ add[v] = x + (tl - lg); push(v, tl, tr); return; } //cout << tl <<"-" << tr << endl; int mid = (tl + tr) >> 1; update(v * 2, tl, mid); update(v * 2 + 1, mid + 1, tr); //t[v] = max(t[v * 2], t[v * 2 + 1]); } void get(int v = 1, int tl = 1, int tr = n){ push(v, tl, tr); if(tl == tr){ ans[tl] = t[v]; return; }else{ int mid = (tl + tr) >> 1; get(v * 2, tl, mid); get(v * 2 + 1, mid + 1, tr); } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); int m; cin >> n >> m; for(int i = 0; i < m; i++){ cin >> lg >> rg >> x; update(); } get(); for(int i = 1; i <= n; i++){ cout << ans[i] <<" "; } }

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

trading.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...