Submission #714045

# Submission time Handle Problem Language Result Execution time Memory
714045 2023-03-23T17:20:46 Z Spade1 Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
//#include "ricehub.h"
#include "grader.cpp"

using namespace std;

queue<int> qL, qR;

int besthub(int R, int L, int X[], ll B) {
    ll cost = 0, cur = 1;
    int ans = 0;
    for (int i = 0; i < R; ++i) {
        if (i != 0) cost += (X[i]-X[i-1])*qL.size();
        if (i != 0) cost -= (X[i]-X[i-1])*qR.size();
        if (!qR.empty() && qR.front() == X[i]) qR.pop();
        if (cur <= i) cur++;
        qL.push(X[i]);
        while (cost > B) {
            cost -= X[i]-qL.front();
            qL.pop();
        }
        while (cur < R) {
            if (cost + X[cur] - X[i] > B) {
                if (cost - (X[i]-qL.front()) + (X[cur]-X[i]) <= cost) {
                    cost -= X[i]-qL.front();
                    cost += X[cur]-X[i];
                    qL.pop();
                    qR.push(X[cur++]);
                }
                else break;
            }
            else {
                cost += X[cur] - X[i];
                qR.push(X[cur++]);
            }
        }
        int curr = qL.size() + qR.size();
        ans = max(ans, curr);
    }
    return ans;
}

Compilation message

/usr/bin/ld: /tmp/cc8EVtzQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccxclSvO.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status