Submission #19261139
Source Code Expand
Copy
import java.io.IOException; import java.io.InputStream; import java.util.NoSuchElementException; public class Main { static long mod = 1000000007; public static void main(String[] args) { FastScanner sc = new FastScanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[] a = new int[n], b = new int[n], c = new int[n], w = new int[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); c[i] = sc.nextInt(); w[i] = sc.nextInt(); } int[] x = new int[m], y = new int[m], z = new int[m]; for(int i = 0; i < m; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); z[i] = sc.nextInt(); } int[][][] dp = new int[101][101][101]; for(int i = 0; i < n; i++) { dp[a[i]][b[i]][c[i]] = w[i]; } for(int i = 0; i < 101; i++) { for(int j = 0; j < 101; j++) { for(int k = 0; k < 101; k++) { int tmp = dp[i][j][k]; if(i == 0 && j == 0 && k == 0) continue; if(i != 0) { tmp = Math.max(tmp, dp[i-1][j][k]); } if(j != 0) { tmp = Math.max(tmp, dp[i][j-1][k]); } if(k != 0) { tmp = Math.max(tmp, dp[i][j][k-1]); } dp[i][j][k] = tmp; } } } for(int i = 0; i < m; i++) { System.out.println(dp[x[i]][y[i]][z[i]]); } } } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; public FastScanner(InputStream in2) { // TODO 自動生成されたコンストラクター・スタブ } private boolean hasNextByte() { if (ptr < buflen) { return true; }else{ ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;} public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();} public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while(isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while(true){ if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; }else if(b == -1 || !isPrintableChar(b)){ return minus ? -n : n; }else{ throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next());} }
Submission Info
Submission Time | |
---|---|
Task | C - Optimal Recommendations |
User | kiruto398 |
Language | Java (OpenJDK 11.0.6) |
Score | 0 |
Code Size | 3612 Byte |
Status | WA |
Exec Time | 470 ms |
Memory | 49536 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
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 | WA | 449 ms | 48000 KB |
10-random-01.txt | AC | 113 ms | 37704 KB |
10-random-02.txt | AC | 357 ms | 45084 KB |
10-random-03.txt | WA | 385 ms | 46564 KB |
10-random-04.txt | WA | 230 ms | 40248 KB |
20-absW-00.txt | AC | 442 ms | 48148 KB |
20-absW-01.txt | AC | 101 ms | 37656 KB |
20-absW-02.txt | AC | 279 ms | 42676 KB |
20-absW-03.txt | AC | 411 ms | 46476 KB |
20-absW-04.txt | AC | 277 ms | 41224 KB |
30-balance-00.txt | WA | 455 ms | 48460 KB |
30-balance-01.txt | AC | 113 ms | 37628 KB |
30-balance-02.txt | AC | 296 ms | 41532 KB |
30-balance-03.txt | WA | 306 ms | 43732 KB |
30-balance-04.txt | WA | 386 ms | 46984 KB |
40-limit_dim-00.txt | WA | 448 ms | 48068 KB |
40-limit_dim-01.txt | WA | 436 ms | 48700 KB |
40-limit_dim-02.txt | WA | 438 ms | 48216 KB |
40-limit_dim-03.txt | WA | 448 ms | 48436 KB |
40-limit_dim-04.txt | WA | 440 ms | 47908 KB |
40-limit_dim-05.txt | WA | 470 ms | 49536 KB |
40-limit_dim-06.txt | WA | 444 ms | 48168 KB |
Corner1.txt | WA | 101 ms | 37632 KB |
Sample1.txt | AC | 101 ms | 37528 KB |