CF 215D 贪心 交罚金的问题
2012-08-30 16:49
106 查看
比较加车还是交罚金比较好。又是一道我觉得不会超,他超了的题。以后学乖了,可能会超的全都写int64
http://codeforces.com/problemset/problem/215/D
学到了怎么向上取整 (a + (b - 1))/ b。
http://codeforces.com/problemset/problem/215/D
学到了怎么向上取整 (a + (b - 1))/ b。
#include <cstdio> __int64 cost,x,t,T; int n,m; __int64 ans; int main(){ scanf("%d%d",&n,&m); ans = 0; for(int i = 1; i <= n; i ++){ scanf("%I64d%I64d%I64d%I64d",&t,&T,&x,&cost); if(t >= T) ans = ans + cost + x * m; else {//compare the cost of add cars or not __int64 tmp =( (m + T - t - 1) / (T - t) )* cost;//向上取整 ans += (tmp > (x * m + cost)? (__int64)(x * m + cost): tmp); } } printf("%I64d\n",ans); return 0; }
相关文章推荐
- CF 593D LCA,贪心
- NOIP 2010 T4 浅谈如何“引水入城”,泛洪填充法BFS架构FLOODFILL及一类区间覆盖问题贪心求法
- cf 830A Office Keys 【二分+贪心】
- 贪心法解登山机器人问题
- 删数问题(贪心问题)
- 【贪心+优先队列】1428 活动安排问题【51nod】【难度:2级算法题】
- (CF 792E Colored Balls) 思维题 贪心
- CF724D. Dense Subsequence[贪心 字典序!]
- 算法分析与设计-15-背包问题的贪心算法
- 简单贪心 区间调度问题
- 【贪心】闭区间问题
- 贪心问题
- hdu 1677 Nested Dolls【贪心解嵌套娃娃问题】
- usaco Barn Repair (牛宿舍问题||贪心)
- CF 489C Given Length and Sum of Digits... 贪心
- 装箱问题,贪心(POJ1017)
- 贪心(盈利问题)
- 贪心算法(二)——一般背包问题
- 贪心算法_活动安排问题_哈弗曼编码
- CF - 779B. Weird Rounding 贪心