Submission #389132

#TimeUsernameProblemLanguageResultExecution timeMemory
389132PedroBigManBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h"
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 1000000000000000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=1000000007LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

ll delivery(int n, int k, int l, int pos[]) 
{
    ll N = (ll) n; ll K = (ll) k; ll L = (ll) l; vector<ll> p; REP(i,0,N) {p.pb((ll) pos[i]);}
	vector<ll> h1,h2; ll newN=0LL;
	REP(i,0,N) 
	{
		if(p[i]==0) {continue;}
		newN++;
		if(p[i]<=(L-1LL)/2LL) {h1.pb(p[i]);}
		else if(p[i]>=(L+2LL)/2LL) {h2.pb(L-p[i]);}
	}
	N=newN;
	ll N1=h1.size(); ll N2 = h2.size(); sort(whole(h1)); sort(whole(h2));
	vector<ll> dp1,dp2; dp1.pb(0LL); dp2.pb(0LL);
	REP(i,0,N1)
	{
		if(i<K) {dp1.pb(2LL*h1[i]);}
		else {dp1.pb(2LL*h1[i]+dp1[i-K+1]);}
	}
	REP(i,0,N2)
	{
		if(i<K) {dp2.pb(2LL*h2[i]);}
		else {dp2.pb(2LL*h2[i]+dp2[i-K+1]);}
	}
	while(dp1.size()<=N) {dp1.pb(INF);} while(dp2.size()<=N) {dp2.pb(INF);}
	vector<ll> minyet; 
	vector<ll> y; 
	REP(i,0,N+1) 
	{
		y.pb(K*dp2[i]-i*L);
		if(i<K) {minyet.pb(y[i]);} else {minyet.pb(min(y[i],minyet[i-K]));}
	}
	vector<ll> f; 
	REP(S,0,N+1) 
	{
		f.pb(min((S*L+minyet[S])/K),L*((S-K+1LL)/K)); 
	}
	ll ans = INF;
	REP(i,0,N+1)
	{
		ans=min(ans,f[i]+dp1[N-i]);
	}
	return ans;
}

Compilation message (stderr)

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:69:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   69 |  while(dp1.size()<=N) {dp1.pb(INF);} while(dp2.size()<=N) {dp2.pb(INF);}
      |        ~~~~~~~~~~^~~
boxes.cpp:69:54: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   69 |  while(dp1.size()<=N) {dp1.pb(INF);} while(dp2.size()<=N) {dp2.pb(INF);}
      |                                            ~~~~~~~~~~^~~
boxes.cpp:80:29: error: no matching function for call to 'min(ll)'
   80 |   f.pb(min((S*L+minyet[S])/K),L*((S-K+1LL)/K));
      |                             ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from boxes.cpp:6:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
boxes.cpp:80:29: note:   candidate expects 2 arguments, 1 provided
   80 |   f.pb(min((S*L+minyet[S])/K),L*((S-K+1LL)/K));
      |                             ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from boxes.cpp:6:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
boxes.cpp:80:29: note:   candidate expects 3 arguments, 1 provided
   80 |   f.pb(min((S*L+minyet[S])/K),L*((S-K+1LL)/K));
      |                             ^
In file included from /usr/include/c++/9/algorithm:62,
                 from boxes.cpp:9:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
boxes.cpp:80:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   80 |   f.pb(min((S*L+minyet[S])/K),L*((S-K+1LL)/K));
      |                             ^
In file included from /usr/include/c++/9/algorithm:62,
                 from boxes.cpp:9:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:80:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   80 |   f.pb(min((S*L+minyet[S])/K),L*((S-K+1LL)/K));
      |                             ^