답안 #967742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967742 2024-04-22T18:08:57 Z Hugo1729 쌀 창고 (IOI11_ricehub) C++11
0 / 100
2 ms 860 KB
#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

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();
      |            ~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -