Submission #146226

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
1462262019-08-22 22:36:16osaaateiasavtnlWatching (JOI13_watching)C++14
100 / 100
239 ms32092 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
const int N = 2007, INF = 1e9 + 7;
int n, p, q;
int a[N], dp[N][N], r1[N], r2[N];
bool check(int m) {
for (int i = 0; i < n; ++i) {
r1[i] = i;
while (r1[i] + 1 < n && a[r1[i] + 1] - a[i] + 1 <= m) ++r1[i];
r2[i] = i;
while (r2[i] + 1 < n && a[r2[i] + 1] - a[i] + 1 <= 2 * m) ++r2[i];
}
for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) dp[i][j] = 0;
for (int i = 0; i <= p; ++i) {
for (int j = 0; j <= q; ++j) {
if (dp[i][j] == n) return 1;
dp[i + 1][j] = max(dp[i + 1][j], r1[dp[i][j]] + 1);
dp[i][j + 1] = max(dp[i][j + 1], r2[dp[i][j]] + 1);
}
}
return 0;
}
signed main() {
#ifdef HOME
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...