简单,两次排序
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #define MAX 50000 struct Vote {
int index;
int a;
int b;
}; struct Vote candidates[MAX];
int N, K; int cmp_1(const void * a, const void * b) {
return ((struct Vote *)b)->a - ((struct Vote *)a)->a;
}
int cmp_2(const void * a, const void * b) {
return ((struct Vote *)b)->b - ((struct Vote *)a)->b;
} int pick() {
qsort(candidates, N, sizeof(candidates[0]), cmp_1);
qsort(candidates, K, sizeof(candidates[0]), cmp_2);
return candidates[0].index;
} int main() {
int i;
int res; scanf("%d%d", &N, &K);
for(i = 0; i < N; i++) {
scanf("%d%d", &candidates[i].a, &candidates[i].b);
candidates[i].index = i + 1;
} res = pick();
printf("%d\n", res);
return 0;
}