Advertisement
erfanul007

UVa 1440

Dec 6th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include<cmath>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. vector<int>atime;
  9. int t,n,ctime,prev,total,wtime,m,x,y,i,j,tript;
  10. cin>>t;
  11. while(t--){
  12. cin>>n>>ctime>>m;
  13. y=m;
  14. while(y--){
  15. cin>>x;
  16. atime.push_back(x);
  17. }
  18. sort(atime.begin(),atime.end());
  19. total=0;
  20. i=0;
  21. if(m%n==0){
  22. i=n;
  23. total=atime[i-1]+2*ctime;
  24. }
  25. else{
  26. i=m%n;
  27. total=atime[i-1]+2*ctime;
  28. }
  29. while(i<m){
  30. if(total>=atime[i+n-1])
  31. total=total+2*ctime;
  32. else
  33. total=atime[i+n-1]+2*ctime;
  34. i=i+n;
  35. }
  36. tript=(m+n-1)/n;
  37. total=total-ctime;
  38. cout<<total<<" "<<tript<<endl;
  39. atime.clear();
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement