Submission #41161


ソースコード

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] $){
System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
var s=new FastScanner(System.in);
var q=new ArrayDeque<Integer>();
String v;
while(!(v=s.next()).equals("exit")) {
switch(v){
case "push":
q.add(s.nextInt());
break;
case "pop":
q.poll();
break;
case "front":
System.out.println(q.peek());
break;
}
}
System.out.flush();
}
}
class FastScanner{
private final BufferedInputStream in;
private static final int bufSize =1<<16;
private final byte buf[] =new byte[bufSize];
private int i =bufSize,k=bufSize;
private final StringBuilder str =new StringBuilder();
FastScanner(InputStream in){
this.in=new BufferedInputStream(in,bufSize);
}
int nextInt(){
return (int)nextLong();
}
long nextLong(){
int c;
long x=0;
boolean sign=true;
while((c=nextChar())<=32)
;
if(c=='-'){
sign=false;
c=nextChar();
}
if(c=='+'){
c=nextChar();
}
while(c>='0'){
x=x*10+(c-'0');
c=nextChar();
}
return sign?x:-x;
}
private int nextChar(){
if(i==k){
try{
k=in.read(buf,i=0,bufSize);
}catch(IOException e){
System.exit(-1);
}
}
return i>=k?-1:buf[i++];
}
String next(){
int c;
str.setLength(0);
while((c=nextChar())<=32&&c!=-1)
;
if(c==-1)
return null;
while(c>32){
str.append((char)c);
c=nextChar();
}
return str.toString();
}
String nextLine(){
int c;
str.setLength(0);
while((c=nextChar())<=32&&c!=-1)
;
if(c==-1)
return null;
while(c!='\n'){
str.append((char)c);
c=nextChar();
}
return str.toString();
}
}

ステータス

項目 データ
問題 0601 - プログラミング入門:Queue
ユーザー名 fal_rnd
投稿日時 2018-08-10 19:41:38
言語 Java
状態 Accepted
得点 1
ソースコード長 1802 Byte
最大実行時間 319 ms
最大メモリ使用量 30924 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
Input01 AC 95 ms 14440 KB
1
Input02 AC 93 ms 13056 KB
1
Input03 AC 102 ms 12916 KB
1
Input04 AC 94 ms 13392 KB
1
Input05 AC 104 ms 13504 KB
1
Input06 AC 112 ms 17100 KB
1
Input07 AC 122 ms 16856 KB
1
Input08 AC 165 ms 19892 KB
1
Input09 AC 257 ms 24304 KB
1
Input10 AC 319 ms 30924 KB
1