Submission #682176

#TimeUsernameProblemLanguageResultExecution timeMemory
682176smartmonkyTrading (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 * 3], add[N * 3], par[N * 3]; int lg, rg, x; int n; void push(int v, int tl, int tr){ t[v] = max(t[v], add[v]); if(tl == tr || add[v] == 0){ add[v] = 0; return; } int mid = (tl + tr) >> 1; par[v * 2 + 1] = par[v * 2] = v; add[v * 2 + 1] = max(add[v * 2 + 1], add[v]); add[v * 2] = max(add[v * 2], x + (mid - lg)); add[v] = 0; } void update(int v = 1, int tl = 1, int tr = n){ push(v, tl, tr); //cout << add[v] <<" " << tl <<"-" << tr << endl; if(tl > rg || tr < lg) return; if(tl >= lg && tr <= rg){ //cout << tl <<"=" << tr << endl; add[v] = max(add[v], x + (tr - lg)); push(v, tl, tr); //cout << t[v] <<"-" << add[v * 2] <<"-" << add[v * 2 + 1] << endl; return; } //cout << tl <<"-" << tr << endl; int mid = (tl + tr) >> 1; update(v * 2, tl, mid); update(v * 2 + 1, mid + 1, tr); } int get(int v = 1, int tl = 1, int tr = n){ push(v, tl, tr); //cout << par[v] <<" " << tl <<"-" << tr << endl; if(tl > rg || tr < lg) return 0; if(tl >= lg && tr <= rg){ //cout << add[v]<< endl; return t[v]; }else{ int mid = (tl + tr) >> 1; return ( 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(); } for(int i = 1; i <= n; i++){ lg = i, rg = i; int x = get(); cout << x <<" "; } }

Compilation message (stderr)

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