标签:content rod nim storage ext 模拟 hat designed details
4 5 88 200 89 400 97 300 91 500
126900
模拟题,从最后倒着往前,如果相邻两个week的差大于S,说明在前一周多做然后store是赚的,否则就在这周再做。
1 #include <cstdio> 2 #include <iostream> 3 #include <cmath> 4 #include <cstdlib> 5 using namespace std; 6 int n,s; 7 int c[10005],y[10005]; 8 int main(){ 9 scanf("%d%d",&n,&s); 10 for (int i = 0;i < n;++i) 11 scanf("%d%d",c+i,y+i); 12 long long ans = 0; 13 for (int i = n-1;i > 0;--i){ 14 if (c[i] - c[i-1] > s){//store 15 ans += s*y[i]; 16 y[i-1] += y[i]; 17 }else ans += c[i]*y[i]; 18 } 19 ans += c[0]*y[0]; 20 printf("%lld\n",ans); 21 return 0; 22 }
标签:content rod nim storage ext 模拟 hat designed details
原文地址:https://www.cnblogs.com/mizersy/p/12233210.html