General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
97009191 Practice:
dante_part_2
1398D - 8 C++17 (GCC 7-32) Wrong answer on test 6 61 ms 67508 KB 2020-10-28 17:27:20 2020-10-28 17:27:20
→ Source
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
#define ll long long
#define MAXN 201
vector<ll> RED(MAXN), GREEN(MAXN), BLUE(MAXN);
vector<vector<vector<ll>>> dp(MAXN, vector<vector<ll>>(MAXN, vector<ll>(MAXN,-1)));
int r, g, b;
 
bool compare(const ll &a, const ll &b){
    return a > b;
}
 
ll f(int i, int j, int k){
    if(dp[i][j][k] != -1) return dp[i][j][k];
    if(i == 0){
        if(j == 0 || k == 0) dp[i][j][k] = 0;
        else{
            // green and blue
            dp[i][j][k] = GREEN[g - j] * BLUE[b - k] + f(i, j - 1, k - 1);
        }
    }
    else if(j == 0){
        if(i == 0 || k == 0) dp[i][j][k] = 0;
        else{
            // red and blue
            dp[i][j][k] = RED[r - i] * BLUE[b - j] + f(i - 1, j, k - 1);
        }
    }
    else if(k == 0){
        if(j == 0 || i == 0) dp[i][j][k] = 0;
        else{
            // red and green
            dp[i][j][k] = RED[r - i] * GREEN[g - j] + f(i - 1, j - 1, k);
        }
    }
    else dp[i][j][k] = max(RED[r - i] * GREEN[g - j] + f(i - 1, j - 1, k), max(RED[r - i] * BLUE[b - k] + f(i - 1, j, k - 1), GREEN[g - j] * BLUE[b - k] + f(i, j - 1, k - 1)));
    return dp[i][j][k];
}
 
int main(){
    cin >> r >> g >> b;
    for(int i = 0; i < r; i++) cin >> RED[i];
    for(int i = 0; i < g; i++) cin >> GREEN[i];
    for(int i = 0; i < b; i++) cin >> BLUE[i];
    sort(RED.begin(), RED.begin() + r, compare);
    sort(GREEN.begin(), GREEN.begin() + g, compare);
    sort(BLUE.begin(), BLUE.begin() + b, compare);

     cout << f(r, g, b) << endl;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details