Submission #490822

# Submission time Handle Problem Language Result Execution time Memory
490822 2021-11-29T12:49:51 Z Karuk Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int[] distribute_candies(int[] c, int[] l, int[] r, int[] v)
{
    int n=sizeof(c);
    int q=sizeof(l);
    int ans[n];
    memset(ans,0,n);
    for(int i=0;i<q;i++)
    {
        for(int j=l[i];j<=r[i];j++)
        {
            if(v[i]>0)ans[i]=min(c[i],ans[i]+v[i]);
            else ans[i]=max(0,ans+v[i]);
        }
    }
    return ans;
}

Compilation message

candies.cpp:3:4: error: structured binding declaration cannot have type 'int'
    3 | int[] distribute_candies(int[] c, int[] l, int[] r, 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(int[] c, int[] l, int[] r, int[] v)
      |       ^~~~~~~~~~~~~~~~~~