# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102541 | 2019-03-25T19:35:41 Z | tincamatei | 구경하기 (JOI13_watching) | C++14 | 594 ms | 16120 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2000; int v[MAX_N]; int smallNext[1+MAX_N], bigNext[1+MAX_N]; int dp[1+MAX_N][1+MAX_N]; void getNexts(int n, int w, int *nextP) { int lastp = 0; for(int i = 0; i < n; ++i) { while(lastp < n - 1 && v[lastp + 1] < v[i] + w) ++lastp; nextP[i] = lastp; } nextP[n] = n - 1; } void runDp(int n, int w) { getNexts(n, w, smallNext); getNexts(n, 2 * w, bigNext); for(int i = 0; i <= n; ++i) for(int j = 0; j <= n; ++j) { dp[i][j] = 0; if(i > 0) dp[i][j] = max(dp[i][j], smallNext[dp[i - 1][j]] + 1); if(j > 0) dp[i][j] = max(dp[i][j], bigNext[dp[i][j - 1]] + 1); } } int main() { #ifdef HOME FILE *fin = fopen("input.in", "r"); FILE *fout = fopen("output.out", "w"); #else FILE *fin = stdin; FILE *fout = stdout; #endif int n, p, q, st, dr; fscanf(fin, "%d%d%d", &n, &p, &q); for(int i = 0; i < n; ++i) fscanf(fin, "%d", &v[i]); st = -1; dr = 1000000000; while(dr - st > 1) { int mid = (st + dr) / 2; runDp(n, mid); if(dp[min(p, n)][min(q, n)] == n) dr = mid; else st = mid; } fprintf(fout, "%d", dr); fclose(fin); fclose(fout); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 594 ms | 16120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |