Skip to content

Commit

Permalink
Create Watering an Array.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
animshamura committed Jan 6, 2024
1 parent 07ff483 commit a598e8b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Watering an Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include<bits/stdc++.h>
using namespace std;
const int sz = 2e5+10;
int t,n,k,d;

int main(){
int a[sz],v[sz];
cin>>t;
while(t--){
int ans,i,j,c,l;
cin>>n>>k>>d;
for(i=1; i<=n; i++) cin>>a[i];
for(i=0; i<k; i++) cin>>v[i];
ans=0;
for(i=0;i<min(2*n+1,d);i++){
j=i%k;
c=0;
for(l=1; l<=n; l++) if(a[l]==l) c++;
ans=max(ans,c+(d-i-1)/2);
for(l=1; l<=v[j]; l++) a[l]++;
}
cout<<ans<<endl;
}
return 0;
}

0 comments on commit a598e8b

Please sign in to comment.