Untitled
user_5379400
plain_text
a year ago
1.2 kB
6
Indexable
#include<iostream> using namespace std; const int mod = 1e9 + 7; int n, ans; int a[111][2]; int L[5], P[5]; int vis[111]; int pos[111]; int time[111][2]; void dfs(int index, int st){ if (index == 4){ int tot = 0; for (int i = 0; i < n; i++){ int mx = 0; for (int j = 1; j <= 3; j++){ if (time[j][0] >= a[i][0] && time[j][1] <= a[i][1]) mx = max(mx, P[pos[j]]); } tot += mx; } ans = max(ans, tot); return; } for (int i = 1; i <= 3; i++){ if (vis[i]) continue; vis[i] = true; pos[index] = i; for (int t = st; t <= 50; t++){ time[index][0] = t; time[index][1] = t + L[i]; dfs(index + 1, t + L[i]); } vis[i] = false; } } void solve(int test){ cin >> n; for (int i = 1; i <= 3; i++) cin >> L[i]; for (int i = 1; i <= 3; i++) cin >> P[i]; for (int i = 0; i < n; i++){ cin >> a[i][0] >> a[i][1]; a[i][1] += a[i][0]; } ans = 0; dfs(1, 1); cout << "Case #" << test << ' ' << ans << '\n'; } int32_t main(){ ios_base::sync_with_stdio(false), cin.tie(0); freopen("file1.txt", "r", stdin); int t = 1; cin >> t; for (int i = 1; i <= t; i++) solve(i); }
Editor is loading...
Leave a Comment