Submission #17427520


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]] = 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]);
    for(int i = 0; i < 100; ++i) dp[0][i + 1][0] = max(dp[0][i + 1][0], dp[0][i][0]);
    for(int i = 0; i < 100; ++i) 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][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 1094 Byte
Status
Exec Time 138 ms
Memory 8792 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
× 4
× 20
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 138 ms 8360 KB
10-random-01.txt 12 ms 7612 KB
10-random-02.txt 77 ms 7604 KB
10-random-03.txt 96 ms 7760 KB
10-random-04.txt 53 ms 7948 KB
20-absW-00.txt 131 ms 8352 KB
20-absW-01.txt 14 ms 7544 KB
20-absW-02.txt 72 ms 8164 KB
20-absW-03.txt 108 ms 8024 KB
20-absW-04.txt 49 ms 7856 KB
30-balance-00.txt 134 ms 8792 KB
30-balance-01.txt 14 ms 7496 KB
30-balance-02.txt 51 ms 7756 KB
30-balance-03.txt 76 ms 8148 KB
30-balance-04.txt 95 ms 8000 KB
40-limit_dim-00.txt 138 ms 8652 KB
40-limit_dim-01.txt 138 ms 8444 KB
40-limit_dim-02.txt 138 ms 8612 KB
40-limit_dim-03.txt 137 ms 8360 KB
40-limit_dim-04.txt 137 ms 8596 KB
40-limit_dim-05.txt 137 ms 8520 KB
40-limit_dim-06.txt 137 ms 8612 KB
Corner1.txt 11 ms 7472 KB
Sample1.txt 11 ms 7424 KB