Submission #17399479


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  long long sal[101][101][101];
  for (int i = 0; i < 101; i ++) {
    for (int j = 0; j < 101; j ++) {
      for (int k = 0; k < 101; k ++) {
        sal[i][j][k] = -1;
      }
    }
  }
  sal[0][0][0] = 0;
  for (int i = 0; i < N; i ++) {
    int a, b, c;
    long long w;
    cin >> a >> b >> c >> w;
    sal[a][b][c] = max(sal[a][b][c], w);
  }
  for (int i = 0; i < 101; i ++) {
    for (int j = 0; j < 101; j ++) {
      for (int k = 0; k < 101; k ++) {
        if (i > 0) sal[i][j][k] = max(sal[i][j][k], sal[i - 1][j][k]);
        if (j > 0) sal[i][j][k] = max(sal[i][j][k], sal[i][j - 1][k]);
        if (k > 0) sal[i][j][k] = max(sal[i][j][k], sal[i][j][k - 1]);
        //if (sal[i][j][k] == -1) cout << 'N' << endl;
      }
    }
  }
  for (int i = 0; i < M; i ++) {
    int x, y, z;
    cin >> x >> y >> z;
    cout << sal[x][y][z] << endl;
  }
}

Submission Info

Submission Time
Task C - Optimal Recommendations
User kumjin3141
Language C++ (GCC 9.2.1)
Score 100
Code Size 982 Byte
Status
Exec Time 143 ms
Memory 11648 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 143 ms 11372 KB
10-random-01.txt 13 ms 11648 KB
10-random-02.txt 81 ms 11516 KB
10-random-03.txt 103 ms 11548 KB
10-random-04.txt 55 ms 11372 KB
20-absW-00.txt 133 ms 11604 KB
20-absW-01.txt 14 ms 11620 KB
20-absW-02.txt 72 ms 11564 KB
20-absW-03.txt 110 ms 11564 KB
20-absW-04.txt 51 ms 11644 KB
30-balance-00.txt 137 ms 11436 KB
30-balance-01.txt 16 ms 11556 KB
30-balance-02.txt 54 ms 11608 KB
30-balance-03.txt 81 ms 11516 KB
30-balance-04.txt 101 ms 11372 KB
40-limit_dim-00.txt 141 ms 11608 KB
40-limit_dim-01.txt 140 ms 11560 KB
40-limit_dim-02.txt 143 ms 11640 KB
40-limit_dim-03.txt 142 ms 11464 KB
40-limit_dim-04.txt 143 ms 11448 KB
40-limit_dim-05.txt 135 ms 11576 KB
40-limit_dim-06.txt 136 ms 11548 KB
Corner1.txt 13 ms 11408 KB
Sample1.txt 17 ms 11416 KB