complete jungol//2194.cpp and fix it
This commit is contained in:
43
storage/jungol/cpp/completed/2194.cpp
Normal file
43
storage/jungol/cpp/completed/2194.cpp
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user