问题 - 4B - 代码强制 (codeforces.com)
![](https://i-blog.csdnimg.cn/blog_migrate/8f3945116c153790357e914cd937ce6c.png)
已经知道还剩多少天,和父母要求的总的学习时间,要在剩余的这些天编一个每天的学习时间,
给出每天最少能学的时间和最多能学的时间,问我们要怎么编
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define x first
#define y second
#define fu(i,a,b) for(int i=a;i<=b;i ++ )
#define fd(i,a,b) for(int i=a;i>=b;i -- )
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N = 4e4+ 10,M = 1e5 + 10,INF = 0x3f3f3f3f ;
const int mod = 1e9;
const double eps = 1e-8;
int n,m,p[N];
inline void solve()
{
int n, sum,l=0,r=0;
cin >> n>> sum;
vector<int> a(n),b(n);
fu(i,0,n-1)
{
cin >> a[i] >> b[i];
l += a[i], r += b[i];
}
if(sum < l || sum > r ) cout << "NO\n";
else
{
cout <<"YES\n";
fu(i,0,n-1)
{
int d = min(sum-l,b[i] -a[i]);
a[i] +=d;l +=d;
}
fu(i,0,n-1)cout <<a[i] <<" \n"[i==n-1];
}
}
signed main()
{
// freopen("1.txt","w",stdout);
ios
int t=1;
// cin>>t;
int now = 1;
while(t -- )
{
// cout<<"Case ";
// cout<<"Scenario #";
// cout<< now ++ <<": ";
// cout<< now ++ <<": \n";
solve();
}
return 0;
}