1 条题解
-
0CDQZxuyifeng LV 9 @ 2017-10-07 19:59:23
//-------------------------------------------AC code-------------------------------------------//
#include<algorithm> #include<iostream> #include<cstdio> using namespace std; typedef long long LL; const int N = 20; int n; LL ans = -0x7fffffff; struct WEEK{ int a, b, c, d; }w[N]; void dfs(int week, LL OI, LL WHK){ if(week == n){ if(OI * WHK > ans) ans = OI * WHK; return; } dfs(week+1, OI + w[week+1].c, max(1ll*0, WHK - w[week+1].d)); dfs(week+1, max(1ll*0, OI - w[week+1].b), WHK + w[week+1].a); } int main(){ freopen("week.in", "r", stdin); freopen("week.out", "w", stdout); scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d%d%d%d", &w[i].a, &w[i].b, &w[i].c, &w[i].d); dfs(0, 1ll*0, 1ll*0); cout << ans; return 0; }
- 1