Submission #406476

# Submission time Handle Problem Language Result Execution time Memory
406476 2021-05-17T16:02:40 Z victoriad Jelly Flavours (IOI20_jelly) C++14
Compilation error
0 ms 0 KB
#include "jelly.h"
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <iomanip>
#include <stack>
#include <fstream>
using namespace std;
 
int ma,mb;
 
int maxi(int x, int y, std::vector<int> a, std::vector<int> b,int nodo,int r){
	if(nodo==a.size() || x<ma && y<mb ||r==a.size()){
		return r;
	}
	else{
		if(a[nodo]<=x && b[nodo]<=y){
			return max(maxi(x-a[nodo],y,a,b,nodo+1,r+1),max(maxi(x,y-b[nodo],a,b,nodo+1,r+1),maxi(x,y,a,b,nodo+1,r)));
		}
		else if(a[nodo]<=x){
			return max(maxi(x-a[nodo],y,a,b,nodo+1,r+1),maxi(x,y,a,b,nodo+1,r));
		}
		else if(b[nodo]<=y){
			return max(maxi(x,y-b[nodo],a,b,nodo+1,r+1),maxi(x,y,a,b,nodo+1,r));
		}
		else{
			return maxi(x,y,a,b,nodo+1,r);
		}
	}
}
int find_maximum_unique(int x, int y, std::vector<int> a, std::vector<int> b) {
	int n = a.size();
	ma=min_element(a[0],a[n-1]);
	mb=min_element(b[0],b[n-1]);
	return maxi(x,y,a,b,0,0);
}

Compilation message

jelly.cpp: In function 'int maxi(int, int, std::vector<int>, std::vector<int>, int, int)':
jelly.cpp:18:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  if(nodo==a.size() || x<ma && y<mb ||r==a.size()){
      |     ~~~~^~~~~~~~~~
jelly.cpp:18:28: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   18 |  if(nodo==a.size() || x<ma && y<mb ||r==a.size()){
      |                       ~~~~~^~~~~~~
jelly.cpp:18:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  if(nodo==a.size() || x<ma && y<mb ||r==a.size()){
      |                                      ~^~~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:71,
                 from /usr/include/c++/10/vector:60,
                 from jelly.h:1,
                 from jelly.cpp:1:
/usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]':
/usr/include/c++/10/bits/stl_algo.h:5636:12:   required from 'constexpr _ForwardIterator std::__min_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/10/bits/stl_algo.h:5660:43:   required from 'constexpr _FIter std::min_element(_FIter, _FIter) [with _FIter = int]'
jelly.cpp:38:28:   required from here
/usr/include/c++/10/bits/predefined_ops.h:43:16: error: invalid type argument of unary '*' (have 'int')
   43 |       { return *__it1 < *__it2; }
      |                ^~~~~~
/usr/include/c++/10/bits/predefined_ops.h:43:25: error: invalid type argument of unary '*' (have 'int')
   43 |       { return *__it1 < *__it2; }
      |                         ^~~~~~