https://vjudge.net/problem/POJ-2393
Because the storage fee is the same. It should be regarded as the idea of superposition.
For each week, either use the current week's production or follow the previous week's used price (not necessarily entered) plus a fixed storage fee.
1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<cstring> 5 #include<algorithm> 6 #include<cmath> 7 #include<set> 8 #define INF 0x3f3f3f3f 9 typedef long long ll; 10 using namespace std; 11 int main() 12 { 13 ll ans=0; 14 int n, s, a, b, mini = INF; 15 cin >> n >> s; 16 for(int i = 0; i < n; i++){ 17 cin >> a >> b; 18 mini = min(mini+s, a); 19 ans += mini*b; 20 } 21 cout << ans << endl; 22 return 0; 23 }