제출 #522295

#제출 시각아이디문제언어결과실행 시간메모리
522295new_acc쌀 창고 (IOI11_ricehub)C++14
100 / 100
16 ms2500 KiB
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(a, b) for(int a = 0; a < (int)(b); a++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e5+10;
ll sp[N];
bool check(int i,int j,ll b){
	int il=(j-i+1)/2;
	ll xd=sp[i+il-1]-(i==0?0:sp[i-1]);
	ll xd2=sp[j]-(j-il<0?0:sp[j-il]);
	return (xd2-xd)<=b;
}
int bs(int pocz,int kon,ll b){
	int p=pocz;
	int sr,res;
	while(pocz<=kon){
		sr=(pocz+kon)/2;
		if(check(p,sr,b)) res=sr,pocz=sr+1;
		else kon=sr-1;
	}
	return res;
}
int besthub(int n,int l,int t[],ll b){
	int ans=0;
	sp[0]=t[0];
	for(int i=1;i<n;i++) sp[i]+=sp[i-1]+t[i];
	rep(i,n) ans=max(ans,bs(i,n-1,b)-i+1);
	return ans;
}

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

ricehub.cpp: In function 'int bs(int, int, ll)':
ricehub.cpp:25:9: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |  return res;
      |         ^~~
ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:31:34: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  rep(i,n) ans=max(ans,bs(i,n-1,b)-i+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...