답안 #781838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781838 2023-07-13T11:50:45 Z hariaakas646 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
// #include <grader.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

int besthub(int r, lli l, vll vec, lli b)
{
    int lo = 0;
    int hi = r;
    vll pref(r);
    pref[0] = vec[0];
    forr(i, 1, r) pref[i] = pref[i - 1] + vec[i];

    while (lo != hi)
    {
        int mid = (hi + lo) / 2;
        bool check = false;

        forr(i, 0, r)
        {
            if (i - mid / 2 >= 0 && i + (mid - 1) / 2 < r)
            {
                int i1 = mid / 2;
                int i2 = (mid - 1) / 2;
                lli v = pref[i];
                if (i - i1 > 0)
                    v -= pref[i - i1 - 1];
                v = -v;
                v += vec[i] * (i1 + 1);
                v += pref[i + i2] - pref[i];
                v -= vec[i] * i2;
                if (v <= b)
                {
                    check = true;
                    break;
                }
            }
            if (i - (mid - 1) / 2 >= 0 && i + (mid) / 2 < r)
            {
                int i1 = (mid - 1) / 2;
                int i2 = (mid) / 2;
                lli v = pref[i];
                if (i - i1 > 0)
                    v -= pref[i - i1 - 1];
                v = -v;
                v += vec[i] * (i1 + 1);
                v += pref[i + i2] - pref[i];
                v -= vec[i] * i2;
                if (v <= b)
                {
                    check = true;
                    break;
                }
            }
        }
        if (check)
        {
            lo = mid;
        }
        else
            hi = mid - 1;
    }
    return lo;
}

int main()
{
    int r;
    lli l, b;
    scd(r);
    sclld(l);
    sclld(b);
    vll vec(r);

    frange(i, r) sclld(vec[i]);
    printf("%d", besthub(r, l, vec, b));
}

Compilation message

ricehub.cpp: In function 'int main()':
ricehub.cpp:6:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
ricehub.cpp:100:5: note: in expansion of macro 'scd'
  100 |     scd(r);
      |     ^~~
ricehub.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
ricehub.cpp:101:5: note: in expansion of macro 'sclld'
  101 |     sclld(l);
      |     ^~~~~
ricehub.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
ricehub.cpp:102:5: note: in expansion of macro 'sclld'
  102 |     sclld(b);
      |     ^~~~~
ricehub.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
ricehub.cpp:105:18: note: in expansion of macro 'sclld'
  105 |     frange(i, r) sclld(vec[i]);
      |                  ^~~~~
/usr/bin/ld: /tmp/cc9ULgrY.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccsIKEPV.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc9ULgrY.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status