답안 #246112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246112 2020-07-08T07:37:37 Z kshitij_sodani Bulldozer (JOI17_bulldozer) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
typedef long double ll;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
//#define endl '\n'
pair<ll,ll> it[2001];
llo cc[2001];
/*ll sl(llo aa,llo bb){
	return (it[aa].b-it[bb].b)/(it[aa].a-it[bb].a);
}*/
ll dist2(llo i,llo j){

	return (it[i].a-it[j].a)*(it[i].a-it[j].a)+(it[i].b-it[j].b)*(it[i].b-it[j].b);
}
/*ll sect(pair<ll,ll> aa,pair<ll,ll> bb,pair<ll,ll> cc,pair<ll,ll> dd){

	


}
*/
ll dist(llo k,llo i,llo j){
	//ll xx=(dist2(i,k)*dist2(i,k)-dist2(j,k)*dist2(j,k)+dist2(i,j)*dist2(i,j))/((ll)2*dist2(i,j));
	ll xx=(dist2(i,k)-dist2(j,k)+dist2(i,j))/((ll)2*sqrt(dist2(i,j)));
	///((ll)2*dist2(i,j));

//	cout<<dist2(i,k)<<","<<dist2(j,k)<<","<<dist2(i,j)<<"<"<<xx<<endl;
	return dist2(i,k)-xx*xx;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	llo n;
	cin>>n;
	llo ans=0;
	vector<ll,llo> ac;
	for(llo i=0;i<n;i++){

		cin>>it[i].a>>it[i].b;
		cin>>cc[i];
		ans=max(ans,cc[i]);
		ac.pb({it[i].a,cc[i]});
	}
	llo kk=0;
	sort(ac.begin(),ac.end());
	for(int i=0;i<n;i++){
		kk=max((llo)0,kk+ac[i].b);
		ans=max(ans,kk);
	}
	cout<<ans<<endl;
	return 0;

	
	
	for(llo i=0;i<n;i++){
		for(llo j=0;j<n;j++){
			if(j==i){
				continue;
			}
			vector<pair<ll,llo>> aa;
			vector<pair<ll,llo>> bb;
		//	cout<<i<<","<<j<<endl;
			for(llo k=0;k<n;k++){
				if(k==i or k==j){
					continue;
				}
				pair<ll,ll> v1;
				pair<ll,ll> v2;
				v1={it[j].a-it[i].a,it[j].b-it[i].b};
				v2={it[j].a-it[k].a,it[j].b-it[k].b};
				if(v1.a*v2.b-v2.b*v2.a>(ll)0){
					aa.pb({dist(k,i,j),cc[k]});
			//		cout<<dist(k,i,j)<<"::"<<k<<endl;
				}
				else{
					bb.pb({dist(k,i,j),cc[k]});
				}
			}
			sort(aa.begin(),aa.end());
			reverse(aa.begin(),aa.end());

			sort(bb.begin(),bb.end());
			aa.pb({0,cc[i]+cc[j]});
			for(auto j:bb){
				aa.pb(j);
			}
			llo cost=0;
			ans=max(ans,cost);
			for(auto jj:aa){
				cost+=jj.b;
				cost=max(cost,(llo)0);
				ans=max(ans,cost);
			}

			
		}
	}

	cout<<ans<<endl;
	/*it[10]={0,0};
	it[11]={3,0};
	it[12]={1.5,2};*/
	//cout<<dist(12,10,11)<<endl;






	return 0;
}

Compilation message

In file included from /usr/include/c++/7/ext/alloc_traits.h:36:0,
                 from /usr/include/c++/7/bits/basic_string.h:40,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 bulldozer.cpp:1:
/usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<long int>':
/usr/include/c++/7/ext/alloc_traits.h:50:10:   required from 'struct __gnu_cxx::__alloc_traits<long int>'
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from 'struct std::_Vector_base<long double, long int>'
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from 'class std::vector<long double, long int>'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/alloc_traits.h:88:43: error: 'long int' is not a class, struct, or union type
       typedef typename _Alloc::value_type value_type;
                                           ^~~~~~~~~~
/usr/include/c++/7/bits/alloc_traits.h:95:70: error: 'long int' is not a class, struct, or union type
       using pointer = __detected_or_t<value_type*, __pointer, _Alloc>;
                                                                      ^
/usr/include/c++/7/bits/alloc_traits.h:135:79: error: 'long int' is not a class, struct, or union type
       using const_pointer = typename _Ptr<__c_pointer, const value_type>::type;
                                                                               ^
/usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<long int>::_Ptr<std::__allocator_traits_base::__v_pointer, void, void>':
/usr/include/c++/7/bits/alloc_traits.h:143:66:   required from 'struct std::allocator_traits<long int>'
/usr/include/c++/7/ext/alloc_traits.h:50:10:   required from 'struct __gnu_cxx::__alloc_traits<long int>'
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from 'struct std::_Vector_base<long double, long int>'
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from 'class std::vector<long double, long int>'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/alloc_traits.h:102:71: error: 'long int' is not a class, struct, or union type
    using type = typename pointer_traits<pointer>::template rebind<_Tp>;
                                                                       ^
/usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<long int>::_Ptr<std::__allocator_traits_base::__cv_pointer, const void, void>':
/usr/include/c++/7/bits/alloc_traits.h:151:79:   required from 'struct std::allocator_traits<long int>'
/usr/include/c++/7/ext/alloc_traits.h:50:10:   required from 'struct __gnu_cxx::__alloc_traits<long int>'
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from 'struct std::_Vector_base<long double, long int>'
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from 'class std::vector<long double, long int>'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/alloc_traits.h:102:71: error: 'long int' is not a class, struct, or union type
/usr/include/c++/7/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<long int>':
/usr/include/c++/7/ext/alloc_traits.h:50:10:   required from 'struct __gnu_cxx::__alloc_traits<long int>'
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from 'struct std::_Vector_base<long double, long int>'
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from 'class std::vector<long double, long int>'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/alloc_traits.h:159:68: error: 'long int' is not a class, struct, or union type
       using difference_type = typename _Diff<_Alloc, pointer>::type;
                                                                    ^
/usr/include/c++/7/bits/alloc_traits.h:167:70: error: 'long int' is not a class, struct, or union type
       using size_type = typename _Size<_Alloc, difference_type>::type;
                                                                      ^
In file included from /usr/include/c++/7/bits/basic_string.h:40:0,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 bulldozer.cpp:1:
/usr/include/c++/7/ext/alloc_traits.h: In instantiation of 'struct __gnu_cxx::__alloc_traits<long int>':
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from 'struct std::_Vector_base<long double, long int>'
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from 'class std::vector<long double, long int>'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/ext/alloc_traits.h:66:23: error: no members matching '__gnu_cxx::__alloc_traits<long int>::_Base_type {aka std::allocator_traits<long int>}::allocate' in '__gnu_cxx::__alloc_traits<long int>::_Base_type {aka struct std::allocator_traits<long int>}'
     using _Base_type::allocate;
                       ^~~~~~~~
/usr/include/c++/7/ext/alloc_traits.h:67:23: error: no members matching '__gnu_cxx::__alloc_traits<long int>::_Base_type {aka std::allocator_traits<long int>}::deallocate' in '__gnu_cxx::__alloc_traits<long int>::_Base_type {aka struct std::allocator_traits<long int>}'
     using _Base_type::deallocate;
                       ^~~~~~~~~~
/usr/include/c++/7/ext/alloc_traits.h:70:23: error: no members matching '__gnu_cxx::__alloc_traits<long int>::_Base_type {aka std::allocator_traits<long int>}::max_size' in '__gnu_cxx::__alloc_traits<long int>::_Base_type {aka struct std::allocator_traits<long int>}'
     using _Base_type::max_size;
                       ^~~~~~~~
In file included from /usr/include/c++/7/ext/alloc_traits.h:36:0,
                 from /usr/include/c++/7/bits/basic_string.h:40,
                 from /usr/include/c++/7/string:52,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 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 bulldozer.cpp:1:
/usr/include/c++/7/bits/alloc_traits.h: In substitution of 'template<class _Alloc, class _Up> using __alloc_rebind = typename std::__allocator_traits_base::__rebind<_Alloc, _Up>::type [with _Alloc = long int; _Up = long double]':
/usr/include/c++/7/bits/alloc_traits.h:206:50:   required by substitution of 'template<class _Alloc> template<class _Tp> using rebind_alloc = std::__alloc_rebind<_Alloc, _Tp> [with _Tp = long double; _Alloc = long int]'
/usr/include/c++/7/ext/alloc_traits.h:117:65:   required from 'struct __gnu_cxx::__alloc_traits<long int>::rebind<long double>'
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from 'struct std::_Vector_base<long double, long int>'
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from 'class std::vector<long double, long int>'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/alloc_traits.h:76:79: error: no type named 'type' in 'struct std::__allocator_traits_base::__rebind<long int, long double, void>'
       = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type;
                                                                               ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from bulldozer.cpp:1:
