Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
145451 吴宗桦 储钱罐 C++ 通过 100 1 MS 268 KB 553 2024-05-05 08:53:50

Tests(5/5):


#include<iostream> using namespace std; int a,b,c,d,e,f[504],g[505],h,i[114514],j,k[11],l; int main() { cin>>a; for(b=1;b<=a;b++) { cin>>l>>c>>d; j=c-l; for(e=1;e<=d;e++) { cin>>g[e]>>f[e]; } i[1]=0; for(e=1;e<=j;e++) i[e]=1E9; for(e=1;e<=d;e++) for(h=f[e];h<=j;h++) i[h]=min(i[h],i[h-f[e]]+g[e]); k[b]=i[j]; } for(b=1;b<=a;b++) { if(k[b]<1E9) cout<<"The minimum amount of money in the piggy-bank is "<<k[b]<<"."<<endl; else cout<<"This is impossible."<<endl; } return 0; }


测评信息: