码迷,mamicode.com
首页 > 其他好文 > 详细

NYOJ 236 心急的c小加

时间:2015-07-03 20:40:19      阅读:91      评论:0      收藏:0      [点我收藏+]

标签:

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct cxj
{
  int a; //a为长度,b为质量
  int b;
  int vis;
}e[5010];
int cmp(cxj x,cxj y)
{
  if(x.b!=y.b)
    return x.b<y.b;
  else
    return x.a<y.a;
}
int main()
{
  int T,n,i,j,t,sum,s;
  scanf("%d",&T);
  while(T--)
  {
    s=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d",&e[i].a,&e[i].b);
        e[i].vis=1;
    }
    sort(e,e+n,cmp);
    for(i=0;i<n;i++)
    {
      t=e[i].a;
      if(e[i].vis==0) continue;
      for(j=i+1;j<n;j++)
      {
        if(e[j].vis&&t<=e[j].a)
        {
          e[j].vis=0;
          t=e[j].a;
        }
      }
     s++; //进行多少次循环,就是花了多少分钟
    }
  printf("%d\n",s);
  }
}

NYOJ 236 心急的c小加

标签:

原文地址:http://www.cnblogs.com/mycapple-zgs-111411/p/4619457.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!