fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. const int N = 500;
  7. int n, x, y, d[N], m[N];
  8.  
  9. int main(int argc, char **argv) {
  10. int T;
  11. scanf("%d", &T);
  12. while (T-- != 0) {
  13. scanf("%d%d%d", &n, &x, &y);
  14. for (int i = 0; i < n; ++i)
  15. scanf("%d%d", &d[i], &m[i]);
  16. vector<int> v;
  17. for (int i = 0; i < n; ++i)
  18. if (d[i] <= x && m[i] >= y)
  19. v.push_back(i);
  20. if (v.empty())
  21. puts("-1");
  22. else {
  23. int sol = v[0];
  24. for (size_t i = 1; i < v.size(); ++i)
  25. if (d[v[i]] < d[sol] || (d[v[i]] == d[sol] && m[v[i]] > m[sol]))
  26. sol = v[i];
  27. printf("%d\n", sol + 1);
  28. }
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 4388KB
stdin
2
3 5 3
4 2
7 1
5 7
4 4 6
3 7
3 8
2 4
5 2
stdout
3
2