Submission #261453

#TimeUsernameProblemLanguageResultExecution timeMemory
261453A02Holiday (IOI14_holiday)C++14
47 / 100
5084 ms2300 KiB
#include"holiday.h" #include <algorithm> #include <set> #include <iostream> #include <vector> #include <utility> #include <set> #include <queue> using namespace std; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { if (d == 0){ return 0; } if (start == 0){ long long total = 0; int can_visit = d; priority_queue<long long> best; long long best_sum = 0; for (int i = 0; i <= 0; i++){ best.push(-attraction[i]); best_sum += attraction[i]; } while (best.size() > can_visit){ best_sum -= -best.top(); best.pop(); } int right = start; total = max(total, best_sum); while (can_visit > 1 && right < n - 1){ can_visit -= 1; right++; best.push(-attraction[right]); best_sum += attraction[right]; while (best.size() > can_visit){ best_sum -= -best.top(); best.pop(); } total = max(total, best_sum); } return total; } long long total = 0; for (int left = start; left >= 0 && start - left < d; left--){ int can_visit = d - (start - left); priority_queue<long long> best; long long best_sum = 0; for (int i = left; i <= start; i++){ best.push(-attraction[i]); best_sum += attraction[i]; } while (best.size() > can_visit){ best_sum -= -best.top(); best.pop(); } int right = start; total = max(total, best_sum); while (can_visit > 2 && right < n - 1){ can_visit -= 2; right++; best.push(-attraction[right]); best_sum += attraction[right]; while (best.size() > can_visit){ best_sum -= -best.top(); best.pop(); } total = max(total, best_sum); } } for (int right = start; right < n && right - start < d; right++){ int can_visit = d - (right - start); priority_queue<long long> best; long long best_sum = 0; for (int i = start; i <= right; i++){ best.push(-attraction[i]); best_sum += attraction[i]; } while (best.size() > can_visit){ best_sum -= -best.top(); best.pop(); } int left = start; total = max(total, best_sum); while (can_visit > 2 && left > 0){ can_visit -= 2; left--; best.push(-attraction[left]); best_sum += attraction[left]; while (best.size() > can_visit){ best_sum -= -best.top(); best.pop(); } total = max(total, best_sum); } } return total; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:33:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (best.size() > can_visit){
                ~~~~~~~~~~~~^~~~~~~~~~~
holiday.cpp:49:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while (best.size() > can_visit){
                    ~~~~~~~~~~~~^~~~~~~~~~~
holiday.cpp:76:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (best.size() > can_visit){
                ~~~~~~~~~~~~^~~~~~~~~~~
holiday.cpp:92:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while (best.size() > can_visit){
                    ~~~~~~~~~~~~^~~~~~~~~~~
holiday.cpp:115:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while (best.size() > can_visit){
                ~~~~~~~~~~~~^~~~~~~~~~~
holiday.cpp:131:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while (best.size() > can_visit){
                    ~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...