# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
473199 |
2021-09-15T10:06:22 Z |
MamdouhN |
San (COCI17_san) |
C++17 |
|
40 ms |
65540 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int n,k;
int towers[100],gold[100];
int dp[50][1000000];
int solve(int idx,int sum)
{
//cout<<idx<<" "<<sum<<endl;
if(idx==n)return 0;
if(sum<1000000)if(dp[idx][sum]!=-1)return dp[idx][sum];
sum+=gold[idx];
int ret = 0;
if(sum>=k)ret = 1;
for(int i=idx+1;i<n;i++)
{
if(towers[i]>=towers[idx])ret+=solve(i,sum);
}
return dp[idx][sum] = ret;
}
main()
{
memset(dp,-1,sizeof dp);
cin>>n>>k;
for(int i=0;i<n;i++)cin>>towers[i]>>gold[i];
int ans = 0;
for(int i=0;i<n;i++)ans+=solve(i,0);
cout<<ans<<endl;
}
Compilation message
san.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
25 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
35 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 |
40 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
35 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
39 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |