标签:贪心
#include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <stack> #include <cstdlib> #include <cmath> #include <set> #include <map> #include <vector> #include <cstring> #define INF 100000000 using namespace std; struct node{ int x,y; bool operator < (const node &a) const { return abs(y - x) < abs(a.x - a.y); } }; node a[205]; int d[1000]; int main(){ int t; //freopen("in.txt","r",stdin); cin >> t; while(t--){ int n; cin >> n; for(int i = 0;i < n;i++){ int x,y; scanf("%d%d",&x,&y); a[i].x = (min(x,y)+1)/2; a[i].y = (max(x,y)+1)/2; } memset(d,0,sizeof(d)); for(int i = 0;i < n;i++){ for(int j = a[i].x;j <= a[i].y;j++){ d[j]++; } } int ans = 0; for(int i = 0;i <= 200;i++){ if(d[i] > ans){ ans ++; } } cout << ans*10 << endl; } return 0; }证明:这个点是经过次数最多的点,因为这个点所在的每一次移动都不能同时进行所以他一定是最小的次数!
标签:贪心
原文地址:http://blog.csdn.net/qq_24667639/article/details/45483055