제출 #214765

#제출 시각아이디문제언어결과실행 시간메모리
214765SamAndSwimming competition (LMIO18_plaukimo_varzybos)C++17
100 / 100
547 ms15960 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000006; int n, a, b; int u[N]; int p[N]; bool dp[N]; bool stg(int x) { dp[0] = true; p[0] = 1; int j = 1; for (int i = 1; i <= n; ++i) { p[i] = p[i - 1]; dp[i] = false; while ((u[i] - u[j] > x)) ++j; if (i - a < 0) continue; if (j - 1 <= i - b) { if (i - b - 1 < 0) dp[i] = true; else if (p[i - a] - p[i - b - 1] > 0) dp[i] = true; } else { if (j - 1 <= i - a) { if (p[i - a] - p[j - 1 - 1] > 0) dp[i] = true; } } if (dp[i]) ++p[i]; } return dp[n]; } int main() { scanf("%d%d%d", &n, &a, &b); for (int i = 1; i <= n; ++i) scanf("%d", &u[i]); sort(u + 1, u + n + 1); int l = 0, r = N; int ans; while (l <= r) { int m = (l + r) / 2; if (stg(m)) { ans = m; r = m - 1; } else l = m + 1; } printf("%d\n", ans); return 0; }

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

plaukimo_varzybos.cpp: In function 'int main()':
plaukimo_varzybos.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &a, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plaukimo_varzybos.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &u[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...