제출 #1252962

#제출 시각아이디문제언어결과실행 시간메모리
1252962salehhasanli쌀 창고 (IOI11_ricehub)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops,no-stack-protector") #pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt,tune=native") #pragma GCC optimize("Ofast") #pragma GCC optimize("fast-math") using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; const int INF = 1e9 + 7; const ll LINF = 1e18; const int MOD = 1e9 + 7; const int N = 2e5 + 5; void fast_io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } ll gcd(ll a, ll b) { while (b) tie(a, b) = make_pair(b, a % b); return a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll power(ll a, ll b, ll m = MOD) { ll res = 1; a %= m; while (b) { if (b & 1) res = res * a % m; a = a * a % m; b >>= 1; } return res; } ll modinv(ll a, ll m = MOD) { return power(a, m - 2, m); } template<typename T> void print_vector(const vector<T> &v, string sep = " ") { for (const auto &x: v) cout << x << sep; cout << '\n'; } template<typename T> T sum_vector(const vector<T> &v) { return accumulate(v.begin(), v.end(), T(0)); } template<typename T> T max_vector(const vector<T> &v) { return *max_element(v.begin(), v.end()); } template<typename T> T min_vector(const vector<T> &v) { return *min_element(v.begin(), v.end()); } template<typename T> void input_vector(vector<T> &v, int n) { v.resize(n); for (T &x: v) cin >> x; } template<typename T> vector<T> prefix_sum(const vector<T> &v) { int n = v.size(); vector<T> ps(n + 1, 0); for (int i = 0; i < n; ++i) ps[i + 1] = ps[i] + v[i]; return ps; } bool is_prime(ll n) { if (n < 2) return false; for (ll i = 2; i * i <= n; ++i) if (n % i == 0) return false; return true; } vector<bool> sieve(int n) { vector<bool> is_prime(n + 1, true); is_prime[0] = is_prime[1] = false; for (int i = 2; i * i <= n; ++i) if (is_prime[i]) for (int j = i * i; j <= n; j += i) is_prime[j] = false; return is_prime; } // using ll = long long; // using ull = unsigned long long; // using ld = long double; // using pii = pair<int, int>;\]{ // using pll = pair<ll, ll>; // using vi = vector<int>; // using vll = vector<ll>; // // const int INF = 1e9 + 7; // const ll LINF = 1e18; // const int MOD = 1e9 + 7; // const int N = 2e5 + 5; bool check(ll mid,vector<ll>a,ll b,ll c,vector<ll>d) { if (mid == 0) { return true; } if (a.size()<mid) { return false; } for (ll i = 0;i<=a.size()-mid;i++) { ll f = i+mid-1; ll e = i+(mid-1)/2; ll r = a[e]; if (r>b) { break; } ll q = e-i; int u = d[e]-d[i]; int p = r*q-u; ll q1 = f-e; ll u1 = d[f]-d[e]; p+= u1-q1*r; if (p<=c) { return true; } } return false; } void solve() { ll n,b,c; cin>>n>>b>>c; vector<ll>a(n); for (int i = 0;i<n;i++) { cin>>a[i]; } sort(a.begin(),a.end()); vector<ll>d(n); for (int i = 0;i<n;i++) { if (i==0) { d[i] = a[i]; } else { d[i] = d[i-1]+a[i]; } } ll l = 0,r = n; ll best = 0; while (l<=r) { ll mid = (l+r)/2; if (check(mid,a,b,c,d)) { best = mid; l = mid+1; } else { r = mid-1; } } cout<<best<<endl; } signed main() { fast_io(); int t = 1; // cin >> t; while (t--) solve(); return 0; } // aacbbcbcaacbbc/

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

/usr/bin/ld: /tmp/ccvkAQWr.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc5mGT5r.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccvkAQWr.o: in function `main':
grader.cpp:(.text.startup+0xaa): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status