Submission #82059

# Submission time Handle Problem Language Result Execution time Memory
82059 2018-10-28T21:12:52 Z wzy Boxes with souvenirs (IOI15_boxes) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "boxes.h"
using namespace std;
#define F first
#define S second
long long dpL[10000001] , dpR[10000001]; 

long long delivery(int N, int K, int L, int p[]) {
	#define int long long 
	int ans = (int) 1e18;
	int k = K;
	int n = N;
	int l = L;
	for(int i = 0 ; i < N ;i ++){
		dpL[i] = 2*p[i];
		if(i >= K) dpL[i] = dpL[i-k] + 2*p[i]; // pick the last block and then solve for [0 , i-k]
	}
	for(int j = N - 1 ; j >= 0 ; j--){
		int u = j + K ;
		dpR[j] = 2*(L - p[j]);
		if(u <= n - 1) dpR[j] = dpR[u] + 2*(L - p[j]); 
	}
	#define pii pair<long long, long long> 
	deque<pii> dq;
	int left = 1;
	for(int i = 0 ; i < N  - 1; i ++){
		while(dq.size() && dq.front().second <= i) dq.pop_front();
		left = max(left, i + 1);
		while(left < N && k >= (left - i - 1)){
			while(dq.size() && dq.back().first >= dpR[left]) dq.pop_back();
			dq.push_back(pii(dpR[left] , left));
			left++;
		}
		ans = min(ans , dpL[i] + dpR[i+1]);
		ans = min(ans , dpL[i] + dq.front().F + L);
	}
	for(int i = 0 ; i < N ; i ++){
		int X = n - i - 1;
		if(X <= k){
			ans = min(ans , dpL[i] + L);
		}
		int Y = i;
		if(Y <= k) ans = min(ans , dpR[i] + L);
	}
	ans = min(ans , dpL[N - 1]);
	ans = min(ans , dpR[0]);
    if(K == N){
    	ans = min(ans ,L);
    }
    return ans;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:48:22: error: no matching function for call to 'min(long long int&, int&)'
      ans = min(ans ,L);
                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:48:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
      ans = min(ans ,L);
                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:48:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
      ans = min(ans ,L);
                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:48:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
      ans = min(ans ,L);
                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:48:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
      ans = min(ans ,L);
                      ^
boxes.cpp:13:6: warning: unused variable 'l' [-Wunused-variable]
  int l = L;
      ^