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

rabbitmilk Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

statement.html

Problem Description

White Rabbit is making milk! Black Rabbit is excited to try the new White Rabbit Milk launched at 7-11 stalls today.

There are N stalls. Black Rabbit wants to choose a contiguous section (of at least size 1) of stores to buy Rabbit Milk, and the satisfaction he gains is the product of quality across all the stores. However, White Rabbit's Milk has inconsistent quality, and may even be zero or negative. Store i has quality Ai. What is the maximum satisfaction he can gain?

It is guaranteed that for any contiguous section of stalls, the absolute value of the product of their quality doesn't exceed 1017.

Input

The first line of input will contain two integers, N.

The next line contains N integers, describing the quality of Rabbit Milk, Ai, of each store.

Output

The output should contain one integer, the maximum number of satisfaction Black Rabbit can gain.

Limits

For all subtasks: 1 ≤ N ≤ 1 000 000. -3 ≤ Ai ≤ 3

Subtask 1 (12%): N ≤ 400.

Subtask 2 (36%): N ≤ 4000.

Subtask 3 (8%): Ai ≥ 0.

Subtask 4 (24%): Ai ≠ 0.

Subtask 5 (20%): No additional constraints.

Subtask 6 (0%): Sample.

Sample Input

7
-1 2 -3 1 -2 0 3

Sample Output

12

Explanation

If he takes the 2nd to 5th stalls, he gets a total of 12 satisfaction.

Tags

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
112101s256MBMinimum
236151s256MBMinimum
3871s256MBMinimum
42461s256MBMinimum
520301s256MBMinimum
6011s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o rabbitmilk -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.