답안 #549438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549438 2022-04-15T19:58:16 Z kilikuma 사탕 분배 (IOI21_candies) C++17
컴파일 오류
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:36: error: extended character   is not valid in an identifier
    3 | int[] distribute_candies(int c[], int l[], int r[], int v[]) {
      |                                   ^
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[]) {
      |      ^~~~~~~~~~~~~~~~~~~