ps | |
---|---|
링크 | acmicpc.net/… |
출처 | BOJ |
문제 번호 | 21757 |
문제명 | 나누기 |
레벨 | 골드 3 |
분류 |
DP |
시간복잡도 | O(n) |
인풋사이즈 | n<100,000 |
사용한 언어 | Python |
제출기록 | 42028KB / 112ms |
최고기록 | 112ms |
해결날짜 | 2022/02/13 |
"""Solution code for "BOJ 21757. 나누기".
- Problem link: https://www.acmicpc.net/problem/21757
- Solution link: http://www.teferi.net/ps/problems/boj/21757
"""
def main():
N = int(input()) # pylint: disable=unused-variable
A = [int(x) for x in input().split()]
q, r = divmod(sum(A), 4)
if r != 0:
print('0')
return
q1, q2, q3 = q, q * 2, q * 3
q1_count = q2_count = q3_count = 0
s = 0
for a_i in A[:-1]:
s += a_i
if s == q3:
q3_count += q2_count
if s == q2:
q2_count += q1_count
if s == q1:
q1_count += 1
print(q3_count)
if __name__ == '__main__':
main()