Submission #523359

#TimeUsernameProblemLanguageResultExecution timeMemory
523359Ahmed2meTable Tennis (info1cup20_tabletennis)C++17
Compilation error
0 ms0 KiB
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> #define ll long long #define fl cout.flush(); #define endl '\n' #define sp ' ' using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; inline void fileim(bool usaco,bool cs,bool cs2,char *s,char *s2) { if(usaco) { #define fin cin #define fout cout } if(cs){freopen( s, "r", stdin );} if(cs2){freopen( s2, "w", stdout );} } const int mxint = 2147483647 ; const ll MOD=1e9+7; const ll N=3e6; const double EPS=1e-6; vector<int>pr;int lp[1000001]; ll power(ll x, ll y) { ll ans=1;while(y){if(y&1){ ans=(ans*x)%MOD; }y/=2;x=(x*x)%MOD;}return ans; } ll bitcount(ll num){ ll rtrn=0;while(num){rtrn++;num=(num&(num-1));}return rtrn; } ll inv(ll x){return power(x , MOD-2);} void linear_seive() { for(int i=2;i<=N;i++) { if(!lp[i]){lp[i]=i;pr.push_back(i);} for(int j=0;j<pr.size()&&pr[j]<=lp[i]&&i*pr[j]<=N;j++){lp[i*pr[j]]=pr[j];} } } ll t=1,n,m,a[200020]; bool good(ll sum) { ll i=1,j=n+m; ll cnt=false; while(i<j) { if(a[i]+a[j]==sum){cnt++;i++;j--;continue;} if(a[i]+a[j]>sum){j--;continue;} if(a[i]+a[j]<sum){i++;continue;} } return cnt>=(n/2); } void print_ans(ll sum) { ll i=1;ll j=n+m; set<ll>ans; while(i<j) { if(a[i]+a[j]==sum){ans.insert(a[i]);ans.insert(a[j]);i++;j--;continue;} if(a[i]+a[j]>sum){j--;continue;} if(a[i]+a[j]<sum){i++;continue;} } for(auto I:ans){cout<<I<<sp;} return; } void solve() { cin>>n>>m; for(int i=1;i<=n+m;i++){cin>>a[i];} set<int>st;sort(a+1,a+n+m+1); for(int i=1;i<=min(n,2*m);i++) { for(int j=max(1,(n+m)-2*m+1);j<=n+m;j++) { st.insert(a[i]+a[j]); } } for(auto I:st){if(good(I)){print_ans(I);return;}} } int main() { ios::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); //cin>>t;//linear_seive();//fileim( 1,1,1, "hps.in","hps.out" ); cout<< fixed << setprecision(15) ;while(t--){solve();}return 0; }

Compilation message (stderr)

tabletennis.cpp: In function 'void linear_seive()':
tabletennis.cpp:45:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for(int j=0;j<pr.size()&&pr[j]<=lp[i]&&i*pr[j]<=N;j++){lp[i*pr[j]]=pr[j];}
      |                     ~^~~~~~~~~~
tabletennis.cpp: In function 'void solve()':
tabletennis.cpp:85:36: error: no matching function for call to 'max(int, long long int)'
   85 |         for(int j=max(1,(n+m)-2*m+1);j<=n+m;j++)
      |                                    ^
In file included from /usr/include/c++/10/memory:63,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from tabletennis.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:85:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   85 |         for(int j=max(1,(n+m)-2*m+1);j<=n+m;j++)
      |                                    ^
In file included from /usr/include/c++/10/memory:63,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from tabletennis.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:85:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   85 |         for(int j=max(1,(n+m)-2*m+1);j<=n+m;j++)
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/c++/10/ext/pb_ds/hash_policy.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from tabletennis.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:85:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   85 |         for(int j=max(1,(n+m)-2*m+1);j<=n+m;j++)
      |                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/c++/10/ext/pb_ds/hash_policy.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from tabletennis.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:85:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   85 |         for(int j=max(1,(n+m)-2*m+1);j<=n+m;j++)
      |                                    ^