Advertisement
Saleh127

CF 1408b

Oct 1st, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 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.  
  14. ll a[1000],c,d,e=1,f,i,j,k=0,l;
  15. cin>>c>>k;
  16. for(i=0; i<c; i++)
  17. {
  18. cin>>a[i];
  19. }
  20. for(i=1; i<c; i++)
  21. {
  22. if(a[i]!=a[i-1])
  23. {
  24. e++;
  25. }
  26. }
  27. if(k==1 && e>1)
  28. {
  29. cout<<-1<<endl;
  30. }
  31. else
  32. {
  33. d=1;
  34. e-=k;
  35. while(e>0)
  36. {
  37. e-=k-1;
  38. d++;
  39. }
  40. cout<<d<<endl;
  41. }
  42. }
  43. return 0;
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement