Advertisement
Guest User

Untitled

a guest
Mar 20th, 2015
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define FOR(i,a,b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
  4. #define REP(i,a,b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
  5. #define ALL(v) v.begin(),v.end()
  6. #define what_is(x) cout<<#x<<" is "<<x<<endl;
  7. #define min3(a,b,c) min(min(a,b),c)
  8. #define max3(a,b,c) max(max(a,b),c)
  9. #define SIZE 1910
  10. #define MAXN 10000000007
  11. #define PI 3.141592653589793
  12. #define open_read1 freopen("C:\\Users\\Hepic\\Desktop\\a.txt","r",stdin)
  13. #define open_read freopen("rblock.in","r",stdin)
  14. #define open_write freopen("rblock.out","w",stdout)
  15.  
  16. using namespace std;
  17.  
  18.  
  19. typedef long long LL;
  20. typedef pair<int,int> PII;
  21.  
  22.  
  23. LL B,F,I;
  24. LL people_per_build,Tfloor,max_val,max_people;
  25. LL num_of_people[SIZE][SIZE],dp_max[SIZE][SIZE];
  26.  
  27.  
  28. int main()
  29. {
  30.     //open_read1;
  31.     scanf("%lld%lld%lld",&B,&F,&I);
  32.  
  33.  
  34.     FOR(b,1,B)
  35.     {
  36.         scanf("%lld",&people_per_build);
  37.  
  38.         FOR(t,1,people_per_build)
  39.         {
  40.             scanf("%lld",&Tfloor);
  41.             ++num_of_people[Tfloor][b];
  42.         }
  43.     }
  44.  
  45.  
  46.  
  47.     FOR(f,F,1)
  48.     {
  49.         max_val=0;
  50.         if(f+I<=F)
  51.             FOR(i,1,B)
  52.                 max_val = max(max_val, dp_max[f+I][i]);
  53.  
  54.  
  55.         FOR(b,1,B)
  56.         {
  57.             if(f+1<=F)
  58.                 dp_max[f][b] = num_of_people[f][b] + max(max_val, dp_max[f+1][b]);
  59.  
  60.             else
  61.                  dp_max[f][b] = num_of_people[f][b] + max_val;
  62.         }
  63.     }
  64.  
  65.  
  66.  
  67.     FOR(b,1,B)
  68.         max_people = max(max_people, dp_max[1][b]);
  69.  
  70.     printf("%lld\n",max_people);
  71.  
  72.  
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement