Submission #1097692

#TimeUsernameProblemLanguageResultExecution timeMemory
1097692Alihan_8Holiday (IOI14_holiday)C++17
7 / 100
5027 ms2136 KiB
#include"holiday.h" #include <bits/stdc++.h> using namespace std; using i64 = long long; template <class F, class S> bool chmax(F &u, const S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } long long int findMaxAttraction(int n, int s, int d, int attraction[]) { vector <int> a(n); for ( int i = 0; i < n; i++ ) a[i] = attraction[i]; i64 opt = 0; for ( int mask = 1; mask < (1 << n); mask++ ){ int l = n, r = -1; i64 cnt = 0; for ( int i = 0; i < n; i++ ){ if ( mask >> i & 1 ){ cnt += a[i]; if ( l == n ) l = i; r = i; } } int x = __builtin_popcount(mask) + max(s, r) - min(l, s); if ( l <= s && r >= s ) x += min(s - l, r - s); chmax(opt, (x <= d) * cnt); } return opt; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...