(wip) P7911 莫名其妙不一样 https://www.luogu.com.cn/problem/P7911

This commit is contained in:
2024-10-08 23:11:04 +08:00
parent 64a7875d1d
commit 318c907321
11 changed files with 2324 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
100
40 32 2 42 47 7 24 14 11 7 19 3 44 49 44 32 4 28 4 48 4 7 41 32 42 41 27 4 20 40 44 30 13 44 8 10 16 46 50 18 20 15 4 32 22 25 10 2 17 10 49 4 47 10 41 28 3 3 26 22 13 40 29 14 9 1 43 21 19 20 10 12 40 6 14 9 14 46 25 50 17 45 1 30 5 37 8 5 47 43 39 12 25 1 40 20 2 10 14 21

View File

@@ -0,0 +1,24 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int k;
cin >> k;
vector<int> arr;
for (int i = 0; i < k; i++) {
int t;
cin >> t;
arr.push_back(t);
}
auto ptr = unique(arr.begin(), arr.end());
arr.erase(ptr, arr.end());
if (arr.size() <= 2) {
cout << -1 << endl;
return 0;
}
sort(arr.begin(), arr.end());
arr.insert(arr.begin(), 1, 0);
auto kp = arr.size()-1;
cout << max(arr[kp - 2], arr[kp] % arr[kp - 1]) << endl;
}