fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3.  
  4. using namespace std;
  5. int dp[2000][2000];
  6. int count(int cur,int h,int a)
  7. {
  8. if(h<=0||a<=0)
  9. return 0;
  10. if(dp[h][a]!=-1)
  11. return dp[h][a];
  12. if(cur)
  13. return(count(0,h+3,a+2)+1);
  14. dp[h][a]=max(count(1,h-5,a-10),count(1,h-20,a+5))+1;
  15. return dp[h][a];
  16. }
  17. int main() {
  18.  
  19. ios_base::sync_with_stdio(false);
  20. cin.tie(NULL);
  21. cout.tie(NULL);
  22. int t,h,a;
  23. memset(dp,-1,sizeof(dp));
  24. cin>>t;
  25. while(t--)
  26. {
  27. cin>>h>>a;
  28. cout<<count(0,h+3,a+2)<<"\n";
  29. }
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 19156KB
stdin
Standard input is empty
stdout
Standard output is empty