QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524340 | #1140. Distributing Candies | Fadel_elsenusi# | Compile Error | / | / | C++17 | 579b | 2024-08-19 15:55:21 | 2024-08-19 15:55:22 |
Judging History
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){ | ^~~~~~~~~~~~~~~~~~