제출 #123294

#제출 시각아이디문제언어결과실행 시간메모리
123294baluteshih쌀 창고 (IOI11_ricehub)C++14
100 / 100
20 ms2552 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll sum[100005];

ll w(int l,int r)
{
	int mid=l+r>>1;
	if(l+r&1)
		return sum[r]-sum[mid]-sum[mid]+sum[l-1];
	else 
		return sum[r]-sum[mid]-sum[mid-1]+sum[l-1];
}

int besthub(int R, int L, int X[], long long B)
{
	int ans=0;
	for(int i=1;i<=R;++i)
		sum[i]=sum[i-1]+X[i-1];
	for(int i=1,j=0;i<=R;++i)
	{
		while(j<R&&w(i,j+1)<=B) ++j;
		ans=max(ans,j-i+1);
	}
	return ans;
}

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

ricehub.cpp: In function 'll w(int, int)':
ricehub.cpp:21:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid=l+r>>1;
          ~^~
ricehub.cpp:22:6: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
  if(l+r&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...