Submission #967748

#TimeUsernameProblemLanguageResultExecution timeMemory
967748Hugo1729Rice Hub (IOI11_ricehub)C++11
17 / 100
11 ms4060 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++){ // cout << i << ' ' << sus1 << ' ' << sus2 << '\n'; a.push_back(X[i]); // cout << "1a" << X[i] << '\n'; sus1+=X[i]; ptr=max(i+1,ptr); if(!b.empty()){ // cout << "2r" << b.front() << '\n'; b.pop_front(); sus2-=X[i]; } while((a.size()*X[i]-sus1)+(sus2-b.size()*X[i])>B){ // cout << "c" <<(a.size()*X[i]-sus1)+(sus2-b.size()*X[i]) << '\n'; sus1-=a.front(); a.pop_front(); } // cout << "sus" << '\n'; while(ptr<R&&a.size()>0&&X[i]-a.front()>=X[ptr]-X[i]){ // cout << "1r" << a.front() << '\n'; sus1-=a.front(); a.pop_front(); while(ptr<R&&(a.size()*X[i]-sus1)+(sus2-b.size()*X[i])+(X[ptr]-X[i])<=B){ // cout << "2a" << X[ptr] << '\n'; b.push_back(X[ptr]); sus2+=X[ptr]; ptr++; } } while(ptr<R&&(a.size()*X[i]-sus1)+(sus2-b.size()*X[i])+(X[ptr]-X[i])<=B){ // cout << "2a" << X[ptr] << '\n'; b.push_back(X[ptr]); sus2+=X[ptr]; ptr++; } // cout << "sus" << '\n'; if(ans<a.size()+b.size())ans=a.size()+b.size(); } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:25:56: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   25 |         while((a.size()*X[i]-sus1)+(sus2-b.size()*X[i])>B){
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
ricehub.cpp:38:81: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   38 |             while(ptr<R&&(a.size()*X[i]-sus1)+(sus2-b.size()*X[i])+(X[ptr]-X[i])<=B){
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ricehub.cpp:46:77: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
   46 |         while(ptr<R&&(a.size()*X[i]-sus1)+(sus2-b.size()*X[i])+(X[ptr]-X[i])<=B){
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
ricehub.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         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...