记录编号 116574 评测结果 AAAAAAAAAA
题目名称 [湖北2011寒假] 未名湖钓鱼 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.008 s
提交时间 2014-08-26 09:47:50 内存使用 0.35 MiB
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint; 
const int INF=0x7ffffff;
//==============struct declaration==============
struct lakes
{
  int fish,cost;
  bool operator <(const lakes &rhs) const
  {
    return fish<rhs.fish;
  }
}lake[5010];
//==============var declaration=================

//==============function declaration============
priority_queue<lakes> Q;
//==============main code=======================
int main()
{  
  string FileName="fisha";//程序名 
  string FloderName="COGS";//文件夹名 
  freopen((FileName+".in").c_str(),"r",stdin);
  freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG  
  system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
#endif    
  int n,sumt,walkt,fisht;
  scanf("%d%d%d%d",&n,&sumt,&walkt,&fisht);
  sumt-=(walkt)*(n-1);
  For(i,1,n)
  {

    scanf("%d%d",&lake[i].fish,&lake[i].cost);
    Q.push(lake[i]);
  }
  int cnt=0;
  while (1)
  {
    lakes u;      
    u=Q.top();Q.pop();
    //printf("%d\n",u.fish);
    if (sumt-fisht>0)
    {
      sumt-=fisht;
      cnt+=u.fish;
      u.fish-=u.cost;
      if (u.fish<0)
        u.fish=0;
      Q.push(u);
    }
    else
      break;
  }
  cout<<cnt;
  return 0;
}
//================fuction code====================