QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524340#1140. Distributing CandiesFadel_elsenusi#Compile Error//C++17579b2024-08-19 15:55:212024-08-19 15:55:22

Judging History

你现在查看的是最新测评结果

  • [2024-08-19 15:55:22]
  • 评测
  • [2024-08-19 15:55:21]
  • 提交

answer

#include <iostream>
#include <algorithm>
using namespace std;
int[] distribute_candies(int[] c, int[] l, int[] r, int[] v){
    int sz=0,vsz=0;
    for(auto i:c){
        sz++;
    }
    for(int i:v){
      vsz++;   
    }
    int arr[sz+1];
    for(int i=0;i<=sz;++i){
        arr[i]=0;
    }
    for(int i=0;i<vsz;++i){
        arr[l[i]]+=v[i];
        arr[r[i]+1]-=v[i];
    }
    for(int i=1;i<sz;++i){
        arr[i]+=arr[i-1];
    }
    for(int i=0;i<sz;++i){
        arr[i]=min(arr[i],c[i]);
        arr[i]=max(0,arr[i]);
    }
    return arr;
}

Details

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