Simple enumeration + clever evasion of large enumeration amount
#include <bits/stdc++.h>using namespace Std;long long N,s1,v1,s2,v2,total;int main () {Ios::sync_with_stdio ( FALSE); Long Long t,maxn=0; cin>>t; while (t--) {cin>>n>>s1>>v1>>s2>>v2; total=0; Long Long kase=0,money=0; Long Long Q1=n/s1,q2=n/s2,q3=max (S1,S2); Long Long Mincomplex=min (min (q1,q2), Q3); if (MINCOMPLEX==Q1) {for (long long i=0;i<=q1;i++) {kase=n-i*s1; money=i*v1+ (KASE/S2) *v2; if (money>=total) Total=money; }} else if (MINCOMPLEX==Q2) {for (long long i=0;i<=q2;i++) {kase=n-i*s2; money=i*v2+ (KASE/S1) *v1; if (money>=total) Total=money; }} else {if (s2*v1>s1*v2) {for (long long i=0;i<=s1-1;i++) { KASE=N-I*S2; money=i*v2+ (KASE/S1) *v1; if (MoNey>=total) Total=money; }} else {for (long long i=0;i<=s2-1;i++) {kase=n-i*s1; money=i*v1+ (KASE/S2) *v2; if (money>=total) Total=money; }}} cout<< "Case #" <<++maxn<< ":" <<total<< "\ n"; } return 0;}
12325-zombie ' s treasure Chest.