Submission #480612

# Submission time Handle Problem Language Result Execution time Memory
480612 2021-10-17T12:43:54 Z Haidara Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int[] distribute_candies(vector<int> c,vector<int> l,vector<int> r, vector<int> v)
{
	int n=l.size();
	int res[c.size()];
	for(int i=0;i<c.size();i++)
		res[i]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=l[i];j<=r[i];j++)
		{
			if(v[i]>0)
				res[j]=min(res[j]+v[i],c[j]);
			else 
				res[j]=max(0,res[j]-v[i]);
		}
	}
	return res;
}

Compilation message

candies.cpp:3:4: error: structured binding declaration cannot have type 'int'
    3 | int[] distribute_candies(vector<int> c,vector<int> l,vector<int> r, vector<int> v)
      |    ^~
candies.cpp:3:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
candies.cpp:3:4: error: empty structured binding declaration
candies.cpp:3:7: error: expected initializer before 'distribute_candies'
    3 | int[] distribute_candies(vector<int> c,vector<int> l,vector<int> r, vector<int> v)
      |       ^~~~~~~~~~~~~~~~~~