#include"iostream"
#include"stdio.h"
#include"algorithm"
using namespace std;
const int MAXN=10005;
typedef long long ll;
int n,s;
struct Node
{
int productCostPerUnit;
int requireNum;
};
Node weeks[MAXN]; ll Solve()
{
ll sum=0;
int i=0;
while(i<n)
{
sum+=weeks[i].productCostPerUnit*weeks[i].requireNum;
int k=1;
while(i+k<n&&weeks[i].productCostPerUnit+k*s<weeks[i+k].productCostPerUnit)
{
sum+=(weeks[i].productCostPerUnit+k*s)*weeks[i+k].requireNum;
k++;
}
i=i+k;
}
return sum;
}
int main()
{
while(scanf("%d%d",&n,&s)==2)
{
for(int i=0;i<n;i++)
scanf("%d%d",&weeks[i].productCostPerUnit,&weeks[i].requireNum);
cout<<Solve()<<endl;
}
return 0;
}

  

poj2393tmp的更多相关文章

随机推荐

  1. Smarty3——foreach

    foreach and  foreachelse篇 foreach用于遍历数组,可以是非关联数组,与section相比要简单些,在smarty3中可以接受没有名称的属性,也可以使用smarty2有名称 ...

  2. Oracle——单行函数

    两种 SQL 函数 单行函数 字符函数 大小写控制函数 SELECT employee_id, last_name, department_id FROM employees WHERE last_n ...

  3. HDU 6047 Maximum Sequence (贪心+单调队列)

    题意:给定一个序列,让你构造出一个序列,满足条件,且最大.条件是 选取一个ai <= max{a[b[j], j]-j} 析:贪心,贪心策略就是先尽量产生大的,所以就是对于B序列尽量从头开始,由 ...

  4. Java IO输入输出流 字符数组流 ByteArrayOutputStream/ByteArrayInputStream

    private static void StringWriterAndReader() throws Exception { //字符串流(字符串的内存流) //字符串输入流 StringWriter ...

  5. C# - dynamic 特性

    dynamic是FrameWork4.0的新特性.dynamic的出现让C#具有了弱语言类型的特性.编译器在编译的时候不再对类型进行检查,编译期默认dynamic对象支持你想要的任何特性. 比如,即使 ...

  6. 使用java实现单链表----(java中的引用就是指针)

    //一直以为java中没有指针,其实java的引用就是指针,只不过堆栈中的引用储存了在堆中的地址,可以看做java中的指针.public class sibgleLink<E> { // ...

  7. super() 的入门使用

    在类的继承中,如果重定义某个方法,该方法会覆盖父类的同名方法,但有时,我们希望能同时实现父类的功能,这时,我们就需要调用父类的方法了,可通过使用 super 来实现,比如:     1 2 3 4 5 ...

  8. 从头开始学eShopOnContainers——开发环境要求

    一.简介 eShopOnContainers是一个简化版的基于.NET Core和Docker等技术开发的面向微服务架构的参考应用,是一个简化版的在线商城/电子商务应用,其包含基于浏览器的Web应用. ...

  9. NSURLConnection 网络请求

    前言 DEPRECATED: The NSURLConnection class should no longer be used. NSURLSession is the replacement f ...

  10. 题解 P4140 【奇数国 】

    题目链接 首先,按照题意,把前$60$个素数打出来$[2$ $-$ $281]$. 因为只有$60$个,再加上本宝宝极其懒得写线性筛于是每一个都$O(\sqrt{n})$暴力筛就好了. 代码如下: # ...