Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long int ull;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef pair<int,int> pii;
- typedef vector< pii > vpii;
- typedef set<int> sti;
- #define pb push_back
- #define pob pop_back
- #define mp make_pair
- #define ff first
- #define ss second
- #define loop1(i,n) for(int i=1; i<=int(n); i++)
- #define loop(i,y) for(int i=0; i<int(y); i++)
- #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- #define cspf(i) printf("Case %d:\n", i)
- /// Constants
- #define eps 1e-9
- #define PI acos(-1.0) // 3.1415926535897932
- int main()
- {
- read();
- int test;
- scanf("%d",&test);
- loop1(t,test){
- vector<pair<int,int>>vt;
- int x,y,i,j,k,l,m;
- string nm;
- vector<string>nmatr,nmdfs,name,tnmatr,tnmdfs,tname;
- int atr[20],dfs[20],mxatr=0,mxdfs=0,atrto=0,dfsto=0,tempatr=0,tempdfs=0;
- for(i=0;i<10;i++){
- cin>>nm;
- name.push_back(nm);
- scanf("%d %d",&x,&y);
- vt.push_back(make_pair(x,y));
- }
- int a[20];
- for(y=0;y<12;y++){
- a[y]=0;
- }
- for(i=0;i<10;i++){
- a[i]=1;
- for(j=i+1;j<10;j++){
- a[j]=1;
- for(k=j+1;k<10;k++){
- a[k]=1;
- for(l=k+1;l<10;l++){
- a[l]=1;
- for(m=l+1;m<10;m++){
- a[m]=1;
- tempatr=0;
- tempdfs=0;
- for(x=0;x<10;x++){
- if(a[x]==1){
- tempatr+=vt[x].first;
- tnmatr.push_back(name[x]);
- }
- else{
- tempdfs+=vt[x].second;
- tnmdfs.push_back(name[x]);
- }
- }
- if(tempatr>mxatr){
- mxatr=tempatr;
- mxdfs=tempdfs;
- nmatr.clear();
- nmatr=tnmatr;
- nmdfs.clear();
- nmdfs=tnmdfs;
- }
- else if(tempatr==mxatr){
- if(tempdfs>mxdfs){
- mxdfs=tempdfs;
- nmatr.clear();
- nmatr=tnmatr;
- nmdfs.clear();
- nmdfs=tnmdfs;
- }
- else if(tempdfs==mxdfs){
- tname=name;
- sort(tname.begin(),tname.end());
- int u;
- nmatr.clear();
- for(u=0;u<5;u++){
- nmatr.push_back(tname[u]);
- }
- nmdfs.clear();
- for(u=5;u<10;u++){
- nmdfs.push_back(tname[u]);
- }
- }
- }
- a[m]=0;
- tname.clear();
- tnmatr.clear();
- tnmdfs.clear();
- }
- a[l]=0;
- }
- a[k]=0;
- }
- a[j]=0;
- }
- a[i]=0;
- }
- cspf(t);
- int f;
- sort(nmatr.begin(),nmatr.end());
- sort(nmdfs.begin(),nmdfs.end());
- printf("(");
- for(f=0;f<5;f++){
- cout<<nmatr[f];
- if(f<4)
- printf(", ");
- }
- printf(")\n(");
- for(f=0;f<5;f++){
- cout<<nmdfs[f];
- if(f<4)
- printf(", ");
- }
- printf(")\n");
- nmatr.clear();
- nmdfs.clear();
- name.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement