BOJ17128_소가 정보섬에 올라온 이유_실버2_이동혁 #18
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
핵심은 리스트를 사용하면서 장난질 칠 때마다 연산을 전부 다시 하는 것을 피하는 것!!
장난질 이전 계산식을 수행한 결과를 리스트에 저정한다(인덱스별로 각각)
품질 점수의 합계를 변수를 따로 지정해 저장한다.
이후 장난질을 한 번씩 할때마다, 총 네개의 리스트 요소들의 부호가 바뀐다.
계산식을 수형한 결과 리스트의 부호를 바꿔주고, 품질 점수 합계를 업데이트해준다.
장난을 할 때마다 리스트의 sum을 갈기면 시간초과가 나니 주의!
Code
품질 점수를 저장할 리스트는 곱하기 해야되니까 모두 1로 채운뒤 초기화
품질 점수 업데이트
장난할 때마다 리스트를 업데이트하고 합계도 업데이트