This a constructive problem on codeforces with a diffcuilty score of 1400.
https://codeforces.com/problemset/problem/1463/B
It's evident that we can always find the correct value of array B by using the function lower_bound for each element in array A.
void solve(){
int n;
cin >> n;
vector<int> a(n);
for (auto& x : a){
cin >> x;
}
long long sum = 0;
for (int i = 0; i < n; ++i){
auto it = upper_bound(pow2_values.begin(), pow2_values.end(), a[i]);
if (it != pow2_values.begin()){
-- it;
}
int x = *it;
cout << x << " \n"[i == n - 1];
sum += (a[i] - x);
}
}
标签:int,array,bound,codeforces,pow2,values,Array,Find
From: https://www.cnblogs.com/yxcblogs/p/18055017