Submission #431123

# Submission time Handle Problem Language Result Execution time Memory
431123 2021-06-17T09:51:31 Z A_D Carnival Tickets (IOI20_tickets) C++14
Compilation error
0 ms 0 KB
#include "tickets.h"
#include <bits/stdc++.h>
using namespace std;
long long find_maximum(int k,vector<vector<int>>x){
	vector<vector<int>> ans;
	vector<int> vec;
	for(int i=0;i<x[0].size();i++){
        vec.push_back(0);
	}
	ans.push_back(vec);
	allocate_tickets(ans);
	vec.clear();
	for(int i=0;i<x[0].size();i++){
        vec.push_back(x[i]);
	}
	sort(vec.begin(),vec.end());
	int sz=x[0].size();
	long long ann=0;
	for(int i=0;i<sz/2;i++){
        ann-=vec[i];
	}
	for(int i=sz;i<vec.size();i++){
        ann+=vec[i];
	}
	return ann;
}

Compilation message

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.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<x[0].size();i++){
      |              ~^~~~~~~~~~~~
tickets.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<x[0].size();i++){
      |              ~^~~~~~~~~~~~
tickets.cpp:14:27: error: no matching function for call to 'std::vector<int>::push_back(__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type&)'
   14 |         vec.push_back(x[i]);
      |                           ^
In file included from /usr/include/c++/10/vector:67,
                 from tickets.h:1,
                 from tickets.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
tickets.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=sz;i<vec.size();i++){
      |               ~^~~~~~~~~~~