Submission #480613

#TimeUsernameProblemLanguageResultExecution timeMemory
480613HaidaraDistributing Candies (IOI21_candies)C++17
0 / 100
87 ms6452 KiB
#include<bits/stdc++.h> using namespace std; int* distribute_candies(vector<int> c,vector<int> l,vector<int> r, vector<int> v) { int n=l.size(); int res[c.size()]; for(int i=0;i<c.size();i++) res[i]=0; for(int i=0;i<n;i++) { for(int j=l[i];j<=r[i];j++) { if(v[i]>0) res[j]=min(res[j]+v[i],c[j]); else res[j]=max(0,res[j]-v[i]); } } return res; }

Compilation message (stderr)

candies.cpp: In function 'int* distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:7:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i=0;i<c.size();i++)
      |              ~^~~~~~~~~
candies.cpp:19:9: warning: address of local variable 'res' returned [-Wreturn-local-addr]
   19 |  return res;
      |         ^~~
candies.cpp:6:6: note: declared here
    6 |  int res[c.size()];
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...