답안 #473228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473228 2021-09-15T10:41:40 Z Ahmed_Solyman San (COCI17_san) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n,k;
ll dp[45][45][10000];
vector<ll>a(45),b(45);

ll solve(ll i,ll prev,ll sum){
    if(i==n)return (sum>=k);
    ll &ret=dp[i][prev][sum];
    if(~ret)return ret;
    ll Take=0;
    ll notTake=solve(i+1,prev,sum);
    if(a[i]>=a[prev]){
        Take=solve(i+1,i,sum+b[i]);
    }
    return ret=Take+notTake;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    if(n<=20){
        ll ans=0;
        for(ll mask=0;mask<(1<<n);mask++){
            ll sum=0,prev=44;
            for(ll i=0;i<n;i++){
                if((1<<i)&mask){
                    if(a[i]>=a[prev]){
                        sum+=b[i];
                    }
                    else{
                        sum=-1;
                        break;
                    }#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n,k;
ll dp[45][45][10000];
vector<ll>a(45),b(45);

ll solve(ll i,ll prev,ll sum){
    if(i==n)return (sum>=k);
    ll &ret=dp[i][prev][sum];
    if(~ret)return ret;
    ll Take=0;
    ll notTake=solve(i+1,prev,sum);
    if(a[i]>=a[prev]){
        Take=solve(i+1,i,sum+b[i]);
    }
    return ret=Take+notTake;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
    if(n<=20){
        ll ans=0;
        for(ll mask=0;mask<(1<<n);mask++){
            ll sum=0,prev=44;
            for(ll i=0;i<n;i++){
                if((1<<i)&mask){
                    if(a[i]>=a[prev]){
                        sum+=b[i];
                    }
                    else{
                        sum=-1;
                        break;
                    }
                    prev=i;
                }
            }
            if(sum>=k)ans++;
        }
        cout<<ans<<endl;
    }
    else{
        cout<<solve(0,44,0)<<endl;
    }
    return 0;
}

                    prev=i;
                }
            }
            if(sum>=k)ans++;
        }
        cout<<ans<<endl;
    }
    else{
        cout<<solve(0,44,0)<<endl;
    }
    return 0;
}

Compilation message

san.cpp:39:22: error: stray '#' in program
   39 |                     }#include <bits/stdc++.h>
      |                      ^
san.cpp: In function 'int main()':
san.cpp:39:23: error: 'include' was not declared in this scope
   39 |                     }#include <bits/stdc++.h>
      |                       ^~~~~~~
san.cpp:39:32: error: 'bits' was not declared in this scope
   39 |                     }#include <bits/stdc++.h>
      |                                ^~~~
san.cpp:39:37: error: 'stdc' was not declared in this scope; did you mean 'std'?
   39 |                     }#include <bits/stdc++.h>
      |                                     ^~~~
      |                                     std
san.cpp:41:1: error: expected primary-expression before 'using'
   41 | using namespace std;
      | ^~~~~
san.cpp:49:30: error: a function-definition is not allowed here before '{' token
   49 | ll solve(ll i,ll prev,ll sum){
      |                              ^
san.cpp:61:1: error: a function-definition is not allowed here before '{' token
   61 | {
      | ^
san.cpp:45:4: warning: unused variable 'n' [-Wunused-variable]
   45 | ll n,k;
      |    ^
san.cpp:45:6: warning: unused variable 'k' [-Wunused-variable]
   45 | ll n,k;
      |      ^
san.cpp:46:4: warning: unused variable 'dp' [-Wunused-variable]
   46 | ll dp[45][45][10000];
      |    ^~