Submission #590290

#TimeUsernameProblemLanguageResultExecution timeMemory
590290Dan4LifeHoliday (IOI14_holiday)C++17
47 / 100
5039 ms6372 KiB
#include <bits/stdc++.h>
#if !defined(LOL)
    #include "holiday.h"
#endif
using namespace std;
 
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define ll long long

ll calc(deque<ll> &a, int d){
    ll ans = 0, sum = 0;
    multiset<ll> S; S.clear();
    for(int i = 0; i < sz(a); i++){
        S.insert(a[i]); sum+=(ll)a[i];
        int rem = d-i; rem = max(rem,0);
        while(sz(S)>rem) sum-=(ll)*S.begin(), S.erase(S.begin());
        ans = max(ans, sum);
    }
    return ans;
}

long long int findMaxAttraction(int n, int s, int d, int a[]) {
    deque<ll> v, w; for(int i = s; i < n; i++) v.pb(a[i]);
    for(int i = 0; i <= s; i++) w.pb(a[i]); reverse(all(w));
    ll ans = max(calc(v,d),calc(w,d));
    for(int i = s-1; i>=0; i--){
        v.push_front(a[i]),
        ans = max(ans, calc(v,d-s+i));
    }
    if(s==0) return ans;
    for(int i = s+1; i < n; i++){
        w.push_front(a[i]),
        ans = max(ans, calc(w,d-i+s));
    }
    return ans;
}

#if defined(LOL)
int main() {
    int n, start, d;
    int attraction[100000];
    int i, n_s;
    n_s = scanf("%d %d %d", &n, &start, &d);
    for (i = 0 ; i < n; ++i) {
    n_s = scanf("%d", &attraction[i]);
    }
    printf("%lld\n", findMaxAttraction(n, start, d, attraction));
    return 0;
}
#endif

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:26:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   26 |     for(int i = 0; i <= s; i++) w.pb(a[i]); reverse(all(w));
      |     ^~~
holiday.cpp:26:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   26 |     for(int i = 0; i <= s; i++) w.pb(a[i]); reverse(all(w));
      |                                             ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...