# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25401 | 2017-06-22T04:34:08 Z | youngyojun | Watching (JOI13_watching) | C++11 | 263 ms | 17744 KB |
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #include <vector> #include <stack> #include <deque> #include <queue> #include <set> #include <map> #include <unordered_map> #include <bitset> #include <string> #define pb push_back #define sz(V) ((int)(V).size()) #define allv(V) ((V).begin()),((V).end()) #define befv(V) ((V)[(sz(V)-2)]) #define sorv(V) sort(allv(V)) #define revv(V) reverse(allv(V)) #define univ(V) (V).erase(unique(allv(V)),(V).end()) #define upmin(a,b) (a)=min((a),(b)) #define upmax(a,b) (a)=max((a),(b)) #define rb(x) ((x)&(-(x))) #define INF (1100000099) #define INFLL (1100000000000000099ll) #define MAXN (2005) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, ll> pil; typedef pair<ll, int> pli; int d[MAXN][MAXN]; int BL[MAXN], SL[MAXN]; int A[MAXN]; int N, P, Q; bool f(const int W) { for(int i = N, j = N; i; i--) { for(; j && A[i]-W < A[j]; j--); SL[i] = j; } for(int i = N, j = N; i; i--) { for(; j && A[i]-2*W < A[j]; j--); BL[i] = j; } for(int i = 1; i <= N; i++) for(int j = 0; j <= Q; j++) { int &ret = d[i][j]; ret = d[SL[i]][j] + 1; if(j) upmin(ret, d[BL[i]][j-1]); } for(int i = 0; i <= Q; i++) if(d[N][i] <= P) return true; return false; } int getAns() { if(N <= P || N <= Q) return 1; int s = 1, e = INF; for(int mid; s < e;) { mid = (s+e)/2; if(f(mid)) e = mid; else s = mid+1; } return s; } int main() { scanf("%d%d%d", &N, &P, &Q); for(int i = 1; i <= N; i++) scanf("%d", &A[i]); sort(A+1, A+N+1); printf("%d\n", getAns()); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 17744 KB | Output is correct |
2 | Correct | 0 ms | 17744 KB | Output is correct |
3 | Correct | 0 ms | 17744 KB | Output is correct |
4 | Correct | 0 ms | 17744 KB | Output is correct |
5 | Correct | 0 ms | 17744 KB | Output is correct |
6 | Correct | 0 ms | 17744 KB | Output is correct |
7 | Correct | 0 ms | 17744 KB | Output is correct |
8 | Correct | 0 ms | 17744 KB | Output is correct |
9 | Correct | 0 ms | 17744 KB | Output is correct |
10 | Correct | 0 ms | 17744 KB | Output is correct |
11 | Correct | 0 ms | 17744 KB | Output is correct |
12 | Correct | 0 ms | 17744 KB | Output is correct |
13 | Correct | 0 ms | 17744 KB | Output is correct |
14 | Correct | 0 ms | 17744 KB | Output is correct |
15 | Correct | 0 ms | 17744 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 17744 KB | Output is correct |
2 | Correct | 0 ms | 17744 KB | Output is correct |
3 | Correct | 239 ms | 17744 KB | Output is correct |
4 | Correct | 0 ms | 17744 KB | Output is correct |
5 | Correct | 0 ms | 17744 KB | Output is correct |
6 | Correct | 0 ms | 17744 KB | Output is correct |
7 | Correct | 6 ms | 17744 KB | Output is correct |
8 | Correct | 123 ms | 17744 KB | Output is correct |
9 | Correct | 16 ms | 17744 KB | Output is correct |
10 | Correct | 16 ms | 17744 KB | Output is correct |
11 | Correct | 263 ms | 17744 KB | Output is correct |
12 | Correct | 146 ms | 17744 KB | Output is correct |
13 | Correct | 9 ms | 17744 KB | Output is correct |
14 | Correct | 6 ms | 17744 KB | Output is correct |
15 | Correct | 6 ms | 17744 KB | Output is correct |