Submission #590260

#TimeUsernameProblemLanguageResultExecution timeMemory
590260Dan4LifeHoliday (IOI14_holiday)C++17
0 / 100
44 ms5336 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()
const int maxn = (int)2e5+10;

long long int findMaxAttraction(int n, int s, int d, int a[]) {
    int ans = 0, sum = 0;
    multiset<int> S; S.clear();
    for(int i = 0; i < n; i++){
        S.insert(a[i]); sum+=a[i];
        int rem = d-i-1;
        if(S.count(a[0])) rem++; rem = max(rem,0);
        while(sz(S)>rem) sum-=*S.begin(), S.erase(S.begin());
        ans = max(ans, sum);
    }
    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:18:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   18 |         if(S.count(a[0])) rem++; rem = max(rem,0);
      |         ^~
holiday.cpp:18:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   18 |         if(S.count(a[0])) rem++; rem = max(rem,0);
      |                                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...