Submission #480613

# Submission time Handle Problem Language Result Execution time Memory
480613 2021-10-17T12:44:37 Z Haidara Distributing Candies (IOI21_candies) C++17
0 / 100
87 ms 6452 KB
#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

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 time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 6452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -