Submission #1063673

#TimeUsernameProblemLanguageResultExecution timeMemory
1063673kkzyrHoliday (IOI14_holiday)C++17
47 / 100
5012 ms2852 KiB
#include <iostream> #include <queue> #include <vector> using namespace std; int opposite[100001]; bool cmp(int a, int b){ return a > b; } long long solve_go_left(int n, int start, int d, int attraction[100000]){ priority_queue<int, vector<int>, decltype(&cmp)> heap(cmp); long long sum = 0; long long ans = 0; for (int i = start;i >= max(0, start - d + 1);i--){ int num_days_left = d - (start - i); if (heap.size() == num_days_left + 1){ sum -= heap.top(); heap.pop(); } if (heap.size() == num_days_left){ if (heap.top() < attraction[i]){ sum -= heap.top(); heap.pop(); sum += attraction[i]; heap.push(attraction[i]); } } else{ heap.push(attraction[i]); sum += attraction[i]; } if (sum > ans){ ans = sum; } } return ans; } long long findMaxAttraction(int n, int start, int d, int attraction[100000]){ long long ans = solve_go_left(n, start, d, attraction); for (int i = 0;i < n;i++){ opposite[n - 1 - i] = attraction[i]; } ans = max(ans, solve_go_left(n, n - 1 - start, d, opposite)); for (int i = max(0, start - d + 1);i < start;i++){ ans = max(ans, solve_go_left(n, n - 1 - i, d - (start - i), opposite)); } if (start != 0){ for (int i = start + 1; i <= min(n - 1, start + d - 1); i++) { ans = max(ans, solve_go_left(n, i, d - (i - start), attraction)); } } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'long long int solve_go_left(int, int, int, int*)':
holiday.cpp:18:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, bool (*)(int, int)>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |         if (heap.size() == num_days_left + 1){
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
holiday.cpp:22:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, bool (*)(int, int)>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |         if (heap.size() == num_days_left){
      |             ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...