Advertisement
pb_jiang

abc258D

Nov 4th, 2022
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include <assert.h>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  5. template <typename... Args> void logger(string vars, Args &&... values)
  6. {
  7.     cerr << vars << " = ";
  8.     string delim = "";
  9.     (..., (cerr << delim << values, delim = ", "));
  10.     cerr << endl;
  11. }
  12.  
  13. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  14. using ll = long long;
  15. using pii = pair<int, int>;
  16.  
  17. int n, x;
  18. int a[200003], b[200003];
  19.  
  20. int main(int argc, char **argv)
  21. {
  22.     cin >> n >> x;
  23.     for (int i = 1; i <= n; ++i)
  24.         cin >> a[i] >> b[i];
  25.     ll ans = LLONG_MAX;
  26.     ll acc = 0;
  27.     for (int i = 1; i <= n; ++i) {
  28.         acc += ll(a[i]) + b[i];
  29.         ans = min(ans, acc + ll(x - i) * b[i]);
  30.     }
  31.     cout << ans << endl;
  32.     return 0;
  33. };
  34. // WA
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. // AC
  43. #include <assert.h>
  44. #include <bits/stdc++.h>
  45. using namespace std;
  46. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  47. template <typename... Args> void logger(string vars, Args &&... values)
  48. {
  49.     cerr << vars << " = ";
  50.     string delim = "";
  51.     (..., (cerr << delim << values, delim = ", "));
  52.     cerr << endl;
  53. }
  54.  
  55. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  56. using ll = long long;
  57. using pii = pair<int, int>;
  58.  
  59. int n, x;
  60. int a[200003], b[200003];
  61.  
  62. int main(int argc, char **argv)
  63. {
  64.     cin >> n >> x;
  65.     for (int i = 1; i <= n; ++i)
  66.         cin >> a[i] >> b[i];
  67.     ll ans = LLONG_MAX;
  68.     ll minb = b[1];
  69.     ll acc = 0;
  70.     for (int i = 1; i <= n; ++i) {
  71.         acc += ll(a[i]) + b[i];
  72.         minb = min(minb, ll(b[i]));
  73.         ans = min(ans, acc + ll(x - i) * minb);
  74.     }
  75.     cout << ans << endl;
  76.     return 0;
  77. };
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement