#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main( )
{
map< string,vector< int >> countriesAndYears;
int n;
string country;
int year,visit;
cin >> n;
for ( int i= 0 ; i< n; ++ i)
{
cin >> country >> year;
countriesAndYears[ country] .push_back ( year) ;
}
for ( const auto & elem : countriesAndYears)
{
sort( elem.begin ( ) ,elem.end ( ) ) ;
}
cin >> n;
for ( int i= 0 ; i< n; ++ i)
{
cin >> country >> visit;
cout << countriesAndYears[ country] [ visit- 1 ] << "\n " ;
}
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSAKewoJbWFwPHN0cmluZyx2ZWN0b3I8aW50Pj4gY291bnRyaWVzQW5kWWVhcnM7CgkKCWludCBuOwoJc3RyaW5nIGNvdW50cnk7CglpbnQgeWVhcix2aXNpdDsKCWNpbiA+PiBuOwoJZm9yKGludCBpPTA7aTxuOysraSkKCXsKCQljaW4gPj4gY291bnRyeSA+PiB5ZWFyOwoJCWNvdW50cmllc0FuZFllYXJzW2NvdW50cnldLnB1c2hfYmFjayh5ZWFyKTsKCX0KCWZvciAoY29uc3QgYXV0byYgZWxlbSA6IGNvdW50cmllc0FuZFllYXJzKQoJewoJCXNvcnQoZWxlbS5iZWdpbigpLGVsZW0uZW5kKCkpOwoJfQoJY2luID4+IG47Cglmb3IoaW50IGk9MDtpPG47KytpKQoJewoJCWNpbiA+PiBjb3VudHJ5ID4+IHZpc2l0OwoJCWNvdXQgPDwgY291bnRyaWVzQW5kWWVhcnNbY291bnRyeV1bdmlzaXQtMV0gPDwgIlxuIjsKCX0KCXJldHVybiAwOwp9
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23:13: error: ‘const struct std::pair<const std::__cxx11::basic_string<char>, std::vector<int> >’ has no member named ‘begin’
sort(elem.begin(),elem.end());
^~~~~
prog.cpp:23:26: error: ‘const struct std::pair<const std::__cxx11::basic_string<char>, std::vector<int> >’ has no member named ‘end’; did you mean ‘second’?
sort(elem.begin(),elem.end());
^~~
stdout