제출 #335876

#제출 시각아이디문제언어결과실행 시간메모리
335876sumit_kk10Rice Hub (IOI11_ricehub)C++14
0 / 100
18 ms1772 KiB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define ld long double
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
 
long long int besthub(int r, int l, int a[], long long int b){
	long long int ans = 1;
	int j = (r/2) - 1, k = (r/2) + 1, i = r/2;
	long long int budget = b, how_many = 1; 
	while(budget >= 0){
		if(j < 0 and k >= r) break;
		if(abs(a[j] - a[i]) <= abs(a[k] - a[i]) and abs(a[j] - a[i]) <= budget and j >= 0){
			budget -= abs(a[j] - a[i]);
			++how_many;
			--j;
		}
		else if(abs(a[k] - a[i]) <= abs(a[j] - a[i]) and abs(a[k] - a[i]) <= budget and k < r){
			budget -= abs(a[k] - a[i]);
			++how_many;
			++k;
		}
		else
			break;
	}
	return how_many;
}

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

ricehub.cpp: In function 'long long int besthub(int, int, int*, long long int)':
ricehub.cpp:10:16: warning: unused variable 'ans' [-Wunused-variable]
   10 |  long long int ans = 1;
      |                ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...