답안 #355599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
355599 2021-01-22T19:11:04 Z David_M 쌀 창고 (IOI11_ricehub) C++14
0 / 100
4 ms 620 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R,int L,int X[],long long B){
	long long ans, pref[100005], l, r, m, b;
	for (int i=0; i<R; i++)pref[i]=X[i]+(!!i)*pref[i-1];
	for (r=0; r<R; r++){
		while(l<r){
			m=l+r>>1;
			b=pref[r]+(!!l)*pref[l-1]-(pref[m]<<1);
			if((l+r+1)&1)b+=X[m];			
			if(b<=B)break;
			l++;
		}
		if(r-l>ans)ans=r-l;
	}
	return ans+1;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:9:7: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    9 |    m=l+r>>1;
      |      ~^~
ricehub.cpp:17:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   17 |  return ans+1;
      |         ~~~^~
ricehub.cpp:15:7: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   15 |   if(r-l>ans)ans=r-l;
      |      ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -