Submission #853040

#TimeUsernameProblemLanguageResultExecution timeMemory
853040onepunchac168Holiday (IOI14_holiday)C++14
0 / 100
11 ms3064 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]; void 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); } cout<<res; } const int M=3e3+5; void 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); } } } cout<<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) { sub1(); } else 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 'void 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 'void 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)
      |                        ~~~~~~~~~^~~~~
holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:99:1: warning: no return statement in function returning non-void [-Wreturn-type]
   99 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...