Submission #827001

# Submission time Handle Problem Language Result Execution time Memory
827001 2023-08-16T07:54:20 Z tigran Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"

#include <bits/stdc++.h>
vector<int> st;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    int n = c.size();
    std::vector<int> s(n);
	int q = l.size();
	int V = 0;
	for (int i = 0; i < v.size(); i++){
		V += v[i];
	}
	for (int i = 0; i < n; i++){
		s[i] = min(c[i], V);
	}
	return s;
}

Compilation message

candies.cpp:4:1: error: 'vector' does not name a type
    4 | vector<int> st;
      | ^~~~~~
candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for (int i = 0; i < v.size(); i++){
      |                  ~~^~~~~~~~~~
candies.cpp:15:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   15 |   s[i] = min(c[i], V);
      |          ^~~
      |          std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:9:6: warning: unused variable 'q' [-Wunused-variable]
    9 |  int q = l.size();
      |      ^