#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using namespace std;
#define F first
#define S second
#define ll long long
// #define int ll
#define pb push_back
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,i) memset(a,i,sizeof(a))
#define in insert
#define lb lower_bound
#define ub upper_bound
#define y1 yy
#define ppb pop_back
#define ull unsigned ll
const int MAX=5e5+55;
const int inf=1e9;
const int N=2e5;
const int C=331;
const int C1=431;
const int mod=1e9+9;
const int mod1=1e9+9;#include "holiday.h"
ll dpL[MAX],dpR[MAX];
ll dp1L[MAX],dp1R[MAX];
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
if(n<=20){
for(ll ds=0;ds<=d;ds++){
multiset<ll> st;
ll ans=0;
ll cur=0;
for(ll i=start;i<n;i++){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-(i-start)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dpR[ds]=ans;
st.clear();
ans=cur=0;
for(ll i=start;i<n;i++){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-2*(i-start)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dp1R[ds]=ans;
}
for(ll ds=0;ds<=d;ds++){
multiset<ll> st;
ll ans=0;
ll cur=0;
for(ll i=start-1;i>=0;i--){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-(start-i-1)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dpL[ds]=ans;
st.clear();
ans=cur=0;
for(ll i=start-1;i>=0;i--){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-2*(start-i-1)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dp1L[ds]=ans;
}
// cout<<dpR[4]<<"\n";
ll ans=0;
for(ll i=0;i<=d;i++){
// cout<<i<<" "<<dpR[i]<<" "<<dp1L[d-i-1]<<"\n";
// cout<<i<<" "<<dp1R[i]<<" "<<dpL[d-i-1]<<"\n";
ans=max(ans,dpR[i]+dp1L[d-i-2]);
ans=max(ans,dp1R[i]+dpL[d-i-1]);
}
return ans;
}
if(start==0){
multiset<int> st;
int ans=0;
int cur=0;
for(int i=0;i<n;i++){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>d-i){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
return ans;
}
for(ll ds=0;ds<=d;ds++){
multiset<ll> st;
ll ans=0;
ll cur=0;
for(ll i=start;i<n;i++){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-(i-start)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dpR[ds]=ans;
st.clear();
ans=cur=0;
for(ll i=start;i<n;i++){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-2*(i-start)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dp1R[ds]=ans;
}
for(ll ds=0;ds<=d;ds++){
multiset<ll> st;
ll ans=0;
ll cur=0;
for(ll i=start-1;i>=0;i--){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-(start-i-1)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dpL[ds]=ans;
st.clear();
ans=cur=0;
for(ll i=start-1;i>=0;i--){
st.in(attraction[i]);
cur+=attraction[i];
while(!st.empty()&&sz(st)>ds-2*(start-i-1)){
cur-=*st.begin();
st.erase(st.begin());
}
ans=max(ans,cur);
}
dp1L[ds]=ans;
}
// cout<<dpR[4]<<"\n";
ll ans=0;
for(ll i=0;i<=d;i++){
// cout<<i<<" "<<dpR[i]<<" "<<dp1L[d-i-1]<<"\n";
// cout<<i<<" "<<dp1R[i]<<" "<<dpL[d-i-1]<<"\n";
ans=max(ans,dpR[i]+dp1L[d-i-2]);
ans=max(ans,dp1R[i]+dpL[d-i-1]);
}
return ans;
}
Compilation message
holiday.cpp:30:22: error: stray '#' in program
30 | const int mod1=1e9+9;#include "holiday.h"
| ^
holiday.cpp:30:23: error: 'include' does not name a type
30 | const int mod1=1e9+9;#include "holiday.h"
| ^~~~~~~
holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:50:5: error: 'dpR' was not declared in this scope; did you mean 'dp1R'?
50 | dpR[ds]=ans;
| ^~~
| dp1R
holiday.cpp:77:5: error: 'dpL' was not declared in this scope; did you mean 'dp1L'?
77 | dpL[ds]=ans;
| ^~~
| dp1L
holiday.cpp:96:17: error: 'dpR' was not declared in this scope; did you mean 'dp1R'?
96 | ans=max(ans,dpR[i]+dp1L[d-i-2]);
| ^~~
| dp1R
holiday.cpp:97:25: error: 'dpL' was not declared in this scope; did you mean 'dp1L'?
97 | ans=max(ans,dp1R[i]+dpL[d-i-1]);
| ^~~
| dp1L
holiday.cpp:129:5: error: 'dpR' was not declared in this scope; did you mean 'dp1R'?
129 | dpR[ds]=ans;
| ^~~
| dp1R
holiday.cpp:156:5: error: 'dpL' was not declared in this scope; did you mean 'dp1L'?
156 | dpL[ds]=ans;
| ^~~
| dp1L
holiday.cpp:175:17: error: 'dpR' was not declared in this scope; did you mean 'dp1R'?
175 | ans=max(ans,dpR[i]+dp1L[d-i-2]);
| ^~~
| dp1R
holiday.cpp:176:25: error: 'dpL' was not declared in this scope; did you mean 'dp1L'?
176 | ans=max(ans,dp1R[i]+dpL[d-i-1]);
| ^~~
| dp1L