Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
109296 | taffy | 跳石头 | C++ | 通过 | 100 | 3 MS | 448 KB | 706 | 2023-11-08 13:24:12 |
#include<bits/stdc++.h> using namespace std; int i, L, n, m, w, pos, ans, mid, l, r, a[50000 + 10]; inline int read() { int s = 0, w = 1; char ch = getchar(); while (ch<'0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); } while (ch >= '0'&&ch <= '9') s = s * 10 + ch - '0', ch = getchar(); return s * w; } bool ok(int x) { for (w = pos = 0, i = 1; i <= n && w <= m; ++i) if (a[i] - pos < x)++w; else pos = a[i]; return w <= m; } int main() { L = read(), n = read(), m = read(); for (int i = 1; i <= n; ++i)a[i] = read(); a[++n] = L; for (l = 1, r = L; l <= r;)if (ok(mid = l + r >> 1))ans = mid, l = mid + 1; else r = mid - 1; cout << ans << endl; return 0; }