CSES - Book Shop

Authors: Sofia Yang, Neha Sane

Table of Contents

SolutionImplementation

Official Editorial

Solution

Time Complexity: O(NX)\mathcal{O}(N\cdot X)

Implementation

C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int x;
cin >> n >> x;
vector<int> cost(n);
vector<int> pages(n);

Java

import java.io.*;
import java.util.*;
public class bookShop {
public static void main(String[] args) throws IOException {
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(b.readLine());
int N = Integer.parseInt(st.nextToken());
int X = Integer.parseInt(st.nextToken());

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!