# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
473226 |
2021-09-15T10:40:52 Z |
Ahmed_Solyman |
San (COCI17_san) |
C++14 |
|
36 ms |
65540 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;
}
prev=i;
}
}
if(sum>=k)ans++;
}
cout<<ans<<endl;
}
else{
cout<<solve(0,44,0)<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
34 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
36 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
34 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
31 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |