답안 #110410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110410 2019-05-10T19:27:28 Z ioilolcom 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define endl "\n"
#define x first
#define y second
#define pii pair<int,int>
typedef long long int ll;




vector<int> v;
int besthub(int R, int L, int X[], long long B)
{
	int n=R;
	ll w=B;
	v.resize(n+1);
	for(int i=0; i<n; i++) {
		v[i+1]=X[i];
	}
	int mx=0;
	for(int idx=1; idx<=n; idx++) {
		vector<pii> l,r;
		int cur=0;
		int curv=0;
		for(int i=idx+1; i<=n; i++) {
			curv+=v[i]-v[idx];
			cur++;
			r.push_back({curv,cur});
		}
		r.push_back({0,0});
		l.push_back({0,0});
		cur=0;
		curv=0;
		for(int i=idx-1; i>=0; i--) {
			curv+=abs(v[i]-v[idx]);
			cur++;
			l.push_back({curv,cur});
		}
		int ans=0;
		for(pii u:l) {
			for(pii v:r) {
				if(u.x+v.x<=w) {
					ans=max(ans,u.y+v.y);
				}
			}
		}
		ans++;
		mx=max(mx,ans);
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:52:9: error: 'ans' was not declared in this scope
  return ans;
         ^~~
ricehub.cpp:52:9: note: suggested alternative: 'abs'
  return ans;
         ^~~
         abs