QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524361#1140. Distributing CandiesFadel_elsenusi#Compile Error//C++17611b2024-08-19 16:21:222024-08-19 16:21:23

Judging History

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

  • [2024-08-19 16:21:23]
  • 评测
  • [2024-08-19 16:21:22]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
array<int,200000>distribute_candies(int c[], int l[], int r[], int v[]){
    int sz=0,vsz=0;
    for(auto i:c){
        sz++;
    }
    for(auto 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: In function ‘std::array<int, 200000> distribute_candies(int*, int*, int*, int*)’:
answer.code:7:16: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
    7 |     for(auto i:c){
      |                ^
      |                std::begin
In file included from /usr/include/c++/13/string:53,
                 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/bits/range_access.h:114:37: note: ‘std::begin’ declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
answer.code:7:16: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
    7 |     for(auto i:c){
      |                ^
      |                std::end
/usr/include/c++/13/bits/range_access.h:116:37: note: ‘std::end’ declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
answer.code:10:16: error: ‘begin’ was not declared in this scope; did you mean ‘std::begin’?
   10 |     for(auto i:v){
      |                ^
      |                std::begin
/usr/include/c++/13/bits/range_access.h:114:37: note: ‘std::begin’ declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
answer.code:10:16: error: ‘end’ was not declared in this scope; did you mean ‘std::end’?
   10 |     for(auto i:v){
      |                ^
      |                std::end
/usr/include/c++/13/bits/range_access.h:116:37: note: ‘std::end’ declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
answer.code:28:16: error: expected primary-expression before ‘]’ token
   28 |     return arr[];
      |                ^