/usr/include/c++/7/bits/stl_vector.h: In instantiation of 'class std::vector<long double, long int>':
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/stl_vector.h:247:20: error: no members matching 'std::vector<long double, long int>::_Base {aka std::_Vector_base<long double, long int>}::_M_allocate' in 'std::vector<long double, long int>::_Base {aka struct std::_Vector_base<long double, long int>}'
       using _Base::_M_allocate;
                    ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:248:20: error: no members matching 'std::vector<long double, long int>::_Base {aka std::_Vector_base<long double, long int>}::_M_deallocate' in 'std::vector<long double, long int>::_Base {aka struct std::_Vector_base<long double, long int>}'
       using _Base::_M_deallocate;
                    ^~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:250:20: error: no members matching 'std::vector<long double, long int>::_Base {aka std::_Vector_base<long double, long int>}::_M_get_Tp_allocator' in 'std::vector<long double, long int>::_Base {aka struct std::_Vector_base<long double, long int>}'
       using _Base::_M_get_Tp_allocator;
                    ^~~~~~~~~~~~~~~~~~~
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:46:24: error: no matching function for call to 'std::vector<long double, long int>::push_back(<brace-enclosed initializer list>)'
   ac.pb({it[i].a,cc[i]});
                        ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from bulldozer.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long double; _Alloc = long int; std::vector<_Tp, _Alloc>::value_type = long double]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const long double&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long double; _Alloc = long int; std::vector<_Tp, _Alloc>::value_type = long double]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<long double, long int>::value_type&& {aka long double&&}'
bulldozer.cpp:49:10: error: 'class std::vector<long double, long int>' has no member named 'begin'
  sort(ac.begin(),ac.end());
          ^~~~~
bulldozer.cpp:49:21: error: 'class std::vector<long double, long int>' has no member named 'end'
  sort(ac.begin(),ac.end());
                     ^~~
bulldozer.cpp:51:22: error: no match for 'operator[]' (operand types are 'std::vector<long double, long int>' and 'int')
   kk=max((llo)0,kk+ac[i].b);
                      ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from bulldozer.cpp:1:
/usr/include/c++/7/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = long double; _Alloc = long int]':
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/stl_vector.h:434:37: error: 'struct std::_Vector_base<long double, long int>::_Vector_impl' has no member named '_M_start'; did you mean '_M_swap_data'?
       { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
                       ~~~~~~~~~~~~~~^~~~~~~~
                       _M_swap_data
/usr/include/c++/7/bits/stl_vector.h:434:61: error: 'struct std::_Vector_base<long double, long int>::_Vector_impl' has no member named '_M_finish'
       { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
                                               ~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:435:28: error: '_M_get_Tp_allocator' was not declared in this scope
         _M_get_Tp_allocator()); }
         ~~~~~~~~~~~~~~~~~~~^~
/usr/include/c++/7/bits/stl_vector.h:435:28: note: suggested alternative: 'get_allocator'
         _M_get_Tp_allocator()); }
         ~~~~~~~~~~~~~~~~~~~^~
         get_allocator
/usr/include/c++/7/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = long double; _Alloc = long int]':
/usr/include/c++/7/bits/stl_vector.h:263:15:   required from 'std::vector<_Tp, _Alloc>::vector() [with _Tp = long double; _Alloc = long int]'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/stl_vector.h:162:37: error: 'struct std::_Vector_base<long double, long int>::_Vector_impl' has no member named '_M_start'; did you mean '_M_swap_data'?
       { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
                       ~~~~~~~~~~~~~~^~~~~~~~
                       _M_swap_data
/usr/include/c++/7/bits/stl_vector.h:162:61: error: 'struct std::_Vector_base<long double, long int>::_Vector_impl' has no member named '_M_end_of_storage'
       { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
                                               ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:163:25: error: 'struct std::_Vector_base<long double, long int>::_Vector_impl' has no member named '_M_start'; did you mean '_M_swap_data'?
         - this->_M_impl._M_start); }
           ~~~~~~~~~~~~~~^~~~~~~~
           _M_swap_data
/usr/include/c++/7/bits/stl_vector.h:162:22: error: '_M_deallocate' was not declared in this scope
       { _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         - this->_M_impl._M_start); }
         ~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = long double; _Alloc = long int]':
/usr/include/c++/7/bits/stl_vector.h:127:17:   required from 'std::_Vector_base<_Tp, _Alloc>::_Vector_base() [with _Tp = long double; _Alloc = long int]'
/usr/include/c++/7/bits/stl_vector.h:263:15:   required from 'std::vector<_Tp, _Alloc>::vector() [with _Tp = long double; _Alloc = long int]'
bulldozer.cpp:40:17:   required from here
/usr/include/c++/7/bits/stl_vector.h:89:65: error: using invalid field 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_M_start'
  : _Tp_alloc_type(), _M_start(), _M_finish(), _M_end_of_storage()
                                                                 ^
/usr/include/c++/7/bits/stl_vector.h:89:65: error: using invalid field 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_M_finish'
/usr/include/c++/7/bits/stl_vector.h:89:65: error: using invalid field 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_M_end_of_storage'