Advertisement
OMEGAHEAD_MonkoX

It doesn’t work

Nov 6th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4.  
  5. using namespace std;
  6. ostream & operator<<(ostream & out, vector<int> const & v)
  7. {
  8.     for (int el: v)
  9.         out<< el <<' ';
  10.     return out;
  11. }
  12. int main()
  13. {
  14.     long long int q,n,    x,  a10,   a5,  a2, a1, answer,  l   ,u  ,t,N,K,    i,summ,m,k,o;
  15.     vector<int> a;
  16.     summ=0;
  17.     q=0;
  18.     o=0;
  19.     cin >> n >> k >> m;
  20.     for (i=0;i<n;++i)
  21.     {
  22.         cin >> x;
  23.         a.push_back(x);
  24.     }
  25.     for (i=0;i<n+1;++i)
  26.     {
  27.        // cout<<"     "<<i<<endl;
  28.         if(((i+q)!=(k+q+1)) & i+q<n & (int(i==0)*(n-(i+q)-1)+int(i!=0)*k+1)>=k)
  29.         {
  30.             summ+=a[i+q];
  31.         }
  32.         else
  33.         {
  34.             if(summ==m)
  35.             {
  36.                 o=q+1;
  37.                 break;
  38.             }
  39.             i=-1;
  40.             ++q;
  41.             summ=0;
  42.         }
  43.         if (q==n) break;
  44.  
  45.     }
  46.     cout<<o;
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement