complete jungol//2194.cpp and fix it

This commit is contained in:
2026-07-10 13:41:41 +09:00
parent 8c0d172f36
commit b737eca173
3 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
#include <algorithm>
#include <iostream>
#include <vector>
#define let auto
#define fn auto
#define usize size_t
using namespace std;
#define LIMIT (((usize) 1 << 63) - 1);
fn fastio() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
fn main() -> int {
fastio();
usize n, s;
cin >> n >> s;
let costs = vector<usize>(n);
let yopps = vector<usize>(n);
// it needs cost S for storing 1 litre of milk for a week.
let cummin = vector<usize>(n);
for (usize i = 0; i < n; i++) {
cin >> costs[i] >> yopps[i];
}
let curr_min = (usize) LIMIT;
for (usize i = 0; i < n; i++) {
curr_min = min(curr_min + s, costs[i]);
cummin[i] = curr_min;
}
let total = (usize) 0;
for (usize i = 0; i < n; i++) {
total += cummin[i] * yopps[i];
}
cout << total << endl;
}