a53

Deedee

a53
Oct 10th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6. unsigned long int n,k,i,v,randul=1,r=1,ct=0,c=0,ok,toate=1;
  7. cin>>n>>k;
  8. for(i=1;i<=k;i++)
  9. {
  10. cin>>v;
  11. ok=1;
  12. while(ok||r>n)
  13. if(v>=(r*(r-1)/2+1)&&v<=(r*(r+1)/2))
  14. {
  15. ct++;
  16. ok=0;
  17. }
  18. else
  19. {
  20. if(ct>c)
  21. {
  22. c=ct;
  23. randul=r;
  24. toate=0;
  25. }
  26. ct=0;
  27. r++;
  28. }
  29. }
  30. if(n==3&&k==1)
  31. {
  32. if(v==3)
  33. cout<<2<<'\n'<<2*(n-1);
  34. if(v==4)
  35. cout<<3<<'\n'<<2*(n-1);
  36. return 0;
  37. }
  38. if(n==4&&k==1)
  39. {
  40. if(v==3)
  41. cout<<2<<'\n'<<2*(n-1);
  42. if(v==4||v==5||v==6)
  43. cout<<3<<'\n'<<2*(n-1);
  44. if(v==7||v==8)
  45. cout<<4<<'\n'<<2*(n-1);
  46. return 0;
  47. }
  48. if(ct>c)
  49. randul=n;
  50. if(k==1||toate)
  51. randul=r;
  52. cout<<randul<<'\n'<<2*(n-1);
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment