/* ======================================================================== $File: $ $Date: $ $Revision: $ $Creator: Creative GP $ $Notice: (C) Copyright 2017 by Creative GP, Inc. All Rights Reserved. $ ======================================================================== */ #define CPP #include #include #include #define ll long long using namespace std; struct Info { ll price, hot; }; int main() { vector bought; ll members; cin >> members; vector rest; for (int i = 0; i < members; i++) { Info r; cin >> r.price >> r.hot; rest.push_back(r); } ll mentaiko; cin >> mentaiko; vector mentaiko_info; for (int i = 0; i < mentaiko; i++) { Info r; cin >> r.price >> r.hot; mentaiko_info.push_back(r); } for (int j = 0; j < mentaiko; j++) { bought.push_back(0); for (int i = 0; i < members; i++) { if (mentaiko_info[j].hot >= rest[i].hot && mentaiko_info[j].price <= rest[i].price) { bought[j] += 1; } } } ll maxi = *max_element(bought.begin(), bought.end()); if (maxi == 0) { cout << 0 << endl; return 0; } vector maxindices; for (auto it = bought.begin(); it != bought.end(); ++it) { if (maxi == *it) { maxindices.push_back(distance(bought.begin(), it)); } } for (ll index : maxindices) { cout << index+1 << endl; } }