Official Analysis (C++ and Java)

Implementation

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

C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
freopen("homework.in", "r", stdin);
int n;
cin >> n;
vector<ll> questions(n);
for (int i = 0; i < n; i++) { cin >> questions[i]; }

Python

with open("homework.in") as read:
n = int(read.readline())
questions = [int(i) for i in read.readline().split()]
left, right = -1, n
total = [0] * n
minimum = [0] * n
max_score_values = []

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!