# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
147281 | karma | 구경하기 (JOI13_watching) | C++11 | 635 ms | 30328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimization ("O3")
#define ll long long
using namespace std;
const int N = 2007;
ll n, pos[N], p, q, f[N][N];
bool Check(ll w)
{
int k = 1, l;
f[0][0] = 0;
for(int j = 1; j <= n; ++j) {
while(pos[j] - pos[k] >= 2 * w) ++k;
f[0][j] = f[0][k - 1] + 1;
}
for(int i = 1; i <= p; ++i) {
k = l = 1; f[i][0] = 0;
for(int j = 1; j <= n; ++j) {
while(pos[j] - pos[k] >= 2 * w) ++k;
while(pos[j] - pos[l] >= w) ++l;
f[i][j] = min({f[i][k - 1] + 1, f[i - 1][j], f[i - 1][l - 1]});
}
}
return f[p][n] <= q;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen("test.inp", "r")) {
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
cin >> n >> p >> q;
for(int i = 1; i <= n; ++i) cin >> pos[i];
if(p + q >= n) return cout << 1, 0;
sort(pos + 1, pos + n + 1);
ll l = 1, h = (ll)1e9;
while(l <= h) {
ll mid = (l + h) >> 1;
if(Check(mid)) h = mid - 1;
else l = mid + 1;
}
cout << l;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |