请求加强数据!
查看原帖
请求加强数据!
109757
AgOH楼主2021/12/11 15:01

RT,如下程序竟然能A……(注意第13行)说好的 1ai1091 \leq a_i \leq {10}^9 呢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

2021/12/11 15:01
加载中...