Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact Form Submission - Suggestion (Silver - More on Prefix Sums) #4916

Open
maggieliu05 opened this issue Nov 10, 2024 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@maggieliu05
Copy link
Contributor

Someone submitted the contact form!

URL: https://usaco.guide/silver/more-prefix-sums
Module: Silver - More on Prefix Sums
Topic: Suggestion
Message:
I don't believe "Nusret Gokce" problem belongs in the exercices section because it doesn't use prefixsum

@maggieliu05 maggieliu05 added the enhancement New feature or request label Nov 10, 2024
@bqi343
Copy link
Member

bqi343 commented Nov 10, 2024

partially agree, though an argument can be made that the solution is similar in structure to the maximum subarray sum solution

@QuicksVolex1
Copy link

As a beginner, i would really appreciate if you can explain how that argument can be made. Since i'm struggling to even convince myself the solution works i think that would be really beneficial.

@bqi343
Copy link
Member

bqi343 commented Nov 10, 2024

it's as the editorial describes. you iterate over the array in one direction keeping a running max, then the other.

N, M = map(int, input().split())

S = list(map(int, input().split()))

running_max = 0
for i in range(N):
	running_max = max(running_max - M, S[i])
	S[i] = running_max

running_max = 0
for i in reversed(range(N)):
	running_max = max(running_max - M, S[i])
	S[i] = running_max

print(" ".join(map(str, S)))

@bqi343 bqi343 closed this as completed Nov 19, 2024
@bqi343
Copy link
Member

bqi343 commented Nov 19, 2024

actually, I'll keep this open because this problem needs an internal solution

@bqi343 bqi343 reopened this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants