QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21154. 합이 7의 배수인 부분 수열

Statistics

Farmer John의 $N$마리 소가 가끔 그러듯이 한 줄로 서 있다. FJ가 구별할 수 있도록 각 소는 서로 다른 정수 ID를 가진다. FJ는 연속한 소 무리의 사진을 찍고 싶지만, 어린 시절 숫자 $1 \ldots 6$와 관련된 충격적인 사건 때문에 ID의 합이 $7$의 배수인 소 무리만 찍으려 한다.

FJ가 사진을 찍을 수 있는 가장 큰 소 무리의 크기를 구하도록 도와주자.

입력

입력의 첫 줄에는 $N$($1 \leq N \leq 50,000$)이 주어진다. 다음 $N$개의 줄에는 각각 소들의 정수 ID $N$개가 주어진다(모두 $0 \ldots 1,000,000$ 범위이다).

출력

ID의 합이 $7$의 배수인 가장 큰 연속한 소 무리의 소 수를 출력한다. 그런 무리가 없으면 0을 출력한다.

큰 소 무리의 ID 합은 표준 32비트 정수에 들어가지 않을 정도로 클 수 있다. 따라서 많은 ID를 더한다면 C/C++의 64비트 long long 같은 더 큰 정수 자료형을 사용할 수 있다.

예제

입력 1

7
3
5
1
6
2
14
10

출력 1

5

참고

이 예제에서는 $5+1+6+2+14 = 28$이다.

문제 작성자: Brian Dean

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.