| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 141975 | 吴悠 | 简单背包问题 | C++ | Wrong Answer | 40 | 0 MS | 244 KB | 389 | 2024-04-06 15:20:59 |
#include<iostream> using namespace std; int a[33]; int bag(int ts,int tn){ if(ts==0){ return 1; } if(ts<0 || (ts>0 && tn<1)){ return 0; } if(bag(ts-a[tn],tn-1)==1){ cout<<a[tn]<<endl; return 1; } return bag(ts,tn-1); } int main(){ int s,n; cin>>s>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } if(!bag(s,n)){ cout<<"Failed"<<endl; } return 0; }