Submission #50949

#TimeUsernameProblemLanguageResultExecution timeMemory
50949TalantHoliday (IOI14_holiday)C++17
30 / 100
5028 ms988 KiB
#include"holiday.h" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back using namespace std; const int N = (1e6 + 5); long long ans; int u[N]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { if (start == 0 && n > 20) { for (int i = 0; i < n; i ++) { u[attraction[i]] ++; int cn = d - i; if (cn <= 0) continue; long long sum = 0; for (int i = 100; i >= 1; i --) { int o = min(u[i],cn); sum += (o * 1ll * i); cn -= o; } ans = max(ans,sum); } return ans; } else { for (int i = 1; i < (1 << n); i ++) { int cn = __builtin_popcount(i); int f = __builtin_ffs(i) - 1; int s = (31 - __builtin_clz(i)); if (start <= f) { if (s - start + cn > d) continue; } else if (start >= s) { if (start - f + cn > d) continue; } else { if ((s - start) + (start - f) + min((s - start),(start - f)) + cn > d) continue; } long long sum = 0; for (int j = 0; j < n; j ++) { if (i & (1 << j)) sum += attraction[j]; } ans = max(ans,sum); } return ans; } }

Compilation message (stderr)

grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
     int i, n_s;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...