#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<climits>
#include<cmath>
#include<numeric>
using namespace std;
struct node
{
int s,t;
};
node table[210];
bool cmp(node a,node b)
{
return a.s<b.s;
}
int main()
{
int T;
//freopen("1083.txt","r",stdin);
scanf("%d",&T);
while(T--)
{
int N;
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d%d",&table[i].s,&table[i].t);
int dan1=table[i].s,dan2=table[i].t;
if(dan1%2==0)dan1/=2;
else dan1=(dan1+1)/2;
if(dan2%2==0)dan2/=2;
else dan2=(dan2+1)/2;
table[i].s=min(dan1,dan2);
table[i].t=max(dan1,dan2);
}
sort(table,table+N,cmp);
int dp[210];
fill(dp,dp+N,0);
dp[0]=10;
for(int i=1;i<N;i++)
{
int min_t=INT_MAX;
int min_j;
for(int j=0;j<i;j++)
{
if(dp[j]!=0&&min_t>table[j].t)
{
min_t=table[j].t;
min_j=j;
}
}
if(table[i].s>table[min_j].t)
{
dp[i]=dp[min_j];
dp[min_j]=0;
}
else dp[i]=10;
}
printf("%d\n",accumulate(dp,dp+N,0));
}
return 0;
}
poj1083 Moving Tables
最新推荐文章于 2020-02-15 20:20:46 发布