1 solutions

  • 1
    @ 2025-9-13 15:14:37
    #include<bits/stdc++.h>
    using namespace std;
    int n,a[1000005],k,maxx=-1,minn=INT_MAX;
    int main() {
    	cin>>n>>k;
    	for(int i=1; i<=n; i++) {
    		cin>>a[i];
    		if(a[i] > maxx) maxx = a[i];
    		if(a[i] < minn) minn = a[i];
    	}
    	for(int i=1; i<=n; i++) {
    		if(a[i]>k) {
    			cout<<maxx<<' ';
    		} else if(a[i]<k) {
    			cout<<minn<<' ';
    		} else {
    			cout<<a[i]<<' ';
    		}
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    75
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    (None)
    # Submissions
    54
    Accepted
    19
    Uploaded By