제출 #861238

#제출 시각아이디문제언어결과실행 시간메모리
861238sleepntsheepRice Hub (IOI11_ricehub)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> #include "ricehub.h" using namespace std; #define ALL(x) x.begin(), x.end() #define N 100005 using ll = long long; int n, l, z = -1; ll b, p[N], a[N]; int optimal_hub(int l, int r) { return (l+r)/2; } ll sum(int l, int r) { return p[r] - p[l-1]; } ll need_budget(int l, int r, int h) { if (h < l || r < h) return 1e18; return a[h] * (h-l+1) - a[h] * (r-h) + sum(h+1, r) - sum(l, h); } ll need_budget(int l, int r) { return min({need_budget(l, r, optimal_hub(l, r)), need_budget(l, r, optimal_hub(l, r) + 1), need_budget(l, r, optimal_hub(l, r) - 1)}); } ll besthub(int r, int l, int *a, ll b) { for (int i = 1; i <= n; ++i) { p[i] = p[i-1] + a[i]; int l = 1, r = i; while (l <= r) { int y = (l+r)/2; if (need_budget(y, i) <= b) z = max(z, i-y+1), r = y - 1; else l = y + 1; } } return z; }

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp:42:4: error: ambiguating new declaration of 'll besthub(int, int, int*, ll)'
   42 | ll besthub(int r, int l, int *a, ll b)
      |    ^~~~~~~
In file included from ricehub.cpp:9:
ricehub.h:1:5: note: old declaration 'int besthub(int, int, int*, long long int)'
    1 | int besthub(int R, int L, int X[], long long B);
      |     ^~~~~~~