Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define FOR(i,a,b) for(auto i=a; i!=b+1-2*(a>b); i+=1-2*(a>b))
- #define REP(i,a,b) for(auto i=a-(a>b); i!=b-(a>b); i+=1-2*(a>b))
- #define ALL(v) v.begin(),v.end()
- #define what_is(x) cout<<#x<<" is "<<x<<endl;
- #define min3(a,b,c) min(min(a,b),c)
- #define max3(a,b,c) max(max(a,b),c)
- #define SIZE 1910
- #define MAXN 10000000007
- #define PI 3.141592653589793
- #define open_read1 freopen("C:\\Users\\Hepic\\Desktop\\a.txt","r",stdin)
- #define open_read freopen("rblock.in","r",stdin)
- #define open_write freopen("rblock.out","w",stdout)
- using namespace std;
- typedef long long LL;
- typedef pair<int,int> PII;
- LL B,F,I;
- LL people_per_build,Tfloor,max_val,max_people;
- LL num_of_people[SIZE][SIZE],dp_max[SIZE][SIZE];
- int main()
- {
- //open_read1;
- scanf("%lld%lld%lld",&B,&F,&I);
- FOR(b,1,B)
- {
- scanf("%lld",&people_per_build);
- FOR(t,1,people_per_build)
- {
- scanf("%lld",&Tfloor);
- ++num_of_people[Tfloor][b];
- }
- }
- FOR(f,F,1)
- {
- max_val=0;
- if(f+I<=F)
- FOR(i,1,B)
- max_val = max(max_val, dp_max[f+I][i]);
- FOR(b,1,B)
- {
- if(f+1<=F)
- dp_max[f][b] = num_of_people[f][b] + max(max_val, dp_max[f+1][b]);
- else
- dp_max[f][b] = num_of_people[f][b] + max_val;
- }
- }
- FOR(b,1,B)
- max_people = max(max_people, dp_max[1][b]);
- printf("%lld\n",max_people);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement