#include #include #include #include using namespace std; int main(int argc, const char * argv[]) { int n; cin >> n; int array[n][4]; vector strList; string tmp; int count = 0; for(int i = 0; i < n*5;i++){ if(i%5 == 4){ cin >> tmp; strList.push_back(tmp); count++; } else{ cin >> array[count][i%5]; } } int yescount[10]; int nocount[10]; for (int i = 0; i < 10; i++) { yescount[i] = 0; nocount[i] = 0; } for (int i = 0; i < n; i++) { if(strList[i] == "YES"){ for (int j = 0; j < 4; j++) { yescount[array[i][j]]++; } } else{ for (int j = 0; j < 4; j++) { nocount[array[i][j]]++; } } } //ジャッジ //判断のパターン //1.1つを除きすべてNOになっている //2.YESの回数が他より多い int result = 0; int tmpresult = 0; //1番の判定 int tmpcount = 0; for (int i = 0; i < 10; i++) { if(nocount[i] == 0){ tmpresult = i; } else{ tmpcount++; } } if(tmpcount == 9){ result = tmpresult; } //2番の判定 int tmpmax = 0; for (int i = 0; i < 10; i++) { if (yescount[i] > tmpmax && nocount[i] == 0) { tmpmax = yescount[i]; tmpresult = i; } } if(tmpmax >= 1){ result = tmpresult; } cout << result; cout << "\n"; }