Submission #122166

#TimeUsernameProblemLanguageResultExecution timeMemory
122166brcodeHoliday (IOI14_holiday)C++14
47 / 100
5012 ms2956 KiB
#include <iostream> #include <queue> #include <holiday.h> using namespace std; long long int findMaxAttraction(int n, int start, int d,int attraction[]){ if(start == 0){ priority_queue<long long> pq; long long sum = 0; long long ans = 0; for(long long i=0;i<n;i++){ pq.push(-1*attraction[i]); sum+=attraction[i]; while(pq.size()+i>d){ long long hold = pq.top(); sum+=hold; pq.pop(); } ans= max(sum,ans); } return ans; }else{ long long ans = 0; for(long long l=0;l<=start;l++){ priority_queue<long long> pq; long long sum = 0; for(long long i=l;i<start;i++){ pq.push(-1*attraction[i]); sum+=attraction[i]; } for(long long r=start;r<n;r++){ if(r-l>=d){ break; } pq.push(-1*attraction[r]); sum+=attraction[r]; while(pq.size() && pq.size()+(r-l)+min(start-l,r-start)>d){ long long hold = pq.top(); sum+=hold; pq.pop(); } ans = max(ans,sum); } } return ans; } }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:14:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(pq.size()+i>d){
                   ~~~~~~~~~~~^~
holiday.cpp:39:72: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 while(pq.size() && pq.size()+(r-l)+min(start-l,r-start)>d){
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...