답안 #436359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436359 2021-06-24T12:56:20 Z PiejanVDC 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"
#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]), q = sizeof(v)/sizeof(v[0]);
    int ans[n];
    memset(ans,0,sizeof(ans));

    for(int i = 0 ; i < q ; i++) {
        for(int j = l[i] ; j <= r[i] ; j++) ans[j]=(v[i]>0?min(c[j],ans[j]+v[i]):max(0,ans[j]-v[i]));
    }
    return ans;
}

Compilation message

candies.cpp:5:4: error: structured binding declaration cannot have type 'int'
    5 | int[] distribute_candies(int[] c, int[] l, int[] r, int[] v) {
      |    ^~
candies.cpp:5:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
candies.cpp:5:4: error: empty structured binding declaration
candies.cpp:5:7: error: expected initializer before 'distribute_candies'
    5 | int[] distribute_candies(int[] c, int[] l, int[] r, int[] v) {
      |       ^~~~~~~~~~~~~~~~~~