Submission #967742

#TimeUsernameProblemLanguageResultExecution timeMemory
967742Hugo1729Rice Hub (IOI11_ricehub)C++11
0 / 100
2 ms860 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; typedef long long ll; int besthub(int R, int L, int X[], long long B){ deque<int> a,b; int ptr=1; ll sus1=0,sus2=0; int ans=0; for(int i=0;i<R;i++){ a.push_front(X[i]); sus1+=X[i]; if(!b.empty()){ b.pop_front(); sus1-=X[i]; } while((a.size()*X[i]-sus1)+(sus2-b.size()*X[i])>B)a.pop_front(); while(ptr<R&&X[i]-a.front()<b.back()-X[i]){ sus1-=a.front(); a.pop_front(); while(ptr<R&&(a.size()*X[i]-sus1)+(sus2-b.size()*X[i])+(X[ptr]-X[i])<=B){ b.push_front(X[ptr]); sus2+=X[ptr]; ptr++; } } if(ans<a.size()+b.size())ans=a.size()+b.size(); } cout << ans; return -1; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:21:56: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   21 |         while((a.size()*X[i]-sus1)+(sus2-b.size()*X[i])>B)a.pop_front();
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
ricehub.cpp:27:81: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   27 |             while(ptr<R&&(a.size()*X[i]-sus1)+(sus2-b.size()*X[i])+(X[ptr]-X[i])<=B){
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ricehub.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if(ans<a.size()+b.size())ans=a.size()+b.size();
      |            ~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...