Advertisement
Saleh127

CF 1418C

Sep 14th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll a[200005],c,d,e=0,f,i,j,k,l;
  14. cin>>c;
  15. for(i=0; i<c; i++)
  16. {
  17. cin>>a[i];
  18.  
  19. }
  20. if(a[0]==1)
  21. {
  22. e++;
  23. }
  24.  
  25. for(i=1; i<c; i++)
  26. {
  27. if(a[i]==1)
  28. {
  29. if(i+1<c)
  30. {
  31. if(a[i+1]==1)
  32. {
  33. if(i+2<c)
  34. {
  35. if(a[i+2]==1)
  36. {
  37. e++;
  38. i+=2;
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }
  45. cout<<e<<endl;
  46. }
  47.  
  48.  
  49. return 0;
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement