QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524355#1140. Distributing CandiesFadel_elsenusi#Compile Error//C++17601b2024-08-19 16:10:092024-08-19 16:10:10

Judging History

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

  • [2024-08-19 16:10:10]
  • 评测
  • [2024-08-19 16:10:09]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
array<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:5:10: error: wrong number of template arguments (1, should be 2)
    5 | array<int>distribute_candies(int[] c, int[] l, int[] r, int[] v){
      |          ^
In file included from /usr/include/c++/13/bits/memory_resource.h:47,
                 from /usr/include/c++/13/string:58,
                 from /usr/include/c++/13/bits/locale_classes.h:40,
                 from /usr/include/c++/13/bits/ios_base.h:41,
                 from /usr/include/c++/13/ios:44,
                 from /usr/include/c++/13/ostream:40,
                 from /usr/include/c++/13/iostream:41,
                 from answer.code:1:
/usr/include/c++/13/tuple:2005:45: note: provided for ‘template<class _Tp, long unsigned int _Nm> struct std::array’
 2005 |   template<typename _Tp, size_t _Nm> struct array;
      |                                             ^~~~~
answer.code:5:36: error: expected ‘,’ or ‘...’ before ‘c’
    5 | array<int>distribute_candies(int[] c, int[] l, int[] r, int[] v){
      |                                    ^
answer.code: In function ‘int distribute_candies(int*)’:
answer.code:7:16: error: ‘c’ was not declared in this scope
    7 |     for(auto i:c){
      |                ^
answer.code:10:15: error: ‘v’ was not declared in this scope
   10 |     for(int i:v){
      |               ^
answer.code:18:13: error: ‘l’ was not declared in this scope
   18 |         arr[l[i]]+=v[i];
      |             ^
answer.code:18:20: error: ‘v’ was not declared in this scope
   18 |         arr[l[i]]+=v[i];
      |                    ^
answer.code:19:13: error: ‘r’ was not declared in this scope
   19 |         arr[r[i]+1]-=v[i];
      |             ^
answer.code:25:27: error: ‘c’ was not declared in this scope
   25 |         arr[i]=min(arr[i],c[i]);
      |                           ^
answer.code:28:12: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
   28 |     return arr;
      |            ^~~
      |            |
      |            int*