0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 23:56:27 +00:00

P5682 [CSP-J2019 江西] 次大值

R44430393
This commit is contained in:
Baoshuo Ren 2020-12-30 18:39:46 +08:00 committed by Baoshuo Ren
parent e1bb425d87
commit b3c5de0cea
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

25
problem/P5682/P5682.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <bits/stdc++.h>
using namespace std;
int n, t, a[200005];
int main() {
set<int> s;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> t;
s.insert(t);
}
if (s.size() <= 1) {
cout << -1 << endl;
}
else {
t = 0;
for (int i : s) {
a[++t] = i;
}
cout << max(a[t - 2], a[t] % a[t - 1]) << endl;
}
return 0;
}