結果
| 問題 | No.3513 Greedy Yokan Party |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-25 19:12:35 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 2,000 ms |
| コード長 | 2,370 bytes |
| 記録 | |
| コンパイル時間 | 4,338 ms |
| コンパイル使用メモリ | 274,184 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-04-25 19:12:47 |
| 合計ジャッジ時間 | 6,969 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
// using mint = modint1000000007;
template <typename T> using vec = vector<T>;
template <typename T> using pa = pair<T, T>;
template <typename T> using mipq = priority_queue<T, vec<T>, greater<T>>;
#define REP(_1, _2, _3, _4, name, ...) name
#define REP1(i, n) for (auto i = decay_t<decltype(n)>{}; (i) < (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) < (r); ++(i))
#define REP3(i, l, r, d) for (auto i = (l); (i) < (r); i += (d))
#define rep(...) REP(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__)
#define rrep(i, r, l) for (int i = (r); i >= (l); --i)
template <typename T> bool chmax(T &a, const T &b) { return (a < b ? a = b, true : false); }
template <typename T> bool chmin(T &a, const T &b) { return (a > b ? a = b, true : false); }
constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int mov[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
void solve();
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int T = 1;
// cin >> T;
while (T--) solve();
}
// h >= x が達成可能?というのは
// k+1 個に分解して、サイズx以上のピースを2つ作れる?ということ
// iから続けてx以上にするための最小幅、はまあしゃくとりでぜんぶわかる
// 1つ目の切断位置を決め打ちすればまあできるのか...
// 実装でバグらせそー
void solve() {
int N, L, K;
cin >> N >> L >> K;
vec<int> A(N + 2);
rep(i, N) cin >> A[i + 1];
A[N + 1] = L;
int l = 1, r = L;
while (r - l > 1) {
int m = (l + r) / 2;
vec<int> nxt(N + 1, INF), width(N + 1, INF);
int j = 0;
rep(i, N + 1) {
while (j < N + 2 && A[j] - A[i] < m) j++;
if (j < N + 2) nxt[i] = j, width[i] = j - i;
}
vec<int> cum(N + 2, INF);
rrep(i, N, 0) cum[i] = min(cum[i + 1], width[i]);
bool ok = false;
rep(i, N + 1) {
if (nxt[i] < N + 2 && N + 1 + 2 - width[i] - cum[nxt[i]] >= K + 1) {
l = m;
ok = true;
break;
}
}
if (!ok) {
r = m;
}
}
cout << l << '\n';
}