제출 #227708

#제출 시각아이디문제언어결과실행 시간메모리
227708PeppaPig구경하기 (JOI13_watching)C++14
100 / 100
260 ms16248 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e3+5; int n, p, q; int pos[N], dp[N][N]; bool f(int mid) { fill_n(dp[0], N * N, 1e9); int l1 = 1, l2 = 1; dp[0][0] = 0; for(int i = 1; i <= n; i++) { while(pos[i] - pos[l1] >= mid) ++l1; while(pos[i] - pos[l2] >= 2 * mid) ++l2; for(int j = 0; j <= n; j++) { dp[i][j] = dp[l2 - 1][j] + 1; if(j) dp[i][j] = min(dp[i][j], dp[l1 - 1][j - 1]); } } for(int i = 0; i <= p; i++) if(dp[n][i] <= q) return true; return false; } int main() { scanf("%d %d %d", &n, &p, &q); for(int i = 1; i <= n; i++) scanf("%d", pos + i); sort(pos + 1, pos + 1 + n); int l = 1, r = 1e9; while(l < r) { int mid = (l + r) >> 1; if(f(mid)) r = mid; else l = mid + 1; } printf("%d\n", r); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

watching.cpp: In function 'int main()':
watching.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &p, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
watching.cpp:31:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d", pos + i);
                                 ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...