Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int arr[100005][3];
- int kolacinja(int W, int B, int R, int i) {
- if(i == -1) {
- return 0;
- }
- int result = 0;
- if(W > 0) {
- result = max(result, kolacinja(W - 1, B, R, i - 1) + arr[i][0]);
- }
- if(B > 0) {
- result = max(result, kolacinja(W, B - 1, R, i - 1) + arr[i][1]);
- }
- if(R > 0) {
- result = max(result, kolacinja(W, B, R - 1, i - 1) + arr[i][2]);
- }
- return result;
- }
- int main()
- {
- int w, b, r, n;
- cin >> w >> b >> r >> n;
- for(int i = 0; i < n; i++) {
- cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
- }
- if(n <= 12) {
- cout << kolacinja(w, b, r, n - 1) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement