Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
- template <typename... Args> void logger(string vars, Args &&... values)
- {
- cerr << vars << " = ";
- string delim = "";
- (..., (cerr << delim << values, delim = ", "));
- cerr << endl;
- }
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- int n, x;
- int a[200003], b[200003];
- int main(int argc, char **argv)
- {
- cin >> n >> x;
- for (int i = 1; i <= n; ++i)
- cin >> a[i] >> b[i];
- ll ans = LLONG_MAX;
- ll acc = 0;
- for (int i = 1; i <= n; ++i) {
- acc += ll(a[i]) + b[i];
- ans = min(ans, acc + ll(x - i) * b[i]);
- }
- cout << ans << endl;
- return 0;
- };
- // WA
- // AC
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
- template <typename... Args> void logger(string vars, Args &&... values)
- {
- cerr << vars << " = ";
- string delim = "";
- (..., (cerr << delim << values, delim = ", "));
- cerr << endl;
- }
- template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
- using ll = long long;
- using pii = pair<int, int>;
- int n, x;
- int a[200003], b[200003];
- int main(int argc, char **argv)
- {
- cin >> n >> x;
- for (int i = 1; i <= n; ++i)
- cin >> a[i] >> b[i];
- ll ans = LLONG_MAX;
- ll minb = b[1];
- ll acc = 0;
- for (int i = 1; i <= n; ++i) {
- acc += ll(a[i]) + b[i];
- minb = min(minb, ll(b[i]));
- ans = min(ans, acc + ll(x - i) * minb);
- }
- cout << ans << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement