记录编号 127620 评测结果 AAAAAAAAAA
题目名称 [USACO Mar03] 奶酪工厂 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.013 s
提交时间 2014-10-15 21:50:40 内存使用 3.23 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 <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==============

//==============var declaration=================
const int MAXN=10010;
LL cost[MAXN],mincost;
LL S,ans=0;
int n,v;
//==============function declaration============

//==============main code=======================
int main()
{  

  freopen("factory.in","r",stdin);
  freopen("factory.out","w",stdout); 
  scanf("%d%lld",&n,&S);
  mincost=10000000000000ll;
  For(i,1,n){
    scanf("%lld%d",cost+i,&v);
    LL minv=10000000000000ll;
    if (mincost+S<cost[i])
      mincost+=S;
    else 
      mincost=cost[i];
    ans+=mincost*v;
  }
  printf("%lld\n",ans);
   
  return 0;
}