Submission #17489545


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

int dp[102][102][102];

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(N), b(N), c(N), w(N);

    for(int i = 0; i < N; ++i){
        cin >> a[i] >> b[i] >> c[i] >> w[i];
        dp[a[i]][b[i]][c[i]] = max(dp[a[i]][b[i]][c[i]], w[i]);
    }

    vector<int> x(M), y(M), z(M);
    for(int i = 0; i < M; ++i){
        cin >> x[i] >> y[i] >> z[i];
    }

    for(int i = 0; i < 100; ++i) {
        dp[i + 1][0][0] = max(dp[i + 1][0][0], dp[i][0][0]);
        dp[0][i + 1][0] = max(dp[0][i + 1][0], dp[0][i][0]);
        dp[0][0][i + 1] = max(dp[0][0][i + 1], dp[0][0][i]);
    }


    for(int i = 1; i < 101; ++i){
        for(int j = 1; j < 101; ++j){
            for(int k = 1; k < 101; ++k){
                // dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
                // dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                // dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k]);
                dp[i][j][k] = max(dp[i][j][k], max(dp[i - 1][j][k], max(dp[i][j - 1][k], dp[i][j][k - 1]))); 
            }
        }
    }

    for(int i = 0; i < M; ++i){
        cout << dp[x[i]][y[i]][z[i]] << endl;
    }

    return 0;
}

Submission Info

Submission Time
Task C - Optimal Recommendations
User URASUMA
Language C++ (GCC 9.2.1)
Score 0
Code Size 1307 Byte
Status
Exec Time 140 ms
Memory 8676 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
× 9
× 15
Set Name Test Cases
All 10-random-00.txt, 10-random-01.txt, 10-random-02.txt, 10-random-03.txt, 10-random-04.txt, 20-absW-00.txt, 20-absW-01.txt, 20-absW-02.txt, 20-absW-03.txt, 20-absW-04.txt, 30-balance-00.txt, 30-balance-01.txt, 30-balance-02.txt, 30-balance-03.txt, 30-balance-04.txt, 40-limit_dim-00.txt, 40-limit_dim-01.txt, 40-limit_dim-02.txt, 40-limit_dim-03.txt, 40-limit_dim-04.txt, 40-limit_dim-05.txt, 40-limit_dim-06.txt, Corner1.txt, Sample1.txt
Case Name Status Exec Time Memory
10-random-00.txt 139 ms 8668 KB
10-random-01.txt 12 ms 7604 KB
10-random-02.txt 76 ms 7824 KB
10-random-03.txt 99 ms 7840 KB
10-random-04.txt 52 ms 7912 KB
20-absW-00.txt 131 ms 8524 KB
20-absW-01.txt 13 ms 7464 KB
20-absW-02.txt 72 ms 8280 KB
20-absW-03.txt 111 ms 8164 KB
20-absW-04.txt 51 ms 7880 KB
30-balance-00.txt 135 ms 8608 KB
30-balance-01.txt 12 ms 7536 KB
30-balance-02.txt 49 ms 7712 KB
30-balance-03.txt 78 ms 8248 KB
30-balance-04.txt 100 ms 7868 KB
40-limit_dim-00.txt 140 ms 8576 KB
40-limit_dim-01.txt 140 ms 8612 KB
40-limit_dim-02.txt 139 ms 8512 KB
40-limit_dim-03.txt 138 ms 8444 KB
40-limit_dim-04.txt 139 ms 8652 KB
40-limit_dim-05.txt 136 ms 8548 KB
40-limit_dim-06.txt 137 ms 8676 KB
Corner1.txt 11 ms 7528 KB
Sample1.txt 10 ms 7708 KB