제출 #56532

#제출 시각아이디문제언어결과실행 시간메모리
56532luciocf구경하기 (JOI13_watching)C++14
50 / 100
1044 ms32852 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010; typedef long long ll; ll n, p, q; ll num[MAXN]; ll dp[MAXN][MAXN]; ll busca2(ll k) { if (k > num[n]) return n; ll ini = 1LL, fim = n, ans; while (ini <= fim) { int mid = (ini+fim)>>1; if (num[mid] <= k) ans = mid, ini = mid+1; else fim = mid-1; } return ans; } bool ok(ll w) { memset(dp, 0LL, sizeof dp); for (int i = 1; i <= p; i++) for (int j = 1; j <= q; j++) dp[i][j] = 1LL; for (int i = 0; i <= p; i++) { for (int j = 0; j <= q; j++) { if (i) dp[i][j] = max(dp[i][j], busca2(num[min(n, dp[i-1][j]+1)]+w-1LL)); if (j) dp[i][j] = max(dp[i][j], busca2(num[min(n, dp[i][j-1]+1)]+2LL*w-1LL)); } } return (dp[p][q] >= n); } ll busca(void) { ll ini = 1, fim = 1e9+10, ans; while (ini <= fim) { ll mid = (ini+fim)>>1; if (ok(mid)) ans = mid, fim = mid-1; else ini = mid+1; } return ans; } int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> p >> q; for (int i = 1; i <= n; i++) cin >> num[i]; if (p+q >= n) { cout << "1\n"; return 0; } sort(num+1, num+n+1); cout << busca() << "\n"; }

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

watching.cpp: In function 'll busca2(ll)':
watching.cpp:17:28: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
     ll ini = 1LL, fim = n, ans;
                            ^~~
watching.cpp: In function 'bool ok(ll)':
watching.cpp:17:28: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
watching.cpp:17:28: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
watching.cpp: In function 'll busca()':
watching.cpp:59:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return ans;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...