fork download
  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cassert>
  4. #include<algorithm>
  5. #include<vector>
  6. using namespace std;
  7. #define pli pair< long long int , int >
  8. int main()
  9. {
  10. int n;
  11. cin>>n;
  12.  
  13. assert(n>=1 && n<=10000);
  14.  
  15. vector<pli> v;
  16. for(int i=1; i<=n; i++)
  17. {
  18. long long int x,y;
  19. cin>>x;
  20. cin>>y;
  21.  
  22. assert(x>=1 && x<=1000000);
  23. assert(y>=1 && y<=1000000);
  24.  
  25.  
  26. v.push_back(pli(x*y,-i));
  27. }
  28. sort(v.rbegin(),v.rend());
  29.  
  30.  
  31. int Q;
  32. cin>>Q;
  33. while(Q--)
  34. {
  35. int k;
  36. cin>>k;
  37.  
  38. assert(k>=1 && k<=n);
  39.  
  40. printf("%d\n",-1*v[k-1].second);
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 3420KB
stdin
5
4 6
1 2
3 4
8 10
4 3
5
1
2
3
4
5
stdout
4
1
3
5
2