답안 #421097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
421097 2021-06-08T18:05:29 Z OttoTheDino 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define rep(i,s,e)                          for (int i = s; i <= e; ++i)
typedef long long ll;
int besthub (int r, int l, int x[], ll b) {
    int ans = 1, right = 0, cur = 1;
    ll tot = 0;
    deque<int> dq;
    dq.pb(x[0]);
    rep (i,1,r-1) {
        while (right<r-1) {
            ll newy = tot;
            dq.push_back(x[right+1]);
            int nmid = dq[((int)dq.size()-1)/2];
            newy += dq.back()-nmid; 
            if (newy<=b) {
                tot = newy;
                ans = max(ans, ++cur);
                right++;
            }
            else {
                dq.pop_back();
                break;
            }
        }
        tot -= dq[((int)dq.size()-1)/2]-dq.front();
        if ((int)dq.size()%2==0) tot -= dq[(int)dq.size()/2]-dq[((int)dq.size()-1)/2];
        dq.pop_front();
        cur--;
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:10:8: error: 'class std::deque<int>' has no member named 'pb'
   10 |     dq.pb(x[0]);
      |        ^~