Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <queue>
- #include <stack>
- using namespace std;
- typedef long long ll;
- const int maxn = 1e5 + 10;
- int pref_1[maxn], pref_2[maxn], pref_3[maxn];
- int main() {
- ios_base::sync_with_stdio(false);
- int n;
- cin >> n;
- vector<int> v(n);
- vector<int> idx(n, -1);
- int sum = 0;
- int res = 0;
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- sum += v[i];
- sum %= 7;
- if(idx[sum] == -1) {
- idx[sum] = i;
- }
- else {
- res = max(res, i - idx[sum]);
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment