Submission #1017224

#TimeUsernameProblemLanguageResultExecution timeMemory
1017224simona1230Holiday (IOI14_holiday)C++17
0 / 100
5037 ms2520 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+1+min(i-s,s-l)); if(days<0)break; if(q.size()>days) { curr-=(-q.top()); q.pop(); } 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:31:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |             if(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...