Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<cmath>
- #include<string>
- using namespace std;
- int main()
- {
- vector<int>atime;
- int t,n,ctime,prev,total,wtime,m,x,y,i,j,tript;
- cin>>t;
- while(t--){
- cin>>n>>ctime>>m;
- y=m;
- while(y--){
- cin>>x;
- atime.push_back(x);
- }
- sort(atime.begin(),atime.end());
- total=0;
- i=0;
- if(m%n==0){
- i=n;
- total=atime[i-1]+2*ctime;
- }
- else{
- i=m%n;
- total=atime[i-1]+2*ctime;
- }
- while(i<m){
- if(total>=atime[i+n-1])
- total=total+2*ctime;
- else
- total=atime[i+n-1]+2*ctime;
- i=i+n;
- }
- tript=(m+n-1)/n;
- total=total-ctime;
- cout<<total<<" "<<tript<<endl;
- atime.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement