Submission #549436

# Submission time Handle Problem Language Result Execution time Memory
549436 2022-04-15T19:56:14 Z kilikuma 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) / sizeof(c[0]);
  int Q = sizeof(l) / sizeof(l[0]);
  int S[N + 1] = {0};
  for (int i = 0; i < Q; i ++) {
    for (int j = l[i]; j <= r[i]; j ++) {
      if (v[i] < 0)
        S[j] = min(c[j], S[j] + v[i]);
      else
        S[j] = max(0, S[j] + v[i]);
    }
  }
  return S;
}

Compilation message

candies.cpp:3:6: error: extended character   is not valid in an identifier
    3 | int[] distribute_candies(int[] c, int[] l, int[] r, int[] v) {
      |      ^
candies.cpp:3:41: error: extended character   is not valid in an identifier
    3 | int[] distribute_candies(int[] c, int[] l, int[] r, int[] v) {
      |                                        ^
candies.cpp:10:30: error: extended character   is not valid in an identifier
   10 |         S[j] = min(c[j], S[j] + v[i]);
      |                              ^
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:6: error: expected initializer before '\U000000a0distribute_candies'
    3 | int[] distribute_candies(int[] c, int[] l, int[] r, int[] v) {
      |      ^~~~~~~~~~~~~~~~~~~