您的位置:首页 > 其它

CF 215D 贪心 交罚金的问题

2012-08-30 16:49 106 查看
比较加车还是交罚金比较好。又是一道我觉得不会超,他超了的题。以后学乖了,可能会超的全都写int64

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: