답안 #705913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705913 2023-03-05T15:55:10 Z Alihan_8 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
// include <ext/pb_ds/assoc_container.hpp>
// include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
// define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define mpr make_pair
#define ln '\n'
void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
//#define int long long
typedef long long ll;
ll besthub(int R, int L, int X[], int B){
    int n = R;
    ll Mx = 0;
    for ( int pos = 0; pos <= L; pos++ ){
        vector <int> res;
        for ( int i = 0; i < n; i++ ){
            res.pb(abs(X[i]-pos));
        }
        sort(all(res));
        ll sum = 0, cnt = 0;
        for ( auto i: res ){
            if ( sum+i > B ) break;
            cnt++, sum += i;
        }
        Mx = max(Mx, cnt);
    }
    return Mx;
}
#if false
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int R, L, B;
    cin >> R >> L >> B;
    int X[R];
    for ( int i = 0; i < R; i++ ) cin >> X[i];
    cout << besthub(R, L, X, B);

    cout << '\n';
/*
5 20 6
1 2 10 12 14
answer: 3
*/
}
#endif

Compilation message

ricehub.cpp: In function 'void IO(std::string)':
ricehub.cpp:12:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:12:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccNiDDrN.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