Submission #3994997


Source Code Expand

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

bool check(ll i){
    bitset<5005> dp;
    dp[0]=true;
    rep(j,n){
        if(i==j)continue;
        dp|=dp<<a[j];
    }
    b=0;
    rep(j,k){
        if(!dp[j])continue;
        if(j+a[i]>=k){
            b=1;
            break;
        }
    }
    if(!b)return false;
    else return true;
}

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);

    cin>>n>>k;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    ll le=0,ri=n-1,mid;
    while(ri-le>1){
        mid=(le+ri)/2;
        if(check(mid))ri=mid;
        else le=mid;
    }
    rrrep(i,min(ri+500,n-1),max(le-500,0LL)){
        bitset<5005> dp;
        dp[0]=true;
        rep(j,n){
            if(i==j)continue;
            dp|=dp<<a[j];
        }
        b=0;
        rep(j,k){
            if(!dp[j])continue;
            if(j+a[i]>=k){
                b=1;
                break;
            }
        }
        if(!b){
            ans=max(ans,i+1);
            break;
        }
    }
    Cout(ans);
    return 0;
}

Submission Info

Submission Time
Task D - No Need
User asdf1
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1793 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:75:28: error: no matching function for call to ‘max(ll&, int)’
             ans=max(ans,i+1);
                            ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
./Main.cpp:75:28: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
             ans...