답안 #480612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480612 2021-10-17T12:43:54 Z Haidara 사탕 분배 (IOI21_candies) C++17
컴파일 오류
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)
      |       ^~~~~~~~~~~~~~~~~~