- 建议
服了,就是不对,再爆我就要爆了(Z1036)
- 2025-3-24 15:24:18 @
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int num[100005]; int main() { //freopen("closest.in", "r", stdin); //freopen("closest.out", "w", stdout); int n, m, x; cin >> n; for (int i = 2; i < n; i++) { cin >> num[i]; } cin >> m; sort(num,num+n); while (m--) { cin >> x; int c= lower_bound(num,num+n,x)-num ; if(c>=n) cout<<num[n-1]<<endl; else { if(num[c]==x) cout<<num[c]<<endl; else (num[c]-x >= x-num[c-1]) ? cout<<num[c-1]<<endl : cout<<num[c]<<endl; }
}
return 0;
}
0 comments
No comments so far...