#include #include #include using namespace std; struct Person{ int price=0; int spice = 0; }; struct Mentaiko { int price = 0; int spice = 0; }; int main() { //整数nの入力 //データの入力 //整数mの入力 //データの入力 //大きさmの配列countを用意 //ループ開始 //ループ開始 //i番目の金額以内かつ、i番目の辛さ以上であればカウントする //0~mまで繰り返す //0~nまで繰り返す int n = 0, m = 0; vector array1; vector array2; cin >> n; for (int i = 0;i < n;i++) { Person buff; cin >> buff.price >> buff.spice; array1.push_back(buff); } cin >> m; for (int i = 0;i < m;i++) { Mentaiko buff; cin >> buff.price >> buff.spice; array2.push_back(buff); } vector count(m, 0); for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) { if (array1[i].price >= array2[j].price && array1[i].spice <= array2[j].spice)count[j]++; } } vector::iterator itr1= max_element(count.begin(), count.end());//最大値のイテレータ int maxvalue = *max_element(count.begin(), count.end());//最大値 if (maxvalue == 0) { cout << 0 << endl; return 0; } size_t maxIndex = distance(count.begin(), itr1);//最大値のインデックス vector indexs; indexs.push_back(maxIndex); vector::iterator itr2; while (true) { if (itr1 != count.end()-1 && *max_element(itr1+1, count.end()) == maxvalue) { itr2 = max_element(itr1+1, count.end()); maxIndex = distance(count.begin(), itr2); indexs.push_back(maxIndex); itr1 = itr2; } else break; } for (int i : indexs) { cout << i+1<