Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bismillahir Rahman-ir Rahim
- #include <bits/stdc++.h>
- using namespace std;
- #define debug(x) cout << '>' << #x << " : " << x << endl;
- #define all(c) c.begin(), c.end()
- #define F first
- #define S second
- typedef unsigned long long ull;
- typedef long long ll;
- int main(){
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- long long int n;
- cin >> n;
- vector <long long> ara(n), pre(n);
- for(int i = 0;i < n; i++){
- cin >> ara[i];
- }
- pre[0] = ara[0];
- for(int i = 1; i < n; i++){
- pre[i] = pre[i-1] + ara[i];
- }
- ll ans = 0, sum = 0;
- for(int i = 0; i < n; i++){
- for(int j = i; j < n; j++){
- if(i!=0)sum = pre[j] - pre[i-1];
- else sum = pre[j];
- if(sum % 7 == 0){
- ans = max(ans, (ll)(j-i+1));
- }
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement