fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. //freopen("in.txt","r",stdin);
  5. int n; cin>>n;
  6. vector<pair<long long int,int> >v;
  7. for(int i=1; i<=n; i++){
  8. long long int x,y; cin>>x>>y;
  9. v.push_back(make_pair(x*y,n-i));
  10. }
  11. sort(v.begin(),v.end());
  12. reverse(v.begin(),v.end());
  13. int q;
  14. cin>>q;
  15. while(q--){
  16. int pos; cin>>pos;
  17. cout<<n-v[pos-1].second<<endl;
  18. }
  19. }
Runtime error #stdin #stdout #stderr 2.64s 397056KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc