HDU 1050(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050
1 #include <cstdio> 2 #include <cstring> 3 using namespace std; 4 5 int main() 6 { 7 int mark[201]; 8 int a, b; 9 int t; 10 int n; 11 while(scanf("%d", &t) != EOF) 12 { 13 for(int i = 0; i < t; i++) 14 { 15 memset(mark, 0, sizeof(mark)); 16 scanf("%d", &n); 17 for(int j = 0; j < n; j++) 18 { 19 scanf("%d %d", &a, &b); 20 if(a > b) 21 { 22 a = a - b; 23 b = a + b; 24 a = b - a; 25 } 26 a = (a + 1) / 2; 27 b = (b + 1) / 2; 28 for(int k = a; k <= b; k++) 29 { 30 mark[k]++; 31 } 32 } 33 int max = 0; 34 for(int j = 1; j < 201; j++) 35 { 36 if(mark[j] > max) 37 { 38 max = mark[j]; 39 } 40 } 41 printf("%d\n", 10 * max); 42 } 43 } 44 return 0; 45 }