/* ======================================================================== $File: $ $Date: $ $Revision: $ $Creator: Creative GP $ $Notice: (C) Copyright 2017 by Creative GP, Inc. All Rights Reserved. $ ======================================================================== */ #define CPP #include #include #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 = 0; ll maxindex = -1; for (auto it = bought.begin(); it != bought.end(); ++it) { if (maxi < *it) { maxi = *it; maxindex = distance(bought.begin(), it); } } cout << maxindex+1 << endl; }