답안 #473537

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473537 2021-09-15T16:27:44 Z _L__ San (COCI17_san) C++17
컴파일 오류
0 ms 0 KB
// This code is written by _L__
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 5e5+13, inf = 1e11;
const ld E = 1e-6;
#define ff first
#define ss second

int main(void){
    F_word;
    ll n, k; cin >> n >> k;
    ll h[n], c[n]; for(int i = 0; i < n; ++i)cin >> h[i] >> c[i];
    vector<pair<ll, ll>> v;
    ll x = (n/2), b = (n-(n/2));
    for(int i = 0; i < (1<<x); ++i){
        ll hg = 0, gg = 0;
        for(int j = 0; j < x; ++j){
            if(i&(1<<j)){
                if(hg <= h[j]){hg = h[j]; gg += c[j];}
                else{gg = -1; break;}
            }
        }
        if(gg != -1)v.push_back({hg, gg});
    }
    unordered_map<ll, vector<ll>> mp;
    for(int i = 0; i < (1<<b); ++i){
        ll hg = 0, gg = 0;
        for(int j = 0; j < b; ++j){
            if(i&(1<<j)){
                if(hg <= h[j+x]){hg = h[j+x]; gg += c[j+x];}
                else {gg = -1; break;}
            }
        }
        if(gg == -1) continue;
        if(i == 0){mp[inf].push_back(0); continue;}
        for(int j = 0; j < b; ++j){
            if(i&(1<<j)){
                mp[h[j+x]].push_back(gg);
                break;
            }
        }
    }
    ll ans = 0;
    for(auto i: mp) sort(i.ss.begin(), i.ss.end());
    for(auto i: v){
        for(auto u: mp){
            if(u.ff >= i.ff){
                ll z = lower_bound(u.ss.begin(), u.ss.end(), max(k-i.ss, 0ll))-u.ss.begin();
                ans += max(u.ss.size()-z,0ll);
            }
        }
    }
    cout << ans << endl;
}

Compilation message

san.cpp: In function 'int main()':
san.cpp:53:45: error: no matching function for call to 'max(long long unsigned int, long long int)'
   53 |                 ans += max(u.ss.size()-z,0ll);
      |                                             ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from san.cpp:2:
/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:
san.cpp:53:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   53 |                 ans += max(u.ss.size()-z,0ll);
      |                                             ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from san.cpp:2:
/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:
san.cpp:53:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
   53 |                 ans += max(u.ss.size()-z,0ll);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from san.cpp:2:
/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:
san.cpp:53:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   53 |                 ans += max(u.ss.size()-z,0ll);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from san.cpp:2:
/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:
san.cpp:53:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   53 |                 ans += max(u.ss.size()-z,0ll);
      |                                             ^