Submission #15544


ソースコード

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
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);
while(true){
switch(s.next()){
case "push":
deque.add(Integer.parseInt(s.next()));
break;
case "top":
System.out.println(deque.peekLast());
break;
case "pop":
deque.pollLast();
break;
case "exit":
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:31:47
言語 Java
状態 Accepted
得点 1
ソースコード長 902 Byte
最大実行時間 1358 ms
最大メモリ使用量 108148 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 66 ms 17964 KB
1
Input02 AC 75 ms 18336 KB
1
Input03 AC 83 ms 18664 KB
1
Input04 AC 77 ms 21172 KB
1
Input05 AC 90 ms 23804 KB
1
Input06 AC 144 ms 36820 KB
1
Input07 AC 212 ms 49000 KB
1
Input08 AC 501 ms 81868 KB
1
Input09 AC 924 ms 104036 KB
1
Input10 AC 1358 ms 108148 KB
1