Submission #17427699


Source Code Expand

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

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

int dp[101][101][101];

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 = 0; i < 100; ++i){
        for(int j = 0; j < 100; ++j){
            for(int k = 0; k < 100; ++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]);
            }
        }
    }

    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 1202 Byte
Status
Exec Time 141 ms
Memory 8748 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
× 8
× 16
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 140 ms 8540 KB
10-random-01.txt 13 ms 7524 KB
10-random-02.txt 82 ms 7624 KB
10-random-03.txt 100 ms 7840 KB
10-random-04.txt 57 ms 7892 KB
20-absW-00.txt 129 ms 8572 KB
20-absW-01.txt 12 ms 7576 KB
20-absW-02.txt 74 ms 8044 KB
20-absW-03.txt 110 ms 8192 KB
20-absW-04.txt 50 ms 7960 KB
30-balance-00.txt 141 ms 8536 KB
30-balance-01.txt 13 ms 7576 KB
30-balance-02.txt 52 ms 7896 KB
30-balance-03.txt 81 ms 8136 KB
30-balance-04.txt 100 ms 7784 KB
40-limit_dim-00.txt 141 ms 8688 KB
40-limit_dim-01.txt 141 ms 8748 KB
40-limit_dim-02.txt 139 ms 8656 KB
40-limit_dim-03.txt 141 ms 8588 KB
40-limit_dim-04.txt 140 ms 8672 KB
40-limit_dim-05.txt 140 ms 8532 KB
40-limit_dim-06.txt 136 ms 8564 KB
Corner1.txt 14 ms 7600 KB
Sample1.txt 12 ms 7520 KB