Submission #1240374

#TimeUsernameProblemLanguageResultExecution timeMemory
1240374coderpemulaSličice (COCI19_slicice)C++20
90 / 90
100 ms448 KiB
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

/* Some Makoto Shinkai's : 

  “Who cares if we can't see any sunshine? I want you more than any blue sky!!!”
    - Tenki no Ko
    
  "By the time the date is over, the comet will be visible in the sky."
    - Kimi no Nawa
    
  “No matter what happens, even if the stars fall, I will live.”
    - Byōsoku 5 Centimeter
  
*/
#include <bits/stdc++.h>
#define Raveluk ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define g1 get<0>
#define g2 get<1>
#define g3 get<2>
#define qf q.front()
#define all(x) (x).begin(), (x).end()
using namespace std;
#define int long long
signed main()
{
  Raveluk
  int n,m,i,j,k,ii;
  cin>>n>>m>>k;
  int anu[n+1],skor[m+1],memo[k+1],ans=0;
  //memset(dp,0,sizeof(dp));
  memset(memo,-1,sizeof(memo));
  for(i=1;i<=n;i++) cin>>anu[i];
  memo[0] = 0;
  for(i=0;i<=m;i++) cin>>skor[i];
  for(i=1;i<=n;i++){
    for(ii=k;ii>=0;ii--){
      for(j=anu[i];j<=m;j++){
        if(ii-(j-anu[i]) < 0 or memo[ii-(j-anu[i])] == -1) continue;
        memo[ii] = max(memo[ii-(j-anu[i])]+skor[j],memo[ii]);
        ans = max(ans,memo[ii]);
      }
    }
  }
  cout<<ans;
  
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...