Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, d, mi = 0, ma = 0;
- cin >> n >> d;
- vector<vector<int>> a(n,2);
- vector <int> b(n);
- for (int i = 0; i < n; i++)
- {
- cin >> a[i][0] >> a[i][1];
- mi = mi + a[i][0];
- ma = ma + a[i][1];
- }
- if ((mi <= d) && (ma >= d))
- {
- cout << "YES" << endl;
- for (int i = 0; i < n; i++)
- {
- b[i] = a[i][1];
- d = d - a[i][1];
- }
- int j = 0;
- while(d != 0)
- {
- b[j] = max(a[j][0], a[j][1] + d);
- d = d + a[j][1] - b[j];
- j++;
- }
- for (int i = 0; i < n; i++)
- cout << b[i] << " ";
- }
- else
- cout << "NO";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement