RT,如下程序竟然能A……(注意第13行)说好的 1≤ai≤109 呢QAQ
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 5;
int smx[maxn], ans[maxn], a[maxn], b[maxn];
int main()
{
int n, x, num = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> x;
if (!smx[x])
{
num++;
smx[x] = 1;
a[num] = x;
}
}
sort(a + 1, a + num + 1);
if (num <= 1)
cout << -1 << endl;
else
cout << max(a[num - 2], a[num] % a[num - 1]) << endl;
return 0;
}
@NaCly_Fish @chen_zhe