Submission #971703

# Submission time Handle Problem Language Result Execution time Memory
971703 2024-04-29T07:59:30 Z batsukh2006 Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
//#include "ricehub"
using namespace std;
#define ss second
#define ff first
#define endl '\n'
int besthub(int r, int l, int x[], long long b){
	int ans=0;
	map<int,int> mp;
	for(int i=0; i<r; i++) mp[r[i]]++;
	for(int i=0; i<r; i++){
		int sum=mp[x[i]];
		int lt=i-1,rt=i+1;
		while(lt>=0||rt<r){
			if(lt>=0&&(abs(x[i]-x[lt])<=abs(x[i]-x[rt])||rt==r)){
				if(abs(x[i]-x[lt])>b) break;
				sum++;
				b-=abs(x[i]-x[lt--]);
			}else{
				if(abs(x[i]-x[rt])>b) break;
				sum++;
				b-=abs(x[i]-x[rt++]);
			}
		}
		ans=max(ans,sum);
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:10:29: error: invalid types 'int[int]' for array subscript
   10 |  for(int i=0; i<r; i++) mp[r[i]]++;
      |                             ^