Advertisement
Saleh127

CF 1176B

Aug 2nd, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);cout.tie(0);
  7.  
  8. int t;
  9. cin>>t;
  10. while(t--)
  11. {
  12. int a[20000],c,d=0,e=0,f=0,i,j,k,l;
  13. cin>>c;
  14. for(i=0;i<c;i++)
  15. {
  16. cin>>a[i];
  17. if(a[i]%3==0) d++;
  18. else if(a[i]%3==1) e++;
  19. else if(a[i]%3==2) f++;
  20. }
  21. k=min(e,f);
  22. d+=k;
  23. e-=k;
  24. f-=k;
  25. d+=(e/3);
  26. d+=(f/3);
  27. cout<<d<<endl;
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement