제출 #1016469

#제출 시각아이디문제언어결과실행 시간메모리
1016469overwatch9휴가 (IOI14_holiday)C++17
0 / 100
5076 ms1624 KiB
#include"holiday.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll findMaxAttraction(int n, int start, int d, int attraction[]) { ll ans = 0; for (int i = 0; i < (1 << n); i++) { vector <int> vis; ll tp = 0; for (int j = 0; j < n; j++) { if (i & (1 << j)) { vis.push_back(j); tp += attraction[j]; } } int days1 = 0, days2 = 0; if (!vis.empty()) { if (vis[0] < start) days1 = start - vis[0]; int lst = 0; for (auto j : vis) { if (j <= start) days1++; else { if (lst <= start) days1 += vis.back() - vis[0]; days1++; } lst = j; } if (vis.back() > start) days2 = vis.back() - start; lst = n; reverse(vis.begin(), vis.end()); for (auto j : vis) { if (j >= start) days2++; else { if (lst >= start) days2 += vis[0] - vis.back(); days2++; } lst = j; } if (min(days1, days2) <= d) ans = max(ans, tp); } } return ans; } // int main() { // int n, st, d; // cin >> n >> st >> d; // int a[n]; // for (int i = 0; i < n; i++) // cin >> a[i]; // cout << findMaxAttraction(n, st, d, a) << '\n'; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...