Submission #19260996
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 | 467 ms |
Memory | 50292 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 | 440 ms | 48164 KB |
10-random-01.txt | AC | 106 ms | 37776 KB |
10-random-02.txt | AC | 356 ms | 44400 KB |
10-random-03.txt | WA | 384 ms | 46460 KB |
10-random-04.txt | WA | 213 ms | 39956 KB |
20-absW-00.txt | AC | 420 ms | 48332 KB |
20-absW-01.txt | AC | 111 ms | 37892 KB |
20-absW-02.txt | AC | 275 ms | 42604 KB |
20-absW-03.txt | AC | 400 ms | 46852 KB |
20-absW-04.txt | AC | 276 ms | 41520 KB |
30-balance-00.txt | WA | 451 ms | 48764 KB |
30-balance-01.txt | AC | 103 ms | 37532 KB |
30-balance-02.txt | AC | 300 ms | 42476 KB |
30-balance-03.txt | WA | 290 ms | 42748 KB |
30-balance-04.txt | WA | 378 ms | 46584 KB |
40-limit_dim-00.txt | WA | 427 ms | 48496 KB |
40-limit_dim-01.txt | WA | 445 ms | 48176 KB |
40-limit_dim-02.txt | WA | 431 ms | 48204 KB |
40-limit_dim-03.txt | WA | 437 ms | 48636 KB |
40-limit_dim-04.txt | WA | 442 ms | 48140 KB |
40-limit_dim-05.txt | WA | 467 ms | 50292 KB |
40-limit_dim-06.txt | WA | 439 ms | 48140 KB |
Corner1.txt | WA | 107 ms | 37740 KB |
Sample1.txt | AC | 106 ms | 37736 KB |