Submission #298067

#TimeUsernameProblemLanguageResultExecution timeMemory
298067mieszko11bHoliday (IOI14_holiday)C++14
7 / 100
5049 ms1408 KiB
#include "holiday.h" #include <bits/stdc++.h> using namespace std; using ll = long long; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll res = 0; vector<int> a(n); for(int i = 0 ; i < n ; i++) a[i] = attraction[i]; for(int mask = 1 ; mask < (1 << n) ; mask++) { ll sum = 0, cost = 0; int aa = n + 1, b = -1; for(int i = 0 ; i < n ; i++) if(mask & (1 << i)) { sum += a[i]; cost++; aa = min(aa, i); b = max(b, i); } cost += (b - aa) + min(abs(start - aa), abs(start - b)); if(cost <= d) res = max(res, sum); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...