제출 #981247

#제출 시각아이디문제언어결과실행 시간메모리
981247AmaarsaaWatching (JOI13_watching)C++14
0 / 100
150 ms262144 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long ; ll a[2004]; ll n; bool Can(ll x, ll s, ll small, ll large) { bool dp[2002][2002][2002] = {0}; int i, j,r; dp[n][small][large]= 1; for (i = n; i >= 1; i --) { for (j = 0; j <= small; j ++) { for ( r = 0; r <= large; r ++) { if ( r > 0 && dp[i][j][r]) { s = lower_bound(a + 1, a + n + 1, a[i] - (2 * x) + 1) - a; s --; if (s == 0) return true; dp[s][j][r - 1] = 1; } if ( j > 0 && dp[i][j][r]) { s = lower_bound(a + 1, a + n + 1, a[i] - x + 1) - a; s --; if (s == 0) return true; dp[s][j - 1][r] = 1; } } } } return 0; } int main() { // freopen("moocast.in", "r", stdin); // freopen("moocast.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(NULL); ll i, lo, hi, mid, small, large, j; cin >> n >> small >> large; if ( small + large >= n) { cout << 1 << endl; return 0; } for (i = 1; i <= n; i ++) { cin >> a[i]; } sort ( a + 1, a + n + 1); lo = 1; hi = 1e9; while ( lo < hi) { mid = (lo + hi)/2; if ( !Can(mid, n, small, large)) lo = mid + 1; else hi = mid; } cout << lo << endl; }

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

watching.cpp: In function 'int main()':
watching.cpp:38:35: warning: unused variable 'j' [-Wunused-variable]
   38 |  ll i, lo, hi, mid, small, large, j;
      |                                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...