# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
462099 | nickyrio | Watching (JOI13_watching) | C++17 | 347 ms | 16196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
int n, p, q;
long long a[N];
int dp[N][N];
void Min(int &a, int b) { a = (a > b ? b : a); }
bool Check(long long w) {
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= p; ++j) dp[i][j] = 1e9;
}
dp[0][0] = 0;
for (int i = 0; i < n; ++i) {
int nxt_p = lower_bound(a, a + n, a[i] + w) - a;
int nxt_q = lower_bound(a, a + n, a[i] + w + w) - a;
for (int np = 0; np <= p; ++np) {
Min(dp[nxt_p][np + 1], dp[i][np]);
Min(dp[nxt_q][np], dp[i][np] + 1);
}
}
for (int i = 0; i <= p; ++i) if (dp[n][i] <= q) return true;
// return dp[n][p] <= q;
return false;
}
int main() {
ios::sync_with_stdio(false); cin.tie(NULL);
cin >> n >> p >> q;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |