0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-25 07:31:59 +00:00

#181. Alice&时间隧道

https://sjzezoj.com/submission/48560
This commit is contained in:
Baoshuo Ren 2022-02-10 01:31:54 +08:00
parent f5a875fab4
commit 1aee9acbc9
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

27
S2OJ/181/181.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <algorithm>
#include <iostream>
using std::cin;
using std::cout;
#define endl '\n'
const int N = 200005;
int n, a[N], ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
std::sort(a + 1, a + 1 + n);
n = std::unique(a + 1, a + 1 + n) - a - 1;
a[n + 1] = std::numeric_limits<int>::max();
for (int i = 1; i <= n; i++) {
for (int j = 2; (j - 1) * a[i] <= a[n]; j++) {
ans = std::max(ans, *(std::lower_bound(a + 1, a + 1 + n + 1, j * a[i]) - 1) % a[i]);
}
}
cout << ans << endl;
return 0;
}