# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335757 | Agnimandur | Labels (NOI20_labels) | Java | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import java.util.*;
import java.io.DataInputStream;
import java.io.IOException;
public class Labels {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public int ni() throws IOException {
int ret = 0;
boolean flip = false;
byte c = read();
while (c < '0' || c > '9') {
if (c == '-') flip = true;
c = read();
}
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
return flip ? -ret : ret;
}
public long nl() throws IOException {
long ret = 0;
boolean flip = false;
byte c = read();
while (c < '0' || c > '9') {
if (c == '-') flip = true;
c = read();
}
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
return flip ? -ret : ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1) {
buffer[0] = -1;
}
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead) {
fillBuffer();
}
return buffer[bufferPointer++];
}
}
public static void main(String[] args) throws IOException {
Reader sc = new Reader();
PrintStream out = new PrintStream(new BufferedOutputStream(System.out));
int N = sc.ni(); // read an integer
int[] arr = new int[N];
int min = 0;
int max = 0;
for (int i = 1; i < N; i++) {
arr[i] = arr[i-1]+sc.ni();
min = Math.min(arr[i],min);
max = Math.max(arr[i],max);
}
if (max-min == N-1) {
int add = 1-min;
for (int i = 0; i < N; i++) {
out.print((arr[i]+add) + " ");
}
} else {
out.print("-1");
}
out.flush(); // remember to flush just once, at the very end of your program
}
}