USACO Silver 2016 December - Counting Haybales

Authors: Albert Zhu, Kevin Sheng


Official Analysis (Java)

Implementation

Time Complexity: O((N+Q)logN)\mathcal{O}((N+Q)\log N)

#include <bits/stdc++.h>
using namespace std;
int main() {
freopen("haybales.in", "r", stdin);
int bale_num;
int query_num;
cin >> bale_num >> query_num;
vector<int> haybales(bale_num);

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!