- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int S = 103;
- const int MOD = 1000000007;
- int _I(){int x; scanf("%d", &x); return x;}
- LL _LL(){LL x; scanf("%lld", &x); return x;}
- int dirX[]={1, 0, -1, 0, 1, -1, 1, -1};
- int dirY[]={0, 1, 0, -1, 1, -1, -1, 1};
- int rX[] = {1, 1, 2, 2, -1, -1, -2, -2};
- int rY[] = {2, -2, 1, -1, 2, -2, 1, -1};
- int sset(int N, int pos){return N=N|(1<<pos);}
- bool check(int N, int pos){return (bool)(N&(1<<pos));}
- int reset(int N, int pos){return N=N&~(1<<pos);}
- ///...............Code Starts From Here...............///
- int yc[S];
- int dp[S][S];
- int w, n, k;
- int brush3(int ind, int movee){
- if(movee > k)return 0;
- if(ind == n)return 0;
- if(dp[ind][movee] != -1)return dp[ind][movee];
- dp[ind][movee] = 1;
- int i;
- for(i = ind+1; (i < n && abs(yc[ind]-yc[i]) <= w); i++){
- dp[ind][movee] += 1;
- }
- dp[ind][movee] += brush3(i, movee+1);
- dp[ind][movee] = max(dp[ind][movee], brush3(ind+1, movee));
- return dp[ind][movee];
- }
- void Do(){
- int t = _I(), cs = 0;
- while(t--){
- memset(dp, -1, sizeof(dp));
- n = _I();
- w = _I();
- k = _I();
- for(int i = 0; i < n; i++){
- int z = _I();
- yc[i] = _I();
- }
- sort(yc, yc+n);
- int ans = brush3(0, 1);
- printf("Case %d: %d\n", ++cs, ans);
- }
- }
- int main(){
- Do();
- return 0;
- }
Monday, July 18, 2016
LightOJ - 1017 - Brush (III)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment