AtCoder Beginner Contest 330

发布时间 2023-11-27 14:59:08作者: yufan1102

B - Minimize Abs 1

思维题

题意:给定一个范围,你选择一个数,使得image

思路:如果A[i]在l,r中间,那么直接打印就行,如果不是就打印就近的

using namespace std;
void solve(){
	int n,l,r;
	cin>>n>>l>>r;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x<l){
			cout<<l<<" ";
		}else if(x>r){
			cout<<r<<" ";
		}else{
			cout<<x<<" ";
		}
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++)solve();
	return 0;
}