Submission #546821

#TimeUsernameProblemLanguageResultExecution timeMemory
546821Trisanu_DasDistributing Candies (IOI21_candies)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> distribute_candies(int c[], int l[], int r[], int v[]){ int n = sizeof(c) / sizeof(int); vector<int> a(n); for(int i = 0; i < q; ++i) { for(int j = l[i]; j <= l[i]; ++j) { a[j] += v[i]; a[j] = max(a[j], 0); a[j] = min(a[j], c[j]); } } return a; }

Compilation message (stderr)

candies.cpp: In function 'std::vector<int> distribute_candies(int*, int*, int*, int*)':
candies.cpp:5:18: warning: 'sizeof' on array function parameter 'c' will return size of 'int*' [-Wsizeof-array-argument]
    5 |   int n = sizeof(c) / sizeof(int);
      |                 ~^~
candies.cpp:4:36: note: declared here
    4 | vector<int> distribute_candies(int c[], int l[], int r[], int v[]){
      |                                ~~~~^~~
candies.cpp:7:22: error: 'q' was not declared in this scope
    7 |   for(int i = 0; i < q; ++i) {
      |                      ^