poj Yogurt factory (贪心水题)

# include <stdio.h>
# include <string.h>
# include <algorithm>
using namespace std;
int main()
{
	int i,n,s;
	__int64 sum ;
	int cost[10010],num[10010];
	while(~scanf("%d%d",&n,&s))
	{
		for(i=0;i<n;i++)
			scanf("%d%d",&cost[i],&num[i]);
	     for(i=0;i<n;i++)
		 {
			 if(i==0)
				 sum=cost[i]*num[i];
			 else
			 {
				 if(cost[i]>cost[i-1]+s)
				 {
					 sum+=(cost[i-1]+s)*num[i];
					 cost[i]=cost[i-1]+s;//更新最省价格
				 }
				 else
				 {
					 sum+=cost[i]*num[i];
				 }
			 }
		 }
		 printf("%I64d\n",sum);
	}
	return 0;
}

时间: 2024-11-10 07:34:42

poj Yogurt factory (贪心水题)的相关文章

poj 2369 Permutations 置换水题

找循环节求lcm就够了,若答案是12345应该输出1,被坑了下. #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> using namespace std; #define INF 0x3FFFFFF #define MAXN 2222 #define eps 1e-6 i

poj 1006:Biorhythms(水题,经典题,中国剩余定理)

Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 110991   Accepted: 34541 Description Some people believe that there are three cycles in a person's life that start the day he or she is born. These three cycles are the physical,

poj 1002:487-3279(水题,提高题 / hash)

487-3279 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 236746   Accepted: 41288 Description Businesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or phras

POJ 1488 Tex Quotes --- 水题

POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 Tex Quotes --- 水题 */ #include <cstdio> #include <cstring> int main() { #ifdef _LOCAL freopen("D:\\input.txt", "r", stdin); #

poj 1003:Hangover(水题,数学模拟)

Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 99450   Accepted: 48213 Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're as

Poj 1094 拓扑排序 水题

Sad..这么水的题WA了无数发,题目要看仔细啊,留下来做个警告把 #include <cstdio> #include <cstring> #include <algorithm> #include <climits> #include <string> #include <iostream> #include <map> #include <cstdlib> #include <list> #i

poj 2497 Strategies 模拟水题

水题,直接贴代码. //poj 2497 //sep9 #include <iostream> #include <algorithm> using namespace std; int a[32]; int main() { int cases,c=0; scanf("%d",&cases); while(cases--){ int tot,n; scanf("%d%d",&tot,&n); int x2,y2,t;

LightOJ 1166 Old Sorting 置换群 或 贪心 水题

LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : 2017-07-20 14:45:30 * @FileName: LightOJ 1166 贪心 或 置换群 水题.cpp * @Platform: Windows * @Author : Lweleth ([email protected]) * @Link : https://github.co

HDU1050(贪心水题)

Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan t