pku3664 Election Time
http://poj.org/problem?id=3664
水题
1 #include <stdio.h> 2 #include <map> 3 4 using namespace std; 5 6 map<pair<int, int>, int> map1; 7 map<pair<int, int>, int>::iterator it; 8 9 int main() 10 { 11 int n, k; 12 int i, x, y, max1, flag1, temp; 13 while(~scanf("%d%d", &n, &k)) 14 { 15 map1.clear(); 16 max1 = 0; 17 flag1 = 1; 18 for(i=1; i<=n; i++) 19 { 20 scanf("%d %d", &x, &y); 21 map1.insert(make_pair(make_pair(x, y), i)); 22 if(map1.size() > k) 23 { 24 map1.erase(map1.begin()); 25 } 26 } 27 for(it=map1.begin(); it!=map1.end(); it++) 28 { 29 temp = ((*it).first).second; 30 if(temp > max1) 31 { 32 max1 = temp; 33 flag1 = (*it).second; 34 } 35 } 36 printf("%d\n", flag1); 37 } 38 return 0; 39 }