Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int maxn = 1000000 + 100;
- int n;
- LL s, p, c, ans;
- LL sum[maxn];
- int main() {
- #ifdef ExRoc
- freopen("test.txt", "r", stdin);
- #endif // ExRoc
- ios::sync_with_stdio(false);
- cin >> n >> s;
- for (int i = 1; i <= n; ++i) {
- cin >> p >> c;
- sum[1] += p;
- sum[c + 1] -= p;
- }
- for (int i = 1; i < maxn; ++i) {
- sum[i] += sum[i - 1];
- ans += min(sum[i], s);
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement