제출 #306137

#제출 시각아이디문제언어결과실행 시간메모리
306137quocnguyen1012구경하기 (JOI13_watching)C++14
0 / 100
104 ms16120 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; const int maxn = 2005; int f[maxn][maxn]; int a[maxn], N; int P, Q; bool check(int len) { const int inf = 1e9; fill_n(&f[0][0], maxn * maxn, inf); f[0][0] = 0; int l = 1, r = 1; for (int i = 1; i <= N; ++i){ while (l <= N && a[l] <= a[i] - len) ++l; while (r <= N && a[r] <= a[i] - 2 * len) ++r; for (int j = 0; j <= P; ++j){ if (j > 0) f[i][j] = min(f[i][j], f[l - 1][j - 1]); f[i][j] = min(f[i][j], f[r - 1][j] + 1); } } return f[N][P] <= Q; } signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> P >> Q; for (int i = 1; i <= N; ++i){ cin >> a[i]; } sort(a + 1, a + 1 + N); if (P + Q >= N) { cout << 1; return 0; } int l = 1, r = 1e9, mid; while (l <= r){ mid = (l + r) / 2; if (!check(mid)) l = mid + 1; else r = mid - 1; } cout << l; }

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

watching.cpp: In function 'int main()':
watching.cpp:38:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   38 |     freopen("A.INP", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
watching.cpp:39:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   39 |     freopen("A.OUT", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...