Task: | Urkupillit |
Sender: | Kuha |
Submission time: | 2015-01-29 12:38:33 +0200 |
Language: | Java |
Status: | READY |
Result: | 12 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | RUNTIME ERROR | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1 | details |
#2 | ACCEPTED | 0.04 s | 1 | details |
#3 | ACCEPTED | 0.04 s | 1 | details |
#4 | ACCEPTED | 0.03 s | 1 | details |
#5 | ACCEPTED | 0.04 s | 1 | details |
#6 | ACCEPTED | 0.04 s | 2 | details |
#7 | ACCEPTED | 0.06 s | 2 | details |
#8 | RUNTIME ERROR | 0.04 s | 2 | details |
#9 | RUNTIME ERROR | 0.06 s | 2 | details |
#10 | RUNTIME ERROR | 0.05 s | 2 | details |
#11 | TIME LIMIT EXCEEDED | -- | 3 | details |
#12 | RUNTIME ERROR | 0.03 s | 3 | details |
#13 | RUNTIME ERROR | 0.03 s | 3 | details |
#14 | RUNTIME ERROR | 0.02 s | 3 | details |
#15 | RUNTIME ERROR | 0.04 s | 3 | details |
Code
import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(); int k = io.nextInt(); int[] urut = new int[n]; int i = 0; int val = 1; while (i != k) { urut[Math.min(n - val, k - i)] = val; i += Math.min(n - val, k + i); val++; } int index = 0; while (val <= n) { if (urut[index] == 0) { urut[index] = val; val++; } index++; } io.println(arr(urut)); io.close(); } private static String arr (int[] a) { String str = ""; for (int n : a) { str += n + " "; } return str; } } class IO extends PrintWriter { private InputStreamReader r; private static final int BUFSIZE = 1 << 15; private char[] buf; private int bufc; private int bufi; private StringBuilder sb; public IO() { super(new BufferedOutputStream(System.out)); r = new InputStreamReader(System.in); buf = new char[BUFSIZE]; bufc = 0; bufi = 0; sb = new StringBuilder(); } private void fillBuf() throws IOException { bufi = 0; bufc = 0; while(bufc == 0) { bufc = r.read(buf, 0, BUFSIZE); if(bufc == -1) { bufc = 0; return; } } } private boolean pumpBuf() throws IOException { if(bufi == bufc) { fillBuf(); } return bufc != 0; } private boolean isDelimiter(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f'; } private void eatDelimiters() throws IOException { while(true) { if(bufi == bufc) { fillBuf(); if(bufc == 0) throw new RuntimeException("IO: Out of input."); } if(!isDelimiter(buf[bufi])) break; ++bufi; } } public String next() { try { sb.setLength(0); eatDelimiters(); int start = bufi; while(true) { if(bufi == bufc) { sb.append(buf, start, bufi - start); fillBuf(); start = 0; if(bufc == 0) break; } if(isDelimiter(buf[bufi])) break; ++bufi; } sb.append(buf, start, bufi - start); return sb.toString(); } catch(IOException e) { throw new RuntimeException("IO.next: Caught IOException."); } } public int nextInt() { try { int ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextInt: Invalid int."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextInt: Invalid int."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -214748364) throw new RuntimeException("IO.nextInt: Invalid int."); ret *= 10; ret -= (int)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextInt: Invalid int."); } else { throw new RuntimeException("IO.nextInt: Invalid int."); } ++bufi; } if(positive) { if(ret == -2147483648) throw new RuntimeException("IO.nextInt: Invalid int."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextInt: Caught IOException."); } } public long nextLong() { try { long ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextLong: Invalid long."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextLong: Invalid long."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -922337203685477580L) throw new RuntimeException("IO.nextLong: Invalid long."); ret *= 10; ret -= (long)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextLong: Invalid long."); } else { throw new RuntimeException("IO.nextLong: Invalid long."); } ++bufi; } if(positive) { if(ret == -9223372036854775808L) throw new RuntimeException("IO.nextLong: Invalid long."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextLong: Caught IOException."); } } public double nextDouble() { return Double.parseDouble(next()); } }
Test details
Test 1
Group: 1
Verdict: ACCEPTED
input |
---|
5 0 |
correct output |
---|
1 2 3 4 5 |
user output |
---|
1 2 3 4 5 |
Test 2
Group: 1
Verdict: ACCEPTED
input |
---|
5 10 |
correct output |
---|
5 4 3 2 1 |
user output |
---|
5 4 3 2 1 |
Test 3
Group: 1
Verdict: ACCEPTED
input |
---|
5 3 |
correct output |
---|
4 1 2 3 5 |
user output |
---|
2 3 4 1 5 |
Test 4
Group: 1
Verdict: ACCEPTED
input |
---|
5 1 |
correct output |
---|
2 1 3 4 5 |
user output |
---|
2 1 3 4 5 |
Test 5
Group: 1
Verdict: ACCEPTED
input |
---|
5 2 |
correct output |
---|
3 1 2 4 5 |
user output |
---|
2 3 1 4 5 |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
100 0 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
100 4950 |
correct output |
---|
100 99 98 97 96 95 94 93 92 91... |
user output |
---|
100 99 98 97 96 95 94 93 92 91... |
Test 8
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100 2279 |
correct output |
---|
100 99 98 97 96 95 94 93 92 91... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -43 at Main.main(Main.java:17)
Test 9
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100 2528 |
correct output |
---|
100 99 98 97 96 95 94 93 92 91... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -7 at Main.main(Main.java:17)
Test 10
Group: 2
Verdict: RUNTIME ERROR
input |
---|
100 4483 |
correct output |
---|
100 99 98 97 96 95 94 93 92 91... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2 at Main.main(Main.java:17)
Test 11
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
100000 0 |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
(empty) |
Test 12
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100000 4999950000 |
correct output |
---|
100000 99999 99998 99997 99996... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int. at IO.nextInt(Main.java:148) at Main.main(Main.java:10)
Test 13
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100000 2969035543 |
correct output |
---|
100000 99999 99998 99997 99996... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int. at IO.nextInt(Main.java:148) at Main.main(Main.java:10)
Test 14
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100000 2495939870 |
correct output |
---|
100000 99999 99998 99997 99996... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.RuntimeException: IO.nextInt: Invalid int. at IO.nextInt(Main.java:148) at Main.main(Main.java:10)
Test 15
Group: 3
Verdict: RUNTIME ERROR
input |
---|
100000 1279770330 |
correct output |
---|
100000 99999 99998 99997 99996... |
user output |
---|
(empty) |
Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1735544628 at Main.main(Main.java:17)