제출 #264750

#제출 시각아이디문제언어결과실행 시간메모리
264750AtalasionWatching (JOI13_watching)C++14
50 / 100
1028 ms32248 KiB
//khodaya khodet komak kon #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define all(x) x.begin(), x.end() #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define int long long using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; const int N = 2000 + 10; const ll MOD = 1000000000 + 7; const ll INF = 1000000000000000010; const ll LOG = 25; int dp[N][N], n, p, q, a[N]; bool isval(int w){ //cout << w << ' '; memset(dp, 0, sizeof dp); for (int i = 0; i <= p; i++) for (int j = 0; j <= q; j++){ int x = dp[i][j]; //cout << i << ' ' << j << ' ' << dp[i][j] << '\n'; x++; if (dp[i][j] >= n - 1) return 1; int koj = upper_bound(a + 1, a + n + 1, a[x] + (w - 1)) - a; dp[i + 1][j] = max(dp[i + 1][j], koj - 1); koj = upper_bound(a + 1, a + n + 1, a[x] + 2 * w - 1) - a; dp[i][j + 1] = max(dp[i][j + 1], koj - 1); } // cout << dp[p][q] << '\n'; return (dp[p][q] >= n - 1); } int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> p >> q; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); n++; a[n] = INF; int l = 0, r = 1000000000; while (r - l > 1){ int md = (l + r) >> 1; if (isval(md)) r = md; else l = md; } cout << r; // isval(32); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...