oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

peanutparty Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

peanutparty.html

Problem Description

A group of peanuts live in a one-dimensional world. To celebrate the commencement of a new peanut civilisation, they have decided to organise a party! However, there is a problem. There are tons and tons of strawberries sprouting all over the one-dimensional world, and peanuts for some reason hate strawberries!

The one-dimesional world is split up into N segments. Each segment of land will have a certain number of strawberries growing on it. The party area would span a length of L such segments. The peanuts want to pick a section of L consecutive segments to hold their party such that the number of strawberries on that section is minimised. Help the peanuts calculate the minimum number of strawberries that are growing on their party land.

Your program is required to implement the following functions:

  1. int minStrawberries(int N, int L, int A[]), where A[] is an array containing the number of strawberries growing on each segment.

Limits

For all subtasks: L <= N, Ai <= 1 000
Subtask 1 (37%): 1 <= N <= 1 000
Subtask 2 (63%): 1 <= N <= 1 000 000

Sample Input 1

5 3
2 3 1 4 5

Sample Output 1

6

Explanation for Sample 1

The section of length 3 that contains the least number of strawberries among [2, 3, 1, 4, 5] is [2, 3, 1], containing 6 strawberries.

Tags

Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
137511s32MBMinimum
263511s32MBMinimum
3011s32MBMinimum

Attachments

Attachment Filesize Last Updated
grader.cpp251B8 Aug 2013, 21:09:46
ans.cpp95B9 Aug 2013, 11:14:02
peanutparty.h66B8 Aug 2013, 21:07:25

Judge Compile Command

g++-8 grader.cpp ans.cpp -o peanutparty -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.