submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s919763242
p03734
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n,wm; cin >> n >> wm; vector<vector<int>> a(4); int w; cin >> w; int v; cin >> v; a[0].push_back(v); for(int i=1;i<n;i++){ int ww; cin >> ww >> v; a[ww-w].push_back(v); } for(int i=0;i<4;i++) sort(a[i].begin(),a[i].end(), greater<int>()); int ans = 0; for(int i=1;i<=a[0].size();i++) for(int j=1;j<=a[1].size();j++) for(int k=1;k<=a[2].size();k++) for(int l=1;l<=a[3].size();m++){ if(i*w + j*(w+1) + k*(w+2) + l*(w+3) <= wm){ int sum=0; for(int m=0;m<i;m++) sum+=a[0][m]; for(int m=0;m<j;m++) sum+=a[1][m]; for(int m=0;m<k;m++) sum+=a[2][m]; for(int m=0;m<l;m++) sum+=a[3][m]; ans = max(ans,sum); } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:36: error: 'm' was not declared in this scope 19 | for(int l=1;l<=a[3].size();m++){ | ^
s167937005
p03734
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n,wm; cin >> n >> wm; vector<vector<int>> a(4); int w; cin >> w; int v; cin >> v; a[0].push_back(v); for(int i=1;i<n;i++){ int ww; cin >> ww >> v; a[ww-w].push_back(v); } for(int i=0;i<4;i++) sort(a[i].begin(),a[i].end(), greater<int>()); int ans = 0; for(int i=1;i<=a[0].begin();i++) for(int j=1;j<=a[1].begin();j++) for(int k=1;k<=a[2].begin();k++) for(int l=1;l<=a[3].begin();l++){ if(i*w + j*(w+1) + k*(w+2) + l*(w+3) > wm) break; int sum=0; for(int m=0;m<i;m++) sum+=a[0][m]; for(int m=0;m<j;m++) sum+=a[1][m]; for(int m=0;m<k;m++) sum+=a[2][m]; for(int m=0;m<l;m++) sum+=a[3][m]; ans = max(ans,sum); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:16: error: no match for 'operator<=' (operand types are 'int' and 'std::vector<int>::iterator') 16 | for(int i=1;i<=a[0].begin();i++) | ~^~~~~~~~~~~~~~ | | | | int std::vector<int>::iterator In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1154:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1154 | operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1154:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/regex.h:1260:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1260 | operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1260:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/regex.h:1353:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1353 | operator<=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1353:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/regex.h:1427:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1427 | operator<=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1427:5: note: template argument deduction/substitution failed: a.cc:16:29: note: 'std::vector<int>::iterator' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/regex.h:1521:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1521 | operator<=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1521:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/regex.h:1599:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1599 | operator<=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1599:5: note: template argument deduction/substitution failed: a.cc:16:29: note: 'std::vector<int>::iterator' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/regex.h:1699:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1699 | operator<=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1699:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1064:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1064 | operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1064:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:469:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 469 | operator<=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:469:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/stl_iterator.h:513:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 513 | operator<=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:513:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1704:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1704 | operator<=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1704:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1767:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1767 | operator<=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1767:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:717:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 717 | operator<=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:717:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/string_view:724:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 724 | operator<=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:724:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/string_view:732:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 732 | operator<=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:732:5: note: template argument deduction/substitution failed: a.cc:16:29: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/basic_string.h:3956:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3956 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3956:5: note: template argument deduction/substitution failed: a.cc:16:29: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 16 | for(int i=1;i<=a[0].begin();i++) | ^ /usr/include/c++/14/bits/basic_string.h:3970:5: note:
s975520948
p03734
C++
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <string> #include <sstream> #include <complex> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #include <array> #include <tuple> #include <random> using namespace std; typedef long long int ll; #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for(ll i = int(a); i < int(b); i++) #define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define const INF 10000000000 int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n, w, wtmp; cin >> n >> w; vector<ll> st[4]; rep(i, n){ ll weight, value; cin >> weight >> value; if(i == 0){ wtmp = weight; } st[w - wtmp].push_back(value); } for(i, 4) { sort(all(st[i])); st[i].push_back(0); reverse(all(st[i])); rep(j, 1, st[i].size()){ st[i][j] += st[i][j - 1]; } } ll ans = 0; rep(i, st[0].size()){ rep(j, st[1].size()){ rep(k, st[2].size()){ rep(l, st[3].size()){ ll fact = wtmp * i + (wtmp + 1) * j + (wtmp + 2) * k + (wtmp + 3) * l; if(fact <= w) { ans = max(ans, st[0][i] + st[1][j] + st[2][k] + st[3][l]); } } } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:48:9: error: 'i' was not declared in this scope 48 | for(i, 4) { | ^ a.cc:26:23: error: expected primary-expression before 'for' 26 | #define repi(i, a, b) for(ll i = int(a); i < int(b); i++) | ^~~ a.cc:25:20: note: in expansion of macro 'repi' 25 | #define _rep(i, n) repi(i, 0, n) | ^~~~ a.cc:24:43: note: in expansion of macro '_rep' 24 | #define _overload3(_1, _2, _3, name, ...) name | ^~~~ a.cc:27:18: note: in expansion of macro '_overload3' 27 | #define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__) | ^~~~~~~~~~ a.cc:58:5: note: in expansion of macro 'rep' 58 | rep(i, st[0].size()){ | ^~~ a.cc:57:16: error: expected ')' before 'for' 57 | ll ans = 0; | ^ | ) a.cc:48:8: note: to match this '(' 48 | for(i, 4) { | ^ a.cc:71:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 71 | cout << ans << endl; | ^~~ | abs
s189284085
p03734
C++
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> using namespace std; //conversion //------------------------------------------ inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; } template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); } //math //------------------------------------------- template<class T> inline T sqr(T x) { return x*x; } //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; //container util //------------------------------------------ #define ALL(b) (b).begin(),(b).end() #define RALL(b) (b).rbegin(), (b).rend() #define PB push_back #define MP make_pair #define SZ(b) int((b).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,b,d) for(int i=(b);i<(d);++i) #define REP(i,n) FOR(i,0,n) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); //clear memory #define CLR(b) memset((b), 0 ,sizeof(b)) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; int main() { int N, W; cin >> N >> W; vector<LL> w(N), v(N); REP(i, N) cin >> w[i] >> v[i]; vector<vector<LL>> dp(N + 1); REP(i, N + 1) { dp[i] = VI(W+1); REP(j, W + 1) dp[i][j] = 0; } dp[0][0] = 0; REP(i, N) REP(j, W + 1) if (j >= w[i]) dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]); else dp[i+1][j] = dp[i][j]; cout << dp[N][W] << endl; return 0; }
a.cc: In function 'int main()': a.cc:79:31: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and 'VI' {aka 'std::vector<int>'}) 79 | dp[i] = VI(W+1); | ^ In file included from /usr/include/c++/14/vector:72, from a.cc:3: /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'VI' {aka 'std::vector<int>'} to 'const std::vector<long long int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66: /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'VI' {aka 'std::vector<int>'} to 'std::vector<long long int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'VI' {aka 'std::vector<int>'} to 'std::initializer_list<long long int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
s671443415
p03734
C++
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include<cmath> #include<cstdlib> #include<queue> #include<ctime> #include<vector> #include<set> #include<map> #include<stack> using namespace std; #define sp cout<<"---------------------------------------------------"<<endl int dp[110][110][310],w[110],v[110]; int main(){ int n,m,i,j,k; cin>>n>>m; for(i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]); for(i=1;i<=n;i++) for(j=1;j<=i;j++) for(k=0;k<=3*i;k++){ dp[i][j][k]=mak(dp[i][j][k],dp[i-1][j][k]); if(k>=w[i]-w[1]) dp[i][j][k]=max(dp[i][j][k],dp[i-1][j-1][k-(w[i]-w[1])]+v[i]); } int ans=0; for(i=1;i<=n;i++) for(j=0;j<=i*3;j++) if(i*w[1]+j<=m) ans=max(ans,dp[n][i][j]); cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:26:29: error: 'mak' was not declared in this scope 26 | dp[i][j][k]=mak(dp[i][j][k],dp[i-1][j][k]); | ^~~
s569103385
p03734
C++
#include<bits/stdc++.h> const int INF = 1e9; const int MOD = 1e9+7; using LL = long long; const LL LINF = 1e18; using namespace std; #define COUT(v) cout<<(v)<<endl #define CIN(n) int(n);cin >> (n) #define YES(n) cout<<((n)? "YES" : "NO")<<endl #define Yes(n) cout<<((n)? "Yes" : "No")<<endl #define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl #define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) <<endl #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) for(int i=0;i<(n);++i) #define REPR(i,n) for(int i=n;i>=0;i--) #define FOREACH(x,a) for(auto& (x) : (a) ) #define ALL(obj) (obj).begin(),(obj).end() #define P pair<int,int> #define I vector<int> #define S set<int> #define pb(v) push_back(v) #define V vector #define rt return #define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end()) class Edge{ public: int from,to,value; Edge(int a,int b,int c){ from = a; to = b; value = c; } Edge(int a,int b){ from = a; to = b; } }; int main(){ CIN(N);CIN(W); V<pair<LL,LL>> vec1,vec2,vec3,vec4; CIN(B);CIN(C); vec1.pb(make_pair(C,B)); LL ans = 0; REP(a,N-1){ CIN(D);CIN(E); if(D-B==0){ vec1.pb(make_pair(E,D)); }else if(D-B==1){ vec2.pb(make_pair(E,D)); }else if(D-B==2){ vec3.pb(make_pair(E,D)); }else{ vec4.pb(make_pair(E,D)); } } if(vec1.empty())vec1.pb(make_pair(0,0)); if(vec2.empty())vec2.pb(make_pair(0,0)); if(vec3.empty())vec3.pb(make_pair(0,0)); if(vec4.empty())vec4.pb(make_pair(0,0)); sort(ALL(vec1)); sort(ALL(vec2)); sort(ALL(vec3)); sort(ALL(vec4)); reverse(ALL(vec1)); reverse(ALL(vec2)); reverse(ALL(vec3)); reverse(ALL(vec4)); //COUT(vec1.size()); //COUT(vec2.size()); //COUT(vec3.size()); //COUT(vec4.size()); REP(a,vec1.size()+1){ REP(b,vec2.size()+1){ REP(c,vec3.size()+1){ REP(d,vec4.size()+1){ LL ins = 0; //COUT(a*vec1.front().second+b*vec2.front().second+c*vec3.front().second+d*vec4.front().second); if(a*vec1.front().second+b*vec2.front().second+c*vec3.front().second+d*vec4.front().second > W)continue; REP(e,a){ ins+=vec1.at(e).first; } REP(f,b){ ins+=vec2.at(f).first; } REP(g,c){ ins+=vec3.at(g).first; } REP(h,d){ ins+=vec4.at(h).first; } ans = max(ins,ans,0LL); //cout<<a*vec1.front().second+b*vec2.front().second+c*vec3.front().second+d*vec4.front().second<<" "<<ins<<endl; } } } } COUT(ans); return 0; }
In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]': a.cc:95:30: required from here 95 | ans = max(ins,ans,0LL); | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function 306 | if (__comp(__a, __b)) | ~~~~~~^~~~~~~~~~
s757198035
p03734
C++
#include <iostream> #include <vector> using namespace std; int dp(int, int); int n, w; int* ws2; int* vs2; int* d; int** vis; int main() { cin >> n >> w; ws2 = new int[n]; vs2 = new int[n]; d = new int[w+1]; for (int i = 0; i < n; i++) { cin >> ws2[i] >> vs2[i]; } for (int i = 0; i < w+1; i++) { d[i] = -1; } vis = new int*[w]; for (int i = 0; i < w; i++) { vis[i] = new int[n]; for (int j = 0; j < n; j++) { vis[i][j] = 0; } } int ans = dp(n, w); cout << ans << endl; } int dp(int layer, int curw) { int& ans = d[curw]; if (ans >= 0) { return ans; } if (layer < 0) { return 0;} ans = 0; for (int i = 0; i < n; i++) { if (curw - ws2[i] >= 0) { if (vis[curw - ws2[i]][i] == 0) { vis[curw-ws[i]][i]] = 1; ans = max(dp(layer-1, curw), dp(layer-1, curw - ws2[i]) + vs2[i]); } } return ans; }
a.cc: In function 'int dp(int, int)': a.cc:43:18: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 43 | vis[curw-ws[i]][i]] = 1; | ^ a.cc:48:2: error: expected '}' at end of input 48 | } | ^ a.cc:35:29: note: to match this '{' 35 | int dp(int layer, int curw) { | ^ a.cc:48:2: warning: control reaches end of non-void function [-Wreturn-type] 48 | } | ^
s702082228
p03734
C++
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <set> #include <stack> #include <queue> using namespace std;   int n,W,v[101],w[101],dp[101][100000001];   int solve(int i,int sum){ if(sum<0)return 0; if(i==n)return 0; if(dp[i][W-sum]!=0)return dp[i][W-sum]; else{ dp[i][W-sum]=solve(i+1,sum); if(sum-w[i]>=0){ dp[i][W-sum]=max(solve(i+1,sum),solve(i+1,sum-w[i])+v[i]); } return dp[i][W-sum]; } }   int main(void){ cin>>n>>W; for(int i=0;i<n;i++){ cin>>w[i]>>v[i]; } cout<<solve(0,W)<<endl; return 0; }
a.cc:9:1: error: extended character   is not valid in an identifier 9 |   | ^ a.cc:11:1: error: extended character   is not valid in an identifier 11 |   | ^ a.cc:24:1: error: extended character   is not valid in an identifier 24 |   | ^ a.cc:9:1: error: '\U000000a0' does not name a type 9 |   | ^ a.cc:11:1: error: '\U000000a0' does not name a type 11 |   | ^ a.cc:24:1: error: '\U000000a0' does not name a type 24 |   | ^
s428594717
p03734
C++
#include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; #define int long long int DP[101][101][1000]; signed main() { int N, W; cin >> N >> W; vector<int>w(N), v(N); for (int i = 0; i < N; i++) { cin >> w[i] >> v[i]; } int w0 = w[0]; for (int i = 0; i < N; i++) w[i] -= w0; for (int i = 0; i <= N; i++)for (int j = 0; j <= N; j++)for (int k = 0; k < 1000; k++)DP[i][j][k] = -1; DP[0][0][0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { for (int k = 0; k < 500; k++) { if (DP[i][j][k] == -1)continue; DP[i + 1][j + 1][k + w[i]] = max(DP[i + 1][j + 1][k + w[i]], DP[i][j][k] + v[i]); DP[i + 1][j][k] = max(DP[i + 1][j][k], DP[i][j][k]); } } } int ans = 0; for (int i = 0; i <= N; i++) { for (int j = 0; j <= min(500,W - w0*i); j++) { ans = max(ans, DP[N][i][j]); } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:35:41: error: no matching function for call to 'min(int, long long int)' 35 | for (int j = 0; j <= min(500,W - w0*i); j++) { | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:35:41: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 35 | for (int j = 0; j <= min(500,W - w0*i); j++) { | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:35:41: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 35 | for (int j = 0; j <= min(500,W - w0*i); j++) { | ~~~^~~~~~~~~~~~~~
s860474126
p03734
C++
#include <iostream> using namespace std; // A utility function that returns maximum of two integers int max(int a, int b) { return (a > b) ? a : b; } // Returns the maximum value that can be put in a knapsack of capacity W int knapSack(int W, int wt[], int val[], int n) { int i, w; int K[n + 1][W + 1]; // Build table K[][] in bottom up manner for (i = 0; i <= n; i++) { for (w = 0; w <= W; w++) {
a.cc: In function 'int knapSack(int, int*, int*, int)': a.cc:41:10: error: expected '}' at end of input 41 | { | ~^ a.cc:41:10: error: expected '}' at end of input a.cc:37:5: note: to match this '{' 37 | { | ^ a.cc:41:10: error: expected '}' at end of input 41 | { | ^ a.cc:25:1: note: to match this '{' 25 | { | ^ a.cc:41:10: warning: no return statement in function returning non-void [-Wreturn-type] 41 | { | ^
s163562719
p03734
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #include<assert.h> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef ll Def; typedef pair<Def,Def> pii; typedef vector<Def> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef vector<vd> vvd; typedef pair<Def,pii> pip; typedef vector<pip>vip; //#define mt make_tuple //typedef tuple<double,int,double> tp; //typedef vector<tp> vt; template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;} template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;} const double PI=acos(-1); const double EPS=1e-7; Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9; int dx[]={0,1,0,-1}; int dy[]={1,0,-1,0}; int main(){ int n,m; cin>>n>>m; ll out=0; vp in(n); rep(i,n)cin>>in[i].first>>in[i].second; ll t=in[0].first; rep(i,n)in[i].first-=t; rep(i,n+1){ ll w=m-i*t; if(w<0)continue; vvi dp(i+1,vi(500)); rep(j,n)for(int k=i-1;k>=0;k--)rep(l,500)if(l+in[j].first<500) dp[k+1][l+in[j].first]=max(dp[k+1][l+in[j].first],dp[k][l]+in[j].second); ll ma=0; // rep(j,w+1)cout<<" "<<dp[j];cout<<endl; rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]); out=max(out,ma); } cout<<out<<endl; }
a.cc:70:1: error: unterminated argument list invoking macro "rep" 70 | | ^ a.cc: In function 'int main()': a.cc:61:17: error: 'rep' was not declared in this scope 61 | rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]); | ^~~ a.cc:61:20: error: expected '}' at end of input 61 | rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]); | ^ a.cc:53:19: note: to match this '{' 53 | rep(i,n+1){ | ^ a.cc:61:20: error: expected '}' at end of input 61 | rep(j,min(w+1,500LL)ma=max(ma,dp[i][j]); | ^ a.cc:45:11: note: to match this '{' 45 | int main(){ | ^
s192719465
p03734
C++
1.#include<iostream> 2.#include<algorithm> 3.#include<vector> 4.using LL = long long; 5.LL N,w; 6.LL W, V; 7.LL size[4],ww[4]; 8.LL ans; 9.std::vector<LL> dp[4]; 10.void value(LL x, LL y, LL z, LL q) { 11. LL sum = 0; 12. for (LL aa = 0; aa < x; aa++) { 13. sum += dp[0][aa]; 14. } 15. for (LL aa = 0; aa < y; aa++) { 16. sum += dp[1][aa]; 17. } 18. for (LL aa = 0; aa < z; aa++) { 19. sum += dp[2][aa]; 20. } 21. for (LL aa = 0; aa < q; aa++) { 22. sum += dp[3][aa]; 23. } 24. ans = std::max(ans, sum); 25. sum = 0; 26.} 27.void solve() { 28. for (LL i = 0; i <= size[0]; i++) { 29. for (LL j = 0; j <= size[1]; j++) { 30. for (LL k = 0; k <= size[2]; k++) { 31. for (LL l = 0; l <= size[3]; l++) { 32. ww[0] = i*w; 33. ww[1] = j*(w + 1); 34. ww[2] = k*(w + 2); 35. ww[3] = l*(w + 3); 36. if ((ww[0] + ww[1] + ww[2] + ww[3]) <= W) { 37. value(i, j, k, l); 38. } 39. } 40. } 41. } 42. } 43.} 44.int main() { 45. std::cin >> N >> W; 46. std::cin >> w>> V; 47. dp[0].push_back(V); 48. for (LL i = 1; i < N; i++) { 49. LL tmp,Q; 50. std::cin >> tmp >> Q; 51. dp[tmp-w].push_back(Q); 52. } 53. for (LL i = 0; i < 4; i++) { 54. std::sort(dp[i].begin(), dp[i].end()); 55. size[i] = dp[i].size(); 56. } 57. solve(); 58. std::cout << ans; 59. return 0; 60.}
a.cc:2:3: error: stray '#' in program 2 | 1.#include<iostream> | ^ a.cc:3:3: error: stray '#' in program 3 | 2.#include<algorithm> | ^ a.cc:4:3: error: stray '#' in program 4 | 3.#include<vector> | ^ a.cc:2:1: error: expected unqualified-id before numeric constant 2 | 1.#include<iostream> | ^~ a.cc:6:1: error: expected unqualified-id before numeric constant 6 | 5.LL N,w; | ^~~~ a.cc:7:1: error: expected unqualified-id before numeric constant 7 | 6.LL W, V; | ^~~~ a.cc:8:1: error: expected unqualified-id before numeric constant 8 | 7.LL size[4],ww[4]; | ^~~~ a.cc:9:1: error: expected unqualified-id before numeric constant 9 | 8.LL ans; | ^~~~ a.cc:10:1: error: expected unqualified-id before numeric constant 10 | 9.std::vector<LL> dp[4]; | ^~~~~ a.cc:11:1: error: expected unqualified-id before numeric constant 11 | 10.void value(LL x, LL y, LL z, LL q) { | ^~~~~~~ a.cc:28:1: error: expected unqualified-id before numeric constant 28 | 27.void solve() { | ^~~~~~~ a.cc:45:1: error: expected unqualified-id before numeric constant 45 | 44.int main() { | ^~~~~~
s616764351
p03734
C++
#include<iostream> #include<algorithm> #include<vector> using LL = long long; LL N,w; LL W, V; LL size[4]; LL ans; std::vector<LL> dp1,dp2,dp3,dp4; void value(LL x, LL y, LL z, LL q) { LL sum = 0; for (LL aa = 0; aa < x; aa++) { sum += dp1[aa]; } for (LL aa = 0; aa < y; aa++) { sum += dp2[aa]; } for (LL aa = 0; aa < z; aa++) { sum += dp3[aa]; } for (LL aa = 0; aa < q; aa++) { sum += dp4[aa]; } ans = std::max(ans, sum); } void solve() { for (LL i = 0; i <= dp1.size; i++) { for (LL j = 0; j <= dp2.size(); j++) { for (LL k = 0;k <= dp3.size(); k++) { for (LL l = 0; l <= dp4.size(); l++) { LL ww=0; ww += i*w; ww += j*(w + 1); ww += k*(w + 2); ww += l*(w + 3); if (ww <= W) { value(i, j, k, l); } } } } } } int main() { std::cin >> N >> W; std::cin >> w>> V; dp1.push_back(V); for (LL i = 1; i < N; i++) { LL tmp,Q; std::cin >> tmp >> Q; if (tmp - w == 0) dp1.push_back(Q); if (tmp - w == 1) dp2.push_back(Q); if (tmp - w == 2) dp3.push_back(Q); if (tmp - w == 3) dp4.push_back(Q); } std::sort(dp1.begin(), dp1.end()); std::sort(dp2.begin(), dp2.end()); std::sort(dp3.begin(), dp3.end()); std::sort(dp4.begin(), dp4.end()); solve(); std::cout << ans << std::endl; return 0; }
a.cc: In function 'void solve()': a.cc:27:33: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int]' (did you forget the '()' ?) 27 | for (LL i = 0; i <= dp1.size; i++) { | ~~~~^~~~ | ()
s787050999
p03734
C
#include<cstdio> #include<deque> #include<cstring> #include<iostream> #include<algorithm> using namespace std; const int SIZEN=1010,inf =0x7fffffff/2; int N,W; int w[SIZEN],v[SIZEN]; int pos[4][SIZEN]={0},he[4][SIZEN]; int cnt[4]; int a[4][SIZEN]; bool cmp(int a,int b) { return a>b; } void work() { int lim[4]; for(int i=0;i<4;i++) { lim[i]=min(cnt[i],W/(w[1]+i)); for(int j=1;j<=lim[i];j++) pos[i][j]=pos[i][j-1]+a[i][j]; } int ans=0; for(int i=0;i<=lim[0];i++) { for(int j=0;j<=lim[1];j++) { if(w[1]*i+(w[1]+1)*j>W) break; for(int k=0;k<=lim[2];k++) { if(w[1]*i+(w[1]+1)*j+(w[1]+2)*k>W) break; for(int p=0;p<=lim[3];p++) { if(w[1]*i+(w[1]+1)*j+(w[1]+2)*k+(w[1]+3)*p>W) break; ans=max(ans,pos[0][i]+pos[1][j]+pos[2][k]+pos[3][p]); } } } } cout<<ans<<endl; } int main() { //freopen("1.in","r",stdin); //freopen("1.out","w",stdout); scanf("%d%d",&N,&W); for(int i=1;i<=N;i++) { scanf("%d%d",&w[i],&v[i]); int t=w[i]-w[1];a[t][++cnt[t]]=v[i]; } for(int i=0;i<4;i++) sort(a[i]+1,a[i]+1+cnt[i],cmp); work(); return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s275064047
p03734
C++
#include<bits/stdc++.h> using namespace std; long long baseW; long long N, W; vector<long long> val[4]; int main(){ cin >> N >> W; for(long long i = 0; i < N; i++){ long long tmpw, tmpv; cin >> tmpw >> tmpv; if(i == 0){ baseW = tmpw; } val[tmpw - baseW].push_back(tmpv); } for(int i = 0; i < 4; i++){ sort(val[i].begin(), val[i].end(), greater<long long>()); val[i].insert(val[i].begin(), 0); for(int j = 0; j < val[i].size() - 1; j++){ val[i][j+1] += val[i][j]; } } long long ans = 0; for(long long i = 0; i < val[0].size(); i++){ for(long long j = 0; j < val[1].size(); j++){ for(long long k = 0; k < val[2].size(); k++){ long long curw; curw = i * baseW + j * (baseW + 1) + k * (baseW + 2); if(curw > W){ continue; }else{ long long l = (W - curw)/(baseW + 3); ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]); } } } } /* for(long long i = 0; i < val[0].size(); i++){ for(long long j = 0; j < val[1].size(); j++){ for(long long k = 0; k < val[2].size(); k++){ for(long long l = 0; l < val[3].size(); l++){ long long curw; if(i * baseW + j * (baseW + 1) + k * (baseW + 2) + l * (baseW + 3) > W){ continue; }else{ ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][l]); } } } } } */ cout << ans << endl; }
a.cc: In function 'int main()': a.cc:36:102: error: no matching function for call to 'min(long long int&, std::vector<long long int>::size_type)' 36 | ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:36:102: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'}) 36 | ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:36:102: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 36 | ans = max(ans, val[0][i] + val[1][j] + val[2][k] + val[3][min(l, val[3].size() - 1)]); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s531315607
p03734
C++
#include <iostream> #include <vector> #define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++) #define DEBUG(i) cout << #i << ": " << i << endl; #define fi first #define se second using namespace std; typedef long long ll; typedef pair<ll, ll> pll; int N, W; pll P[100]; vector<ll> q[4]; int main(void) { cin >> N >> W; REP(i, 0, N) cin >> P[i].fi >> P[i].se; ll m = min_element(P, P + N)->fi; sort(P, P + N); reverse(P, P + N); REP(i, 0, 4) q[i].push_back(0); REP(i, 0, N) q[P[i].fi - m].push_back(P[i].se); REP(i, 0, 4) REP(j, 1, q[i].size()) q[i][j] += q[i][j - 1]; ll ans = 0; REP(i, 0, q[0].size() + 1) { REP(j, 0, q[1].size() + 1) { REP(k, 0, q[2].size() + 1) { REP(l, 0, q[3].size() + 1) { if(i * m + j * (m + 1) + k * (m + 2) + l * (m + 3) <= W) { ans = max(ans, q[0][i] + q[1][j] + q[2][k] + q[3][l]); } } } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:10: error: 'min_element' was not declared in this scope 19 | ll m = min_element(P, P + N)->fi; | ^~~~~~~~~~~ a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'short'? 20 | sort(P, P + N); | ^~~~ | short a.cc:21:3: error: 'reverse' was not declared in this scope 21 | reverse(P, P + N); | ^~~~~~~
s222678999
p03734
C++
#include<iostream> #include<sstream> #include<fstream> #include<string> #include<vector> #include<deque> #include<queue> #include<stack> #include<set> #include<map> #include<algorithm> #include<functional> #include<utility> #include<bitset> #include<cmath> #include<cstdlib> #include<ctime> #include<cstdio> #include<cstring> #define NW 100000000005 typedef long long ll; using namespace std; ll dp[105][NW],w[105],v[105],N,W; const ll INF=1000000005; int main() { cin>>N>>W; fill(dp[0],dp[0]+W+1,INF); dp[0][0]=0; for (int i=0;i<N;i++) cin>>w[i]>>v[i]; for (int i=0;i<N;i++) for (int j=0;W;j++) if (j<v[i]) dp[i+1][j]=dp[i][j]; else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]); ll res=0; for (int i=0;i<W;i++) if (dp[N][i]<=W) res=i; cout<<res; }
/tmp/ccDtYmrF.o: in function `main': a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x90): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0xdb): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x19c): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x1e3): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccDtYmrF.o a.cc:(.text+0x286): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s734941612
p03734
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, k; ll w[110], v[110], wb; ll knap[110][110][310]; ll INF = 1LL<<40; int main() { int i, j, l; scanf("%lld%lld",&n,&k); for (i=1;i<=n;i++) scanf("%lld%lld",&w[i],&v[i]); wb = w[1]; for (i=1;i<=n;i++) w[i] -= wb; for (i=0;i<=n;i++) for (l=0;l<=3*n;l++) knap[i][0][] = -INF; knap[0][0][0] = 0; for (i=0;i<=n;i++) { for (j=1;j<=n;j++) { for (l=0;l<=3*n;l++) { knap[i][j][l] = max(knap[i][j-1][l],((l>=w[j]&&i>=1)?knap[i-1][j-1][l-w[j]]+v[j]:(-INF))); } } } ll res = 0; for (i=0;i<=n;i++) { for (l=0;l<=min(k-wb*i,3*n);l++) { res = max(res,knap[i][n][l]); } } printf("%lld\n",res); return 0; }
a.cc: In function 'int main()': a.cc:19:56: error: expected primary-expression before ']' token 19 | for (i=0;i<=n;i++) for (l=0;l<=3*n;l++) knap[i][0][] = -INF; | ^
s228079575
p03734
C++
#include <bits/stdc++.h> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back((a)) #define all(x) (x).begin(),(x).end() #define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x)) #define fi first #define se second #define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__) void _dbg(string){cout<<endl;} template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);} template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;} template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;} #define INF 1120000000 int main(){ int n,w; cin>>n>>w; vector<long> we(n),va(n); rep(i,n) cin>>we[i]>>va[i]; vector<long> vals[4]; rep(i,n){ vals[we[i]-we[0]].pb(va[i]); } rep(i,4) vals[i].pb(0); rep(i,4){ sort(all(vals[i])); repl(j,1,vals[i].size()) vals[i][j] += vals[i][j-1]; } long ans = 0; rep(i,vals[0].size()) rep(j,vals[1].size()) rep(k,vals[2].size()){ long cw = (i+j+k)*we[0] + j + 2*k; if(cw > w) break; int p = (w-cw)/(we[0]+3); p = min(vals[3].size()-1, p); ans = max(ans, vals[0][i]+vals[1][j]+vals[2][k]+vals[3][p]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:39:12: error: no matching function for call to 'min(std::vector<long int>::size_type, int&)' 39 | p = min(vals[3].size()-1, p); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:39:12: note: deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int') 39 | p = min(vals[3].size()-1, p); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:39:12: note: mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int' 39 | p = min(vals[3].size()-1, p); | ~~~^~~~~~~~~~~~~~~~~~~~~
s655904483
p03734
C++
#include <iostream> #include <vector> using namespace std; struct solver { vector<long> ws; vector<long> vs; solver(vector<long> ws_, vector<long> vs_) : ws(ws_), vs(vs_) {} long solve(int n, long wlimit) { if (n == 0) { return 0; } if (*min_element(ws.begin(), ws.end()) > wlimit) { return 0; } if (ws[n-1] > wlimit) return solve(n-1, wlimit); return max(vs[n-1] + solve(n-1, wlimit - ws[n-1]), solve(n-1, wlimit)); } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, w; cin >> n >> w; vector<long> ws(n), vs(n); for (int i = 0; i < n; i++) { cin >> ws[i]; cin >> vs[i]; } solver s{ws, vs}; cout << s.solve(n, w) << endl; return 0; }
a.cc: In member function 'long int solver::solve(int, long int)': a.cc:16:10: error: 'min_element' was not declared in this scope 16 | if (*min_element(ws.begin(), ws.end()) > wlimit) { | ^~~~~~~~~~~
s249654262
p03734
C
#include <stdio.h> #define MAXN 110 #define MAXW 500 int solve(int* w, int* v, int N, int W) { static int m[MAXN][MAXW]; int mi = w[0]; for(int i = 0; i < N; i++) W -= mi, w[i] -= mi; for(int i = 1; i < N; i++) for(int j = 0; j < W; j++) if(w[i] > j) m[i][j] = m[i - 1][j]; else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]); return m[N][W]; } int main(void) { int N, W, v[MAXN], w[MAXN]; scanf("%d", &N); for(int i = 0; i < N; i++) scanf("%d%d", &w[i], &v[i]); printf("%d", solve(w, v, N, W)); return 0; }
main.c: In function 'solve': main.c:11:28: error: implicit declaration of function 'max' [-Wimplicit-function-declaration] 11 | else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]); | ^~~
s690715805
p03734
C
#include <stdio.h> #define MAXN 110 #define MAXW 500 int solve(int* w, int* v, int N, int W) { static int m[MAXN][MAXW]; int mi = w[0]; for(int i = 0; i < n; i++) W -= mi, w[i] -= mi; for(int i = 1; i < n; i++) for(int j = 0; j < W; j++) if(w[i] > j) m[i][j] = m[i - 1][j]; else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]); return m[N][W]; } int main(void) { int N, W, v[MAXN], w[MAXN]; scanf("%d", &N); for(int i = 0; i < N; i++) scanf("%d%d", &w[i], &v[i]); printf("%d", solve(w, v, N, W)); return 0; }
main.c: In function 'solve': main.c:7:24: error: 'n' undeclared (first use in this function) 7 | for(int i = 0; i < n; i++) W -= mi, w[i] -= mi; | ^ main.c:7:24: note: each undeclared identifier is reported only once for each function it appears in main.c:11:28: error: implicit declaration of function 'max' [-Wimplicit-function-declaration] 11 | else m[i][j] = max(m[i - 1][j], m[i - 1][j - w[i]] + v[i]); | ^~~
s321105878
p03734
C++
#include <cstdio> #include <cstring> #include <map> #include <vector> #include <iostream> #include <iomanip> using namespace std; typedef long long ll; int n; ll W; vector<ll> v[4]; int w0; int input(){ int x;cin>>x;return x; } ll s[4][101]; int main(){ cin >> n >> W; w0=input(); v[0].push_back(input()); for(int i=0;i<n-1;++i){ v[input()-w0].push_back(input()); } int m[4]={}; for(int i=0;i<4;++i){ m[i]=v[i].size(); sort(v[i].begin(), v[i].end()); reverse(v[i].begin(), v[i].end()); s[i][0]=0; for(int j=1;j<=m[i];++j) s[i][j]=s[i][j-1]+v[i][j-1]; } ll ans = 0; for(int a=0;a<=m[0];++a){ for(int b=0;b<=m[1];++b){ for(int c=0;c<=m[2];++c){ if(w0*a+(w0+1)*b+(w0+2)*c>W) continue; int d = min(m[3],(int)((W-(w0*a+(w0+1)*b+(w0+2)*c))/(w0+3))); ans = max(ans, s[0][a]+s[1][b]+s[2][c]+s[3][d]); } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:5: error: 'sort' was not declared in this scope; did you mean 'short'? 30 | sort(v[i].begin(), v[i].end()); | ^~~~ | short a.cc:31:5: error: 'reverse' was not declared in this scope 31 | reverse(v[i].begin(), v[i].end()); | ^~~~~~~
s720529247
p03734
C++
#include <iostream> #include <algorithm> using namespace std; int main(void){ int N; int W; cin >> N >> W; int w_i[N],v_i[N]; int dp[N+1][401]; int tmp_i; cin >> w_i[0] >> v_i[0]; for(int i=1;i<N;i++){ cin >> tmp_i >> v_i[i]; w_i[i] = tmp_i - w_i[0] + 1; } w_i[0] = 1 for(int i=0;i<=400;i++){ dp[N][i] = 0; } for(int i=N-1;i>=0;i--){ for(int w=0;w<=401;w++){ if(w < w_i[i]){ dp[i][w] = dp[i+1][w]; } else{ dp[i][w] = max(dp[i+1][w], dp[i+1][w - w_i[i]] + v_i[i]); } } } cout << dp[0][W] << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:15: error: expected ';' before 'for' 22 | w_i[0] = 1 | ^ | ; 23 | for(int i=0;i<=400;i++){ | ~~~ a.cc:23:17: error: 'i' was not declared in this scope 23 | for(int i=0;i<=400;i++){ | ^
s545018986
p03734
Java
import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.zip.ZipFile; // class name example: practice_1__2017_04_16 /* ------------------------- Summary: Total : 4 Correct: 4 Wrong : 0 Class need to be named: Main */ public class Main { // ------------------------------------------------------------------------- private final boolean debugMode = false; private static final int[] fileTestCases = {1, 2, 3, 4}; //private final int[] fileTestCases = {0}; private int correct = 0; private int totalTestCases = 0; private InputReader in; private PrintWriter out; // ------------------------------------------------------------------------- // private void solveManyTestCasesPerFile(int fileTestCase) throws IOException { // many test cases per file // int T = in.nextInt(); // // for (int testNo = 1; testNo <= T; testNo++) { // // // // if (debugMode) { // String actualResult = "'"; // assertResults(fileTestCase, testNo - 1, actualResult); // } // } // } static class Knapsack { public static int knapSack(int W, int wt[], int val[], int n) { int i, w; int K[][] = new int[n + 1][W + 1]; for (i = 0; i <= n; i++) { for (w = 0; w <= W; w++) { if (i == 0 || w == 0) K[i][w] = 0; else if (wt[i - 1] <= w) K[i][w] = Math.max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]); else K[i][w] = K[i - 1][w]; } } return K[n][W]; } // public static void main(String args[]) // { // int val[] = new int[]{60, 100, 120}; // int wt[] = new int[]{10, 20, 30}; // int W = 50; // int n = val.length; // System.out.println(knapSack(W, wt, val, n)); // } } // Your objective is to maximize the total value of the selected items. private void solveOneTestCasePerFile(int fileTestCase) throws IOException { // 1 test case per file int items = in.nextInt(); int targetWeight = in.nextInt(); int[] weights = new int[items]; int[] values = new int[items]; for (int i = 0; i < items; i++) { weights[i] = in.nextInt(); values[i] = in.nextInt(); } int ans = Knapsack.knapSack(targetWeight, weights, values, items); System.out.println(ans); if (debugMode) { String actualResult = ans + ""; assertResults(fileTestCase, 0, actualResult); } } // ------------------------------------------------------------------------- private void assertResults(int fileTestCase, int testNo, String actualResult) throws IOException { if (debugMode) { System.out.println("------------------------- Test case: " + fileTestCase); List<String> expected; Path zipOutPath = absTestCasePath().resolve("_" + fileTestCase + "_output.zip"); // zip if (Files.exists(zipOutPath)) { ZipFile zipFile = new ZipFile(zipOutPath.toFile()); InputStream stream = zipFile.getInputStream(zipFile.entries().nextElement()); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); expected = new ArrayList<>(); String line = reader.readLine(); while (line != null) { expected.add(line); line = reader.readLine(); } } else { Path outputPath = absTestCasePath().resolve("_" + fileTestCase + "_output.txt"); // txt expected = Files.readAllLines(outputPath); } String expectedResult = expected.get(testNo); // assert System.out.println("actual : " + actualResult); System.out.println("expected: " + expectedResult); if (!actualResult.equals(expectedResult)) { System.out.println("test case: " + (fileTestCase) + " - wrong answer"); } else { correct++; } totalTestCases++; System.out.println("-------------------------"); } } private void run() throws IOException { out = new PrintWriter(System.out); if (debugMode) { for (int fileTestCase : fileTestCases) { Path zipInPath = absTestCasePath().resolve("_" + fileTestCase + "_input.zip"); if (Files.exists(zipInPath)) { // test case in zip or txt format + in + out ZipFile zipFile = new ZipFile(zipInPath.toFile()); InputStream stream = zipFile.getInputStream(zipFile.entries().nextElement()); in = new InputReader(stream); } else { Path inputPath = absTestCasePath().resolve("_" + fileTestCase + "_input.txt"); in = new InputReader(new FileInputStream(inputPath.toFile())); } solveOneTestCasePerFile(fileTestCase); } System.out.println("Summary:"); System.out.println("Total : " + totalTestCases); System.out.println("Correct: " + correct); System.out.println("Wrong : " + (totalTestCases - correct)); } else { in = new InputReader(System.in); solveOneTestCasePerFile(-1); } } public static void main(String[] args) throws IOException { new Practice1__2017_05_05().run(); } private Path absTestCasePath() { return Paths.get(new File(getClass().getResource("").getPath().replace("target", "src")) .getAbsolutePath()).getParent().resolve("test_cases"); } // ------------------------------------------------------------------------- private class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); } public String nextString() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(nextString()); } public long nextLong() { return Long.parseLong(nextString()); } public double nextDouble() { return Double.parseDouble(nextString()); } } }
Main.java:163: error: cannot find symbol new Practice1__2017_05_05().run(); ^ symbol: class Practice1__2017_05_05 location: class Main 1 error
s221188546
p03734
Java
import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import java.util.zip.ZipFile; // class name example: practice_1__2017_04_16 /* ------------------------- Summary: Total : 4 Correct: 4 Wrong : 0 */ public class AtCoderPracticeTemplate { // ------------------------------------------------------------------------- private final boolean debugMode = false; private static final int[] fileTestCases = {1, 2, 3, 4}; //private final int[] fileTestCases = {0}; private int correct = 0; private int totalTestCases = 0; private InputReader in; private PrintWriter out; // ------------------------------------------------------------------------- // private void solveManyTestCasesPerFile(int fileTestCase) throws IOException { // many test cases per file // int T = in.nextInt(); // // for (int testNo = 1; testNo <= T; testNo++) { // // // // if (debugMode) { // String actualResult = "'"; // assertResults(fileTestCase, testNo - 1, actualResult); // } // } // } static class Knapsack { static int max(int a, int b) { return (a > b) ? a : b; } static int knapSack(int W, int wt[], int val[], int n) { int i, w; int K[][] = new int[n + 1][W + 1]; for (i = 0; i <= n; i++) { for (w = 0; w <= W; w++) { if (i == 0 || w == 0) K[i][w] = 0; else if (wt[i - 1] <= w) K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]); else K[i][w] = K[i - 1][w]; } } return K[n][W]; } // public static void main(String args[]) // { // int val[] = new int[]{60, 100, 120}; // int wt[] = new int[]{10, 20, 30}; // int W = 50; // int n = val.length; // System.out.println(knapSack(W, wt, val, n)); // } } // Your objective is to maximize the total value of the selected items. private void solveOneTestCasePerFile(int fileTestCase) throws IOException { // 1 test case per file int items = in.nextInt(); int targetWeight = in.nextInt(); int[] weights = new int[items]; int[] values = new int[items]; for (int i = 0; i < items; i++) { weights[i] = in.nextInt(); values[i] = in.nextInt(); } int ans = Knapsack.knapSack(targetWeight, weights, values, items); if (debugMode) { String actualResult = ans + ""; assertResults(fileTestCase, 0, actualResult); } } // ------------------------------------------------------------------------- private void assertResults(int fileTestCase, int testNo, String actualResult) throws IOException { if (debugMode) { System.out.println("------------------------- Test case: " + fileTestCase); List<String> expected; Path zipOutPath = absTestCasePath().resolve("_" + fileTestCase + "_output.zip"); // zip if (Files.exists(zipOutPath)) { ZipFile zipFile = new ZipFile(zipOutPath.toFile()); InputStream stream = zipFile.getInputStream(zipFile.entries().nextElement()); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); expected = new ArrayList<>(); String line = reader.readLine(); while (line != null) { expected.add(line); line = reader.readLine(); } } else { Path outputPath = absTestCasePath().resolve("_" + fileTestCase + "_output.txt"); // txt expected = Files.readAllLines(outputPath); } String expectedResult = expected.get(testNo); // assert System.out.println("actual : " + actualResult); System.out.println("expected: " + expectedResult); if (!actualResult.equals(expectedResult)) { System.out.println("test case: " + (fileTestCase) + " - wrong answer"); } else { correct++; } totalTestCases++; System.out.println("-------------------------"); } } private void run() throws IOException { out = new PrintWriter(System.out); if (debugMode) { for (int fileTestCase : fileTestCases) { Path zipInPath = absTestCasePath().resolve("_" + fileTestCase + "_input.zip"); if (Files.exists(zipInPath)) { // test case in zip or txt format + in + out ZipFile zipFile = new ZipFile(zipInPath.toFile()); InputStream stream = zipFile.getInputStream(zipFile.entries().nextElement()); in = new InputReader(stream); } else { Path inputPath = absTestCasePath().resolve("_" + fileTestCase + "_input.txt"); in = new InputReader(new FileInputStream(inputPath.toFile())); } solveOneTestCasePerFile(fileTestCase); } System.out.println("Summary:"); System.out.println("Total : " + totalTestCases); System.out.println("Correct: " + correct); System.out.println("Wrong : " + (totalTestCases - correct)); } else { in = new InputReader(System.in); solveOneTestCasePerFile(-1); } } public static void main(String[] args) throws IOException { new AtCoderPracticeTemplate().run(); } private Path absTestCasePath() { return Paths.get(new File(getClass().getResource("").getPath().replace("target", "src")) .getAbsolutePath()).getParent().resolve("test_cases"); } // ------------------------------------------------------------------------- private class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); } public String nextString() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(nextString()); } public long nextLong() { return Long.parseLong(nextString()); } public double nextDouble() { return Double.parseDouble(nextString()); } } }
Main.java:19: error: class AtCoderPracticeTemplate is public, should be declared in a file named AtCoderPracticeTemplate.java public class AtCoderPracticeTemplate { ^ 1 error
s524943855
p03734
C++
#include <bits/stdc++.h> using namespace std; map <int, int> us, ans; int n, m, i, j, a[200], b[200], res = 0; int main() { vector <int> v; vector <pair <int, int> > q; cin >> n >> m; for(i = 0; i < n; ++i) cin >> a[i] >> b[i]; v.push_back(0); for(i = 0; i < n; ++i) { for(j = 0; j < v.size(); ++j) q.push_back(v[j]); for(j = 0; j < q.size(); ++j) { if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) { us[q[j] + a[i]] = 1; ans[q[j] + a[i]] = ans[q[j]] + b[i]; v.push_back(q[j] + a[i]); res = max(res, ans[q[j] + a[i]]); } else if(q[j] + a[i] <= m) { ans[q[j] + a[i]] = min(ans[q[j] + a[i]], ans[q[j]] + b[i]); res = max(res, ans[q[j] + a[i]]); } } } cout << res; return 0; }
a.cc: In function 'int main()': a.cc:17:24: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 17 | q.push_back(v[j]); | ~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]' 1283 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'const std::vector<std::pair<int, int> >::value_type&' {aka 'const std::pair<int, int>&'} 1283 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]' 1300 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'} 1300 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:20:24: error: no match for 'operator+' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:20:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'const _CharT*' and 'std::pair<int, int>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:20:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:20:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:20:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:20:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:20:29: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 20 | if(us[q[j] + a[i]] == 0 && q[j] + a[i] <= m) | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT
s717820538
p03734
C++
#include<iostream> #include<vector> using namespace std; vector<int> weight(105); vector<int> value(105); vector<vector<int>> select(105+1, vector<int>(1000+1,0)); int zeroOnePack(int N, int C, const vector<int>& weight, const vector<int>& value) { for(int i = 1; i <= N; ++i) { for(int j = 1; j <= C; ++j) { if (weight[i - 1] > j) select[i][j] = select[i - 1][j]; else select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); } } return select[N][C]; } int main() { int n, c; scanf("%d %d", &n, &c); for(int i = 0; i < n; i++){ int tw, tv; scanf("%d %d", &weight[i], &value[i]); } cout << zeroOnePack(n, c, weight, value) << endl; return 0; }
a.cc:7:27: error: 'std::vector<std::vector<int> > select' redeclared as different kind of entity 7 | vector<vector<int>> select(105+1, vector<int>(1000+1,0)); | ^ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179, from /usr/include/stdlib.h:514, from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)' 102 | extern int select (int __nfds, fd_set *__restrict __readfds, | ^~~~~~ a.cc: In function 'int zeroOnePack(int, int, const std::vector<int>&, const std::vector<int>&)': a.cc:16:25: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | select[i][j] = select[i - 1][j]; | ^ a.cc:16:28: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | select[i][j] = select[i - 1][j]; | ^ a.cc:16:44: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | select[i][j] = select[i - 1][j]; | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] a.cc:16:47: warning: pointer to a function used in arithmetic [-Wpointer-arith] 16 | select[i][j] = select[i - 1][j]; | ^ a.cc:16:30: error: assignment of read-only location '*(select + (((sizetype)i) + ((sizetype)j)))' 16 | select[i][j] = select[i - 1][j]; | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ a.cc:18:25: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ^ a.cc:18:28: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ^ a.cc:18:48: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] a.cc:18:51: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ^ a.cc:18:66: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ^ cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith] a.cc:18:85: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ^ a.cc:18:87: warning: pointer to a function used in arithmetic [-Wpointer-arith] 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); a.cc:18:35: error: no matching function for call to 'max(int (&)(int, fd_set*, fd_set*, fd_set*, timeval*), int (*)(int, fd_set*, fd_set*, fd_set*, timeval*))' 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:18:35: note: deduced conflicting types for parameter 'const _Tp' ('int(int, fd_set*, fd_set*, fd_set*, timeval*)' and 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)') 18 | select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided a.cc:21:20: warning: pointer to a function used in arithmetic [-Wpointer-arith] 21 | return select[N][C]; | ^ a.cc:21:23: warning: pointer to a function used in arithmetic [-Wpointer-arith] 21 | return select[N][C]; | ^ a.cc:21:23: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'int' [-fpermissive] 21 | return select[N][C]; | ^ | | | int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)
s554748893
p03734
C++
#include<iostream> #include<vector> using namespace std; vector<int> weight(105); vector<int> value(105); vector<vector<int>> select(105+1, vector<int>(1000000000+1,0)); int zeroOnePack(int N, int C, const vector<int>& weight, const vector<int>& value) { vector<vector<int>> select(N+1, vector<int>(C+1,0)); for(int i = 1; i <= N; ++i) { for(int j = 1; j <= C; ++j) { if (weight[i - 1] > j) select[i][j] = select[i - 1][j]; else select[i][j] = max(select[i - 1][j], select[i - 1][j - weight[i - 1]] + value[i - 1]); } } return select[N][C]; } int main() { int n, c; scanf("%d %d", &n, &c); for(int i = 0; i < n; i++){ int tw, tv; scanf("%d %d", &weight[i], &value[i]); } cout << zeroOnePack(n, c, weight, value) << endl; return 0; }
a.cc:7:27: error: 'std::vector<std::vector<int> > select' redeclared as different kind of entity 7 | vector<vector<int>> select(105+1, vector<int>(1000000000+1,0)); | ^ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179, from /usr/include/stdlib.h:514, from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)' 102 | extern int select (int __nfds, fd_set *__restrict __readfds, | ^~~~~~
s241995819
p03734
C++
D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max
a.cc:1:14: warning: missing terminating ' character 1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max | ^ a.cc:1:14: error: missing terminating ' character 1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:1:1: error: 'D' does not name a type 1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max | ^ a.cc:1:8: error: expected ')' before '=' token 1 | D={};(x=eval$';D.dup.map{|a,b|a-=eval$`;a<0||D[a]=[*D[a],b+x].max};D[W||=x]=0)while/ /=~gets;p D.values.max | ~ ^ | )
s828229170
p03734
C++
#include<cstdio> #include<cstring> #include<vector> #include<map> using namespace std; typedef long long ll; struct x_t { int w, v; }; struct f_t { unsigned f[4]; // f_t(){f[0]=f[1]=f[2]=f[3]=0;} operator < (const f_t& rhs) const { return memcmp(f, rhs.f, 16)<0; } }; int N, W; vector<x_t> x; map<f_t,x_t> m; int max(int a, int b) { if(a>b) return a; return b; } int max_u(int &m, int v) { if(m<v) m=v; return m; } x_t solve(int n, f_t f, int w, int v) { x_t a, b; if(w>W) return (x_t){w, 0}; if(n<0) return (x_t){w, v}; if(m.find(f)!=m.end()) return m[f]; a=solve(n-1, f, w, v); m[f]=a; f.f[n/32]|=(1<<(n%32)); b=solve(n-1, f, w+x[n].w, v+x[n].v); m[f]=b; if(a.v>b.v) return a; return b; } int main(void) { int i; f_t f={{0}}; while(scanf("%d%d", &N, &W)==2) { x.resize(N); m.clear(); for(i=0;i<N;i++) scanf("%d%d", &x[i].w, &x[i].v); printf("%d\n", solve(N-1, f, 0, 0).v); } return 0; }
a.cc:22:9: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive] 22 | operator < (const f_t& rhs) const { | ^~~~~~~~
s685679290
p03734
C++
#include<iostream> #include<cstring> #include<cmath> using namespace std; long long dp[105][405][105]; long long www[405]; long long vvv[405]; long long main(){ long long n,w; cin>>n>>w; memset(dp,0,sizeof(dp)); for(long long i=0;i<n;i++){ cin>>www[i]>>vvv[i]; } long long tmp=www[0]-1; for(long long i=1;i<n;i++){ www[i]-=www[0]; } www[0]=0; for(long long i=1;i<405;i++) dp[0][i][1]=vvv[0]; for(long long i=0;i<n;i++) www[i]++; for(long long i=1;i<n;i++){ for(long long j=0;j<402;j++){ for(long long k=1;k<=n;k++){ //if(i==1&&j==1&&k==1) cout<<"~~~~~~~~~~ "<<dp[i-1][j][k]<<endl; if(j>=www[i]) dp[i][j][k]=max(dp[i-1][j][k],dp[i-1][j-www[i]][k-1]+vvv[i]); else dp[i][j][k]=dp[i-1][j][k]; } } } long long ans=0; for(long long j=0;j<405;j++){ for(long long k=0;k<=n;k++){ if(k*tmp+j<=w){ // cout<<k*tmp+j<<' '<<dp[n-1][j][k]<<endl; // cout<<dp[n-1][j][k]<<endl; ans=max(ans,dp[n-1][j][k]); } } } cout<<ans<<endl; }
cc1plus: error: '::main' must return 'int'
s488482988
p03734
C++
#include "bits/stdc++.h" using namespace std; int n, W; int w[105]; int v[105]; ll dp[105][105][305]; ll solve(int idx, int left, int wt) { if(left == 0) return 0; if(idx > n) { if(left != 0) return INT_MIN; else return 0; } if(dp[idx][left][wt] != -1) return dp[idx][left][wt]; if(w[idx] > wt) return dp[idx][left][wt] = solve(idx + 1, left, wt); else return dp[idx][left][wt] = max(v[idx] + solve(idx + 1, left - 1, wt - w[idx]), solve(idx + 1, left, wt)); } int main() { scanf("%d %d", &n, &W); for(int i = 1 ; i <= n ; i++) scanf("%d %d", &w[i], &v[i]); int x = w[1]; for(int i = 1 ; i <= n ; i++) w[i] -= x; ll ans = 0; for(int i = 1 ; i <= n ; i++) { if((W - i*x) < 0 ) continue; int wgt = min(3*i, W - i*x); memset(dp, -1, sizeof(dp)); ans = max(ans, solve(1, i, wgt)); } printf("%lld", ans); return 0; }
a.cc:8:1: error: 'll' does not name a type 8 | ll dp[105][105][305]; | ^~ a.cc:10:1: error: 'll' does not name a type 10 | ll solve(int idx, int left, int wt) | ^~ a.cc: In function 'int main()': a.cc:37:5: error: 'll' was not declared in this scope 37 | ll ans = 0; | ^~ a.cc:43:16: error: 'dp' was not declared in this scope; did you mean 'dup'? 43 | memset(dp, -1, sizeof(dp)); | ^~ | dup a.cc:44:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 44 | ans = max(ans, solve(1, i, wgt)); | ^~~ | abs a.cc:44:24: error: 'solve' was not declared in this scope 44 | ans = max(ans, solve(1, i, wgt)); | ^~~~~ a.cc:46:20: error: 'ans' was not declared in this scope; did you mean 'abs'? 46 | printf("%lld", ans); | ^~~ | abs
s322044812
p03734
C++
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cmath> #include <cassert> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #define ALL(a) (a).begin(),(a).end() #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define rep(i,n) FOR(i,0,n) #define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--) #define rrep(i,n) RFOR(i,n,0) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define vint vector<int> #define vdbl vector<double> #define vstr vector<string> using namespace std; typedef long long ll; typedef unsigned long long ull; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; ll W; cin >> N >> W; ll w[N],v[N]; rep(i,N) cin >> w[i] >> v[i]; if(W <= 10000){ ll dp[N+1][W+1] = {}; rep(i,N){ rep(j,W+1){ if(j >= w[i]) dp[i+1][j] = max(dp[i+1][j],dp[i][j-w[i]]+v[i]); } } cout << dp[N][W] << endl; }else{ if(W < w[0]) { cout << 0 << endl; return 0; } ll dp[N+1][N+1][3*N] = {}; rep(i,N){ FOR(j,1,i+1){ rep(k,3*(i+1)){ int d = w[i] - w[0]; if(k >= d) dp[i+1][j][k] = max(dp[i][j][k],dp[i][j-1][k-d]) } } } int a = W / w[0]; int b = W - w[0] * a; cout << dp[N][a][b] << endl; } }
a.cc: In function 'int main()': a.cc:61:100: error: expected ';' before '}' token 61 | if(k >= d) dp[i+1][j][k] = max(dp[i][j][k],dp[i][j-1][k-d]) | ^ | ; 62 | } | ~
s583427324
p03734
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define repeat(i,n) for(int i=0;i<(n);i++) typedef pair<int, int> pii; struct Data{ int w, v, id; bool operator<(const Data &r)const{ return v!=r.v ? v>r.v : w<r.w; } }; int N, W; vector<int> w, v; int used[101]; int calc(int i, int rest){ if(i==N) return 0; int ret=0; ret=calc(i+1, rest); if(rest-w[i]>=0) ret=max(ret, rec(i+1, rest-w[i])+v[i]); return ret; } int main(){ cin>> N>> W; w.resize(N); v.resize(N); repeat(i, N) cin>> w[i]>> v[i]; vector<Data> item; repeat(i, N) item.push_back(Data{w[i], v[i], i}); sort(item.begin(), item.end()); int s=0; int r=w[0]; int X=(r+3)*N; int jj=0; int u=N; while(u>15){ auto e=item[jj]; if(W-e.w>=0){ s+=e.v; W-=e.w; u--; } used[jj]=1; jj+=1; } cout<< s+calc(jj, W)<< endl; return 0; }
a.cc: In function 'int calc(int, int)': a.cc:25:34: error: 'rec' was not declared in this scope; did you mean 'ret'? 25 | if(rest-w[i]>=0) ret=max(ret, rec(i+1, rest-w[i])+v[i]); | ^~~ | ret
s054928324
p03734
C
#include <stdio.h> #include <math.h> const int MAX_N = 1000; // nの最大値 const int MAX_W = 1000000000; // Wの最大値 void solve_dp2(); // 入力 int n, W; int w[MAX_N], v[MAX_N]; // DPテーブル // dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。 int dp[MAX_N + 1][MAX_W + 1]; int main(){ int i,a,b; scanf("%d%d",&n,&W); for (i = 0; i < n; i++){ scanf("%d%d",&a,&b); w[i] = a; v[i] = b; } solve_dp2(); return 0; } void solve_dp2() { for (int j = 0; j <= W; j++) { dp[n][j] = 0; } for (int i = n - 1; i >= 0; i--) { for (int j = 0; j <= W; j++) { if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = fmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]); } } printf("%d\n", dp[0][W]); return 0; }
main.c:10:5: error: variably modified 'w' at file scope 10 | int w[MAX_N], v[MAX_N]; | ^ main.c:10:15: error: variably modified 'v' at file scope 10 | int w[MAX_N], v[MAX_N]; | ^ main.c:14:5: error: variably modified 'dp' at file scope 14 | int dp[MAX_N + 1][MAX_W + 1]; | ^~ main.c:14:5: error: variably modified 'dp' at file scope main.c: In function 'solve_dp2': main.c:45:10: error: 'return' with a value, in function returning void [-Wreturn-mismatch] 45 | return 0; | ^ main.c:32:6: note: declared here 32 | void solve_dp2() { | ^~~~~~~~~
s773807262
p03734
C
#include <stdio.h> #include <math.h> const int MAX_N = 100; // nの最大値 const int MAX_W = 1000000000; // Wの最大値 void solve_dp2(); // 入力 int n, W; int w[MAX_N], v[MAX_N]; // DPテーブル // dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。 int dp[MAX_N + 1][MAX_W + 1]; int main(){ int i,a,b; scanf("%d%d",&n,&W); for (i = 0; i < n; i++){ scanf("%d%d",&a,&b); w[i] = a; v[i] = b; } solve_dp2(); return 0; } void solve_dp2() { for (int j = 0; j <= W; j++) { dp[n][j] = 0; } for (int i = n - 1; i >= 0; i--) { for (int j = 0; j <= W; j++) { if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = fmax(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]); } } printf("%d", dp[0][W]); }
main.c:10:5: error: variably modified 'w' at file scope 10 | int w[MAX_N], v[MAX_N]; | ^ main.c:10:15: error: variably modified 'v' at file scope 10 | int w[MAX_N], v[MAX_N]; | ^ main.c:14:5: error: variably modified 'dp' at file scope 14 | int dp[MAX_N + 1][MAX_W + 1]; | ^~ main.c:14:5: error: variably modified 'dp' at file scope
s468285354
p03734
Java
import java.io.BufferedInputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.concurrent.atomic.AtomicLong; public class Main { static long first = -1; static int w = -1; // 14:33- public static void main(String[] args) { Scanner sc = new Scanner(new BufferedInputStream(System.in)); int n = sc.nextInt(); w = sc.nextInt(); ArrayList[] ws = new ArrayList[4]; for (int i = 0; i < ws.length; i++) ws[i] = new ArrayList(); for (int i = 0; i < n; i++) { int wi = sc.nextInt(); if (i == 0) first = wi; int vi = sc.nextInt(); ws[wi - first].add(vi); } for (int i = 0; i < ws.length; i++) Collections.sort(ws[i]); ArrayList[] prf = new ArrayList[4]; for (int i = 0; i < prf.length; i++) { prf[i] = new ArrayList(); prf[i].add(0L); } for (int i = 0; i < ws.length; i++) { int k = 1; int lastElem = ws[i].size() - 1; for (int j = lastElem; j >= 0; j--) { long val = (Integer) ws[i].get(j); val += (long) prf[i].get(k-1); prf[i].add(val); k++; } } AtomicLong max = new AtomicLong(); int[] choice = new int[4]; doit(choice, ws, prf, 0, max); System.out.println(max.get()); } private static void doit(int[] choice, ArrayList[] ws, ArrayList[] prf, int pos, AtomicLong max) { if (pos == ws.length) { long avail = w; long worth = 0; for (int i = 0; i < choice.length; i++) { avail -= choice[i] * (first + i); if (avail < 0) break; // for (int j = 0; j < choice[i]; j++) worth += (Integer) ws[i].get(ws[i].size() - 1 - j); worth += (long) prf[i].get(choice[i]); } if (avail >= 0) max.set(Math.max(worth, max.get())); return; } for (int i = 0; i <= ws[pos].size(); i++) { choice[pos] = i; doit(choice, ws, prf, pos + 1, max); } } }
Main.java:26: error: incompatible types: possible lossy conversion from long to int ws[wi - first].add(vi); ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s062192787
p03734
C++
#include <bits/stdc++.h> using namespace std; int ans; int n,W; vector<int> w(100,0),v(100,0); void dfs(int wsum,int vsum,int i){ if(i == n){ if(ans < vsum) ans = vsum; } else{ dfs(wsum,vsum,i+1); if(wsum+w[i] <= W){ dfs(wsum+w[i],vsum+v[i],i+1); } else{ if(ans < vsum) ans = vsum; } } } void sol(){ if(w[0]<=W) dfs(0,0,0); }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s072314790
p03734
C++
#include <cstdio> #include <cstring> #include <iostream> #include <map> #include <algorithm> #define int long long using namespace std; const int maxn = 1000 + 5; int T; int N, V; map<int,int> value; map<int,int> volume; map<int,int> dp; void input() { std::ios::sync_with_stdio(false); scanf("%lld%lld", &N, &V); for(int i = 0; i < N; ++i) { cin >> volume[i]; cin >> value[i]; } } void solve() { std::ios::sync_with_stdio(false); dp.clear(); for(int i = 0; i < N; ++i) { for(int j = V; j >= volume[i]; --j) { dp[j] = max(dp[j - volume[i]] + value[i], dp[j]); } } cout << dp[V] << endl; } int main() { input(); solve(); return 0; }
cc1plus: error: '::main' must return 'int'
s264631696
p03734
C++
#include <bits/stdc++.h> using namespace std; int max; int n,W; vector<int> w(100,0),v(100,0); void dfs(int wsum,int vsum,int i){ if(i == n){ if(max < vsum) max = vsum; } else{ dfs(wsum,vsum,i+1); if(wsum+w[i] <= W){ dfs(wsum+w[i],vsum+v[i],i+1); } else{ if(max < vsum) max = vsum; } } } void sol(){ dfs(0,0,0); } int main(void){ max = 0; cin >> n >> W; for(int i = 0, i < n; i++) cin >> w[i] >> v[i]; sol(); cout << max << endl; }
a.cc: In function 'void dfs(int, int, int)': a.cc:12:12: error: reference to 'max' is ambiguous 12 | if(max < vsum) | ^~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ In file included from /usr/include/c++/14/algorithm:60: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:5: note: 'int max' 5 | int max; | ^~~ a.cc:13:13: error: reference to 'max' is ambiguous 13 | max = vsum; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:5: note: 'int max' 5 | int max; | ^~~ a.cc:21:16: error: reference to 'max' is ambiguous 21 | if(max < vsum) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:5: note: 'int max' 5 | int max; | ^~~ a.cc:22:17: error: reference to 'max' is ambiguous 22 | max = vsum; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:5: note: 'int max' 5 | int max; | ^~~ a.cc: In function 'int main()': a.cc:32:5: error: reference to 'max' is ambiguous 32 | max = 0; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:5: note: 'int max' 5 | int max; | ^~~ a.cc:34:21: error: expected ';' before '<' token 34 | for(int i = 0, i < n; i++) | ^~ | ; a.cc:34:22: error: expected primary-expression before '<' token 34 | for(int i = 0, i < n; i++) | ^ a.cc:37:13: error: reference to 'max' is ambiguous 37 | cout << max << endl; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:5:5: note: 'int max' 5 | int max; | ^~~
s928494842
p03734
C++
#include<iostream> #include<algorithm> #define MOD 1000000007 #define INF 1123456789012345 #define in cin #define out cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; using namespace std; LL N, W, v[112], w[112]; pair<LL, LL> ps[1 << 20]; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } LL N2 = N / 2; rep(i, 1 << N2) { LL sw = 0, sv = 0; for (int j = 0; j < N2; ++j) { if (i >> j & 1) { sw += w[j]; sv += v[j]; } } ps[i] = make_pair(sw, sv); } sort(ps, ps + (1 << N2)); LL m = 1; for (int i = 1; i < 1 << N2; ++i) { if (ps[m - 1].second < ps[i].second) { ps[m++] = ps[i]; } } LL ans = 0; for (int i = 0; i < 1 << (N - N2); i++) { LL sw = 0, sv = 0; rep(j, N - N2) { if (i >> j & 1) { sw += w[N2 + j]; sv += v[N2 + j]; } } if (sw <= W) { LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second; ans = max(ans, sv + tv); } } out << ans << endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:55:24: required from here 55 | LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, clas
s428721766
p03734
C++
#include<iostream> #include<algorithm> #define MOD 1000000007 #define INF 1123456789012345 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, v[112], w[112]; std::pair<LL, LL> ps[1 << 20]; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } LL N2 = N / 2; rep(i, 1 << N2) { LL sw = 0, sv = 0; for (int j = 0; j < N2; ++j) { if (i >> j & 1) { sw += w[j]; sv += v[j]; } } ps[i] = std::make_pair(sw, sv); } std::sort(ps, ps + (1 << N2)); LL m = 1; for (int i = 1; i < 1 << N2; ++i) { if (ps[m - 1].second < ps[i].second) { ps[m++] = ps[i]; } } LL ans = 0; for (int i = 0; i < 1 << (N - N2); i++) { LL sw = 0, sv = 0; rep(j, N - N2) { if (i >> j & 1) { sw += w[N2 + j]; sv += v[N2 + j]; } } if (sw <= W) { LL tv = (std::lower_bound(ps, ps + m, std::make_pair(W - sw, INF)) - 1)->second; ans = std::max(ans, sv + tv); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:55:29: required from here 55 | LL tv = (std::lower_bound(ps, ps + m, std::make_pair(W - sw, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT,
s335410203
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[(1 << 20)]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); int seek = 1; for (int i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:26: required from here 47 | LL iter = (lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note:
s348318395
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 1123456789012345 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, v[112], w[112]; std::pair<LL, LL> ps[1 << 20]; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } LL N2 = N / 2; rep(i, 1 << N2) { LL sw = 0, sv = 0; for (int j = 0; j < N2; ++j) { if (i >> j & 1) { sw += w[j]; sv += v[j]; } } ps[i] = std::make_pair(sw, sv); } std::sort(ps, ps + (1 << N2)); LL m = 1; for (int i = 1; i < 1 << N2; ++i) { if (ps[m - 1].second < ps[i].second) { ps[m++] = ps[i]; } } LL ans = 0; for (int i = 0; i < 1 << (N - N2); i++) { LL sw = 0, sv = 0; rep (j, N - N2) { if (i >> j & 1) { sw += w[N2 + j]; sv += v[N2 + j]; } } if (sw <= W) { LL tv = (std::lower_bound(ps, ps + m, std::make_pair(W - sw, INF)) - 1)->second; ans = std::max(ans, sv + tv); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:54:29: required from here 54 | LL tv = (std::lower_bound(ps, ps + m, std::make_pair(W - sw, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template a
s955311913
p03734
C++
#include <cstdio> int Num=0; long int WCap=0; long int Weight[100]={}; long int Value[100]={}; inline int Max(int L,int R){ return L>=R?L:R; } int Search(int Depth,int RemCap); int main(){ scanf(" %d %ld",&Num,&WCap); for(int i=0;i<Num;i++){ scanf(" %ld %ld",&Weight[i],&Value[i]); } printf("%d\n",Search(0,WCap)); } int Search(int Depth,int RemCap){ //printf("Start:%d,%d\n",Depth,RemCap); if(Depth==Num){ return 0; } if(Weight[Depth]>RemCap){ return Search(Depth+1,RemCap); } return Max(Search(Depth+1,RemCap),Search(Depth+1,RemCap-Weight[Depth])+Value[Depth]); }v
a.cc:31:2: error: 'v' does not name a type 31 | }v | ^
s196817465
p03734
C++
#include <iostream> #include <algorithm> #define MOD 1000000007 #define INF 112345678900000 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL> ps[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, 1 << N2) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } ps[i] = std::make_pair(sum_w, sum_v); } std::sort(ps, ps + (1 << N2)); LL seek = 1; for (LL i = 1; i < 1 << N2; ++i) { if (ps[seek - 1].second < ps[i].second) { ps[seek++] = ps[i]; } } rep(i, 1 << (N - N2)) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { auto tmp = std::make_pair(W - sum_w, INF); LL iter = (std::lower_bound(ps, ps + seek, tmp) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:31: required from here 49 | LL iter = (std::lower_bound(ps, ps + seek, tmp) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std
s219794928
p03734
C++
#include <iostream> #include <algorithm> #define MOD 1000000007 #define INF 112345678900000 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL> res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, 1 << N2) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < 1 << N2; ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, 1 << (N - N2)) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { auto tmp = std::make_pair(W - sum_w, INF); LL iter = (std::lower_bound(res, res + seek, tmp) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:31: required from here 49 | LL iter = (std::lower_bound(res, res + seek, tmp) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool
s597352487
p03734
C++
#include "bits/stdc++.h" using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--) #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL typedef long long ll; ll N,W; ll w[110]; ll v[110]; ll dp[110][110][1000]; int main() { cin >> N >> W; REP(i,N) cin >> w[i] >> v[i]; ll w0 = w[0]; REP(i,N) w[i] -= w0; REP(i,110)REP(k,110)REP(j,310) dp[i][k][j] = 0; for(int i=0;i<N;i++) { for(int k=0;k<N;k++){ REP(j,310) dp[i+1][k+1][j] = dp[i][k+1][j]; RREP(j,310) { if(j-w[i]>=0) { dp[i+1][k+1][j] = max(dp[i+1][k+1][j],dp[i][k][j-w[i]] + v[i]); } } } } ll ans = 0; for(int k=1;k<=N;k++){ ll Wt = W - w0 * k; REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:18: error: no matching function for call to 'min(int, ll)' 42 | REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); | ~~~^~~~~~~~~~ a.cc:4:42: note: in definition of macro 'REP' 4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:42:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 42 | REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); | ~~~^~~~~~~~~~ a.cc:4:42: note: in definition of macro 'REP' 4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) | ^ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:42:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); | ~~~^~~~~~~~~~ a.cc:4:42: note: in definition of macro 'REP' 4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) | ^
s171389213
p03734
C++
#include <iostream> #include <algorithm> #define MOD 1000000007 #define INF 112345678900000 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL> res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, 1 << N2) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < 1 << N2; ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, 1 << (N - N2)) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:48:31: required from here 48 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'te
s239448088
p03734
C++
#include "bits/stdc++.h" using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--) #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) #define MOD 1000000007 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL typedef long long ll; ll N,W; ll w[110]; ll v[110]; ll dp[110][110][310]; int main() { cin >> N >> W; REP(i,N) cin >> w[i] >> v[i]; ll w0 = w[0]; REP(i,N) w[i] -= w0; REP(i,110)REP(k,110)REP(j,310) dp[i][k][j] = 0; for(int i=0;i<N;i++) { for(int k=0;k<N;k++){ REP(j,310) dp[i+1][k+1][j] = dp[i][k+1][j]; RREP(j,310) { if(j-w[i]>=0) { dp[i+1][k+1][j] = max(dp[i+1][k+1][j],dp[i][k][j-w[i]] + v[i]); } } } } ll ans = 0; for(int k=1;k<=N;k++){ ll Wt = W - w0 * k; REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:18: error: no matching function for call to 'min(int, ll)' 42 | REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); | ~~~^~~~~~~~~~ a.cc:4:42: note: in definition of macro 'REP' 4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:42:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 42 | REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); | ~~~^~~~~~~~~~ a.cc:4:42: note: in definition of macro 'REP' 4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) | ^ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:42:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]); | ~~~^~~~~~~~~~ a.cc:4:42: note: in definition of macro 'REP' 4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) | ^
s574179812
p03734
C++
#include <iostream> #include <string> #include <algorithm> using namespace std; #define FOR(i,a,b) for(int i = (a); i < (b); i++) #define REP(i,n) FOR(i,0,n) #define FORCLS(i,a,b) for(int i = (a); i <= (b); i++) #define REPCLS(i,n) FORCLS(i,1,n) using Int = long; Int N, W; const Int N_MAX = 101; const Int W_MAX = 1000000004; Int dp[N_MAX][W_MAX]; Int w[N_MAX]; Int v[N_MAX]; void solve() { cin >> N >> W; REP(i, N){ cin >> w[i + 1] >> v[i + 1]; } REP(i, W + 1) { dp[0][i] = 0; } for(int i = 1; i <= N; i++) { for(int j = 0; j <= W; j++) { Int v0 = dp[i-1][j]; Int v1 = (w[i] <= j) ? dp[i-1][j - w[i]] + v[i] : 0; dp[i][j] = max(v0, v1); } } cout << dp[N][W] << endl; } #ifdef DEBUG #define MAIN hoge #else #define MAIN main #endif int MAIN() { solve(); return 0; }
/tmp/ccZQKjap.o: in function `solve()': a.cc:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZQKjap.o a.cc:(.text+0x81): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZQKjap.o a.cc:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZQKjap.o a.cc:(.text+0x169): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccZQKjap.o a.cc:(.text+0x1a4): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccZQKjap.o collect2: error: ld returned 1 exit status
s915658706
p03734
C++
#include <iostream> #include <algorithm> #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL> res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:48:31: required from here 48 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'te
s152495374
p03734
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vint; typedef vector<vector<int> > vvint; typedef vector<long long> vll, vLL; typedef vector<vector<long long> > vvll, vvLL; #define VV(T) vector<vector< T > > template <class T> void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){ v.assign(a, vector<T>(b, t)); } #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep(i,0,n) #define clr(a) memset((a), 0 ,sizeof(a)) #define ALL(a) a.begin(),a.end() #define PB push_back const int INF = (1e9); const ll MOD = 1e9+7; const double EPS = 1e-5; const double PI=atan2(0,-1); int max = 0; int n,W; vint w(100,0),v(100,0); void dfs(int wsum,int vsum,int i){ if(i == n){ if(max < vsum) max = vsum; } else{ dfs(wsum,vsum,i+1); if(wsum+w[i] <= W){ dfs(wsum+w[i],vsum+v[i],i+1); } else{ if(max < vsum) max = vsum; } } } void sol(){ dfs(0,0,0); } int main(void){ cin >> n >> W; rep(i,n) cin >> w[i] >> v[i]; sol(); cout << max << endl; }
a.cc: In function 'void dfs(int, int, int)': a.cc:38:12: error: reference to 'max' is ambiguous 38 | if(max < vsum) | ^~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ In file included from /usr/include/c++/14/algorithm:60: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:32:5: note: 'int max' 32 | int max = 0; | ^~~ a.cc:39:13: error: reference to 'max' is ambiguous 39 | max = vsum; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:32:5: note: 'int max' 32 | int max = 0; | ^~~ a.cc:47:16: error: reference to 'max' is ambiguous 47 | if(max < vsum) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:32:5: note: 'int max' 32 | int max = 0; | ^~~ a.cc:48:17: error: reference to 'max' is ambiguous 48 | max = vsum; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:32:5: note: 'int max' 32 | int max = 0; | ^~~ a.cc: In function 'int main()': a.cc:62:13: error: reference to 'max' is ambiguous 62 | cout << max << endl; | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ a.cc:32:5: note: 'int max' 32 | int max = 0; | ^~~
s139533213
p03734
C++
#include <iostream> #include <algorithm> #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:48:31: required from here 48 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'te
s263522463
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:31: required from here 47 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5
s451150428
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:31: required from here 47 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5
s115630549
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (LL i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:31: required from here 47 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5
s068882890
p03734
C++
#include <iostream> #include <algorithm> #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (int i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:48:31: required from here 48 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'te
s646110388
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[1 << 20]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (int i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:31: required from here 47 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5
s130071382
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[(1 << 20)]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); LL seek = 1; for (int i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:31: required from here 47 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5
s425788256
p03734
C++
#include "bits/stdc++.h" #define MOD 1000000007 #define INF 11234567890 #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i<N;++i) typedef long long int LL; LL N, W, w[112], v[112]; std::pair<LL, LL>res[(1 << 20)]; LL N2, ans; int main() { in >> N >> W; rep(i, N) { in >> w[i] >> v[i]; } N2 = N / 2; rep(i, (1 << N2)) { LL sum_w = 0, sum_v = 0; rep(j, N2) { if (i >> j & 1) { sum_w += w[j], sum_v += v[j]; } } res[i] = std::make_pair(sum_w, sum_v); } std::sort(res, res + (1 << N2)); int seek = 1; for (int i = 1; i < (1 << N2); ++i) { if (res[seek - 1].second < res[i].second) { res[seek++] = res[i]; } } rep(i, (1 << (N - N2))) { LL sum_w = 0, sum_v = 0; rep(j, N - N2) { if (i >> j & 1) { sum_w += w[N2 + j]; sum_v += v[N2 + j]; } } if (sum_w <= W) { LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; ans = std::max(ans, sum_v + iter); } } out << ans << std::endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:31: required from here 47 | LL iter = (std::lower_bound(res, res + seek, std::make_pair(W - sum_w, INF)) - 1)->second; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'const std::pair<long long int, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5
s257165755
p03734
C++
#include<bits/stdc++.h> #include<vector> #include<list> #include<stack> #include<queue> #include<algorithm> using namespace std; int main(){ int N, long long W,v,w; scanf("%d %lld",&N,&W); vector<long long> dp(W+1); fill(dp.begin(), dp.end(), 0); for(int i=0;i<N;i++){ scanf("%lld %lld",&w,&v); dp[w]=max(dp[w],v); for(int j=0;j<W-w+1;j++){ if(dp[j]!=0){ dp[j+w]=max(dp[j+w],dp[j]+v); } } } printf("%lld\n",*max_element(dp.begin(),dp.end())); return 0; }
a.cc: In function 'int main()': a.cc:11:5: error: expected unqualified-id before 'long' 11 | long long W,v,w; | ^~~~ a.cc:12:25: error: 'W' was not declared in this scope 12 | scanf("%d %lld",&N,&W); | ^ a.cc:16:28: error: 'w' was not declared in this scope 16 | scanf("%lld %lld",&w,&v); | ^ a.cc:16:31: error: 'v' was not declared in this scope 16 | scanf("%lld %lld",&w,&v); | ^
s612925911
p03734
C++
// g++ temp.cpp // C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C //#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> /* //#if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> */ // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> /* //#if __cplusplus >= 201103L #include <array> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> */ using namespace std; #define fi first #define se second #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define each(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define maxch(x,y) x=max(x,y) #define minch(x,y) x=min(x,y) #define mp(a,b) make_pair(a,b) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define maxch(x,y) x=max(x,y) #define minch(x,y) x=min(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;} template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;} #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> P; typedef pair<P, int> PPI; #define INF INT_MAX/3 #define MAX_N 100 #define MAX_W 100000 ll n,w,i; ll sum_W = 0; void solve(){ cin.tie(0); ios::sync_with_stdio(false); cin>>n>>w; ll a,b; vector<P> v; rep(i,n){ cin>>a>>b; sum+=a; v.pb(P(a,b)); } ll dp[MAX_N+1][sum_W+5]; for(ll i=n-1;i>=0;i--){ for(ll j = 0; j <= w; j++){ if(j<v[i].fi){ dp[i][j] = dp[i+1][j]; } else { dp[i][j] = max(dp[i+1][j],dp[i+1][j-v[i].fi] +v[i].se); } } } cout<<dp[0][w]<<endl; } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:157:5: error: 'sum' was not declared in this scope 157 | sum+=a; | ^~~
s240749134
p03734
C++
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <fstream> #include <vector> #include <string> #include <set> #include <list> #include <map> #include <queue> #include <iterator> #include <iomanip> #include <stdio.h> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cmath> #include <ctime> #include <utility> #include <functional> #include <stack> #include <deque> #include <sstream> using namespace std; #define ll long long #define ld long double #define pdd pair<double,double> #define pll pair<ll, ll> #define pii pair<int,int> #define mod 1000000007 #define infinity (ll)1e18+1 #define PI 3.14159265358979 #define MP make_pair #define SZ size() #define PB push_back #define vi vector<int> #define vll vector<ll> #define vpll vector<pll> #define vpii vector<pii> #define FOR(i,a,b) for(ll i = (a); i < (b); ++i) #define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i) #define REPEAT(i) FOR(counter1234,0,i) #define ALL(a) a.begin(), a.end() int f(int a, int b) { return a > b; } int main() { int n; cin >> n; ll W; cin >> W; vll w(n), v(n); FOR(i, 0, n) cin >> w[i] >> v[i]; ll best = 0; vi w0, w1, w2, w3; FOR(i, 0, n) { if (w[i] - w[0] == 0) w0.push_back(v[i]); if (w[i] - w[0] == 1) w1.push_back(v[i]); if (w[i] - w[0] == 2) w2.push_back(v[i]); if (w[i] - w[0] == 3) w3.push_back(v[i]); } sort(ALL(w0), f); sort(ALL(w1), f); sort(ALL(w2, f)); sort(ALL(w3), f); ll curr = 0; FOR(x1, 0, w0.size() + 1) FOR(x2, 0, w1.size() + 1) FOR(x3, 0, w2.size() + 1) FOR(x4, 0, w3.size() + 1) { if (x1*w[0] + x2*(w[0] + 1) + x3*(w[0] + 2) + x4*(w[0] + 3) <= W) { curr = 0; FOR(i, 0, x1) curr += w0[i]; FOR(i, 0, x2) curr += w1[i]; FOR(i, 0, x3) curr += w2[i]; FOR(i, 0, x4) curr += w3[i]; best = max(best, curr); } } cout << best; return 0; }
a.cc:77:23: error: macro "ALL" passed 2 arguments, but takes just 1 77 | sort(ALL(w2, f)); | ^ a.cc:47:9: note: macro "ALL" defined here 47 | #define ALL(a) a.begin(), a.end() | ^~~ a.cc: In function 'int main()': a.cc:77:14: error: 'ALL' was not declared in this scope 77 | sort(ALL(w2, f)); | ^~~
s444393575
p03734
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<int> v[4]; int sum[4][110]; int main() { //freopen("file.in", "r", stdin); //freopen("file.out", "w", stdout); int n,w,a,b,x,sol=0; scanf("%d%d",&n,&w); scanf("%d%d",&a,&b); v[0].push_back(b); for(int i=2;i<=n;i++) { scanf("%d%d",&x,&b); v[x-a].push_back(b); } for(int i=0;i<4;i++) { sort(v[i].begin(),v[i].end()); reverse(v[i].begin(),v[i].end()); for(int j=0;j<v[i].size();j++) sum[i][j+1]=sum[i][j]+v[i][j]; } for(int i=0;i<=v[0].size();i++) for(int j=0;j<=v[1].size();j++) for(int q=0;q<=v[2].size();q++) { long long s=1LL*a*i+1LL*(a+1)*j+1LL*(a+2)*q; if(s>w) continue; int k=min(1LL*v[3].size(),(w-s)/(a+3)); sol=max(sol,sum[0][i]+sum[1][j]+sum[2][q]+sum[3][k]); } printf("%d",sol); return 0; }
a.cc: In function 'int main()': a.cc:36:26: error: no matching function for call to 'min(long long unsigned int, long long int)' 36 | int k=min(1LL*v[3].size(),(w-s)/(a+3)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:36:26: note: deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int') 36 | int k=min(1LL*v[3].size(),(w-s)/(a+3)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:36:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int' 36 | int k=min(1LL*v[3].size(),(w-s)/(a+3)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s196806221
p03734
C++
// a code about cooties #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <cstring> #include <cassert> using namespace std; #define rep(i,a,n) for (int i=a;i<(int)(n);i++) #define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--) template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;} template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;} template<typename T, typename U> ostream& operator<<(ostream& s, pair<T, U> t) {s << "(" << t.first << "," << t.second << ")"; return s;} template<typename T, typename U> istream& operator>>(istream& s, pair<T, U> &t) {s >> t.first >> t.second; return s;} typedef long long ll; const int N = 123; const ll INF = 1e18; ll dp[N][N * 3]; int main() { ios_base::sync_with_stdio(false); int n; ll w; cin >> n >> w; vector<pair<ll, ll>> a(n); cin >> a; ll w0 = a[0].first; //rep(i, 0, N) rep(j, 0, N * 3) dp[i][j] = INF; //dp[0][0] = 0; ll res = 0; rep(i, 0, n) { ll weight, value; tie(weight, value) = a[i]; weight -= a[0]; per(inside, 0, N) rep(added, 0, N) { ll cw = inside * w0 + added; if (cw + weight + w0 <= w) { dp[inside + 1][added + weight] = max(dp[inside + 1][added + weight], dp[inside][added] + value); res = max(res, dp[inside + 1][added + weight]); } } } cout << res << endl; }
a.cc: In function 'int main()': a.cc:41:16: error: no match for 'operator-=' (operand types are 'll' {aka 'long long int'} and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'}) 41 | weight -= a[0]; a.cc: In instantiation of 'std::istream& operator>>(std::istream&, std::vector<_Tp>&) [with T = std::pair<long long int, long long int>; std::istream = std::basic_istream<char>]': a.cc:33:12: required from here 33 | cin >> a; | ^ a.cc:17:91: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'}) 17 | template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;} | ~~^~~~~ In file included from /usr/include/c++/14/iostream:42, from a.cc:2: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std:
s312012384
p03735
C++
#include <bits/stdc++.h> using namespace std; #define ll int64_t typedef pair<int,int> P; const int N=2e5+5; const int INF=numeric_limits<int>::max(); int n,x[N],y[N],mn[N],mx[N]; set<P> Smin,Smax; P Rx,Rn,Bx,Bn; void del(int id){ Smin.erase({mn[id],id}); Smax.erase({mx[id],id}); } void add(int id){ Smin.emplace(mn[id],id); Smax.emplace(mx[id],id); } int main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n; for(int i=0;i<n;++i){ cin>>x[i]>>y[i]; mn[i]=min(x[i],y[i]); mx[i]=max(x[i],y[i]); Smin.emplace(mn[i],i); Smax.emplace(mx[i],i); } ll res=numeric_limits<ll>::max(); //choose Rmin->Rmax->Bmin->Bmax Rn=*Smin.begin(); auto it=Smax.rbegin(); if(it->second==Rn.second) it--; Rx=*it; if(mx[Rn.second]<mn[Rx.second]) Bn={mx[Rn.second],Rn.second}, Bx={mn[Rx.second],Rx.second}; else Bn={mn[Rx.second],Rx.second}, Bx={mx[Rn.second],Rn.second}; //choose Bmin first P oldBn=Bn,oldBx=Bx; if(Smax.begin()->first<Bn.first) Bn=*Smax.begin(); for(int i=0;i<n;++i) if(i!=Rn.second&&i!=Rx.second&&i!=Bn.second){ if(mn[i]<Bn.first) Bx.first=max(Bx.first,mx[i]); else Bx.first=max(Bx.first,mn[i]); } res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); //choose Bmax first Bn=oldBn,Bx=oldBx; if(Smin.rbegin()->first>Bx.first) Bx=*Smin.rbegin(); for(int i=0;i<n;++i) if(i!=Rn.second&&i!=Rx.second&&i!=Bx.second){ if(mx[i]>Bx.first) Bn.first=min(Bn.first,mn[i]); else Bn.first=min(Bn.first,mx[i]); } res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); //choose Bmin->Rmax->Bmax->Rmin Bn=Rn; Rn={mx[Bn.second],Bn.second}; Bx={mn[Rx.second],Rx.second}; P oldRn=Rn; oldBx=Bx; //choose Rmin first if(Smax.begin()->first<Rn.first) Rn=*Smax.begin(); for(int i=0;i<n;++i) if(i!=Rn.second&&i!=Rx.second&&i!=Bn.second){ if(mx[i]>=Rn.first) Bx.first=max(Bx.first,mn[i]); else Bx.first=max(Bx.first,mx[i]); } res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); //choose Bmax first Rn=oldRn; Bx=oldBx; if(Smin.rbegin()->first>Bx.first) Bx=*Smin.rbegin(); for(int i=0;i<n;++i) if(i!=Rx.second&&i!=Bn.second&&i!=Bx.second){ if(mn[i]<=Bx.first) Rn.first=min(Rn.first,mx[i]); else Rn.first=min(Rn.first,mn[i]); } res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); // cerr<<Rx.first<<' '<<Rn.first<<' '<<Bx.first<<' '<<Bn.first<<'\n'; cout<<res<<'\n'; }
a.cc: In function 'int main()': a.cc:53:16: error: no matching function for call to 'min(int64_t&, long long int)' 53 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:53:16: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 53 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:53:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 53 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:62:16: error: no matching function for call to 'min(int64_t&, long long int)' 62 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:62:16: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 62 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:62:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 62 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:76:16: error: no matching function for call to 'min(int64_t&, long long int)' 76 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:76:16: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 76 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:76:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 76 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:86:16: error: no matching function for call to 'min(int64_t&, long long int)' 86 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:86:16: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 86 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:86:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 86 | res=min(res,1LL*(Rx.first-Rn.first)*(Bx.first-Bn.first)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s752935291
p03735
C++
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; cin >> N; vector<pair<ll, ll>> P(N); ll mi = 1e10, ma = 0, mi_index, ma_index; for (int i = 0; i < N; i++) { ll X, Y; cin >> X >> Y; if (X > Y) swap(X, Y); P[i] = {X, Y}; } sort(P.begin(), P.end()); mi = P[0].first; mi_index = 0; if (N == 1) { cout << 0 << endl; return 0; } if (N == 2) { cout << min(abs((P[0].first-P[1].first)*(P[0].second-P[1].second)), abs((P[0].first-P[1].second)*(P[0].second-P[1].first))); return 0; } for (int i = 0; i < N; i++) { if (ma <= P[i].second) { ma = P[i].second; ma_index = i; } } ll cand1, cand2; ll rmin = mi, rmax = mi, bmax = ma, bmin = ma; for (int i = 0; i < N; i++) { rmax = max(rmax, P[i].first); bmin = min(bmin, P[i].second); } cand1 = (rmax-rmin)*(bmax-bmin); if (mi_index == ma_index) { cout << cand1 << endl; return 0; } rmin = mi; rmax = ma; bmin = min(P[mi_index].second, P[ma_index].first); bmax = max(P[mi_index].second, P[ma_index].first); ll l = bmax-bmin-1, r = 1e9+1; while (r-l > 1) { ll c = (l+r)/2; priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; for (int i = 0; i < N; i++) { if (i == mi_index || i == ma_index) continue; pq.push({P[i].first, -1}); pq.push({P[i].second+c, 1}); if (P[i].second - P[i].first > c) { pq.push({P[i].first + c, 1}); pq.push({P[i].second, -1}); } } int cnt = 0; bool check = false; while (!pq.empty()) { ll now = pq.top().first; cnt -= pq.top().second; pq.pop(); if (!((now >= bmin && now <= bmax+c) || (now >= bmax && now <= bmax+c))) continue; if (cnt == N-2) { check = true; break; } } if (check) r = c; else l = c; } cand2 = r * (rmax - rmin); cout << min(cand1, cand2) << endl; return 0; } #include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; cin >> N; vector<pair<ll, ll>> P(N); ll mi = 1e10, ma = 0, mi_index, ma_index; for (int i = 0; i < N; i++) { ll X, Y; cin >> X >> Y; if (X > Y) swap(X, Y); P[i] = {X, Y}; } sort(P.begin(), P.end()); mi = P[0].first; mi_index = 0; if (N == 1) { cout << 0 << endl; return 0; } if (N == 2) { cout << min(abs((P[0].first-P[1].first)*(P[0].second-P[1].second)), abs((P[0].first-P[1].second)*(P[0].second-P[1].first))); return 0; } for (int i = 0; i < N; i++) { if (ma <= P[i].second) { ma = P[i].second; ma_index = i; } } ll cand1, cand2; ll rmin = mi, rmax = mi, bmax = ma, bmin = ma; for (int i = 0; i < N; i++) { rmax = max(rmax, P[i].first); bmin = min(bmin, P[i].second); } cand1 = (rmax-rmin)*(bmax-bmin); if (mi_index == ma_index) { cout << cand1 << endl; return 0; } rmin = mi; rmax = ma; bmin = min(P[mi_index].second, P[ma_index].first); bmax = max(P[mi_index].second, P[ma_index].first); ll l = bmax-bmin-1, r = 1e9+1; while (r-l > 1) { ll c = (l+r)/2; priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq; for (int i = 0; i < N; i++) { if (i == mi_index || i == ma_index) continue; pq.push({P[i].first, -1}); pq.push({P[i].second+c, 1}); if (P[i].second - P[i].first > c) { pq.push({P[i].first + c, 1}); pq.push({P[i].second, -1}); } } int cnt = 0; bool check = false; while (!pq.empty()) { ll now = pq.top().first; cnt -= pq.top().second; pq.pop(); if (!((now >= bmin && now <= bmax+c) || (now >= bmax && now <= bmax+c))) continue; if (cnt == N-2) { check = true; break; } } if (check) r = c; else l = c; } cand2 = r * (rmax - rmin); cout << min(cand1, cand2) << endl; return 0; }
a.cc:91:5: error: redefinition of 'int main()' 91 | int main() { | ^~~~ a.cc:5:5: note: 'int main()' previously defined here 5 | int main() { | ^~~~
s338644910
p03735
C++
// 最大最小で場合分けまで考察済み // sortして順番で良い証明ができなかった
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s938213817
p03735
C++
瞬殺(最近のコンテストで類題が出た)
a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token 1 | 瞬殺(最近のコンテストで類題が出た) | ^
s871548403
p03735
C++
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <cmath> #include <cstdio> #include <iomanip> #include <fstream> #include <cassert> #include <cstring> #include <unordered_set> #include <unordered_map> #include <numeric> #include <ctime> #include <bitset> #include <complex> #include <chrono> #include <random> #include <functional> using namespace std; typedef long long ll; const int N = 2e5 + 9; const int INF = 1e9 + 239; mt19937 rng(10); int a[N]; int b[N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } ll ans = (ll)INF * INF; for (int j = 0; j < 10; j++) int min_f = INF; int min_s = INF; int max_f = -INF; int max_s = -INF; for (int i = 0; i < n; i++) { int v = rng() & 1; if (v) swap(a[i], b[i]); min_f = min(min_f, a[i]); min_s = min(min_s, b[i]); max_f = max(max_f, a[i]); max_s = max(max_s, b[i]); if (v) swap(a[i], b[i]); } ans = min(ans, ((ll)max_f - (ll)min_f) * (max_s - min_s)); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:54:25: error: 'min_f' was not declared in this scope; did you mean 'min_s'? 54 | min_f = min(min_f, a[i]); | ^~~~~ | min_s a.cc:60:49: error: 'min_f' was not declared in this scope; did you mean 'min_s'? 60 | ans = min(ans, ((ll)max_f - (ll)min_f) * (max_s - min_s)); | ^~~~~ | min_s a.cc: At global scope: a.cc:62:9: error: 'cout' does not name a type 62 | cout << ans << endl; | ^~~~ a.cc:63:1: error: expected declaration before '}' token 63 | } | ^
s711651332
p03735
C++
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) #define ALL(obj) (obj).begin(), (obj).end() #define EPS (1e-9) #define INF (1e17) #define PI (acos(-1)) //const double PI = acos(-1); //const double EPS = 1e-15; //long long INF=(long long)1E17; #define i_7 (long long)(1e9+7) //#define i_7 998'244'353 long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } long long po(long a, long b){ if(b==0){ return 1; } long long z = po(a,b/2); z = mod(z*z); if(b%2!=0){ z = mod(a*z); } return z; } bool prime_(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=std::sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd_(long long a, long long b){ if(a<b){ std::swap(a,b); } if(a%b==0){ return b; }else{ return gcd_(b,a%b); } } long long lcm_(long long x, long long y){ return (x/gcd_(x,y))*y; } //using namespace std; //using namespace boost::multiprecision; //using namespace __gnu_pbds; int main(){ using namespace std; int n; cin>>n; long long x[n], y[n]; typedef pair<long long, long long> P; vector<P> xy; REP(i,n){ cin>>x[i]>>y[i]; if(x[i] > y[i]){ swap(x[i], y[i]); } xy.push_back(P{x[i], y[i]}); } sort(ALL(xy)); REP(i,n){ x[i] = xy[i].first; y[i] = xy[i].second; } long long m = INF, M = 0; int mi = -1, Mi = -1; REP(i,n){ if(m > x[i]){ m = x[i]; mi = i; } if(M < y[i]){ M = y[i]; Mi = i; } } long long my = INF; REP(i,n){ my = min(my, y[i]); } long long ans = (x[n-1] - x[0]) * (M - my); long long rm = x[0], rM = x[n-1], bm = my, bM = M; REP(i,n){ long long temp; return 0; }
a.cc: In function 'int main()': a.cc:111:2: error: expected '}' at end of input 111 | } | ^ a.cc:69:11: note: to match this '{' 69 | int main(){ | ^
s331670747
p03735
C++
#include <bits/stdc++.h> using namespace std; #define int long long // #define double long double #define FOR(i, a, b) for(ll i = (a); i < (b); ++i) #define FORR(i, a, b) for(ll i = (a); i > (b); --i) #define REP(i, n) for(ll i = 0; i < (n); ++i) #define REPR(i, n) for(ll i = n; i >= 0; i--) #define FOREACH(x, a) for(auto &(x) : (a)) #define VECCIN(x) \ for(auto &youso_ : (x)) cin >> youso_ #define bitcnt(x) __builtin_popcount(x) #define lbit(x) __builtin_ffsll(x) #define rbit(x) __builtin_clzll(x) #define SZ(x) ((ll)(x).size()) #define fi first #define se second #define All(a) (a).begin(), (a).end() #define rAll(a) (a).rbegin(), (a).rend() #define vmin(x) min_element(All(x)) #define vmax(x) max_element(All(x)) #define PERM(c) \ sort(All(c)); \ for(bool cp = true; cp; cp = next_permutation(All(c))) #define MKORDER(n) \ vector<ll> od(n); \ iota(All(od), 0LL); template <typename T = long long> inline T IN() { T x; cin >> x; return (x); } inline void CIN() {} template <class Head, class... Tail> inline void CIN(Head &&head, Tail &&... tail) { cin >> head; CIN(move(tail)...); } #define CCIN(...) \ char __VA_ARGS__; \ CIN(__VA_ARGS__) #define DCIN(...) \ double __VA_ARGS__; \ CIN(__VA_ARGS__) #define LCIN(...) \ ll __VA_ARGS__; \ CIN(__VA_ARGS__) #define SCIN(...) \ string __VA_ARGS__; \ CIN(__VA_ARGS__) #define Yes(a) cout << (a ? "Yes" : "No") << "\n" #define YES(a) cout << (a ? "YES" : "NO") << "\n" #define Printv(v) \ { \ FOREACH(x, v) { cout << x << " "; } \ cout << "\n"; \ } template <typename T = string> inline void eputs(T s) { cout << s << "\n"; exit(0); } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); } // generic lambdas template <typename F> #if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard) [[nodiscard]] #elif defined(__GNUC__) && \ (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4) __attribute__((warn_unused_result)) #endif // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard) static inline constexpr decltype(auto) fix(F &&f) noexcept { return [f = std::forward<F>(f)](auto &&... args) { return f(f, std::forward<decltype(args)>(args)...); }; } template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>; template <typename T> using PQ = priority_queue<T>; typedef long long ll; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<ll, ll> PL; typedef vector<PL> VPL; typedef vector<bool> VB; typedef vector<double> VD; typedef vector<string> VS; const int INF = 1e9; const int MOD = 1e9 + 7; // const int MOD = 998244353; const ll LINF = 1e18; const double PI = atan(1.0) * 4.0; const ll dw[] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll dh[] = {0, 1, 1, 1, 0, -1, -1, -1}; #define PI 3.141592653589793238 signed main() { LCIN(N); VL x(N), y(N); multiset<ll> r, b; REP(i, N) { cin >> x[i] >> y[i]; if(y[i] < x[i]) swap(y[i], x[i]); r.emplace(y[i]); b.emplace(x[i]); } MKORDER(N); sort(All(od), [&](ll a, ll b) { return PL(x[a],y[a])<PL(x[b],y[b]);}); ll ans = (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin()); REP(i, N) { ll idx = od[i]; b.erase(b.find(x[idx])), r.emplace(r.find(x[idx])); r.erase(r.find(y[idx])), b.emplace(b.find(y[idx])); ans = min(ans, (*r.rbegin() - *r.begin()) * (*b.rbegin() - *b.begin())); } cout << ans << "\n"; }
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33, from /usr/include/c++/14/bits/allocator.h:46, from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = long long int; _Args = {std::_Rb_tree_const_iterator<long long int>}; _Tp = std::_Rb_tree_node<long long int>]': /usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = long long int; _Args = {std::_Rb_tree_const_iterator<long long int>}; _Tp = std::_Rb_tree_node<long long int>; allocator_type = std::allocator<std::_Rb_tree_node<long long int> >]' 575 | __a.construct(__p, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:593:32: required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(_Link_type, _Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long long int>}; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; _Link_type = std::_Rb_tree_node<long long int>*]' 593 | _Alloc_traits::construct(_M_get_Node_allocator(), | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 594 | __node->_M_valptr(), | ~~~~~~~~~~~~~~~~~~~~ 595 | std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:610:21: required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long long int>}; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; _Link_type = std::_Rb_tree_node<long long int>*]' 610 | _M_construct_node(__tmp, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1633:32: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Auto_node::_Auto_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long long int>}; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]' 1633 | _M_node(__t._M_create_node(std::forward<_Args>(__args)...)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:2447:13: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_equal(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long long int>}; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::iterator]' 2447 | _Auto_node __z(*this, std::forward<_Args>(__args)...); | ^~~ /usr/include/c++/14/bits/stl_multiset.h:460:32: required from 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long long int>}; _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator]' 460 | { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); } | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:121:43: required from here 121 | b.erase(b.find(x[idx])), r.emplace(r.find(x[idx])); | ~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/new_allocator.h:191:11: error: cannot convert 'std::_Rb_tree_const_iterator<long long int>' to 'long long int' in initialization 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s242178168
p03735
C++
#include<bits/stdc++.h> #define INF 1000000007 using namespace std; struct sakura { long long x; long long y; } ball[MAXN];const int MAXN = 222222; long long x[MAXN]; long long y[MAXN]; long long maxn[MAXN]; long long minl[MAXN]; long long n,ans,ans1,ans2,bmax,bmin,rmax,rmin; inline bool cmp(sakura xx,sakura yy){ return xx.x<yy.x; } int main() { scanf("%lld",&n); bmax=rmax=-1;bmin=rmin=INF; for(register int i=1;i<=n;++i) { scanf("%lld%lld",&x[i],&y[i]); if(x[i]>y[i]) swap(x[i],y[i]); ball[i].x=x[i];ball[i].y=y[i]; bmax=max(bmax,y[i]); bmin=min(bmin,y[i]); rmax=max(rmax,x[i]); rmin=min(rmin,x[i]); } ans1=(bmax-bmin)*(rmax-rmin); bmin=rmin;sort(ball+1,ball+n+1,cmp); ans2=INF;maxn[1]=minl[1]=ball[1].y; for(register int i=2;i<=n;++i) { maxn[i]=max(maxn[i-1],ball[i].y); minl[i]=min(minl[i-1],ball[i].y); if(i!=n) ans2=min(ans2,max(maxn[i],ball[n].x)-min(minl[i],ball[i+1].x)); } ans2*=(bmax-bmin);ans=min(ans1,ans2); printf("%lld\n",ans); return 0; }
a.cc:10:6: error: 'MAXN' was not declared in this scope 10 | ball[MAXN];const int MAXN = 222222; | ^~~~ a.cc: In function 'int main()': a.cc:21:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 21 | for(register int i=1;i<=n;++i) | ^ a.cc:25:9: error: 'ball' was not declared in this scope 25 | ball[i].x=x[i];ball[i].y=y[i]; | ^~~~ a.cc:32:20: error: 'ball' was not declared in this scope 32 | bmin=rmin;sort(ball+1,ball+n+1,cmp); | ^~~~ a.cc:34:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 34 | for(register int i=2;i<=n;++i) | ^
s347553522
p03735
C++
#include<bits/stdc++.h> #define INF 1000000007 using namespace std; struct sakura { long long x; long long y; } const int MAXN = 222222; ball[MAXN]; long long x[MAXN]; long long y[MAXN]; long long maxn[MAXN]; long long minl[MAXN]; long long n,ans,ans1,ans2,bmax,bmin,rmax,rmin; inline bool cmp(sakura xx,sakura yy){ return xx.x<yy.x; } int main() { scanf("%lld",&n); bmax=rmax=-1;bmin=rmin=INF; for(register int i=1;i<=n;++i) { scanf("%lld%lld",&x[i],&y[i]); if(x[i]>y[i]) swap(x[i],y[i]); ball[i].x=x[i];ball[i].y=y[i]; bmax=max(bmax,y[i]); bmin=min(bmin,y[i]); rmax=max(rmax,x[i]); rmin=min(rmin,x[i]); } ans1=(bmax-bmin)*(rmax-rmin); bmin=rmin;sort(ball+1,ball+n+1,cmp); ans2=INF;maxn[1]=minl[1]=ball[1].y; for(register int i=2;i<=n;++i) { maxn[i]=max(maxn[i-1],ball[i].y); minl[i]=min(minl[i-1],ball[i].y); if(i!=n) ans2=min(ans2,max(maxn[i],ball[n].x)-min(minl[i],ball[i+1].x)); } ans2*=(bmax-bmin);ans=min(ans1,ans2); printf("%lld\n",ans); return 0; }
a.cc:8:2: error: expected ';' after struct definition 8 | } | ^ | ; a.cc:10:1: error: 'ball' does not name a type 10 | ball[MAXN]; | ^~~~ a.cc: In function 'int main()': a.cc:21:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 21 | for(register int i=1;i<=n;++i) | ^ a.cc:25:9: error: 'ball' was not declared in this scope 25 | ball[i].x=x[i];ball[i].y=y[i]; | ^~~~ a.cc:32:20: error: 'ball' was not declared in this scope 32 | bmin=rmin;sort(ball+1,ball+n+1,cmp); | ^~~~ a.cc:34:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 34 | for(register int i=2;i<=n;++i) | ^
s001565730
p03735
C++
#include<bits/stdc++.h> #define INF 1000000007 using namespace std; struct sakura { long long x; long long y; } const int MAXN = 200000 + 30000; ball[MAXN]; long long x[MAXN]; long long y[MAXN]; long long maxn[MAXN]; long long minl[MAXN]; long long n,ans,ans1,ans2,bmax,bmin,rmax,rmin; inline bool cmp(sakura xx,sakura yy){ return xx.x<yy.x; } int main() { scanf("%lld",&n); bmax=rmax=-1;bmin=rmin=INF; for(register int i=1;i<=n;++i) { scanf("%lld%lld",&x[i],&y[i]); if(x[i]>y[i]) swap(x[i],y[i]); ball[i].x=x[i];ball[i].y=y[i]; bmax=max(bmax,y[i]); bmin=min(bmin,y[i]); rmax=max(rmax,x[i]); rmin=min(rmin,x[i]); } ans1=(bmax-bmin)*(rmax-rmin); bmin=rmin;sort(ball+1,ball+n+1,cmp); ans2=INF;maxn[1]=minl[1]=ball[1].y; for(register int i=2;i<=n;++i) { maxn[i]=max(maxn[i-1],ball[i].y); minl[i]=min(minl[i-1],ball[i].y); if(i!=n) ans2=min(ans2,max(maxn[i],ball[n].x)-min(minl[i],ball[i+1].x)); } ans2*=(bmax-bmin);ans=min(ans1,ans2); printf("%lld\n",ans); return 0; }
a.cc:8:2: error: expected ';' after struct definition 8 | } | ^ | ; a.cc:10:1: error: 'ball' does not name a type 10 | ball[MAXN]; | ^~~~ a.cc: In function 'int main()': a.cc:21:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 21 | for(register int i=1;i<=n;++i) | ^ a.cc:25:9: error: 'ball' was not declared in this scope 25 | ball[i].x=x[i];ball[i].y=y[i]; | ^~~~ a.cc:32:20: error: 'ball' was not declared in this scope 32 | bmin=rmin;sort(ball+1,ball+n+1,cmp); | ^~~~ a.cc:34:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 34 | for(register int i=2;i<=n;++i) | ^
s234111144
p03735
C++
#include<bits/stdc++.h> //ios::sync_with_stdio(false); //cin.tie(0); using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pii,int> ppii; typedef pair<int,pii> pipi; typedef pair<ll,ll> pll; typedef pair<pll,ll> ppll; typedef pair<ll,pll> plpl; typedef tuple<ll,ll,ll> tl; ll mod=1000000007; ll mod2=998244353; ll inf=1000000000000000000; double pi=2*acos(0); #define rep(i,m,n) for(ll i=m;i<n;i++) #define rrep(i,n,m) for(ll i=n;i>=m;i--) int dh[4]={1,-1,0,0}; int dw[4]={0,0,1,-1}; int ddh[8]={-1,-1,-1,0,0,1,1,1}; int ddw[8]={-1,0,1,-1,1,-1,0,1}; ll lmax(ll a,ll b){ if(a<b)return b; else return a; } ll lmin(ll a,ll b){ if(a<b)return a; else return b; } ll gcd(ll a,ll b){ if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b); } ll Pow(ll n,ll k){ ll ret=1; ll now=n; while(k>0){ if(k&1)ret*=now; now*=now; k/=2; } return ret; } ll gya[200010]; ll kai[200010]; ll m; ll beki(ll n,ll k){ ll ret=1; ll now=n; while(k>0){ if(k%2==1){ ret*=now; ret%=m; } now*=now; now%=m; k/=2; } return ret; } ll gyaku(ll n){ return beki(n,mod-2); } void nckinit(ll n){ kai[0]=1; kai[1]=1; for(int i=2;i<=n;i++){ kai[i]=kai[i-1]*i; kai[i]%=mod; } gya[n]=gyaku(kai[n]); for(int i=n-1;i>=1;i--){ gya[i]=gya[i+1]*(i+1); gya[i]%=mod; } gya[0]=1; } ll nck(ll n,ll k){ if(k<0)return 0; if(k==0||n==k)return 1; ll ret=kai[n]; ret*=gya[n-k]; ret%=mod; ret*=gya[k]; ret%=mod; return ret; } ll npk(ll n,ll k){ if(k<0)return 0; if(k==0)return 1; ll ret=kai[n]; ret*=gya[n-k]; ret%=mod; return ret; } random_device rnd; mt19937 mt(rnd()); uniform_real_distribution<double> ra(1,6); int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n;cin>>n; ll a[n],b[n]; multiset<ll> st1,st2; vector<pll> v; rep(i,0,n){ cin>>a[i]>>b[i]; if(a[i]>b[i])swap(a[i],b[i]); st1.insert(a[i]); st2.insert(b[i]); v.push_back({a[i],i}); v.push_back({b[i],i}); } sort(v.begin(),v.end()); bool used[n]; fill(used,used+n,false); used[v.back().second]=true; ll ans=inf; ll c=0; rep(i,0,v.size()-1){ if(c==0){ auto itr=st1.end();itr--; auto itr2=st2.end();itr2--; ans=min(ans,(*itr-*st1.begin())*(*itr2-*st2.begin())); } ll now=v[i].first,num=v[i].second; if(used[num]){ c=1; continue; } c=0; used[num]=true; ll na=a[num]; ll nb=b[num]; itr=st1.lower_bound(na); itr2=st2.lower_bound(nb); st1.erase(itr); st2.erase(itr2); st1.insert(nb); st2.insert(na); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:138:5: error: 'itr' was not declared in this scope 138 | itr=st1.lower_bound(na); | ^~~ a.cc:139:5: error: 'itr2' was not declared in this scope 139 | itr2=st2.lower_bound(nb); | ^~~~
s039776870
p03735
C++
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> using namespace std; namespace __output { template<class T1, class T2> void pr(const pair<T1,T2>& x); template<class T, size_t SZ> void pr(const array<T,SZ>& x); template<class T> void pr(const vector<T>& x); template<class T> void pr(const set<T>& x); template<class T1, class T2> void pr(const map<T1,T2>& x); template<class T> void pr(const T& x) { cout << x; } template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) { pr(first); pr(rest...); } template<class T1, class T2> void pr(const pair<T1,T2>& x) { pr("{",x.first,", ",x.second,"}"); } template<class T, bool pretty = true> void prContain(const T& x) { if (pretty) pr("{"); bool fst = 1; for (const auto& a: x) pr(!fst?pretty?", ":" ":"",a), fst = 0; if (pretty) pr("}"); } template<class T> void pc(const T& x) { prContain<T, false>(x); pr("\n"); } template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); } template<class T> void pr(const vector<T>& x) { prContain(x); } template<class T> void pr(const set<T>& x) { prContain(x); } template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); } void ps() { pr("\n"); } template<class Arg> void ps(const Arg& first) { pr(first); ps(); } template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) { pr(first," "); ps(rest...); } } using namespace __output; #define TRACE(x) x #define __pn(x) pr(#x, " = ") #define pd(...) __pn((__VA_ARGS__)), ps(__VA_ARGS__), cout << flush struct ball { int bag_idx; int ball_idx; int value; friend ostream& operator<<(ostream& os, const ball& b) { os << "{" << b.bag_idx << ", " << b.ball_idx << ", " << b.value << "}"; return os; } }; struct bag { int a; int b; int a_gidx; int b_gidx; friend ostream& operator<<(ostream& os, const bag& b) { os << "{" << b.a << ", " << b.a << ", " << b.a_gidx << ", " << b.b_gidx << "}"; return os; } }; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; vector<bag> bags(N); vector<ball> balls(2 * N); long long initial_product; int global_min = INT_MAX; int global_max = 0; int largest_red = 0; int smallest_blue = INT_MAX; for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; bags[i] = a < b ? bag{a, b} : bag{b, a}; int lower = bags[i].a; int upper = bags[i].b; largest_red = max(largest_red, lower); smallest_blue = min(smallest_blue, upper); global_min = min(global_min, lower); global_max = max(global_max, upper); balls[2 * i] = ball{i, 0, bags[i].a}; balls[2 * i + 1] = ball{i, 1, bags[i].b}; } initial_product = (long long)(global_max - smallest_blue) * (long long)(largest_red - global_min); sort( balls.begin(), balls.end(), [](ball b1, ball b2) { return b1.value < b2.value; } ); for (int i = 0; i < balls.size(); i++) { int bag_idx = balls[i].bag_idx; if (balls[i].ball_idx) { bags[bag_idx].b_gidx = i; } else { bags[bag_idx].a_gidx = i; } } map<int, int> blues; map<int, int> reds; int global_max_idx = balls[2 * N - 1].bag_idx; blues[global_max_idx] = 1; reds[global_max_idx] = 0; int global_min_idx = balls[0].bag_idx; blues[global_min_idx] = 0; reds[global_min_idx] = 1; map<int, int> reds2 = reds; int r_max_idx_bound; for (int i = 2 * N - 2; i > 0; i--) { ball bal = balls[i]; if (reds2.count(bal.bag_idx)) { if (bal.bag_idx == global_min_idx or bal.bag_idx == global_max_idx) { r_max_idx_bound = i; } else { r_max_idx_bound = i + 1; } break; } reds2[bal.bag_idx] = bool(bal.ball_idx); } int cur_r_min; for (int i = 1; i < 2 * N; i++) { int bag_idx = balls[i].bag_idx; if (reds.count(bag_idx)) { cur_r_min = i; break; } reds[bag_idx] = 1; blues[bag_idx] = 0; } int smallest_diff = INT_MAX; for (int i = 2 * N - 2; i >= r_max_idx_bound; i--) { int bag_idx = balls[i].bag_idx; if (!reds.count(bag_idx)) { reds[bag_idx] = 1; blues[bag_idx] = 0; } smallest_diff = min(smallest_diff, balls[i].value - balls[cur_r_min].value); if (i == r_max_idx_bound) break; cur_r_min = min(cur_r_min, bags[i].a_gidx); blues[bag_idx] = 1; reds[bag_idx] = 0; } long long new_product = (long long)smallest_diff * (long long)(global_max - global_min); cout << min(initial_product, new_product) << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:85:22: error: 'INT_MAX' was not declared in this scope 85 | int global_min = INT_MAX; | ^~~~~~~ a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include <set> +++ |+#include <climits> 6 | using namespace std;
s828564848
p03735
C
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rep1(i,n) for(int i=1;i<=(int)(n);++i) #define rep11(i,n) for(int i=1;i<(int)(n);++i) #define repo(i,o,n) for(int i=o;i<(int)(n);++i) #define repm(i,n) for(int i=(int)(n)-1;i>=0;--i) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define sperase(v,n) (v).erase(remove(all(v), n), (v).end()) #define vdelete(v) (v).erase(unique(all(v)), (v).end()) #define pb(n) push_back(n) #define mp make_pair #define MOD 1000000007 #define INF LONG_LONG_MAX int n,x,y,max_min=INF,min_max,MIN=INF,MAX; signed main() { cin >> n; rep(i,n) { cin >> x >> y; if (x > y) swap(x,y); MIN = min(MIN,x); MAX = max(MAX,y); max_min = min(max_min,y); min_max = max(min_max,x); } cout << min((min_max-MIN) * (MAX-max_min), (MAX-MIN) * abs(min_max-max_min)) << endl; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s881154033
p03735
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; int main(){ ll n;cin>>n; ll x[n],y[n]; ll ma=0; ll mi=1000000000000; vector<pll> v; ll dai[n],syou[n]; for(ll i=0;i<n;i++){ cin>>x[i]>>y[i]; ma=max(ma,min(y[i],x[i])); mi=min(mi,max(x[i],y[i])); v.push_back(make_pair(x[i],i)); v.push_back(make_pair(y[i],i)); dai[i]=max(x[i],y[i]); syou[i]=min(x[i],y[i]); } if(n==1){ cout<<0<<endl; return 0; } sort(v.begin(),v.end()); ll ans=(v[v.size()-1].first-ma)*(mi-v[0].first); if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ ans=1000000000000000000; } ll nma=0,nmi=0; for(ll i=0;i<n;i++){ if(dai[i]==v[v.size()-1].first)nma++; if(syou[i]==v[0].first)nmi++; } ll cnt[n]; fill(cnt,cnt+n,0); ll sum=0; ll bma,bmi; for(ll i=v.size()-1;i>=0;i--){ ll now=v[i].second; if(cnt[now]==1){ bma=v[i].first; break; } if(syou[now]==v[0].first){ if(sum==nmi-1){ bma=v[i].first; break; } else{ sum++; } } cnt[now]++; } for(ll i=0;;i++){ ll now=v[i].second; if(cnt[now]==1){ bmi=v[i].first; break; } } ans=min(ans,(bma-bmi)*(v[v.size()-1].first-v[0].first)); cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:27:48: error: no match for 'operator>' (operand types are 'long long int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'}) 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1176:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1176 | operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1176:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/regex.h:1236:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1236 | operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1236:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/regex.h:1329:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1329 | operator>(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1329:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/regex.h:1403:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1403 | operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1403:5: note: template argument deduction/substitution failed: a.cc:27:61: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/regex.h:1497:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1497 | operator>(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1497:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/regex.h:1573:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1573 | operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1573:5: note: template argument deduction/substitution failed: a.cc:27:61: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/regex.h:1673:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1673 | operator>(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1673:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::pair<_T1, _T2>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:27:61: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int' 27 | if(v[0].first<v[1].first&&v[v.size()-1].first>v[v.size()-2]first&&v[0].second==v[v.size()-1].second){ | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits>
s913371872
p03735
C++
#include <iostream> #include <cstdio> #include <algorithm> typedef long long LL; const int MAXN = 2e5; const LL INF = 0x3f3f3f3f; int n; int mins[MAXN | 1], maxs[MAXN | 1]; LL ans; struct Num { int a, b; Num() {} friend bool operator < (const Num &x, const Num &y) { return x.a < y.a; } } p[MAXN | 1]; inline int read() { register int x = 0; register char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } return x; } n = read(); int min = 0, max = INF; int bmax = -1, rmax = -1; int bmin = INF, rmin = INF; for (int i = 1; i <= n; ++i) { p[i].a = read(); p[i].b = read(); if (p[i].a > p[i].b) std::swap(p[i].a, p[i].b); bmax = std::max(bmax, p[i].b); bmin = std::min(bmin, p[i].b); rmax = std::max(rmax, p[i].a); rmin = std::min(rmin, p[i].a); } std::sort(p + 1, p + 1 + n); ans = 1LL * (bmax - bmin) * (rmax - rmin); bmin = rmin; LL ans2 = INF; maxs[1] = mins[1] = p[1].b; for (int i = 2; i <= n; ++i) { maxs[i] = std::max(maxs[i - 1], p[i].b); mins[i] = std::min(mins[i - 1], p[i].b); if (i != n) ans2 = std::min(ans2, 1LL * std::max(maxs[i], p[n].a) - std::min(mins[i], p[i + 1].a)); } printf("%d\n", std::min(ans, ans2 * (bmax - bmin))); return 0; }
a.cc: In function 'int read()': a.cc:23:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 23 | register int x = 0; | ^ a.cc:24:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 24 | register char ch = getchar(); | ^~ a.cc: At global scope: a.cc:33:9: error: 'n' does not name a type 33 | n = read(); | ^ a.cc:37:9: error: expected unqualified-id before 'for' 37 | for (int i = 1; i <= n; ++i) { | ^~~ a.cc:37:25: error: 'i' does not name a type 37 | for (int i = 1; i <= n; ++i) { | ^ a.cc:37:33: error: expected unqualified-id before '++' token 37 | for (int i = 1; i <= n; ++i) { | ^~ a.cc:46:18: error: expected constructor, destructor, or type conversion before '(' token 46 | std::sort(p + 1, p + 1 + n); | ^ a.cc:47:9: error: 'ans' does not name a type 47 | ans = 1LL * (bmax - bmin) * (rmax - rmin); | ^~~ a.cc:48:9: error: 'bmin' does not name a type 48 | bmin = rmin; | ^~~~ a.cc:50:9: error: 'maxs' does not name a type 50 | maxs[1] = mins[1] = p[1].b; | ^~~~ a.cc:51:9: error: expected unqualified-id before 'for' 51 | for (int i = 2; i <= n; ++i) { | ^~~ a.cc:51:25: error: 'i' does not name a type 51 | for (int i = 2; i <= n; ++i) { | ^ a.cc:51:33: error: expected unqualified-id before '++' token 51 | for (int i = 2; i <= n; ++i) { | ^~ a.cc:56:15: error: expected constructor, destructor, or type conversion before '(' token 56 | printf("%d\n", std::min(ans, ans2 * (bmax - bmin))); | ^ a.cc:57:9: error: expected unqualified-id before 'return' 57 | return 0; | ^~~~~~ a.cc:58:1: error: expected declaration before '}' token 58 | } | ^
s648823514
p03735
C++
#include<vector> #include<cmath> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #define pb push_back #define gt getchar() #define ll long long #define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout) typedef std::pair<int,int> P; #define mk std::make_pair #define fr first #define sc second inline int in() { int k=0;char ch=gt;bool p=1; while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0; while(ch>'-')k=k*10+ch-'0',ch=gt; return p?k:-k; } const int N=4e5+5; ll ans=1e18; ll x[N],y[N],n,Mx,Mi,mx,mi,fz[N<<1],tot; std::vector<int>G[N<<1]; inline void upd(int x,int i){if(x>Mx)Mx=x,mx=i;if(x<Mi)Mi=x,mi=i;} inline void work1() { int mmx=-2e9,mmi=2e9; mmx=std::max(mmx,y[mx]); mmi=std::min(mmi,x[mi]); for(int i=1;i<=n;++i) if(i!=mx&&i!=mi) mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); ans=std::min(ans,1ll*(mmx-Mi)*(Mx-mmi)); } inline void work2() { for(int i=1;i<=n;++i)fz[++tot]=x[i],fz[++tot]=y[i]; std::sort(fz+1,fz+tot+1);tot=std::unique(fz+1,fz+tot+1)-fz-1; int mmi=std::min(y[mx],x[mi]),mmx=y[mx]+x[mi]-mmi; for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]); int l=std::lower_bound(fz+1,fz+tot+1,mmi)-fz; for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)G[std::lower_bound(fz+1,fz+tot+1,y[i])-fz].pb(i); for(int i=2;i<=l;++i) { ans=std::min(ans,1ll*(Mx-Mi)*(mmx-fz[i])); for(int j:G[i])mmx=std::max(mmx,x[j]); } } int main() { n=in();Mx=-2e9,Mi=2e9; for(int i=1;i<=n;++i) { upd(x[i]=in(),i),upd(y[i]=in(),i); if(x[i]<y[i])std::swap(x[i],y[i]); } work1(),work2();printf("%lld\n",ans); return 0; }
a.cc: In function 'void work1()': a.cc:30:21: error: no matching function for call to 'max(int&, long long int&)' 30 | mmx=std::max(mmx,y[mx]); | ~~~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:21: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 30 | mmx=std::max(mmx,y[mx]); | ~~~~~~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:5: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:21: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 30 | mmx=std::max(mmx,y[mx]); | ~~~~~~~~^~~~~~~~~~~ a.cc:31:21: error: no matching function for call to 'min(int&, long long int&)' 31 | mmi=std::min(mmi,x[mi]); | ~~~~~~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:31:21: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 31 | mmi=std::min(mmi,x[mi]); | ~~~~~~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:31:21: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 31 | mmi=std::min(mmi,x[mi]); | ~~~~~~~~^~~~~~~~~~~ a.cc:34:37: error: no matching function for call to 'max(int&, long long int&)' 34 | mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:34:37: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 34 | mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:34:37: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 34 | mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); | ~~~~~~~~^~~~~~~~~~ a.cc:34:60: error: no matching function for call to 'min(int&, long long int&)' 34 | mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:34:60: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 34 | mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:34:60: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 34 | mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]); | ~~~~~~~~^~~~~~~~~~ a.cc: In function 'void work2()': a.cc:42:58: error: no matching function for call to 'min(int&, long long int&)' 42 | for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:42:58: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 42 | for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:42:58: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 42 | for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]); | ~~~~~~~~^~~~~~~~~~ a.cc:42:81: error: no matching function for call to 'max(int&, long long int&)' 42 | for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]); | ~~~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_
s861698903
p03735
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll #define REP(i,n) for(int i=0;i<n;++i) #define SORT(name) sort(name.begin(), name.end()) #define ZERO(p) memset(p, 0, sizeof(p)) #define MINUS(p) memset(p, -1, sizeof(p)) #if 1 # define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__) #else # define DBG(fmt, ...) #endif const ll LLINF = (1LL<<60); const int INF = (1LL<<30); const double DINF = std::numeric_limits<double>::infinity(); const int MOD = 1000000007; #define MAX_N 200010 ll N; vector<ll> X, Y; enum State { Suspend = 0, Red = 1, Blue = 2 }; vector< pair<ll, ll> > XY; // first: val, second: index vector<ll> pair_pos; // XY[i] の、相方の XY での位置 signed main() { cin >> N; X.resize(N); Y.resize(N); REP(i, N) { cin >> X[i] >> Y[i]; // 小さい方を X にしておく if(X[i] > Y[i]) { swap(X[i], Y[i]); } XY.push_back(make_pair(X[i], i)); XY.push_back(make_pair(Y[i], i)); } SORT(XY); // pair_pos の作成 pair_pos.assign(2 * N, 0); { vector< vector<ll> > table(N, vector<ll>()); // X or Y で位置 i にいるものの、 XY での位置 REP(i, 2 * N) { table[XY[i].second].push_back(i); } REP(i, N) { pair_pos[table[i][0]] = table[i][1]; pair_pos[table[i][1]] = table[i][0]; } } // パターン 1 // 最小の値を赤に、最大の値を青にする場合 // → 赤にできるだけ小さい値を、青にできるだけ大きい値を入れるのが最善 ll r_min = XY[0].first; ll r_max = XY[pair_pos[2 * N - 1]].first; ll b_min = XY[pair_pos[0]].first; ll b_max = XY[2 * N - 1].first; // r_max/b_min を求める vector<ll> color(2 * N, Suspend); // XY[i] はどっちの色か color[0] = Red; color[pair_pos[2 * N - 1]] = Red; color[pair_pos[0]] = Blue; color[2 * N - 1] = Blue; ll cnt = 2; REP(i, 2 * N) { if(color[i] == Suspend) { color[i] = Red; color[pair_pos[i]] = Blue; r_max = max(r_max, XY[i].first); b_min = min(b_min, XY[pair_pos[i]].first); cnt++; } } assert(cnt == N); ll ans = (r_max - r_min) * (b_max - b_min); // パターン 2 // 最小の値も最大の値も赤にする場合 // → 青が取る区間を最小にするのが最善 if(pair_pos[0] == 2 * N - 1) { // 最大と最小が同じ袋 printf("%lld\n", ans); assert(false); return 0; } ll pos1 = 0; ll pos2 = 2 * N - 1; r_min = XY[pos1].first; r_max = XY[pos2].first; b_min = min(XY[pair_pos[pos1]].first, XY[pair_pos[pos2]].first); b_max = max(XY[pair_pos[pos1]].first, XY[pair_pos[pos2]].first); color.assign(2 * N, Suspend); color[pos1] = Red; color[pos2] = Red; color[pair_pos[pos2]] = Blue; color[pair_pos[pos1]] = Blue; cnt = 2; // まず [b_min, b_max] の中でまだ色が決まっていないやつを手当たり次第に取る ll l = min(pair_pos[0], pair_pos[2 * N - 1]); ll r = max(pair_pos[0], pair_pos[2 * N - 1]); ll base_l = l; ll base_r = r; if(cnt < N) { // とりあえずなるべく左側のもので充填してみる REP(i, 2 * N) { if(color[i] == Suspend) { color[i] = Blue; color[pair_pos[i]] = Red; cnt++; l = min(l, i); r = max(r, i); if(cnt == N) { break; } } } } assert(cnt == N); // 左から見て [l, r] を小さくできそうならそうする REP(i, 2 * N) { assert(color[i] != Suspend); if(color[i] == Blue) { l = i; if(l < pair_pos[i] && pair_pos[i] < r) { swap(color[i], color[pair_pos[i]]); } else { break; } } } // 右から見て [l, r] を小さくできそうならそうする for(ll i = 2 * N - 1; i >= 0; --i) { assert(color[i] != Suspend); if(color[i] == Blue) { r = i; if(l < pair_pos[i] && pair_pos[i] < r) { swap(color[i], color[pair_pos[i]]); } else { break; } } } b_max = XY[r].first; b_min = XY[l].first; ans = min(ans, (r_max - r_min) * (b_max - b_min)); // 一応両端を広げるパターンもやっておく r_min = XY[pos1].first; r_max = XY[pos2].first; b_min = min(XY[pair_pos[pos1]].first, XY[pair_pos[pos2]].first); b_max = max(XY[pair_pos[pos1]].first, XY[pair_pos[pos2]].first); color.assign(2 * N, Suspend); color[pos1] = Red; color[pos2] = Red; color[pair_pos[pos2]] = Blue; color[pair_pos[pos1]] = Blue; cnt = 2; l = min(pair_pos[0], pair_pos[2 * N - 1]); r = max(pair_pos[0], pair_pos[2 * N - 1]); ll base_l = l; ll base_r = r; // まず [b_min, b_max] の中でまだ色が決まっていないやつを手当たり次第に取る for(ll i = base_l + 1; i < base_r; ++i) { if(color[i] == Suspend) { color[i] = Blue; color[pair_pos[i]] = Red; cnt++; } if(cnt == N) { break; } } // まだ色がついていない場所があるなら、なるべく青の max - min が // 大きくならないような範囲を探す while(cnt < N) { ll next_l = l; while(next_l >= 0) { if(color[next_l] == Suspend) { break; } next_l--; } ll next_r = r; while(next_r < 2 * N) { if(color[next_r] == Suspend) { break; } next_r++; } if(next_l >= 0 && next_r < 2 * N) { // どちらか近い方をとる ll sub_l = abs(XY[base_l].first - XY[next_l].first); ll sub_r = abs(XY[base_r].first - XY[next_r].first); if(sub_l < sub_r) { color[next_l] = Blue; color[pair_pos[next_l]] = Red; l = next_l; } else { color[next_r] = Blue; color[pair_pos[next_r]] = Red; r = next_r; } cnt++; } else if(next_l >= 0 && next_r >= 2 * N) { // l をとる color[next_l] = Blue; color[pair_pos[next_l]] = Red; l = next_l; cnt++; } else if(next_l < 0 && next_r < 2 * N) { // r をとる color[next_r] = Blue; color[pair_pos[next_r]] = Red; r = next_r; cnt++; } else { assert(false); } } assert(cnt == N); b_max = XY[r].first; b_min = XY[l].first; ans = min(ans, (r_max - r_min) * (b_max - b_min)); printf("%lld\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:162:8: error: redeclaration of 'll base_l' 162 | ll base_l = l; | ^~~~~~ a.cc:109:8: note: 'll base_l' previously declared here 109 | ll base_l = l; | ^~~~~~ a.cc:163:8: error: redeclaration of 'll base_r' 163 | ll base_r = r; | ^~~~~~ a.cc:110:8: note: 'll base_r' previously declared here 110 | ll base_r = r; | ^~~~~~
s767670308
p03735
C++
#include<iostream> #include<string> #include<string.h> #include<stdio.h> #include<algorithm> #include<math.h> #include<vector> #include<queue> #include<map> #include<set> using namespace std; #define rep(i,a,b) for (i=a;i<=b;i++) typedef long long ll; #define maxd 1e9+7 int n; multiset<LL> a,b; struct node{ int x,y; }ball[200500]; int read() { int x=0,f=1;char ch=getchar(); while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();} while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();} return x*f; } ll query() { return ((*a.rbegin()-*a.begin())*(*b.rbegin()-*b.begin())); } bool cmp(node p,node q) { return ((p.x<q.x) && ((p.x==q.x) && (p.y<q.y))); } int main() { n=read();int i; for (i=1;i<=n;i++) { ball[i].x=read();ball[i].y=read(); if (ball[i].x>ball[i].y) swap(ball[i].x,ball[i].y); a.insert(ball[i].x); b.insert(ball[i].y); } ll ans=query(); sort(ball+1,ball+1+n,cmp); for (i=1;i<=n;i++) { int nx=ball[i].x,ny=ball[i].y; a.erase(a.find(nx));b.erase(b.find(ny)); a.insert(ny);b.insert(nx); ans=min(ans,query()); } printf("%lld",ans); return 0; }
a.cc:16:10: error: 'LL' was not declared in this scope; did you mean 'll'? 16 | multiset<LL> a,b; | ^~ | ll a.cc:16:12: error: template argument 1 is invalid 16 | multiset<LL> a,b; | ^ a.cc:16:12: error: template argument 2 is invalid a.cc:16:12: error: template argument 3 is invalid a.cc: In function 'll query()': a.cc:31:17: error: request for member 'rbegin' in 'a', which is of non-class type 'int' 31 | return ((*a.rbegin()-*a.begin())*(*b.rbegin()-*b.begin())); | ^~~~~~ a.cc:31:29: error: request for member 'begin' in 'a', which is of non-class type 'int' 31 | return ((*a.rbegin()-*a.begin())*(*b.rbegin()-*b.begin())); | ^~~~~ a.cc:31:42: error: request for member 'rbegin' in 'b', which is of non-class type 'int' 31 | return ((*a.rbegin()-*a.begin())*(*b.rbegin()-*b.begin())); | ^~~~~~ a.cc:31:54: error: request for member 'begin' in 'b', which is of non-class type 'int' 31 | return ((*a.rbegin()-*a.begin())*(*b.rbegin()-*b.begin())); | ^~~~~ a.cc: In function 'int main()': a.cc:46:11: error: request for member 'insert' in 'a', which is of non-class type 'int' 46 | a.insert(ball[i].x); | ^~~~~~ a.cc:47:11: error: request for member 'insert' in 'b', which is of non-class type 'int' 47 | b.insert(ball[i].y); | ^~~~~~ a.cc:54:11: error: request for member 'erase' in 'a', which is of non-class type 'int' 54 | a.erase(a.find(nx));b.erase(b.find(ny)); | ^~~~~ a.cc:54:19: error: request for member 'find' in 'a', which is of non-class type 'int' 54 | a.erase(a.find(nx));b.erase(b.find(ny)); | ^~~~ a.cc:54:31: error: request for member 'erase' in 'b', which is of non-class type 'int' 54 | a.erase(a.find(nx));b.erase(b.find(ny)); | ^~~~~ a.cc:54:39: error: request for member 'find' in 'b', which is of non-class type 'int' 54 | a.erase(a.find(nx));b.erase(b.find(ny)); | ^~~~ a.cc:55:11: error: request for member 'insert' in 'a', which is of non-class type 'int' 55 | a.insert(ny);b.insert(nx); | ^~~~~~ a.cc:55:24: error: request for member 'insert' in 'b', which is of non-class type 'int' 55 | a.insert(ny);b.insert(nx); | ^~~~~~
s065357764
p03735
C++
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <vector> #include <string> #include <algorithm> #include <queue> #include <stack> #include <map> #include <set> #include <unordered_set> #include <unordered_map> #include <bitset> #include <limits> #include <random> #include <complex> #include <cmath> #include <cstdio> #include <cstdlib> #include <cassert> using namespace std; #define REP(i,n) for (int i = 0; i < n; i++) template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >; typedef long long ll; int main () { int N; cin >> N; vector < int > x(N),y(N); REP(i,N) cin >> x[i] >> y[i]; vector < int > val(N * 2); REP(i,N) { val.push_back(x[i]); val.push_back(y[i]); } sort(val.begin(), val.end()); int min_val = val.front(); int max_val = val.back(); int max1 = -1e9 - 1, min1 = 1e9 + 1; REP(i,N) { max1 = max(max1, max(x[i], y[i])); min1 = min(min1, min(x[i], y[i])); } int return 0; }
a.cc: In function 'int main()': a.cc:52:5: error: expected unqualified-id before 'return' 52 | return 0; | ^~~~~~
s126005874
p03735
C++
#include <cmath> #include <iostream> #include <vector> #include <queue> #include <deque> #include <map> #include <set> #include <stack> #include <tuple> #include <bitset> #include <algorithm> #include <functional> #include <utility> #include <iomanip> #define typeof(x) __typeof__(x) #define int long long int #define mod(x) ((x % MOD) + MOD) % MOD #define rep(i,a,b) for(int i=(a);i<(b);++i) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i) #define ALL(c) (c).begin(),(c).end() #define RALL(c) (c).rbegin(),(c).rend() #define SZ(c) (int)((c).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) #define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin()) #define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin()) #define COUNT(c,x) UB(c,x)-LB(c,x) #define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end()); #define COPY(c1,c2) copy(ALL(c1),(c2).begin()) #define PB push_back #define MP make_pair #define vec vector #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl; using namespace std; typedef pair<int,int> P; struct edge { int to, cost; }; const int INF = 1e18; const int MOD = 1e9+7; template<typename T> ostream& operator << (ostream& s, const vector<T>& v) { int len = v.size(); s << "["; for (int i = 0; i < len; i++) { s << v[i]; if (i < len - 1) s << " "; } s << "]"; return s; } signed main() { int N; cin >> N; vec<int> x(N), y(N); int maximum = 1, minimum = 1e9; int max_count = 0, min_count = 0; int max_i = -1, min_i = -1; rep(i, 0, N) { cin >> x[i] >> y[i]; if (maximum < max(x[i], y[i])) { maximum = max(x[i], y[i]); max_i = i; max_count = 1; } else if (maximum == max(x[i], y[i])) { max_count++; } if (minimum > min(x[i], y[i])) { minimum = min(x[i], y[i]); min_i = i; min_count = 1; } else if (minimum == min(x[i], y[i])) { min_count++; } } int minimax[2] = {1,1}, maxmini[2] = {1e9,1e9}; rep(i, 0, N) { if (i == max_i && i == min_i) { continue; } else if (i == max_i) { minimax[0] = max(minimax[0], min(x[i], y[i])); maxmini[0] = min(maxmini[0], min(x[i], y[i])); } else if (i == min_i) { minimax[0] = max(minimax[0], max(x[i], y[i])); maxmini[0] = min(maxmini[0], max(x[i], y[i])); } else { minimax[0] = max(minimax[0], min(x[i], y[i])); maxmini[0] = min(maxmini[0], max(x[i], y[i])); } } rep(i, 0, N) { minimax[1] = max(minimax[1], min(x[i], y[i])); maxmini[1] = min(maxmini[1], max(x[i], y[i])); } cout << min((minimax[1] - minimum)*(maximum - maxmini[1]), (maximum - minimum)*(minimax[0] - maxmini[0])) << endl; return 0; }
a.cc: In function 'int main()': a.cc:85:41: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing] 85 | int minimax[2] = {1,1}, maxmini[2] = {1e9,1e9}; | ^~~ a.cc:85:45: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing] 85 | int minimax[2] = {1,1}, maxmini[2] = {1e9,1e9}; | ^~~
s280180363
p03735
C++
#include <cmath> #include <iostream> #include <vector> #include <queue> #include <deque> #include <map> #include <set> #include <stack> #include <tuple> #include <bitset> #include <algorithm> #include <functional> #include <utility> #include <iomanip> #define typeof(x) __typeof__(x) #define int long long int #define mod(x) ((x % MOD) + MOD) % MOD #define rep(i,a,b) for(int i=(a);i<(b);++i) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i) #define ALL(c) (c).begin(),(c).end() #define RALL(c) (c).rbegin(),(c).rend() #define SZ(c) (int)((c).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) #define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin()) #define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin()) #define COUNT(c,x) UB(c,x)-LB(c,x) #define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end()); #define COPY(c1,c2) copy(ALL(c1),(c2).begin()) #define PB push_back #define MP make_pair #define vec vector #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl; using namespace std; typedef pair<int,int> P; struct edge { int to, cost; }; const int INF = 1e18; const int MOD = 1e9+7; template<typename T> ostream& operator << (ostream& s, const vector<T>& v) { int len = v.size(); s << "["; for (int i = 0; i < len; i++) { s << v[i]; if (i < len - 1) s << " "; } s << "]"; return s; } signed main() { int N; cin >> N; vec<int> x(N), y(N); int maximum = 1, minimum = 1e9; int max_count = 0, min_count = 0; int max_i = -1, min_i = -1; rep(i, 0, N) { cin >> x[i] >> y[i]; if (maximum < max(x[i], y[i])) { maximum = max(x[i], y[i]); max_i = i; max_count = 1; } else if (maximum == max(x[i], y[i])) { max_count++; } if (minimum > min(x[i], y[i])) { minimum = min(x[i], y[i]); min_i = i; min_count = 1; } else if (minimum == min(x[i], y[i])) { min_count++; } } int minimax[2] = {1,1}, maxmini[2] = {1e9,1e9}; rep(i, 0, N) { if (i == max_i && i == min_i) { continue; } else if (i == max_i) { minimax[0] = max(minimax[0], min(x[i], y[i])); maxmini[0] = min(maxmini[0], min(x[i], y[i])); } else if (i == min_i) { minimax[0] = max(minimax[0], max(x[i], y[i])); maxmini[0] = min(maxmini[0], max(x[i], y[i])); } else { minimax[0] = max(minimax[0], min(x[i], y[i])); maxmini[0] = min(maxmini[0], max(x[i], y[i])); } } rep(i, 0, N) { minimax[1] = max(minimax[1], min(x[i], y[i])); maxmini[1] = min(maxmini[1], max(x[i], y[i])); } cout << min((minimax[1] - minimum)*(maximum - maxmini[1]), (maximum - minimum)*(minimax[0] - maxmini[0])) << endl; return 0; }
a.cc: In function 'int main()': a.cc:85:41: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing] 85 | int minimax[2] = {1,1}, maxmini[2] = {1e9,1e9}; | ^~~ a.cc:85:45: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing] 85 | int minimax[2] = {1,1}, maxmini[2] = {1e9,1e9}; | ^~~
s322197467
p03735
C++
package main import "fmt" var N int = 200005 var x [N]int var y [N]int // 2018-08-12T14:13:15+0800 // 2018-08-12T14:36:33+0800 // 2018-08-12T14:44:00+0800 # Pause to calm down. // 2018-08-12T15:16:18+0800 # @see https://arc073.contest.atcoder.jp/submissions/2997568 // 2018-08-12T15:23:55+0800 # @see https://arc073.contest.atcoder.jp/submissions/2997602 // 2018-08-12T15:28:39+0800 # @see https://arc073.contest.atcoder.jp/submissions/2997622 // 2018-08-12T15:47:46+0800 func main() { var N int fmt.Scanf("%d", &N) if N <= 1 { fmt.Scanf("%d%d", &N, &N) fmt.Println(0) return } for i := 0; i < N; i++ { fmt.Scanf("%d%d", &x[i], &y[i]) } min := [2]int{1000000005, 1000000005} min2 := [2]int{1000000005, 1000000005} mini := 0 max := [2]int{0, 0} max2 := [2]int{0, 0} maxi := 0 for i := 0; i < N; i++ { if x[i] > y[i] { x[i], y[i] = y[i], x[i] } if x[i] < min[0] { mini = i } if x[i] < min[0] || (x[i] == min[0] && y[i] < min[1]) { min[0] = x[i] min[1] = y[i] } if y[i] < min2[1] || (y[i] == min2[1] && x[i] < min2[0]) { min2[0] = x[i] min2[1] = y[i] } if y[i] > max[1] { maxi = i } if y[i] > max[1] || (y[i] == max[1] && x[i] > max[0]) { max[0] = x[i] max[1] = y[i] } if x[i] > max2[0] || (x[i] == max2[0] && y[i] > max2[1]) { max2[0] = x[i] max2[1] = y[i] } } if mini == maxi || min[0] == x[maxi] || max[1] == y[mini] { fmt.Println(diff(max[1], min2[1]) * diff(max2[0], min[0])) return } out := maxOfTwo(min[0], min2[1], max[1], max2[0]) fmt.Println(out) } func diff(a, b int) int { c := a - b if c < 0 { return -c } return c } func maxOfTwo(min, min2, max, max2 int) int { a := diff(max, min) * diff(max2, min2) b := diff(max, min2) * diff(max2, min) if a < b { return a } return b }
a.cc:1:1: error: 'package' does not name a type 1 | package main | ^~~~~~~ a.cc:66:1: error: 'func' does not name a type 66 | func diff(a, b int) int { | ^~~~ a.cc:74:1: error: 'func' does not name a type 74 | func maxOfTwo(min, min2, max, max2 int) int { | ^~~~
s991423533
p03735
C++
#include<cstdio> #include<algorithm> using namespace std; typedef long long int64; const int64 N = 200005; int64 x[N]; int64 y[N]; int64 maxOfTwo(int64 min1, int64 min2, int64 max1, int64 max2) { int64 t = abs(max1 - min1); int64 t2 = abs(max2 - min2); int64 a = abs(max1 - min1) * abs(max2 - min2); int64 b = abs(max1 - min2) * abs(max2 - min1); a = t*t2; return min(a, b); } // 2018-08-12T15:51:00+0800 // 2018-08-12T16:36:40+0800 # @see https://arc073.contest.atcoder.jp/submissions/2997912 // 2018-08-12T16:44:57+0800 # @see https://arc073.contest.atcoder.jp/submissions/2997948 // 2018-08-12T16:47:03+0800 int main() { // freopen(".in","r",stdin); int64 N, i; scanf("%lld", &N); if (N <= 1) { scanf("%lld%lld", &N, &N); printf("%d", 0); return 0; } for (i = 0; i < N; i++) { scanf("%lld%lld", &x[i], &y[i]); } int64 min1[2] = {1000000005, 1000000005}; int64 min2[2] = {1000000005, 1000000005}; int64 mini = 0; int64 max1[2] = {0, 0}; int64 max2[2] = {0, 0}; int64 maxi = 0; int64 t; for (i = 0; i < N; i++) { if (x[i] > y[i]) { t = y[i]; y[i] = x[i]; x[i] = t; } if (x[i] < min1[0]) { mini = i; } if (x[i] < min1[0] || (x[i] == min1[0] && y[i] < min1[1]) ) { min1[0] = x[i]; min1[1] = y[i]; } if (y[i] < min2[1] || (y[i] == min2[1] && x[i] < min2[0]) ) { min2[0] = x[i]; min2[1] = y[i]; } if (y[i] > max1[1] ) { maxi = i; } if (y[i] > max1[1] || (y[i] == max1[1] && x[i] > max1[0]) ) { max1[0] = x[i]; max1[1] = y[i]; } if (x[i] > max2[0] || (x[i] == max2[0] && y[i] > max2[1]) ) { max2[0] = x[i]; max2[1] = y[i]; } } if (mini == maxi || min1[0] == x[maxi] || max1[1] == y[mini] ) { printf("%lld", abs(max1[1]- min2[1]) * abs(max2[0] - min1[0])); return 0; } int64 out = maxOfTwo(min1[0], min2[1], max1[1], max2[0]); out = min(out, maxOfTwo(min1[0], min2[0], max1[1], max2[1])); out = min(out, maxOfTwo(min1[0], min[1], max1[1], max1[0])); printf("%lld", out); }
a.cc: In function 'int main()': a.cc:79:45: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 79 | out = min(out, maxOfTwo(min1[0], min[1], max1[1], max1[0])); | ^
s526152888
p03735
C++
#include "bits/stdc++.h" #define ll long long #define rep2(i,a,b) for(int i=a;i<=b;++i) #define rep(i,n) for(int i=0;i<n;i++) #define pii pair<int,int> #define tii tuple<int,int,int> #define pq priority_queue<int> #define pqg priority_queue<int,vector<int>,greater<int>> #define pb push_back ll int MOD=998244353; #define INF 1e9 #define N 310000 using namespace std; string alphabet("abcdefghijklmnopqrstuvwxyz"); main(){ int n; cin>>n; vector<pii> v; ll int x[N],y[N]; rep(i,n){ cin>>x[i]>>y[i]; v.pb({x[i],i});v.pb({y[i],i}); } sort(v.begin(),v.end()); rep(i,n){ if(x[i]<y[i]) swap(x[i],y[i]); } ll int xM=0,xm=INF,yM=0,ym=INF; rep(i,n){ if(x[i]>xM) xM=x[i]; if(x[i]<xm) xm=x[i]; if(y[i]>yM) yM=y[i]; if(y[i]<ym) ym=y[i]; } ll int ans1=(xM-xm)*(yM-ym); ll int a=v[0],b=v[2*n-1]; pqg p; ll int d=0; rep(i,n){ if(y[i]==a){ p.push({x[i],i}); d=max(d,x[i]); } else { p.push({y[i],i}); d=max(d,y[i]); } } ll int c=p.top().first,range=d-c; while(1){ pii pp=p.front(); if(pp.first==x[pp.second]){ break; } else if(x[pp.second]!=b){ p.pop(); p.push({x[pp.second],pp.second}); c=p.top().first;d=max(d,x[pp.second]); range=min(range,d-c); } else break; } ll ans2=(b-a)*range; cout<<min(ans1,ans2); return 0; }
a.cc:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 17 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:38:17: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'long long int' in initialization 38 | ll int a=v[0],b=v[2*n-1]; | ^ a.cc:38:28: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} to 'long long int' in initialization 38 | ll int a=v[0],b=v[2*n-1]; | ^ a.cc:43:19: error: no matching function for call to 'std::priority_queue<int, std::vector<int>, std::greater<int> >::push(<brace-enclosed initializer list>)' 43 | p.push({x[i],i}); | ~~~~~~^~~~~~~~~~ In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157, from a.cc:1: /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; value_type = int]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<int, std::vector<int>, std::greater<int> >::value_type&' {aka 'const int&'} 736 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; value_type = int]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int, std::vector<int>, std::greater<int> >::value_type&&' {aka 'int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:47:19: error: no matching function for call to 'std::priority_queue<int, std::vector<int>, std::greater<int> >::push(<brace-enclosed initializer list>)' 47 | p.push({y[i],i}); | ~~~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; value_type = int]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<int, std::vector<int>, std::greater<int> >::value_type&' {aka 'const int&'} 736 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; value_type = int]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int, std::vector<int>, std::greater<int> >::value_type&&' {aka 'int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:51:22: error: request for member 'first' in 'p.std::priority_queue<int, std::vector<int>, std::greater<int> >::top()', which is of non-class type 'const __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'const int'} 51 | ll int c=p.top().first,range=d-c; | ^~~~~ a.cc:53:18: error: 'class std::priority_queue<int, std::vector<int>, std::greater<int> >' has no member named 'front' 53 | pii pp=p.front(); | ^~~~~ a.cc:59:19: error: no matching function for call to 'std::priority_queue<int, std::vector<int>, std::greater<int> >::push(<brace-enclosed initializer list>)' 59 | p.push({x[pp.second],pp.second}); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; value_type = int]' 736 | push(const value_type& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<int, std::vector<int>, std::greater<int> >::value_type&' {aka 'const int&'} 736 | push(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>; value_type = int]' 744 | push(value_type&& __x) | ^~~~ /usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<int, std::vector<int>, std::greater<int> >::value_type&&' {aka 'int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:60:23: error: request for member 'first' in 'p.std::priority_queue<int, std::vector<int>, std::greater<int> >::top()', which is of non-class type 'const __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'const int'} 60 | c=p.top().first;d=max(d,x[pp.second]); | ^~~~~ a.cc:61:13: error: 'range' was not declared in this scope 61 | range=min(range,d-c); | ^~~~~ a.cc:65:19: error: 'range' was not declared in this scope 65 | ll ans2=(b-a)*range; | ^~~~~
s342287785
p03735
C++
#include <iostream> #include <queue> #include <map> #include <list> #include <vector> #include <string> #include <stack> #include <limits> #include <climits> #include <cassert> #include <fstream> #include <cstring> #include <cmath> #include <bitset> #include <iomanip> #include <algorithm> #include <functional> #include <cstdio> #include <ciso646> #include <set> #include <array> #include <unordered_map> #include <unordered_set> #include <type_traits> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define VEC2(T, N, M) vector<N, vector<T>(M)> #define inf 0x3f3f3f3f3f3f3f3f #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define SET(a,c) memset(a,c,sizeof a) #define CLR(a) memset(a,0,sizeof a) #define VS vector<string> #define VI vector<ll> #define DEBUG(x) cout<<#x<<": "<<x<<endl #define MIN(a,b) (a>b?b:a) #define MAX(a,b) (a>b?a:b) #define pi 2*acos(0.0) #define INFILE() freopen("in0.txt","r",stdin) #define OUTFILE()freopen("out0.txt","w",stdout) #define ll long long #define ull unsigned long long #define pii pair<ll,ll> #define pcc pair<char,char> #define pic pair<ll,char> #define pci pair<char,ll> #define eps 1e-14 #define FST first #define SEC second #define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15) << std::fixed; template <class T> using vec2 = std::vector<vector<T>>; namespace { struct input_returnner { ll N; input_returnner(ll N_ = 0) :N(N_) {} template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template<typename T> operator T() const { T res; cin >> res; return res; } template<typename T> T operator - (T right) { return T(input_returnner()) - right; } template<typename T> T operator + (T right) { return T(input_returnner()) + right; } template<typename T> T operator * (T right) { return T(input_returnner()) * right; } template<typename T> T operator / (T right) { return T(input_returnner()) / right; } template<typename T> T operator << (T right) { return T(input_returnner()) << right; } template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; } }; template<typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(ll N) { return std::move(input_returnner(N)); } } template<typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; } template < typename T > struct is_vector : std::false_type {}; template < typename T > struct is_vector<std::vector<T>> : std::true_type {}; template < typename T > constexpr bool is_vector_v = is_vector<T>::value; template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) { if (!v.empty()) { for (int i = 0; i < v.size(); ++i) { out << v[i] << (i == v.size() - 1 ? "\n" : (is_vector_v<T> ? "" : ", ")); } } return out; } namespace std { // ref: https://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set template <class T> inline void hash_combine(std::size_t& seed, T const& v) { seed ^= std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t& seed, Tuple const& tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename ... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const& tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...> >::apply(seed, tt); return seed; } }; } // ref: https://stackoverflow.com/questions/6245735/pretty-print-stdtuple namespace aux { template<std::size_t...> struct seq {}; template<std::size_t N, std::size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template<std::size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template<class Ch, class Tr, class Tuple, std::size_t... Is> void print_tuple(std::basic_ostream<Ch, Tr>& os, Tuple const& t, seq<Is...>) { using swallow = int[]; (void)swallow { 0, (void(os << (Is == 0 ? "" : ", ") << std::get<Is>(t)), 0)... }; } } // aux:: template<class Ch, class Tr, class... Args> auto operator<<(std::basic_ostream<Ch, Tr>& os, std::tuple<Args...> const& t) -> std::basic_ostream<Ch, Tr>& { os << "("; aux::print_tuple(os, t, aux::gen_seq<sizeof...(Args)>()); return os << ")"; } template<class S, class T> std::ostream & operator<<(std::ostream & os, const std::pair<S, T> & p) { return os << "(" << p.first << ", " << p.second << ")"; } // ref: https://stackoverflow.com/questions/8542591/c11-reverse-range-based-for-loo:p template <typename T> struct reversion_wrapper { T& iterable; }; template <typename T> auto begin(reversion_wrapper<T> w) { return std::rbegin(w.iterable); } template <typename T> auto end(reversion_wrapper<T> w) { return std::rend(w.iterable); } template <typename T> reversion_wrapper<T> REV(T&& iterable) { return { iterable }; } ll MOD = 1e9 + 7; class prime; void solve(); signed main() { SETUP; solve(); #ifdef _DEBUG system("pause"); #endif return 0; } #define int ll // ---------------------- template ---------------------- void solve() { int N; cin >> N; vector<pii> xy; vector<int> v; int ma = 0; int mi = inf; REP(i, N) { int x, y; cin >> x >> y; if (x > y) swap(x, y); xy.emplace_back(x, y); ma = max(x, ma); ma = max(y, ma); mi = min(x, mi); mi = min(y, mi); v.push_back(x); v.push_back(y); } int res; { int lmax = 0; int lmin = inf; int rmax = 0; int rmin = inf; REP(i, N) { lmax = max(lmax, xy[i].first); lmin = min(lmin, xy[i].first); rmax = max(rmax, xy[i].second); rmin = min(rmin, xy[i].second); } res = (lmax - lmin) *(rmax - rmin); } { int rma = 0; int rmi = inf; for (auto &a : xy) { if (a.first == mi and a.second == ma) { cout << res << endl; return; } } int rma = 0; int rmi = inf; for (auto &a : v) { if (a != ma and a != mi) { rma = max(a, rma); rmi = min(a, rmi); } } res = min(res, (ma - mi)*(rma - rmi)); } cout << res << endl; }
a.cc: In function 'void solve()': a.cc:252:21: error: redeclaration of 'long long int rma' 252 | int rma = 0; | ^~~ a.cc:244:21: note: 'long long int rma' previously declared here 244 | int rma = 0; | ^~~ a.cc:253:21: error: redeclaration of 'long long int rmi' 253 | int rmi = inf; | ^~~ a.cc:245:21: note: 'long long int rmi' previously declared here 245 | int rmi = inf; | ^~~
s258382636
p03735
C++
#include <bits/stdc++.h> using namespace std; long long int a[202000][2]; int main() { int n; scanf("%d",&n); if(n==1) { long long int qwer,qwert; scanf("%lld%lld",&qwer,&qwert); long long int qasw=qwer-qwert; if(qasw<0) { qasw=qasw*(-1); } printf("0\n"); } else { //long long int a[200][2]; // long long int p,q; long long int minn1=1000000002,minn2=1000000002,maxx1=0,maxx2=0; int wei1,wei2; for(int i=0;i<n;i++) { long long int wer,werr; scanf("%lld%lld",&wer,&werr); a[i][0]=min(wer,werr); a[i][1]=max(wer,werr); if(a[i][1]>maxx1) { maxx1=a[i][1]; wei2=i; } if(a[i][0]<minn2) { minn2=a[i][0]; wei1=i; } } //printf("%d %d\n",wei1,wei2); if(wei1==wei2) { for(int i=0;i<n;i++) { if(i==wei1) { continue; } else { if(a[i][0]>maxx2) { maxx2=a[i][0]; } if(a[i][1]<minn1) { minn1=a[i][1]; } } } // printf("%lld %lld %lld %lld\n",maxx1,maxx2,minn1,minn2); printf("%lld\n",(maxx1-minn1)*(maxx2-minn2)); } else { maxx2=a[wei2][0]; minn1=a[wei1][1]; for(int i=0;i<n;i++) { if(i==wei1||i==wei2) { continue; } else { if(a[i][0]>maxx2) { maxx2=a[i][0]; } if(a[i][1]<minn1) { minn1=a[i][1]; } } } //printf("%lld %lld %lld %lld\n",maxx1,maxx2,minn1,minn2); long long int p=(maxx1-minn1)*(maxx2-minn2); long long int p1=min(a[wei1][1],a[wei2][0]); long long int p2=max(a[wei1][1],a[wei2][0]); for(int i=0;i<n;i++) { if(i==wei1||i==wei2) { continue; } else { if(a[i][0]<=p1&&a[i][1]<=p1) { p1=a[i][1]; } if(a[i][0]=>p2&&a[i][1]=>p2) { p2=a[i][0]; } if(a[i][0]<=p1&&a[i][1]=>p2) { if(p1-a[i][0]<=a[i][1]-p2) { p1=a[i][0]; } else { p2=a[i][1]; } } } } long long int ppp=(maxx1-minn2)*(p2-p1); printf("%lld\n",min(p,ppp)); // printf("%lld\n",p); } } return 0; }
a.cc: In function 'int main()': a.cc:106:22: error: expected primary-expression before '>' token 106 | if(a[i][0]=>p2&&a[i][1]=>p2) | ^ a.cc:106:35: error: expected primary-expression before '>' token 106 | if(a[i][0]=>p2&&a[i][1]=>p2) | ^ a.cc:110:35: error: expected primary-expression before '>' token 110 | if(a[i][0]<=p1&&a[i][1]=>p2) | ^
s311066607
p03735
C++
#include<bits/stdc++.h> #define INF 0x7fffffff #define P pair<int,int> #define ll long long #define f first #define s second using namespace std; int n,nn,mx=-INF,mn=INF; P a[200005]; ll ans; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();} return x*f; } int main(){ n=read(); for(int i=1;i<=n;++i){ a[i].f=read(),a[i].s=read(); if(a[i].f>a[i].s) swap(a[i].f,a[i].s); mx=max(mx,a[i].s),mn=min(mn,a[i].s); } sort(a+1,a+n+1); ans=1ll*(mx-mn)*(a[n].f-a[1].f),nn=nx=a[1].s; for(int i=2;i<=n;++i){ ans=min(ans,1ll*(mx-a[1].f)*(a[n].f-min(nn,a[i].f))); nn=min(nn,a[i].s); } printf("%lld",ans); }
a.cc: In function 'int main()': a.cc:25:40: error: 'nx' was not declared in this scope; did you mean 'nn'? 25 | ans=1ll*(mx-mn)*(a[n].f-a[1].f),nn=nx=a[1].s; | ^~ | nn
s490727645
p03735
C++
#include <algorithm> #include <cstring> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <vector> using namespace std; using ll = long long; const ll INF = 1ll << 60; struct Enclosure { ll l, r; ll len() const { return r - l; } Enclosure add(ll v) const { return {min(l, v), max(r, v)}; } bool containsLeft(ll L) const { return l <= L; } bool containsRight(ll R) const { return R <= r; } bool contains(ll L, ll R) const { return containsLeft(L) && containsRight(R); } }; int main() { int N; while (cin >> N) { vector<vector<ll>> xy(N, vector<ll>(2)); for (int i = 0; i < N; i++) { for (int j = 0; j < 2; j++) { cin >> xy[i][j]; } } vector<int> ind(2 * N); for (int i = 0; i < 2 * N; i++) ind[i] = i; sort(ind.begin(), ind.end(), [&](int a, int b) { return xy[a / 2][a % 2] < xy[b / 2][b % 2]; }); vector<int> order; vector<bool> used(N, false); for (int i = 0; i < 2 * N; i++) { int j = i % 2 == 0 ? i / 2 : 2 * N - i / 2 - 1; int g = ind[j] / 2; if (!used[g]) { order.push_back(g); used[g] = true; } } vector<ll> mnmn(N + 1, INF), mnmx(N + 1, 0), mxmn(N + 1, INF), mxmx(N + 1, 0); for (int i = N - 1; i >= 0; i--) { int j = order[i]; auto p = minmax(xy[j][0], xy[j][1]); mnmn[i] = min(mnmn[i + 1], p.first); mnmx[i] = max(mnmx[i + 1], p.first); mxmn[i] = min(mxmn[i + 1], p.second); mxmx[i] = max(mxmx[i + 1], p.second); } function<ll(int, Enclosure, Enclosure)> dfs = [&](int i, const Enclosure& red, const Enclosure& blue) { if (i >= N) { return red.len() * blue.len(); } ll limL = mnmn[i], limR = mxmx[i], bestR = mnmx[i], bestL = mxmn[i]; if (red.contains(limL, limR) && blue.containsLeft(limL)) { return red.len() * blue.add(bestR).len(); } if (red.contains(limL, limR) && blue.containsRight(limR)) { return red.len() * blue.add(bestL).len(); } if (red.containsLeft(limL) && blue.contains(limL, limR)) { return red.add(bestR).len() * blue.len(); } if (red.containsRight(limR) && blue.contains(limL, limR)) { return red.add(bestL).len() * blue.len(); } int j = order[i]; ll x = xy[j][0], y = xy[j][1]; return min(dfs(i + 1, red.add(x), blue.add(y)), dfs(i + 1, red.add(y), blue.add(x))); }; cout << dfs(0, {INF, 0}, {INF, 0}) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:58:5: error: 'function' was not declared in this scope 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^~~~~~~~ a.cc:9:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 8 | #include <set> +++ |+#include <functional> 9 | #include <vector> a.cc:58:42: error: expression list treated as compound expression in functional cast [-fpermissive] 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^ a.cc:58:16: error: expected primary-expression before '(' token 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^ a.cc:58:17: error: expected primary-expression before 'int' 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^~~ a.cc:58:31: error: expected primary-expression before ',' token 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^ a.cc:58:42: error: expected primary-expression before ')' token 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^ a.cc:58:45: error: 'dfs' was not declared in this scope; did you mean 'ffs'? 58 | function<ll(int, Enclosure, Enclosure)> dfs = | ^~~ | ffs
s970338971
p03735
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; template<typename T> void input(T &x) { x=0; T a=1; register char c=getchar(); for(;c<48||c>57;c=getchar()) if(c==45) a=-1; for(;c>=48&&c<=57;c=getchar()) x=x*10+c-48; x*=a; return; } #define MAXN 200010 struct Ball { int x,y; void Input() { input(x),input(y); if(x>y) swap(x,y); return; } bool operator < (const Ball &q) const { if(x!=q.x) return x<q.x; return y<q.y; } }; Ball a[MAXN]; #define inf 2147483647 int main() { int n; input(n); if(n==1) { puts("0"); // fclose(stdin),fclose(stdout); return 0; } for(int i=1;i<=n;i++) a[i].Input(); sort(a+1,a+n+1); int Max=0,Min=inf,pos_Max,pos_Min; for(int i=1;i<=n;i++) { if(a[i].x<Min) Min=a[pos_Min=i].x; if(a[i].y>Max) Max=a[pos_Max=i].y; } int Rmax=Max,Rmin=inf,Bmin=Min,Bmax=0; for(int i=1;i<=n;i++) { Rmin=min(Rmin,a[i].y), Bmax=max(Bmax,a[i].x); } ll ans=(ll)(Rmax-Rmin)*(Bmax-Bmin); if(pos_Max!=pos_Min) { Bmax=Max,Bmin=Min,Rmax=a[n].x; ll Ans=inf; for(int i=1,j=a[1].y;i<n;i++) { Rmax=max(a[i].y,Rmax), Rmin=min(min(j,a[i].y),a[i+1].x), j=min(j,a[i].y), Ans=min(Ans,Rmax-Rmin); } ans=min(ans,Ans*(Bmax-Bmin)); } printf("%lld\n",ans); return 0; }
a.cc: In function 'void input(T&)': a.cc:10:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 10 | register char c=getchar(); | ^ a.cc: In function 'int main()': a.cc:70:32: error: no matching function for call to 'min(ll&, int)' 70 | Ans=min(Ans,Rmax-Rmin); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:70:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 70 | Ans=min(Ans,Rmax-Rmin); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:70:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 70 | Ans=min(Ans,Rmax-Rmin); | ~~~^~~~~~~~~~~~~~~ a.cc: In instantiation of 'void input(T&) [with T = int]': a.cc:26:8: required from here 26 | input(x),input(y); | ~~~~~^~~ a.cc:10:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 10 | register char c=getchar(); | ^
s425292262
p03735
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; template<typename T> void input(T &x) { x=0; T a=1; register char c=getchar(); for(;c<48||c>57;c=getchar()) if(c==45) a=-1; for(;c>=48&&c<=57;c=getchar()) x=x*10+c-48; x*=a; return; } #define MAXN 200010 struct Ball { int x,y; void Input() { input(x),input(y); if(x>y) swap(x,y); return; } bool operator < (const Ball &q) const { if(x!=q.x) return x<q.x; return y<q.y; } }; Ball a[MAXN]; int main() { int n; input(n); if(n==1) { puts("0"); // fclose(stdin),fclose(stdout); return 0; } for(int i=1;i<=n;i++) a[i].Input(); sort(a+1,a+n+1); int Max=a[1].y,Min=a[1].x,_max=1,_min=1; for(int i=2;i<=n;i++) { if(a[i].x<=Min&&a[i].y>=Max){ Min=a[i].x;Max=a[i].y; _max=i;_min=i; } else if(a[i].x<Min) { Min=a[i].x; _min=i; } else if(a[i].y>Max){ Max=a[i].y; _max=i; } } int Rmax=Max;Bmin=Min,Rmin=a[_min].y;Bmax=a[_max].x; for(int i=1;i<=n;i++){ Rmin=min(Rmin,a[i].y); Bmax=max(Bmax,a[i].x); } ll ans=(ll)(Rmax-Rmin)*(Bmax-Bmin); if(_max!=_min) { Bmax=Max; Bmin=Min; Rmax=max(a[n].x,a[1].y); int premin=a[1].y; Rmin=min(a[1].y,a[2].x); ll ans0=Rmax-Rmin; for(int i=2;i<n;i++) { Rmax=max(a[i].y,Rmax); Rmin=min(min(premin,a[i].y),a[i+1].x); premin=min(premin,a[i].y); if(Rmax-Rmin<ans0)ans0=Rmax-Rmin; } ans0*=Bmax-Bmin; ans=min(ans,ans0); } printf("%lld\n",ans); return 0; }
a.cc: In function 'void input(T&)': a.cc:10:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 10 | register char c=getchar(); | ^ a.cc: In function 'int main()': a.cc:63:22: error: 'Bmin' was not declared in this scope; did you mean '_min'? 63 | int Rmax=Max;Bmin=Min,Rmin=a[_min].y;Bmax=a[_max].x; | ^~~~ | _min a.cc:63:31: error: 'Rmin' was not declared in this scope; did you mean '_min'? 63 | int Rmax=Max;Bmin=Min,Rmin=a[_min].y;Bmax=a[_max].x; | ^~~~ | _min a.cc:63:46: error: 'Bmax' was not declared in this scope; did you mean 'Rmax'? 63 | int Rmax=Max;Bmin=Min,Rmin=a[_min].y;Bmax=a[_max].x; | ^~~~ | Rmax a.cc: In instantiation of 'void input(T&) [with T = int]': a.cc:26:8: required from here 26 | input(x),input(y); | ~~~~~^~~ a.cc:10:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 10 | register char c=getchar(); | ^
s316817498
p03735
C++
wanan#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; long long n,minid,maxid,mina,maxa,minb,maxb,ans; struct node { long long x,y; }q[400005]; bool cmp(node t1,node t2) { return (t1.x<t2.x || (t1.x==t1.x && t1.y<t2.y)); } int main() { scanf("%lld",&n); if (n==1) { printf("0\n"); return 0; } for (long long i=1;i<=n;i++) { scanf("%lld%lld",&q[i].x,&q[i].y); if (q[i].x>q[i].y) swap(q[i].x,q[i].y); } sort(q+1,q+n+1,cmp); minid=1;maxid=1; for(int i=2;i<=n;i++) { if (q[i].x<=q[minid].x && q[i].y>=q[maxid].y) maxid=minid=i; else if(q[i].x<q[minid].x) minid=i; else if(q[i].y>q[maxid].y) maxid=i; } mina=maxa=q[minid].x; minb=maxb=q[maxid].y; for (long long i=1;i<=n;i++) { maxa=max(q[i].x,maxa); minb=min(q[i].y,minb); } ans=(maxa-mina)*(maxb-minb); if (maxid!=minid) { maxa=q[maxid].y;mina=q[minid].x; maxb=max(q[n].x,q[1].y); minb=min(q[1].y,q[2].x); long long premin=q[1].y,s=(long long)maxb-minb; for(long long i=2;i<n;i++) { maxb=max(q[i].y,maxb); minb=min(min(premin,q[i].y),q[i+1].x); premin=min(premin,q[i].y); s=min(s,maxb-minb); } s*=maxa-mina; ans=min(ans,s); } printf("%lld\n",ans); wanan cout<<ans<<endl;
a.cc:1:6: error: stray '#' in program 1 | wanan#include <iostream> | ^ a.cc:1:1: error: 'wanan' does not name a type 1 | wanan#include <iostream> | ^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:3: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdio.h:34, from /usr/include/c++/14/cstdio:42, from a.cc:2: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/includ
s127151482
p03735
C++
#include<iostream> #include<sstream> #include<fstream> #include<string> #include<vector> #include<deque> #include<queue> #include<stack> #include<set> #include<map> #include<algorithm> #include<functional> #include<utility> #include<bitset> #include<cmath> #include<cstdlib> #include<ctime> #include<cstdio> #include<cstring> using namespace std; typedef long long ll; int n; pair<int,int> x[200010]; multiset<int> b,r; ll ans; int main() { cin>>n; for (int i=1;i<=n;i++) { cin>>x[i].first>>x[i].second; if (x[i].first>x[i].second) swap(x[i].first,x[i].second); b.insert(x[i].first),r.insert(x[i].second); } ans=(b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin()); sort(x+1,x+n+1); for (int i=1;i<=n;i++) { b.erase(b.find(x[i].first)),r.insert(x[i].first); r.erase(r.find(x[i].second)),b.insert(x[i].second); ans=min(ans,1LL*(*b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin())); } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:35:32: error: no match for 'operator*' (operand types are 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >' and 'int') 35 | ans=(b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin()); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | int | std::reverse_iterator<std::_Rb_tree_const_iterator<int> > In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:257:7: note: candidate: 'constexpr std::reverse_iterator<_Iterator>::reference std::reverse_iterator<_Iterator>::operator*() const [with _Iterator = std::_Rb_tree_const_iterator<int>; reference = const int&]' 257 | operator*() const | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:257:7: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/bits/stl_iterator.h: In instantiation of 'constexpr std::reverse_iterator<_Iterator> std::reverse_iterator<_Iterator>::operator-(difference_type) const [with _Iterator = std::_Rb_tree_const_iterator<int>; difference_type = long int]': a.cc:35:30: required from here 35 | ans=(b.rbegin()-*b.begin())*(*r.rbegin()-*r.begin()); | ^ /usr/include/c++/14/bits/stl_iterator.h:364:41: error: no match for 'operator+' (operand types are 'const std::_Rb_tree_const_iterator<int>' and 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >::difference_type' {aka 'long int'}) 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >::difference_type' {aka 'long int'} 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >::difference_type' {aka 'long int'} 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: 'const std::_Rb_tree_const_iterator<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<int>' 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'std::reverse_iterator<std::_Rb_tree_const_iterator<int> >::difference_type' {aka 'long int'} 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: 'const std::_Rb_tree_const_iterator<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: 'const std::_Rb_tree_const_iterator<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'const std::_Rb_tree_const_iterator<int>' have incompatible cv-qualifiers 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: 'const std::_Rb_tree_const_iterator<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_iterator.h:364:41: note: types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'const std::_Rb_tree_const_iterator<int>' have incompatible cv-qualifiers 364 | { return reverse_iterator(current + __n); } | ~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution fa
s426258037
p03735
C++
#include <vector> #include <algorithm> #include <set> #include <map> #include <list> #include <queue> #include <deque> #include <string> #include <iostream> #include <climits> using namespace std; using ll = long long; #define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++) #define rep(i,n) reps(i,0,n) const ll INF = LLONG_MAX*0.9; typedef pair<int,int> pii; int N; vector<pii> v; int main(){ ll mi = INF, ma = -INF; ll rMax = -INF, bMin = INF; cin >> N; v.resize(N); rep(i,N){ cin >> v[i].first >> v[i].second; if(v[i].first > v[i].second) swap(v[i].first,v[i].second); mi = min(mi,v[i].first); ma = max(ma,v[i].second); rMax = max(rMax,v[i].first); bMin = min(bMin,v[i].second); } ll ans = (rMax - mi)* (ma-bMin); ll rMin = INF; sort(v.begin(),v.end()); rep(i,N-1){ rMax = max(rMax, v[i].second); rMin = min(rMin, v[i].second); ans = min(ans, (rMax - min(rMin, v[i + 1].first))*(ma - mi)); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:17: error: no matching function for call to 'min(ll&, int&)' 30 | mi = min(mi,v[i].first); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:30:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 30 | mi = min(mi,v[i].first); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:30:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 30 | mi = min(mi,v[i].first); | ~~~^~~~~~~~~~~~~~~ a.cc:31:17: error: no matching function for call to 'max(ll&, int&)' 31 | ma = max(ma,v[i].second); | ~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 31 | ma = max(ma,v[i].second); | ~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 31 | ma = max(ma,v[i].second); | ~~~^~~~~~~~~~~~~~~~ a.cc:32:19: error: no matching function for call to 'max(ll&, int&)' 32 | rMax = max(rMax,v[i].first); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 32 | rMax = max(rMax,v[i].first); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | rMax = max(rMax,v[i].first); | ~~~^~~~~~~~~~~~~~~~~ a.cc:33:19: error: no matching function for call to 'min(ll&, int&)' 33 | bMin = min(bMin,v[i].second); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:33:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 33 | bMin = min(bMin,v[i].second); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:33:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 33 | bMin = min(bMin,v[i].second); | ~~~^~~~~~~~~~~~~~~~~~ a.cc:41:27: error: no matching function for call to 'max(ll&, int&)' 41 | rMax = max(rMax, v[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:41:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | rMax = max(rMax, v[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:41:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | rMax = max(rMax, v[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ a.cc:42:27: error: no matching function for call to 'min(ll&, int&)' 42 | rMin = min(rMin, v[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:42:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 42 | rMin = min(rMin, v[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5