답안 #549442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
549442 2022-04-15T20:07:23 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:5: error: extended character   is not valid in an identifier
    3 | int* distribute_candies(int c[], int l[], int r[], int v[]) {
      |     ^
candies.cpp:3:35: error: extended character   is not valid in an identifier
    3 | int* distribute_candies(int c[], int l[], int r[], int v[]) {
      |                                  ^
candies.cpp:3:35: error: 'int\U000000a0l' has not been declared
    3 | int* distribute_candies(int c[], int l[], int r[], int v[]) {
      |                                  ^~~~~
candies.cpp: In function 'int* \U000000a0distribute_candies(int*, int*, int*, int*)':
candies.cpp:4:18: warning: 'sizeof' on array function parameter 'c' will return size of 'int*' [-Wsizeof-array-argument]
    4 |   int N = sizeof(c) / sizeof(c[0]);
      |                 ~^~
candies.cpp:3:30: note: declared here
    3 | int* distribute_candies(int c[], int l[], int r[], int v[]) {
      |                         ~~~~^~~
candies.cpp:5:18: error: 'l' was not declared in this scope
    5 |   int Q = sizeof(l) / sizeof(l[0]);
      |                  ^
candies.cpp:15:10: warning: address of local variable 'S' returned [-Wreturn-local-addr]
   15 |   return S;
      |          ^
candies.cpp:6:7: note: declared here
    6 |   int S[N + 1] = {0};
      |       ^