Submission #853046

#TimeUsernameProblemLanguageResultExecution timeMemory
853046onepunchac168Holiday (IOI14_holiday)C++14
0 / 100
9 ms1372 KiB
#include"holiday.h" #include <bits/stdc++.h> using namespace std; #define task "STOUR" #define fi first #define se second #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; const char nl='\n'; /* void onepunchac168(); signed main() { ios_base::sync_with_stdio(false); cin.tie(0); if (fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } onepunchac168(); }*/ ll n,s,d; const int N=1e5+5; ll a[N]; ll sub1() { priority_queue<ll,vector <ll> ,greater <ll> > qu; ll res=0; ll sum=0; for (int i=1;i<=n;i++) { qu.push(a[i]); sum+=a[i]; while (qu.size()>d-i+1) { if (qu.empty()) { break; } sum-=qu.top(); qu.pop(); } res=max(res,sum); } return res; } const int M=3e3+5; ll sub2() { ll res=0; for (int i=1;i<=s;i++) { priority_queue<ll,vector <ll> ,greater <ll> > qu; ll sum=0; for (int j=i;j<=n;j++) { qu.push(a[j]); sum+=a[j]; if (j>=s) { ll pp=(s-i)+(j-s)+min(s-i,j-s); while (qu.size()>d-pp) { if (qu.empty()) { break; } sum-=qu.top(); qu.pop(); } res=max(res,sum); } } } return res; } long long int findMaxAttraction(int n, int start, int d, int attraction[]) { n=n; s=start+1; d=d; for (int i=0;i<n;i++) { a[i+1]=attraction[i]; } if (s==1) { return sub1(); } return sub2(); } /* void onepunchac168() { cin>>n>>s>>d; s++; for (int i=1;i<=n;i++) { cin>>a[i]; } if (s==1) { sub1(); } else sub2(); } */

Compilation message (stderr)

holiday.cpp: In function 'll sub1()':
holiday.cpp:40:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   40 |         while (qu.size()>d-i+1)
      |                ~~~~~~~~~^~~~~~
holiday.cpp: In function 'll sub2()':
holiday.cpp:70:33: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   70 |                 while (qu.size()>d-pp)
      |                        ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...