Submission #22976

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
229762017-04-30 19:12:53BruteforcemanWatching (JOI13_watching)C++11
100 / 100
296 ms21332 KiB
#include <bits/stdc++.h>
using namespace std;
int N, P, Q;
int a[2222];
int big[2222];
int tiny[2222];
int search(int b, int e, int val) {
if(b == e) {
return b;
}
int m = (b + e) >> 1;
if(val < a[m]) return search(b, m, val);
else return search(m + 1, e, val);
}
const int inf = 1e8;
int dp[2222][2222];
bool good(int w) {
for(int i = 1; i <= N; i++) {
tiny[i] = search(1, N, a[i] - w) - 1;
big[i] = search(1, N, a[i] - w - w) - 1;
}
for(int i = 1; i <= N; i++) {
for(int j = 0; j <= P; j++) {
dp[i][j] = inf;
if(j) dp[i][j] = min(dp[i][j], dp[tiny[i]][j - 1]);
dp[i][j] = min(dp[i][j], dp[big[i]][j] + 1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:46:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &N, &P, &Q);
                                  ^
watching.cpp:48:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...