Submission #361908

# Submission time Handle Problem Language Result Execution time Memory
361908 2021-02-01T04:00:20 Z beksultan04 Holiday (IOI14_holiday) C++14
7 / 100
5000 ms 8952 KB
#include"holiday.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
int N,strt,q[200001];
lol rec(int pos,int d,bool nap,lol sum=0){
    if (pos < 0 || pos >= N || d <= 0)ret sum;
    lol ans = 0;
    if (nap){
        ans = max(ans,rec(pos-1,d-1,1,sum));
        ans = max(ans,rec(pos-1,d-2,1,sum+q[pos]));
        ans = max(ans,rec(strt,d-abs(pos-strt),0,sum));
        ans = max(ans,rec(strt,d-abs(pos-strt)-1,0,sum+q[pos]));
    }
    else {
        ans = max(ans,rec(pos+1,d-1,0,sum));
        ans = max(ans,rec(pos+1,d-2,0,sum+q[pos]));
    }
    ret ans;
}

lol int findMaxAttraction(int n, int start, int d, int attraction[]) {
    for (int i=0;i<n;++i)q[i] = attraction[i];
    N = n;
    strt = start+1;
    ret (rec(start,d,1));
}
# Verdict Execution time Memory Grader output
1 Correct 13 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 14 ms 364 KB Output is correct
4 Correct 7 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5088 ms 8952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5091 ms 620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 8940 KB Time limit exceeded
2 Halted 0 ms 0 KB -