답안 #365246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365246 2021-02-11T10:13:52 Z Meloric Just Long Neckties (JOI20_ho_t1) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()

using namespace std;

const int inf  = 1e18;

void p(vector<int>& A){
	//for(auto e : A)cout << e << ' ';
	//cout << '\n';
}
void solve(){
	int n; cin >> n;
	vector<pii>A(n+1);
	vector<int>B(n);
	for(int i = 0; i< n+1; i++)cin >> A[i].X, A[i].Y = i;
	for(int i = 0; i< n; i++)cin >> B[i];
	
	sort(all(A));
	sort(all(B));
	
	vector<int> pref(n), suff(n);
	for(int i = 0; i< n; i++)pref[i] = max(A[i].X-B[i], 0ll);
	for(int i = 0; i< n; i++)suff[i] = max(A[i+1].X-B[i], 0ll);
	p(pref);p(suff);
	
	for(int i = 1; i< n; i++)pref[i] = max(pref[i], pref[i-1]);
	for(int i = n-2; i>=0; i--)suff[i] = max(suff[i], suff[i+1]);
	
	p(pref);p(suff);
	
	vector<int> ans(n+1);
	ans[A[0].Y] = suff[0];
	ans[A[n].Y] = pref[n-1];
	
	for(int i = 1; i< n; i++){
		ans[A[i].Y] = max(pref[i-1], suff[i]);
		//cout << A[i].Y << ' ';
	}
	//cout << '\n';
	for(auto e : ans)cout << e << ' ';
}

	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int t = 1;
	//cin >> t;
	while(t--)solve();
}

Compilation message

ho_t1.cpp: In function 'void solve()':
ho_t1.cpp:28:57: error: no matching function for call to 'max(long int, long long int)'
   28 |  for(int i = 0; i< n; i++)pref[i] = max(A[i].X-B[i], 0ll);
      |                                                         ^
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/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:28:57: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   28 |  for(int i = 0; i< n; i++)pref[i] = max(A[i].X-B[i], 0ll);
      |                                                         ^
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/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:28:57: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   28 |  for(int i = 0; i< n; i++)pref[i] = max(A[i].X-B[i], 0ll);
      |                                                         ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:28:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   28 |  for(int i = 0; i< n; i++)pref[i] = max(A[i].X-B[i], 0ll);
      |                                                         ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:28:57: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   28 |  for(int i = 0; i< n; i++)pref[i] = max(A[i].X-B[i], 0ll);
      |                                                         ^
ho_t1.cpp:29:59: error: no matching function for call to 'max(long int, long long int)'
   29 |  for(int i = 0; i< n; i++)suff[i] = max(A[i+1].X-B[i], 0ll);
      |                                                           ^
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/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:29:59: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   29 |  for(int i = 0; i< n; i++)suff[i] = max(A[i+1].X-B[i], 0ll);
      |                                                           ^
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/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:29:59: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   29 |  for(int i = 0; i< n; i++)suff[i] = max(A[i+1].X-B[i], 0ll);
      |                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:29:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   29 |  for(int i = 0; i< n; i++)suff[i] = max(A[i+1].X-B[i], 0ll);
      |                                                           ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from ho_t1.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
ho_t1.cpp:29:59: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   29 |  for(int i = 0; i< n; i++)suff[i] = max(A[i+1].X-B[i], 0ll);
      |                                                           ^