forked from t3nsor/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbwidow.cpp
More file actions
33 lines (33 loc) · 762 Bytes
/
bwidow.cpp
File metadata and controls
33 lines (33 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 2014-10-02
#include <cstdio>
int r[1000];
int R[1000];
int main() {
int T; scanf("%d", &T);
while (T--) {
int N; scanf("%d", &N);
int biggest_R = -1;
int biggest_pos;
for (int i = 0; i < N; i++) {
scanf("%d %d", r+i, R+i);
if (R[i] > biggest_R) {
biggest_R = R[i];
biggest_pos = i;
}
}
bool ok = true;
for (int i = 0; i < N; i++) {
if (i == biggest_pos) continue;
if (R[i] >= r[biggest_pos]) {
ok = false;
break;
}
}
if (ok) {
printf("%d\n", biggest_pos+1);
} else {
puts("-1");
}
}
return 0;
}