답안 #920900

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920900 2024-02-03T07:30:47 Z cowwycow 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"

void file(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(name".inp", "r")) {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
}

long long n, c, k;
long long a[100005] = {0};
long long pre[100005];

int besthub (){
	cin >> n >> c >> k;
	pre[0] = 0;
	for(long long i = 1; i <= n; i++){
		cin >> a[i];
		pre[i] += pre[i - 1] + a[i];
	}
	long long ans = 0;
	for(long long i = 1; i <= n; i++){
		long long l = i, r = n, mid;
		while(l < r){
			mid = (l + r + 1) / 2;
			long long pos = (i + mid) / 2;
			long long cost = a[pos - 1] * (pos - i + 1) - (pre[pos] - pre[i - 1]) + (pre[mid] - pre[pos]) - (mid - pos) * a[pos - 1];
			if(cost > k){
				r = mid - 1;
			}else{
				l = mid;
			}
		}
		ans = max(ans, l - i + 1);
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'void file()':
ricehub.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cctI8Vq1.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