Submission #830885

# Submission time Handle Problem Language Result Execution time Memory
830885 2023-08-19T12:31:51 Z Johann Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

int N, Q;

std::vector<int> distribute_candies(vi c, vi l, vi r, vi v)
{
    N = sz(c);
    Q = sz(l);
    vi S(N, 0);

    for (int q = 0; q < Q; ++q)
    {
        S[l[q]] += v[q];
        S[++r[q]] -= v[q];
    }
    partial_sum(all(S), S.begin());
    for (int i = 0; i < N; ++i)
        S[i] = min(c[i], S[i]);

    vector<int> ans;
    for (ll x : S)
        ans.push_back(x);

    return ans;
}

Compilation message

/usr/bin/ld: /tmp/cc5BFc6U.o: in function `main':
grader.cpp:(.text.startup+0x30e): undefined reference to `distribute_candies(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status