Official Analysis (Java)

Implementation

Time Complexity: O(NlogN)\mathcal{O}(N\log{N})

C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class LazySegtree {
private:
static constexpr array<ll, 2> ID = {0, INT32_MAX}; // default tree value
static constexpr int LZ_ID = 0; // default lazy value
const int sz;
vector<array<ll, 2>> t; // t[v] = {sum, minimum}

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!