↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
#define _CRT_SECURE_NO_WARNINGS↵
#include <iostream>↵
#include <vector>↵
#include <algorithm>↵
#include <set>↵
#include <string>↵
#include <cmath>↵
#include <iomanip>↵
using namespace std;↵
↵
↵
int main()↵
{↵
freopen("26.txt","r",stdin);↵
int n; cin>>n;↵
vector<pair<int,int>>b;↵
vector<int>a,c;↵
for(int i=0;i<n;i++){↵
int sum=0,x,y,t=0;↵
cin>>x;↵
for(int j=1;j<5;j++){↵
cin>>y;↵
if(y==2)t++;↵
sum+=y;↵
}↵
if(t==0){↵
b.push_back(make_pair(sum,x));↵
}↵
else if(t==3){↵
a.push_back(x);↵
}↵
else if(t==4){↵
c.push_back(x);↵
}↵
}↵
sort(b.begin(),b.end());↵
sort(a.begin(),a.end());↵
sort(c.begin(),c.end());↵
vector<int>b1,b2;↵
for(int i=b.size()-1;i>0;i--){↵
b1.push_back(b[i].second);↵
if(b[i].first!=b[i-1].first){↵
sort(b1.begin(),b1.end());↵
for(int j=0;j<b1.size();j++){↵
b2.push_back(b1[j]);↵
↵
}b1.clear();↵
if(i==1)b2.push_back(b[i-1].second);↵
}↵
else if(i==1){↵
b1.push_back(b[i-1].second);↵
sort(b1.begin(),b1.end());↵
for(int j=0;j<b1.size();j++){↵
b2.push_back(b1[j]);↵
}b1.clear();↵
}↵
}↵
↵
cout<<b2[n/4-1]<<" ";↵
if(a.size()==0){↵
cout<<c[0];↵
}↵
else cout<<a[0];↵
return 0;↵
}↵
↵
↵
//8↵
//4 4 4 4 4↵
//7 5 5 5 2↵
//10 3 4 4 5↵
//1 4 4 4 3↵
//6 3 5 5 3↵
//2 2 2 2 2↵
//13 2 2 2 3↵
//3 3 3 3 3↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
↵
#define _CRT_SECURE_NO_WARNINGS↵
#include <iostream>↵
#include <vector>↵
#include <algorithm>↵
#include <set>↵
#include <string>↵
#include <cmath>↵
#include <iomanip>↵
using namespace std;↵
↵
↵
int main()↵
{↵
freopen("26.txt","r",stdin);↵
int n; cin>>n;↵
vector<pair<int,int>>b;↵
vector<int>a,c;↵
for(int i=0;i<n;i++){↵
int sum=0,x,y,t=0;↵
cin>>x;↵
for(int j=1;j<5;j++){↵
cin>>y;↵
if(y==2)t++;↵
sum+=y;↵
}↵
if(t==0){↵
b.push_back(make_pair(sum,x));↵
}↵
else if(t==3){↵
a.push_back(x);↵
}↵
else if(t==4){↵
c.push_back(x);↵
}↵
}↵
sort(b.begin(),b.end());↵
sort(a.begin(),a.end());↵
sort(c.begin(),c.end());↵
vector<int>b1,b2;↵
for(int i=b.size()-1;i>0;i--){↵
b1.push_back(b[i].second);↵
if(b[i].first!=b[i-1].first){↵
sort(b1.begin(),b1.end());↵
for(int j=0;j<b1.size();j++){↵
b2.push_back(b1[j]);↵
↵
}b1.clear();↵
if(i==1)b2.push_back(b[i-1].second);↵
}↵
else if(i==1){↵
b1.push_back(b[i-1].second);↵
sort(b1.begin(),b1.end());↵
for(int j=0;j<b1.size();j++){↵
b2.push_back(b1[j]);↵
}b1.clear();↵
}↵
}↵
↵
cout<<b2[n/4-1]<<" ";↵
if(a.size()==0){↵
cout<<c[0];↵
}↵
else cout<<a[0];↵
return 0;↵
}↵
↵
↵
//8↵
//4 4 4 4 4↵
//7 5 5 5 2↵
//10 3 4 4 5↵
//1 4 4 4 3↵
//6 3 5 5 3↵
//2 2 2 2 2↵
//13 2 2 2 3↵
//3 3 3 3 3↵