上星期天做的,没有做出来,郁闷呀

//第二次网络预赛
/*
6 3
radish 1 10 15
rose 1 18 23
watermelon 2 28 13 23
grapefruit 3 61 26 39
pitaya 4 70 29 41
blueberry 5 31 14 18
*/
#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<set>
using namespace std;
struct plant //typedef
{
  string name;
  double sum;
  bool operator>(const plant &a) const
  {
    return a.sum>sum;
  }
 };
/*
struct cmp
{
  bool (const double &a,const double &b)
  {
    if(a!=b)
      return a>b;
    else
      {
    return a>b;
      }
  }
};
void Swap(double &m,double &n)
{
    int temp = m;
    m = n;
    n = temp;
}
void Qsort(double *a,int m,int n)
{  
    if(m<n)
    {
        int i = m;
        int j = n+1;
        double temp = a[m];//选第一个元素为参考
        while(1)
        {
            i++;
            while(a[i] < temp) i++;
            j-=1;
            while(a[j] > temp) j--;
            if(i < j) Swap(a[i],a[j]);
            else break;
        }
        a[m] = a[j];
        a[j] = temp;
        Qsort(a,m,j-1);
        Qsort(a,j+1,n);
    }  
}
*/
int main()
{
  ifstream cin("c.in");
  int n,m;
  set<plant>s;
  //  double sarr[1000];
  plant plan;//[1000];
  cin>>n;
  cin>>m;
  for(int i=0;i<n;i++)
    {
      cin>>plan.name;//-
      //      string na;
      //      cin>>na;
      //      plan.insert(na);
      int k;
      cin>>k;
      if(k==1)
    {
      int ji,yan;
      cin>>ji;
      cin>>yan;
      plan.sum=(double)yan/ji;//-
    }
      else
    {
      int k1,k2;
      cin>>k1;
      cin>>k2;
      int yan;
      cin>>yan;
      if(k%2==0)
        {
          plan.sum=(double)(yan*k)/(k1*k/2+k2*k/2);//-
        }
      else
        {
          plan.sum=(double)(yan*k)/(k1*(k/2+1)+k2*k/2);//-
        }

    }
      //      sarr[i]=plan[i].sum;
      //      cout<<sarr[i]<<" ";
      s.insert(plan);
      set<plant>::iterator it;
      for(it=s.begin();it<s.end();it++)
    {
      cout<<(*it).name<<endl;
    }
    }
  cout<<endl;
  /*
  //  Qsort(plan.sum,0,n);
  for(int i=0;i<n;i++)
    {
      cout<<plan[i].name<<" ";
    }
  */
  return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值