Submission #1017249

#TimeUsernameProblemLanguageResultExecution timeMemory
1017249simona1230Holiday (IOI14_holiday)C++17
47 / 100
5064 ms1752 KiB
#include"holiday.h" #include<bits/stdc++.h> using namespace std; int a[100001],n,s,d; long long ans; priority_queue<int> q; void solve() { for(int l=0;l<=s;l++) { while(q.size())q.pop(); long long curr=0; for(int i=l;i<s;i++) { q.push(-a[i]); curr+=a[i]; if(q.size()>d) { curr-=(-q.top()); q.pop(); } } for(int i=s;i<n;i++) { q.push(-a[i]); curr+=a[i]; int days=d-(i-l+min(i-s,s-l)); if(days<0)break; while(q.size()>days) { curr-=(-q.top()); q.pop(); } //cout<<l<<" "<<i<<" "<<days<<" "<<curr<<" "<<q.size()<<endl; ans=max(ans,curr); } } } long long int findMaxAttraction(int N, int start, int D, int attraction[]) { n=N; d=D; s=start; for(int i=0;i<n;i++) a[i]=attraction[i]; solve(); return ans; }

Compilation message (stderr)

holiday.cpp: In function 'void solve()':
holiday.cpp:18:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |             if(q.size()>d)
      |                ~~~~~~~~^~
holiday.cpp:32:27: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |             while(q.size()>days)
      |                   ~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...