답안 #937863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
937863 2024-03-04T15:43:24 Z Litusiano Self Study (JOI22_ho_t2) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

vector<pair<int,int>> v;
int n,m;
bool check(int mid){
	vector<int> need(n);
	int left = 0;
	for(int i = 0; i<n; i++){
		int z = max(v[i].first, v[i].second);
		int k = (mid+z-1)/z;
		if(k > m) need[i] = mid-(m * z);
		else left+=m-k;
	}
	for(int i = 0; i<n; i++){
		left -= (need[i] + v[i].second - 1)/v[i].second;	
	}
	return left>=0;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	v.resize(n);
	for(auto& x : v) cin>>x.first;
	for(auto& x : v) cin>>x.second;
	int ans = LLONG_MAX;
	for(auto i : v){
		ans = min(ans,max(v[i].first,v[i].second));
	}
	cout<<ans<<endl;
	return 0;
	int l = 0; int r = 1e18;
	while(r > l+1){
		int mid = (l+r)/2;
		if(check(mid)) l = mid;
		else r = mid;
	}
	cout<<l<<endl;
}	

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:32:22: error: no match for 'operator[]' (operand types are 'std::vector<std::pair<long long int, long long int> >' and 'std::pair<long long int, long long int>')
   32 |   ans = min(ans,max(v[i].first,v[i].second));
      |                      ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::reference = std::pair<long long int, long long int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::const_reference = const std::pair<long long int, long long int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
Main.cpp:32:33: error: no match for 'operator[]' (operand types are 'std::vector<std::pair<long long int, long long int> >' and 'std::pair<long long int, long long int>')
   32 |   ans = min(ans,max(v[i].first,v[i].second));
      |                                 ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::reference = std::pair<long long int, long long int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::const_reference = const std::pair<long long int, long long int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~