1 solutions

  • 0
    @ 2024-7-20 12:44:08

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,l,i,x,ma=0;
    	//freopen("ant.in","r",stdin);
    	//freopen("ant.out","w",stdout);
    	cin>>n;
    	cin>>l;
    	for(i=1;i<=n;++i){
    		scanf("%d",&x);
    		x=min(x,l-x);
    		ma=max(ma,x);
    	}
    	cout<<ma;
    }
    
    
    • 1

    Information

    ID
    286
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    3
    Accepted
    1
    Uploaded By