General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
92351019 Practice:
omhari
1389B - 12 C++14 (GCC 6-32) Memory limit exceeded on test 3 654 ms 262144 KB 2020-09-09 15:34:50 2020-09-09 15:34:50
→ Source
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  Name:- OMHARI 
  Institution:- UNIVERSIT OF CALCUTTA(INFORMATION TECHNOLOGY)
  Email:- [email protected]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include<bits/stdc++.h>
using namespace std; 

#define F               first
#define S               second
#define ull             unsigned long long
#define ll              long long
#define db              long double
#define ST              string
#define pb              push_back
#define mp              make_pair
#define el              "\n"
#define vll             vector <ll>
#define vi              vector <int>
#define pii             pair <int, int>
#define pll             pair <ll, ll>
#define vec(v)          vector <v>
#define all(v)          (v.begin(), v.end()) 
#define rall(v)         (v.rbegin(), v.rend()) 
#define is_sort(v)      is_sorted all(v)
#define max_of(v)       *max_element all(v)
#define min_of(v)       *min_element all(v)
#define itos(s)         to_string(s)
#define cntone(x)       __builtin_popcountll(x)
#define cntzro(x)       __builtin_clz(x)
#define clr(x,y) 		memset(x, y, sizeof(x))
#define For(i, a, b)    for(int i=a; i<b; i++)
#define Forr(i, a, b)   for(int i=a; i>=b; i--)
const ll mod = 1e9+7;
int n,k,z;
int dp[100005][6];

int go(vi v, int i, int kk, int zz, int pre)
{
    if(i<0 || i>=n || kk<1)
    return 0;

    if(dp[i][zz]!=-1)
    return dp[i][zz];

    int ans=0;
    if(zz>0 && pre==1)
    ans=max(ans, v[i] + go(v, i-1, kk-1, zz-1, pre^1));

    ans=max(ans, v[i] + go(v, i+1, kk-1, zz, 1));

    return dp[i][zz]=ans;
}

void solve()
{
    cin>>n>>k>>z;
    vi v(n);
    For(i, 0, n) cin>>v[i];

    int ans=v[0];
    clr(dp, -1);
    ans+=go(v, 1, k, z, 1);
    cout<<ans<<el;

}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    /***************-Code starts from here-***************/
    int t;
    cin>>t;
    while(t--)
    solve();
    return 0; 
} 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details