This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include"holiday.h"
using namespace std;
/***********************/
vector<int> arr;
int maxd;
#define ll long long
ll brute(int city, int d, vector<bool> vis){
if(d > 7) return 0;
ll ans = 0;
if(!vis[city]){
vis[city] = true;
ans =arr[city] + brute(city, d+1, vis);
}
if(city >0)
ans = max(ans, brute(city-1, d+1, vis));
if(city < vis.size() - 1)
ans = max(ans, brute(city+1, d+1, vis));
return ans;
}
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
arr.clear();
arr.assign(n, 0);
maxd = d;
for(int i =0; i<n ;i++){
arr[i] = attraction[i];
}
vector<bool> vis;
vis.assign(n, 0);
return brute(start, 1,vis );
}
/***********************/
Compilation message (stderr)
holiday.cpp: In function 'long long int brute(int, int, std::vector<bool>)':
holiday.cpp:23:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | if(city < vis.size() - 1)
| ~~~~~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |