Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================
- // Name : ACM
- // Author : Tarango Khan
- // Team : BRACU Byteheads
- //============================================================================
- #include <bits/stdc++.h>
- using namespace std;
- int inf = 999999999;
- int DP[51][1001];
- int N,K;
- int call(int ball,int floor){
- if(floor <= 1) return floor;
- if(ball == 1) return floor;
- if(DP[ball][floor] != -1) return DP[ball][floor];
- int res = inf;
- for(int f = 1;f<=floor;f++){
- int ret1 = call(ball-1,f-1);
- int ret2 = call(ball,floor-f);
- res = min(res,max(ret1,ret2));
- }
- return DP[ball][floor] = res + 1;
- }
- int main() {
- int nCase,tst;
- string s;
- cin >> nCase;
- memset(DP,-1,sizeof(DP));
- for(int cs = 1;cs<=nCase;cs++){
- cin >> tst >> N >> K;
- int res = call(N,K);
- printf("%d %d\n",cs,res);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment