제출 #1145000

#제출 시각아이디문제언어결과실행 시간메모리
1145000MedetbekTable Tennis (info1cup20_tabletennis)C++20
컴파일 에러
0 ms0 KiB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
#include <bits/stdc++.h>

#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
#define nl '\n'
#define pb push_back
#define sz(s) (int)(s).size()
#define f first
#define s second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
const ll N = 1e5+10, MX = 1e18+1, MOD = 1e9 + 7;
void solve(){
    ll n, k;
    cin >> n >> k;
    ll m = n + k;
    ll a[m+1];
    for(int i = 1; i <= m; i++){
        cin >> a[i];
    }
    sort(a + 1, a + 1 + m);
    map <int, int> cnt;
    vector <int> v;
    set <pair <int, int> > sum;
    for(int i = 1; i <= min(m), m); i++){
        for(int j = n; j >= max(1ll, 1ll); j--){
            ll sm = a[i]+a[j];
            cnt[sm]++;
            v.pb(sm);
        }
    }
    for(auto x:v){
        if(cnt[x] > 0){
            sum.insert({cnt[x], x});
            cnt[x]=0;
        }
    }
    for(auto [y, x]:sum){
        ll l = 1, r = m; 
        vector <int> ans;
        while(l < r){
            if(a[l] + a[r] > x){
                r--;
            }else if(a[l] + a[r] < x){
                l++;
            }else{
                ans.pb(a[l]);
                ans.pb(a[r]);
                l++;
                r--;
            }
        }
        if(sz(ans) >= n){
            sort(all(ans));
            for(int i = 0; i < n; i++){
                cout << ans[i] << " ";
            }
            return;
        }
    }
}
main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll ql =1;
	 while(ql--){
	    solve();
	}
}

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.cpp: In function 'void solve()':
tabletennis.cpp:29:28: error: no matching function for call to 'min(long long int&)'
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                         ~~~^~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tabletennis.cpp:3:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:29:28: note:   candidate expects 2 arguments, 1 provided
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                         ~~~^~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from tabletennis.cpp:3:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:29:28: note:   candidate expects 3 arguments, 1 provided
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                         ~~~^~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from tabletennis.cpp:3:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:29:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                         ~~~^~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from tabletennis.cpp:3:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
tabletennis.cpp:29:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                         ~~~^~~
tabletennis.cpp:29:34: error: expected ';' before ')' token
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                                  ^
      |                                  ;
tabletennis.cpp:29:37: error: 'i' was not declared in this scope
   29 |     for(int i = 1; i <= min(m), m); i++){
      |                                     ^
tabletennis.cpp: At global scope:
tabletennis.cpp:66:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   66 | main(){
      | ^~~~