Advertisement
H-a-y-K

Untitled

Apr 20th, 2021
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.  
  11.     int *arr = new int[n];
  12.  
  13.     for (int i = 0; i < n; i++)
  14.         std::cin >> arr[i];
  15.  
  16.     int count = 0;
  17.     int max_count = 0;
  18.  
  19.     for (int i = 0, sum = 0; i < n; i++)
  20.     {
  21.         for (int j = i; j < n; j++)
  22.         {
  23.             sum += arr[j];
  24.             if (sum % 19 == 0)
  25.                 if (j-i+1 > max_count)
  26.                     max_count = j-i+1;
  27.             if (max_count == n)
  28.                 break;
  29.         }
  30.  
  31.         if (max_count == n)
  32.             break;
  33.  
  34.         sum = 0;
  35.     }
  36.  
  37.     cout << max_count;
  38.  
  39.     delete []arr;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement