Submission #500231

# Submission time Handle Problem Language Result Execution time Memory
500231 2021-12-30T13:32:13 Z sazid_alam Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"

#include <bits/stdc++.h>
using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n = c.size();
    vector<int> s(n, 0) sum(n + 1, 0);

    for(int i = 0; i < (int)v.size(); i++){
        for(int j = l[i]; j <= r[i]; j++){
            if(v[j] > 0) s[j] = min(c[j], s[j] + v[j]);
            else s[j] = max(0, s[j] + v[j]);
        }
    }

    return s;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:9:25: error: expected ',' or ';' before 'sum'
    9 |     vector<int> s(n, 0) sum(n + 1, 0);
      |                         ^~~