답안 #537054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537054 2022-03-14T10:40:44 Z pavement 구경하기 (JOI13_watching) C++17
100 / 100
156 ms 31732 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using db = double;
using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using iii = tuple<int, int, int>;
using iiii = tuple<int, int, int, int>;
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

int N, P, Q, A[2005], dp[2005][2005];

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> P >> Q;
	P = min(N, P);
	Q = min(N, Q);
	for (int i = 1; i <= N; i++) cin >> A[i];
	sort(A + 1, A + 1 + N);
	int lo = 1, hi = A[N] - A[1] + 1, ans = -1;
	while (lo <= hi) {
		int mid = (lo + hi) >> 1;
		for (int i = 1, tmp = 0, tmp2 = 0; i <= N; i++) {
			while (A[tmp + 1] <= A[i] - mid) tmp++;
			while (A[tmp2 + 1] <= A[i] - 2 * mid) tmp2++;
			for (int j = 0; j <= P; j++)
				dp[i][j] = min(j ? dp[tmp][j - 1] : LLONG_MAX, dp[tmp2][j] + 1);
		}
		if (dp[N][P] <= Q) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	cout << ans << '\n';
}

Compilation message

watching.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 724 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 724 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 1 ms 724 KB Output is correct
14 Correct 1 ms 724 KB Output is correct
15 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 8360 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 126 ms 31724 KB Output is correct
4 Correct 147 ms 31700 KB Output is correct
5 Correct 11 ms 9560 KB Output is correct
6 Correct 149 ms 31732 KB Output is correct
7 Correct 7 ms 8532 KB Output is correct
8 Correct 18 ms 10344 KB Output is correct
9 Correct 90 ms 20160 KB Output is correct
10 Correct 156 ms 31720 KB Output is correct
11 Correct 13 ms 9784 KB Output is correct
12 Correct 101 ms 23700 KB Output is correct
13 Correct 8 ms 8592 KB Output is correct
14 Correct 9 ms 8696 KB Output is correct
15 Correct 7 ms 8660 KB Output is correct