Advertisement
Zeinab_Hamdy

Untitled

Aug 1st, 2023
1,157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.83 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define nl "\n"
  4. #define fi first
  5. #define se second
  6. #define pb push_back
  7. #define ll long long
  8. #define ull unsigned ll
  9. #define RV  return void
  10. #define inf 2000000000
  11. #define sz(x) int(x.size())
  12. #define all(v) v.begin(), v.end()
  13. #define rall(v) v.rbegin(), v.rend()
  14. #define Mini(x) *min_element(all(x))
  15. #define Maxi(x) *max_element(all(x))
  16. #define fixed(n) fixed << setprecision(n)
  17. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  18. #define cin(v) for (auto&i:v) cin >> i;
  19. #define cout(v) for (auto&i:v) cout << i << " ";
  20. #define clr(memo, x) memset(memo, x, sizeof memo)
  21. #define updmin(a, b) a = min(a, b)
  22. #define updmax(a, b) a = max(a, b)
  23. #define vi vector < int >
  24. #define vl vector < ll >
  25. #define vc vector < char >
  26. #define vs vector < string >
  27. #define v2i vector < vector < int > >
  28. #define v2l vector < vector < int > >
  29. #define seti set < int >
  30. #define setl set < ll >
  31. #define mapii map < int , int >
  32. #define mapll map < ll , ll >
  33. #define mapli map < ll , int >
  34. #define mapci map < char , int >
  35. #define mapsi map < string , int >
  36. #define pll pair < ll , ll >
  37. #define pii pair < int , int >
  38. #define range(l,r,x) for(int i=l ; i < r ; i+=x)
  39. #define FastCode ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  40. vector < string > ternary= {"NO\n" , "YES\n"};
  41.  
  42. void  Zainab(){
  43.             #ifndef ONLINE_JUDGE
  44.               freopen("input.txt", "r", stdin);
  45.               freopen("output.txt", "w", stdout);
  46.             #endif
  47. }
  48.  
  49.  
  50. /*================================  Prblem solution  ================================ */
  51.  
  52. vector < int > freq(21) ;
  53. const int N = 1005;
  54. vector < vector < int > > dp( N, vector <int> ( 21 ,-1));
  55.  
  56.  
  57.  
  58. int rec(int curr , int last ){
  59.    
  60.     if(curr <= 0 or last >= 21) return !curr ;
  61.     int& ret = dp[curr][last];
  62.     if(~ret) return ret ;
  63.     ret =0;
  64.     if( curr-last >=0 and freq[last] > 0){
  65.         ret+= rec(curr-last , last);
  66.         freq[last]--;
  67.     }
  68.  
  69.     ret+= rec(curr , last+1);
  70.     return ret ;
  71. }
  72.  
  73.  
  74. void myCode(){
  75.  
  76.  
  77. vector < pair < int , int > > v(5) ;
  78. vector < int > val={  4 ,  6 , 8 ,  12 , 20 } , tempFreq(21);
  79.  
  80. for(int i =0 ; i < 5 ; i++){
  81.     cin >> v[i].fi ;
  82.     v[i].se=val[i];
  83. }
  84.  
  85.  
  86. for(int i =0 ; i < 5 ; i++){
  87.     for(int j=1 ; j <= v[i].se ; j++) freq[j]+=v[i].fi ;
  88. }
  89.  
  90. tempFreq=freq;
  91.  
  92.  
  93. vector < pair < int , int > > ans( N );
  94. for(int i =1 ; i < N; i++){
  95.    ans[i].se=rec(i , 0);
  96.    ans[i].fi=i;
  97.   freq= tempFreq;
  98.  
  99. }
  100.  
  101. //for(int i =0 ; i < N ; i++){
  102. //    cout << i << " " << ans[i].se << nl;
  103. //}
  104.  
  105.  // sort
  106.  // print
  107.  
  108.  
  109.  
  110. }
  111.  
  112.  
  113.  
  114.  
  115. int main(){
  116.                                    FastCode ;
  117.                               //      Zainab() ;
  118.  
  119.     int testCase=1;
  120.         // cin >> testCase ;
  121.       for(int i=1 ; i<= testCase ; i++)
  122.         myCode();
  123.  
  124.     return 0;
  125. }
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement