Advertisement
erfanul007

Argentia UVa 11804

Jan 9th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vpii;
  10. typedef set<int> sti;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  18. #define loop(i,y) for(int i=0; i<int(y); i++)
  19. #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
  20. #define read() freopen("input.txt", "r", stdin)
  21. #define write() freopen("output.txt", "w", stdout)
  22. #define cspf(i) printf("Case %d:\n", i)
  23. /// Constants
  24. #define eps 1e-9
  25. #define PI acos(-1.0) // 3.1415926535897932
  26.  
  27. int main()
  28. {
  29. read();
  30. int test;
  31. scanf("%d",&test);
  32. loop1(t,test){
  33. vector<pair<int,int>>vt;
  34. int x,y,i,j,k,l,m;
  35. string nm;
  36. vector<string>nmatr,nmdfs,name,tnmatr,tnmdfs,tname;
  37. int atr[20],dfs[20],mxatr=0,mxdfs=0,atrto=0,dfsto=0,tempatr=0,tempdfs=0;
  38. for(i=0;i<10;i++){
  39. cin>>nm;
  40. name.push_back(nm);
  41. scanf("%d %d",&x,&y);
  42. vt.push_back(make_pair(x,y));
  43. }
  44. int a[20];
  45. for(y=0;y<12;y++){
  46. a[y]=0;
  47. }
  48. for(i=0;i<10;i++){
  49. a[i]=1;
  50. for(j=i+1;j<10;j++){
  51. a[j]=1;
  52. for(k=j+1;k<10;k++){
  53. a[k]=1;
  54. for(l=k+1;l<10;l++){
  55. a[l]=1;
  56. for(m=l+1;m<10;m++){
  57. a[m]=1;
  58. tempatr=0;
  59. tempdfs=0;
  60. for(x=0;x<10;x++){
  61. if(a[x]==1){
  62. tempatr+=vt[x].first;
  63. tnmatr.push_back(name[x]);
  64. }
  65. else{
  66. tempdfs+=vt[x].second;
  67. tnmdfs.push_back(name[x]);
  68. }
  69. }
  70. if(tempatr>mxatr){
  71. mxatr=tempatr;
  72. mxdfs=tempdfs;
  73. nmatr.clear();
  74. nmatr=tnmatr;
  75. nmdfs.clear();
  76. nmdfs=tnmdfs;
  77. }
  78. else if(tempatr==mxatr){
  79. if(tempdfs>mxdfs){
  80. mxdfs=tempdfs;
  81. nmatr.clear();
  82. nmatr=tnmatr;
  83. nmdfs.clear();
  84. nmdfs=tnmdfs;
  85. }
  86. else if(tempdfs==mxdfs){
  87. tname=name;
  88. sort(tname.begin(),tname.end());
  89. int u;
  90. nmatr.clear();
  91. for(u=0;u<5;u++){
  92. nmatr.push_back(tname[u]);
  93. }
  94. nmdfs.clear();
  95. for(u=5;u<10;u++){
  96. nmdfs.push_back(tname[u]);
  97. }
  98. }
  99. }
  100. a[m]=0;
  101. tname.clear();
  102. tnmatr.clear();
  103. tnmdfs.clear();
  104. }
  105. a[l]=0;
  106. }
  107. a[k]=0;
  108. }
  109. a[j]=0;
  110. }
  111. a[i]=0;
  112. }
  113. cspf(t);
  114. int f;
  115. sort(nmatr.begin(),nmatr.end());
  116. sort(nmdfs.begin(),nmdfs.end());
  117. printf("(");
  118. for(f=0;f<5;f++){
  119. cout<<nmatr[f];
  120. if(f<4)
  121. printf(", ");
  122. }
  123. printf(")\n(");
  124. for(f=0;f<5;f++){
  125. cout<<nmdfs[f];
  126. if(f<4)
  127. printf(", ");
  128. }
  129. printf(")\n");
  130. nmatr.clear();
  131. nmdfs.clear();
  132. name.clear();
  133.  
  134. }
  135. return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement