提交记录: https://www.luogu.com.cn/record/152479095 代码:
#include<bits/stdc++.h> using namespace std; int main() { int a,s,d,f,g,h=INT_MIN,j,k,l; cin>>a>>s; for(int i=1;i<=a;i++) { cin>>d; f=d%s; g=min(f,s-f); h=max(h,g); } cout<<h; return 0; }