Submission #17427710


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

    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 100
Code Size 1202 Byte
Status
Exec Time 141 ms
Memory 8868 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
× 24
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 141 ms 8604 KB
10-random-01.txt 13 ms 7716 KB
10-random-02.txt 80 ms 7812 KB
10-random-03.txt 101 ms 7940 KB
10-random-04.txt 53 ms 7916 KB
20-absW-00.txt 130 ms 8772 KB
20-absW-01.txt 12 ms 7572 KB
20-absW-02.txt 69 ms 8268 KB
20-absW-03.txt 110 ms 8248 KB
20-absW-04.txt 53 ms 7900 KB
30-balance-00.txt 138 ms 8868 KB
30-balance-01.txt 15 ms 7652 KB
30-balance-02.txt 48 ms 7916 KB
30-balance-03.txt 82 ms 8116 KB
30-balance-04.txt 100 ms 8100 KB
40-limit_dim-00.txt 137 ms 8756 KB
40-limit_dim-01.txt 140 ms 8612 KB
40-limit_dim-02.txt 139 ms 8644 KB
40-limit_dim-03.txt 138 ms 8608 KB
40-limit_dim-04.txt 139 ms 8636 KB
40-limit_dim-05.txt 138 ms 8828 KB
40-limit_dim-06.txt 137 ms 8648 KB
Corner1.txt 14 ms 7708 KB
Sample1.txt 13 ms 7736 KB