# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
492464 | ponytail | Watching (JOI13_watching) | C++17 | 342 ms | 31692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9 + 7;
void solve(int tc) {
int N, P, Q;
cin >> N >> P >> Q;
P = min(P, N);
Q = min(Q, N);
int A[N+1];
for(int i=1; i<=N; i++) cin >> A[i];
sort(A+1, A+N+1);
int lb = 1, rb = 1e9;
while(lb < rb) {
int w = (lb+rb) >> 1;
int dp[P+1][Q+1]; // max index we can reach by P small and Q big
dp[0][0] = 0;
int sing[N+1], doub[N+1];
for(int i=1; i<=N; i++) {
for(int j=i; j<=N; j++) {
if(A[j] - A[i] + 1 <= w) sing[i] = j;
if(A[j] - A[i] + 1 <= 2*w) doub[i] = j;
}
}
int idx = 0;
for(int i=1; i<=P; i++) {
dp[i][0] = (idx == N ? N : sing[idx + 1]);
idx = dp[i][0];
}
idx = 0;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |