提交时间:2024-01-21 15:02:21
运行 ID: 121056
#include<bits/stdc++.h> using namespace std; int x[5005]; int b[5005]; int n,l; int main(){ int max,min=0,max2=0; cin>>n>>l; max=l+1; for(int i=0;i<n;i++){ cin>>x[i]; int temp; if(x[i]<max){ max=x[i]; } if(x[i]>max2){ max2=x[i]; } if(l+1-x[i]>l+1-(l+1-x[i])){ temp=l+1-(l+1-x[i]); } else{ temp=l+1-x[i]; } if(min<temp){ min=temp; } } cout<<min<<" "; if((l+1-max)>max2){ cout<<l+1-max; } else{ cout<<max2; } }