比较加车还是交罚金比较好。又是一道我觉得不会超,他超了的题。以后学乖了,可能会超的全都写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;
}