Submission #502335

# Submission time Handle Problem Language Result Execution time Memory
502335 2022-01-05T19:16:10 Z BeefcakeCat Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include<fstream>
using namespace std;
int* distribute_candies(int c[], int l[], int r[], int v[])
{
    static int s[200000] = {0};
    for(int i = 0; i < q; i++)
    {
        for(int j = l[i]; j <= r[i]; j++)
        {
            s[j] += v[i];
            if(s[j] > c[j])
            {
                s[j] = c[j];
            }
            else if(s[j] < 0)
            {
                s[j] = 0;
            }
        }
    }
    return s;
}

Compilation message

candies.cpp: In function 'int* distribute_candies(int*, int*, int*, int*)':
candies.cpp:6:24: error: 'q' was not declared in this scope
    6 |     for(int i = 0; i < q; i++)
      |                        ^