-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// #include <bits/stdc++.h> // for some reason the USACO grader doesn't like this for this problem? | ||
#include <fstream> | ||
#include <vector> | ||
using namespace std; | ||
|
||
#define MAX_N 50000 | ||
#define ll long long | ||
|
||
vector<ll> cows(MAX_N + 1); | ||
|
||
int main() | ||
{ | ||
ifstream fin("div7.in"); | ||
ofstream fout("div7.out"); | ||
|
||
int N; | ||
fin >> N; | ||
|
||
cows[0] = 0; | ||
|
||
for (int i = 1; i <= N; ++i) | ||
{ | ||
fin >> cows[i]; | ||
} | ||
|
||
for (int i = 1; i <= N; ++i) | ||
{ | ||
cows[i] += cows[i - 1]; | ||
cows[i] %= 7; | ||
} | ||
|
||
vector<int> firstSum(7, -1); | ||
int answer = 0; | ||
for (int i = 1; i <= N; ++i) | ||
{ | ||
if (firstSum[cows[i]] != -1) | ||
answer = max(answer, i - firstSum[cows[i]]); | ||
else | ||
firstSum[cows[i]] = i; | ||
} | ||
|
||
fout << answer << '\n'; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
7 | ||
3 | ||
5 | ||
1 | ||
6 | ||
2 | ||
14 | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5 |