답안 #804979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804979 2023-08-03T12:16:15 Z Gangsta 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
// a >> b = a / pow(2,b)
// a << b = a * pow(2,b)
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define sz size()
#define ss second
#define ff first
#define N 200001
#define pll pair<ll,ll>

using namespace std;

ll besthub(int r, int l, int x[N], ll b){
	ll tmp, md ans, mx = 0;
	for(int i = 1; i <= l; i++){
		ans = 0;
		tmp = b;
		md = i;
		vector <ll> v;
		for(int i = 0; i < r; i++){
			v.pb(abs(md - x[i]));
		}
		sort(v.begin(), v.end());
		for(auto i : v){
			if(tmp <= i) break;
			ans++;
			tmp -= i;
		}
		mx = max(mx,ans);
	}
	return mx;
}

//int main(){
//	ll r, l, x[N], b;
//	cin >> r >> l;
//	for(int i = 0; i < r; i++) cin >> x[i];
//	cin >> b;
//	cout << besthub(r,l,x,b);
//}

Compilation message

ricehub.cpp: In function 'long long int besthub(int, int, int*, long long int)':
ricehub.cpp:15:13: error: expected initializer before 'ans'
   15 |  ll tmp, md ans, mx = 0;
      |             ^~~
ricehub.cpp:17:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |   ans = 0;
      |   ^~~
      |   abs
ricehub.cpp:19:3: error: 'md' was not declared in this scope
   19 |   md = i;
      |   ^~
ricehub.cpp:30:3: error: 'mx' was not declared in this scope; did you mean 'x'?
   30 |   mx = max(mx,ans);
      |   ^~
      |   x
ricehub.cpp:32:9: error: 'mx' was not declared in this scope; did you mean 'x'?
   32 |  return mx;
      |         ^~
      |         x