Submission #15543
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import java.util.Scanner; import java.util.function.LongSupplier; public class Main{ static final Scanner s= new Scanner(System.in); static final long [] fal_rnd( long [] ar,LongSupplier sp){ int l=-1,r=ar.length; while (l+1!=r) ar[Math.random()<0.5?++l:--r]=sp.getAsLong(); return ar; } public static void main(String[] __){ IDeque deque= new IDeque(1000000); StringBuilder sb = new StringBuilder(); while ( true ){ switch (s.next()){ case "push" : deque.add(Integer.parseInt(s.next())); break ; case "top" : sb.append(deque.peekLast()+ "\n" ); break ; case "pop" : deque.pollLast(); break ; case "exit" : System.out.print(sb.toString()); return ; } } } } class IDeque{ int array[],index=0; IDeque( int size) { array= new int [size]; } void add( int v) { array[index++]=v; } int peekLast() { return array[index-1]; } int pollLast() { return array[index--]; } } |
ステータス
項目 | データ |
---|---|
問題 | 0600 - プログラミング入門:Stack |
ユーザー名 | fal_rnd |
投稿日時 | 2017-04-26 15:30:47 |
言語 | Java |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 979 Byte |
最大実行時間 | 893 ms |
最大メモリ使用量 | 110324 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
Input01 | AC | 62 ms | 18732 KB |
1
|
Input02 | AC | 68 ms | 18872 KB |
1
|
Input03 | AC | 71 ms | 17800 KB |
1
|
Input04 | AC | 80 ms | 20212 KB |
1
|
Input05 | AC | 80 ms | 22556 KB |
1
|
Input06 | AC | 126 ms | 40672 KB |
1
|
Input07 | AC | 174 ms | 53140 KB |
1
|
Input08 | AC | 334 ms | 82988 KB |
1
|
Input09 | AC | 633 ms | 104276 KB |
1
|
Input10 | AC | 893 ms | 110324 KB |
1
|