Submission #50772

#TimeUsernameProblemLanguageResultExecution timeMemory
50772Just_Solve_The_ProblemHoliday (IOI14_holiday)C++11
7 / 100
352 ms996 KiB
#include <bits/stdc++.h> #include"holiday.h" using namespace std; #define pb push_back #define sz(s) (int)s.size() #define ll long long int cnt[123]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll ans = 0; if (n <= 20) { for (int mask = 1; mask < (1 << n); mask++) { vector < int > v; for (int i = 0; i < n; i++) { if (mask & (1 << i)) { v.pb(i); } } ll res = 0; ll time = sz(v); if (start > v.back() || start < v[0]) { if (start > v.back()) { time += abs(start - v[0]); } else { time += abs(start - v.back()); } } else { time += min(abs(start - v[0]), abs(start - v.back())) + v.back() - v[0]; } for (int to : v) { res += attraction[to]; } if (time <= d) { ans = max(ans, res); } } } else if (start == 0) { ll res; for (int i = 0; i < n; i++) { cnt[attraction[i]]++; res = 0; int cn = 0; for (int j = 100; j >= 0; j--) { if (i + cn + cnt[j] > d) { res += (i + cn + cnt[j] - d) * j; break; } else { res += cnt[j] * j; } cn += cnt[j]; } ans = max(ans, res); } } 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...