We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) throws IOException {
InputReader reader = new InputReader(System.in);
int N = reader.readInt();
int H = reader.readInt();
int I = reader.readInt();
int[][] people = new int[N][H];
for (int n=0; n
}
int[][] save = new int[N][H];
int[] max = new int[H];
for (int n=0; n
}
for (int h=1; h= I) {
value = Math.max(value, max[h-I]);
static final class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
private int read() throws IOException {
if (curChar >= numChars) {
curChar = 0;
numChars = stream.read(buf);
if (numChars <= 0) {
return -1;
}
}
return buf[curChar++];
}
public final int readInt() throws IOException {
return (int)readLong();
}
public final long readLong() throws IOException {
int c = read();
while (isSpaceChar(c)) {
c = read();
if (c == -1) throw new IOException();
}
boolean negative = false;
if (c == '-') {
negative = true;
c = read();
}
long res = 0;
do {
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return negative ? -res : res;
}
public final int[] readIntArray(int size) throws IOException {
int[] array = new int[size];
for (int i=0; i<size; i++) {
array[i] = readInt();
}
return array;
}
public final long[] readLongArray(int size) throws IOException {
long[] array = new long[size];
for (int i=0; i<size; i++) {
array[i] = readLong();
}
return array;
}
private boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Superman Celebrates Diwali
You are viewing a single comment's thread. Return to all comments →
import java.io.IOException; import java.io.InputStream;
public class Solution {
int[][] people = new int[N][H]; for (int n=0; n
} int[][] save = new int[N][H]; int[] max = new int[H]; for (int n=0; n
} for (int h=1; h= I) { value = Math.max(value, max[h-I]);
} value += people[n][h]; maxPeople = Math.max(maxPeople, value); save[n][h] = value; } max[h] = maxPeople;
} int answer = 0; for (int n=0; n
}