QOJ.ac

QOJ

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

#21154. Sottosequenze con somma multipla di sette

Statistics

Le $N$ mucche di Farmer John sono in fila, come fanno di tanto in tanto. Ogni mucca ha un identificatore intero distinto, così FJ può distinguerle. FJ vorrebbe fotografare un gruppo contiguo di mucche, ma a causa di un incidente traumatico dell’infanzia legato ai numeri $1 \ldots 6$, vuole fotografare un gruppo solo se la somma dei suoi identificatori è un multiplo di $7$.

Aiuta FJ a determinare la dimensione del gruppo più grande che può fotografare.

Input

La prima riga contiene $N$ ($1 \leq N \leq 50,000$). Ciascuna delle successive $N$ righe contiene gli $N$ identificatori interi delle mucche (tutti nell’intervallo $0 \ldots 1,000,000$).

Output

Stampa il numero di mucche del più grande gruppo consecutivo la cui somma degli identificatori è un multiplo di $7$. Se non esiste un tale gruppo, stampa 0.

Nota che la somma degli identificatori di un grande gruppo di mucche potrebbe essere troppo grande per un intero standard a 32 bit. Se sommi molti identificatori, puoi quindi usare un tipo intero più grande, come long long a 64 bit in C/C++.

Esempi

Input 1

7
3
5
1
6
2
14
10

Output 1

5

Nota

In questo esempio, $5+1+6+2+14 = 28$.

Autore del problema: 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.