Advertisement
Saleh127

UVA 10670

Aug 26th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 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; while(t--)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. int t,k;
  11. cin>>t;
  12. for(k=1;k<=t;k++)
  13. {
  14. int n,m,l,a,c,d,i,j;
  15. cin>>n>>m>>l;
  16. vector<pair<int,string> >ans;
  17. while(l--)
  18. {
  19. string agnt;
  20. char x;
  21. while(cin>>x && x!=':')
  22. {
  23. agnt+=x;
  24. }
  25. cin>>a>>x>>c;
  26. d=n;
  27. int cst=0;
  28. while((d/2)*a>c && d/2>=m)
  29. {
  30. d/=2;
  31. cst+=c;
  32. }
  33. cst+=(d-m)*a;
  34.  
  35. ans.push_back(make_pair(cst,agnt));
  36. }
  37. sort(ans.begin(),ans.end());
  38. cout<<"Case "<<k<<endl;
  39. for(i=0;i<ans.size();i++)
  40. {
  41. cout<<ans[i].second<<" "<<ans[i].first<<endl;
  42. }
  43. }
  44. return 0;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement