node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
17,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
20,
41,
13,
20,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
42,
2,
40,
4,
18,
13,
40,
4,
18,
13,
30,
41,
13,
41,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
0,
13,
2,
13,
13,
0,
13,
4,
18,
13,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
0,
13,
2,
13,
13,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
180,
11
],
[
180,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
24,
29
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
32,
35
],
[
35,
36
],
[
35,
37
],
[
14,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
43,
44
],
[
43,
45
],
[
14,
46
],
[
46,
47
],
[
46,
48
],
[
14,
49
],
[
49,
50
],
[
49,
51
],
[
14,
52
],
[
52,
53
],
[
52,
54
],
[
14,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
56,
61
],
[
61,
62
],
[
61,
63
],
[
56,
64
],
[
64,
65
],
[
65,
66
],
[
56,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
71,
76
],
[
68,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
80,
82
],
[
68,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
14,
92
],
[
92,
93
],
[
92,
94
],
[
14,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
96,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
95,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
105,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
111,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
116,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
116,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
116,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
116,
141
],
[
141,
142
],
[
142,
143
],
[
141,
144
],
[
110,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
146,
150
],
[
145,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
151,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
159,
161
],
[
151,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
151,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
173,
173
],
[
173,
174
],
[
173,
175
],
[
173,
176
],
[
12,
177
],
[
177,
178
],
[
0,
179
],
[
179,
180
],
[
179,
181
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tString[] nAndQuantum = new String[2];\n\t\tnAndQuantum = input.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(nAndQuantum[0]);\n\t\tint quantum = Integer.parseInt(nAndQuantum[1]);\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tString[] nameAndTime = new String[2];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}\n\t\tint totalTime = 0;\n\t\twhile(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tString[] nAndQuantum = new String[2];\n\t\tnAndQuantum = input.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(nAndQuantum[0]);\n\t\tint quantum = Integer.parseInt(nAndQuantum[1]);\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tString[] nameAndTime = new String[2];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}\n\t\tint totalTime = 0;\n\t\twhile(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tString[] nAndQuantum = new String[2];\n\t\tnAndQuantum = input.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(nAndQuantum[0]);\n\t\tint quantum = Integer.parseInt(nAndQuantum[1]);\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tString[] nameAndTime = new String[2];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}\n\t\tint totalTime = 0;\n\t\twhile(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner input = new Scanner(System.in);\n\t\tString[] nAndQuantum = new String[2];\n\t\tnAndQuantum = input.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(nAndQuantum[0]);\n\t\tint quantum = Integer.parseInt(nAndQuantum[1]);\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tString[] nameAndTime = new String[2];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}\n\t\tint totalTime = 0;\n\t\twhile(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}",
"Scanner input = new Scanner(System.in);",
"input",
"new Scanner(System.in)",
"String[] nAndQuantum = new String[2];",
"nAndQuantum",
"new String[2]",
"2",
"nAndQuantum = input.nextLine().split(\" \")",
"nAndQuantum",
"input.nextLine().split(\" \")",
"input.nextLine().split",
"input.nextLine()",
"input.nextLine",
"input",
"\" \"",
"int n = Integer.parseInt(nAndQuantum[0]);",
"n",
"Integer.parseInt(nAndQuantum[0])",
"Integer.parseInt",
"Integer",
"nAndQuantum[0]",
"nAndQuantum",
"0",
"int quantum = Integer.parseInt(nAndQuantum[1]);",
"quantum",
"Integer.parseInt(nAndQuantum[1])",
"Integer.parseInt",
"Integer",
"nAndQuantum[1]",
"nAndQuantum",
"1",
"Queue<Integer> times = new LinkedList<Integer>();",
"times",
"new LinkedList<Integer>()",
"Queue<String> names = new LinkedList<String>();",
"names",
"new LinkedList<String>()",
"String[] nameAndTime = new String[2];",
"nameAndTime",
"new String[2]",
"2",
"for(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}",
"{\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}",
"nameAndTime = input.nextLine().split(\" \")",
"nameAndTime",
"input.nextLine().split(\" \")",
"input.nextLine().split",
"input.nextLine()",
"input.nextLine",
"input",
"\" \"",
"names.add(nameAndTime[0])",
"names.add",
"names",
"nameAndTime[0]",
"nameAndTime",
"0",
"times.add(Integer.parseInt(nameAndTime[1]))",
"times.add",
"times",
"Integer.parseInt(nameAndTime[1])",
"Integer.parseInt",
"Integer",
"nameAndTime[1]",
"nameAndTime",
"1",
"int totalTime = 0;",
"totalTime",
"0",
"while(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}",
"!times.isEmpty() && !names.isEmpty()",
"!times.isEmpty()",
"times.isEmpty()",
"times.isEmpty",
"times",
"!names.isEmpty()",
"names.isEmpty()",
"names.isEmpty",
"names",
"{\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}",
"String name;",
"name",
"int time;",
"time",
"if(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}",
"times.peek() > quantum",
"times.peek()",
"times.peek",
"times",
"quantum",
"{\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}",
"time = times.poll()",
"time",
"times.poll()",
"times.poll",
"times",
"totalTime = totalTime + quantum",
"totalTime",
"totalTime + quantum",
"totalTime",
"quantum",
"name = names.poll()",
"name",
"names.poll()",
"names.poll",
"names",
"time = time - quantum",
"time",
"time - quantum",
"time",
"quantum",
"times.add(time)",
"times.add",
"times",
"time",
"names.add(name)",
"names.add",
"names",
"name",
"if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}",
"times.peek() <= quantum",
"times.peek()",
"times.peek",
"times",
"quantum",
"{\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}",
"time = times.poll()",
"time",
"times.poll()",
"times.poll",
"times",
"totalTime = totalTime + time",
"totalTime",
"totalTime + time",
"totalTime",
"time",
"name = names.poll()",
"name",
"names.poll()",
"names.poll",
"names",
"System.out.println(name + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + totalTime",
"name + \" \" + totalTime",
"name",
"\" \"",
"totalTime",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tString[] nAndQuantum = new String[2];\n\t\tnAndQuantum = input.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(nAndQuantum[0]);\n\t\tint quantum = Integer.parseInt(nAndQuantum[1]);\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tString[] nameAndTime = new String[2];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}\n\t\tint totalTime = 0;\n\t\twhile(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tString[] nAndQuantum = new String[2];\n\t\tnAndQuantum = input.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(nAndQuantum[0]);\n\t\tint quantum = Integer.parseInt(nAndQuantum[1]);\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tString[] nameAndTime = new String[2];\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tnameAndTime = input.nextLine().split(\" \");\n\t\t\tnames.add(nameAndTime[0]);\n\t\t\ttimes.add(Integer.parseInt(nameAndTime[1]));\n\t\t\t\n\t\t}\n\t\tint totalTime = 0;\n\t\twhile(!times.isEmpty() && !names.isEmpty()) {\n\t\t\tString name;\n\t\t\tint time;\n\t\t\tif(times.peek() > quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + quantum;\n\t\t\t\tname = names.poll();\n\t\t\t\ttime = time - quantum;\n\t\t\t\ttimes.add(time);\n\t\t\t\tnames.add(name);\n\t\t\t\t\n\t\t\t}\n\t\t\telse if(times.peek() <= quantum) {\n\t\t\t\ttime = times.poll();\n\t\t\t\ttotalTime = totalTime + time;\n\t\t\t\tname = names.poll();\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t\t\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String[] nAndQuantum = new String[2];
nAndQuantum = input.nextLine().split(" ");
int n = Integer.parseInt(nAndQuantum[0]);
int quantum = Integer.parseInt(nAndQuantum[1]);
Queue<Integer> times = new LinkedList<Integer>();
Queue<String> names = new LinkedList<String>();
String[] nameAndTime = new String[2];
for(int i = 0; i < n; i++) {
nameAndTime = input.nextLine().split(" ");
names.add(nameAndTime[0]);
times.add(Integer.parseInt(nameAndTime[1]));
}
int totalTime = 0;
while(!times.isEmpty() && !names.isEmpty()) {
String name;
int time;
if(times.peek() > quantum) {
time = times.poll();
totalTime = totalTime + quantum;
name = names.poll();
time = time - quantum;
times.add(time);
names.add(name);
}
else if(times.peek() <= quantum) {
time = times.poll();
totalTime = totalTime + time;
name = names.poll();
System.out.println(name + " " + totalTime);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
17,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
17,
0,
13,
17,
12,
13,
30,
29,
13,
12,
13,
30,
29,
2,
13,
17,
12,
13,
30,
41,
13,
20,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
0,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
40,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
29,
17,
41,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
13,
17,
30,
0,
13,
17,
40,
13,
29,
13,
12,
13,
30,
41,
13,
20,
4,
18,
13,
17,
41,
13,
13,
42,
2,
13,
17,
30,
4,
18,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
13,
17,
30,
4,
18,
13,
17,
4,
18,
13,
17,
14,
2,
13,
17,
30,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
29,
4,
18,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
314,
5
],
[
314,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
8,
52
],
[
52,
53
],
[
53,
54
],
[
8,
55
],
[
55,
56
],
[
55,
57
],
[
8,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
58,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
63,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
75,
85
],
[
85,
86
],
[
85,
87
],
[
75,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
69,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
104,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
104,
109
],
[
6,
110
],
[
110,
111
],
[
314,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
112,
116
],
[
116,
117
],
[
112,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
120,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
118,
131
],
[
131,
132
],
[
314,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
133,
137
],
[
137,
138
],
[
133,
139
],
[
139,
140
],
[
133,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
143,
150
],
[
150,
151
],
[
150,
152
],
[
133,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
133,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
133,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
176,
178
],
[
171,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
182,
184
],
[
171,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
185,
191
],
[
191,
192
],
[
191,
193
],
[
167,
194
],
[
194,
195
],
[
165,
196
],
[
196,
197
],
[
133,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
201,
202
],
[
202,
203
],
[
201,
204
],
[
204,
205
],
[
205,
206
],
[
200,
207
],
[
207,
208
],
[
207,
209
],
[
209,
210
],
[
209,
211
],
[
200,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
214,
216
],
[
200,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
217,
221
],
[
221,
222
],
[
222,
223
],
[
222,
224
],
[
200,
225
],
[
225,
226
],
[
200,
227
],
[
227,
228
],
[
133,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
231,
235
],
[
235,
236
],
[
236,
237
],
[
235,
238
],
[
231,
239
],
[
239,
240
],
[
239,
241
],
[
231,
242
],
[
242,
243
],
[
243,
244
],
[
243,
245
],
[
242,
246
],
[
246,
247
],
[
247,
248
],
[
248,
249
],
[
247,
250
],
[
250,
251
],
[
250,
252
],
[
246,
253
],
[
253,
254
],
[
253,
255
],
[
255,
256
],
[
255,
257
],
[
246,
258
],
[
258,
259
],
[
259,
260
],
[
259,
261
],
[
258,
262
],
[
262,
263
],
[
263,
264
],
[
264,
265
],
[
263,
266
],
[
231,
267
],
[
267,
268
],
[
268,
269
],
[
267,
270
],
[
231,
271
],
[
271,
272
],
[
272,
273
],
[
272,
274
],
[
271,
275
],
[
275,
276
],
[
276,
277
],
[
277,
278
],
[
276,
279
],
[
279,
280
],
[
279,
281
],
[
231,
282
],
[
282,
283
],
[
283,
284
],
[
282,
285
],
[
231,
286
],
[
286,
287
],
[
287,
288
],
[
288,
289
],
[
314,
290
],
[
290,
291
],
[
290,
292
],
[
292,
293
],
[
290,
294
],
[
294,
295
],
[
290,
296
],
[
296,
297
],
[
296,
298
],
[
298,
299
],
[
299,
300
],
[
300,
301
],
[
300,
302
],
[
299,
303
],
[
298,
304
],
[
304,
305
],
[
305,
306
],
[
305,
307
],
[
304,
308
],
[
296,
309
],
[
309,
310
],
[
296,
311
],
[
311,
312
],
[
0,
313
],
[
313,
314
],
[
313,
315
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tstatic class Node<E> {\n\t\tpublic E value;\n\t\tpublic Node<E> next;\t\t\n\t\tpublic Node(E value) {\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}\n\t}\n\n\tstatic class SimpleQueue<E> {\n\t\t\n\t\tprivate Node<E> head;\n\t\tprivate Node<E> tail;\n\t\tint size;\n\t\t\n\t\tpublic SimpleQueue() {\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}\n\t\t\n\t\tpublic int getSize() {\n\t\t\treturn size;\n\t\t}\n\t\t\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\t\t\n\t\tpublic void enqueue(E element) {\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}\n\t\t\n\t\tpublic E dequeue() {\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}\n\t\t\n\t\tpublic String toString() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}\t\t\n\t}\n\t\n\tstatic class Process {\t\t\n\t\tpublic String name;\n\t\tpublic int time;\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tSimpleQueue<Process> queue = new SimpleQueue<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}\n\t\tsc.close();\n\n\t\tint total = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}\n\t}\n}\n\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tstatic class Node<E> {\n\t\tpublic E value;\n\t\tpublic Node<E> next;\t\t\n\t\tpublic Node(E value) {\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}\n\t}\n\n\tstatic class SimpleQueue<E> {\n\t\t\n\t\tprivate Node<E> head;\n\t\tprivate Node<E> tail;\n\t\tint size;\n\t\t\n\t\tpublic SimpleQueue() {\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}\n\t\t\n\t\tpublic int getSize() {\n\t\t\treturn size;\n\t\t}\n\t\t\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\t\t\n\t\tpublic void enqueue(E element) {\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}\n\t\t\n\t\tpublic E dequeue() {\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}\n\t\t\n\t\tpublic String toString() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}\t\t\n\t}\n\t\n\tstatic class Process {\t\t\n\t\tpublic String name;\n\t\tpublic int time;\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tSimpleQueue<Process> queue = new SimpleQueue<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}\n\t\tsc.close();\n\n\t\tint total = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tSimpleQueue<Process> queue = new SimpleQueue<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}\n\t\tsc.close();\n\n\t\tint total = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}\n\t}",
"main",
"{\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tSimpleQueue<Process> queue = new SimpleQueue<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}\n\t\tsc.close();\n\n\t\tint total = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"SimpleQueue<Process> queue = new SimpleQueue<Process>();",
"queue",
"new SimpleQueue<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"queue.enqueue(new Process(name, time))",
"queue.enqueue",
"queue",
"new Process(name, time)",
"sc.close()",
"sc.close",
"sc",
"int total = 0;",
"total",
"0",
"while (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}",
"Process process = queue.dequeue();",
"process",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}",
"process.time > q",
"process.time",
"process",
"process.time",
"q",
"{\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}",
"process.time = process.time - q",
"process.time",
"process",
"process.time",
"process.time - q",
"process.time",
"process",
"process.time",
"q",
"total += q",
"total",
"q",
"queue.enqueue(process)",
"queue.enqueue",
"queue",
"process",
"{\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}",
"total += process.time",
"total",
"process.time",
"process",
"process.time",
"System.out.println(process.name + \" \" + total)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + total",
"process.name + \" \" + total",
"process.name",
"process",
"process.name",
"\" \"",
"total",
"String[] args",
"args",
"static class Node<E> {\n\t\tpublic E value;\n\t\tpublic Node<E> next;\t\t\n\t\tpublic Node(E value) {\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}\n\t}",
"Node",
"public E value;",
"value",
"public Node<E> next;",
"next",
"public Node(E value) {\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}",
"Node",
"{\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}",
"this.value = value",
"this.value",
"this",
"this.value",
"value",
"this.next = null",
"this.next",
"this",
"this.next",
"null",
"E value",
"value",
"static class SimpleQueue<E> {\n\t\t\n\t\tprivate Node<E> head;\n\t\tprivate Node<E> tail;\n\t\tint size;\n\t\t\n\t\tpublic SimpleQueue() {\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}\n\t\t\n\t\tpublic int getSize() {\n\t\t\treturn size;\n\t\t}\n\t\t\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\t\t\n\t\tpublic void enqueue(E element) {\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}\n\t\t\n\t\tpublic E dequeue() {\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}\n\t\t\n\t\tpublic String toString() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}\t\t\n\t}",
"SimpleQueue",
"private Node<E> head;",
"head",
"private Node<E> tail;",
"tail",
"int size;",
"size",
"public SimpleQueue() {\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}",
"SimpleQueue",
"{\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}",
"size = 0",
"size",
"0",
"head = null",
"head",
"null",
"tail = null",
"tail",
"null",
"public int getSize() {\n\t\t\treturn size;\n\t\t}",
"getSize",
"{\n\t\t\treturn size;\n\t\t}",
"return size;",
"size",
"public boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}",
"isEmpty",
"{\n\t\t\treturn size == 0;\n\t\t}",
"return size == 0;",
"size == 0",
"size",
"0",
"public void enqueue(E element) {\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}",
"enqueue",
"{\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}",
"Node<E> node = new Node<E>(element);",
"node",
"new Node<E>(element)",
"if (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}",
"head == null && tail == null",
"head == null",
"head",
"null",
"tail == null",
"tail",
"null",
"{\n\t\t\t\thead = tail = node;\n\t\t\t}",
"head = tail = node",
"head",
"tail = node",
"tail",
"node",
"{\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}",
"tail.next = node",
"tail.next",
"tail",
"tail.next",
"node",
"tail = node",
"tail",
"node",
"size++",
"size",
"E element",
"element",
"public E dequeue() {\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}",
"dequeue",
"{\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}",
"if (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}",
"isEmpty()",
"isEmpty",
"{\n\t\t\t\treturn null;\n\t\t\t}",
"return null;",
"null",
"E element = head.value;",
"element",
"head.value",
"head",
"head.value",
"head = head.next",
"head",
"head.next",
"head",
"head.next",
"if (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}",
"head == null",
"head",
"null",
"{\n\t\t\t\ttail = null;\n\t\t\t}",
"tail = null",
"tail",
"null",
"size--",
"size",
"return element;",
"element",
"public String toString() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}",
"toString",
"{\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"sb.append(\"[\")",
"sb.append",
"sb",
"\"[\"",
"Node<E> current = head;",
"current",
"head",
"while (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}",
"current != null",
"current",
"null",
"{\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}",
"sb.append(current.value)",
"sb.append",
"sb",
"current.value",
"current",
"current.value",
"current = current.next",
"current",
"current.next",
"current",
"current.next",
"if (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}",
"current != null",
"current",
"null",
"{\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}",
"sb.append(\", \")",
"sb.append",
"sb",
"\", \"",
"sb.append(\"](\")",
"sb.append",
"sb",
"\"](\"",
"if (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}",
"tail != null",
"tail",
"null",
"{\n\t\t\t\tsb.append(tail.value);\n\t\t\t}",
"sb.append(tail.value)",
"sb.append",
"sb",
"tail.value",
"tail",
"tail.value",
"sb.append(\")\")",
"sb.append",
"sb",
"\")\"",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"static class Process {\t\t\n\t\tpublic String name;\n\t\tpublic int time;\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\t\t\n\t}",
"Process",
"public String name;",
"name",
"public int time;",
"time",
"public Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"Process",
"{\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n\tstatic class Node<E> {\n\t\tpublic E value;\n\t\tpublic Node<E> next;\t\t\n\t\tpublic Node(E value) {\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}\n\t}\n\n\tstatic class SimpleQueue<E> {\n\t\t\n\t\tprivate Node<E> head;\n\t\tprivate Node<E> tail;\n\t\tint size;\n\t\t\n\t\tpublic SimpleQueue() {\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}\n\t\t\n\t\tpublic int getSize() {\n\t\t\treturn size;\n\t\t}\n\t\t\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\t\t\n\t\tpublic void enqueue(E element) {\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}\n\t\t\n\t\tpublic E dequeue() {\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}\n\t\t\n\t\tpublic String toString() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}\t\t\n\t}\n\t\n\tstatic class Process {\t\t\n\t\tpublic String name;\n\t\tpublic int time;\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tSimpleQueue<Process> queue = new SimpleQueue<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}\n\t\tsc.close();\n\n\t\tint total = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}\n\t}\n}",
"public class Main {\n\n\tstatic class Node<E> {\n\t\tpublic E value;\n\t\tpublic Node<E> next;\t\t\n\t\tpublic Node(E value) {\n\t\t\tthis.value = value;\n\t\t\tthis.next = null;\n\t\t}\n\t}\n\n\tstatic class SimpleQueue<E> {\n\t\t\n\t\tprivate Node<E> head;\n\t\tprivate Node<E> tail;\n\t\tint size;\n\t\t\n\t\tpublic SimpleQueue() {\n\t\t\tsize = 0;\n\t\t\thead = null;\n\t\t\ttail = null;\n\t\t}\n\t\t\n\t\tpublic int getSize() {\n\t\t\treturn size;\n\t\t}\n\t\t\n\t\tpublic boolean isEmpty() {\n\t\t\treturn size == 0;\n\t\t}\n\t\t\n\t\tpublic void enqueue(E element) {\n\t\t\tNode<E> node = new Node<E>(element);\n\t\t\tif (head == null && tail == null) {\n\t\t\t\thead = tail = node;\n\t\t\t} else {\n\t\t\t\ttail.next = node;\n\t\t\t\ttail = node;\n\t\t\t}\n\t\t\tsize++;\n\t\t}\n\t\t\n\t\tpublic E dequeue() {\t\t\t\n\t\t\tif (isEmpty()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tE element = head.value;\n\t\t\thead = head.next;\n\t\t\tif (head == null) {\n\t\t\t\ttail = null;\n\t\t\t}\n\t\t\tsize--;\n\t\t\treturn element;\t\t\t\n\t\t}\n\t\t\n\t\tpublic String toString() {\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tsb.append(\"[\");\n\t\t\tNode<E> current = head;\n\t\t\twhile (current != null) {\n\t\t\t\tsb.append(current.value);\n\t\t\t\tcurrent = current.next;\n\t\t\t\tif (current != null) {\n\t\t\t\t\tsb.append(\", \");\n\t\t\t\t}\n\t\t\t}\t\t\t\n\t\t\tsb.append(\"](\");\n\t\t\tif (tail != null) {\n\t\t\t\tsb.append(tail.value);\n\t\t\t}\n\t\t\tsb.append(\")\");\n\t\t\treturn sb.toString();\n\t\t}\t\t\n\t}\n\t\n\tstatic class Process {\t\t\n\t\tpublic String name;\n\t\tpublic int time;\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\t\t\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tSimpleQueue<Process> queue = new SimpleQueue<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tqueue.enqueue(new Process(name, time));\n\t\t}\n\t\tsc.close();\n\n\t\tint total = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\t\n\t\t\tProcess process = queue.dequeue();\n\t\t\tif (process.time > q) {\n\t\t\t\tprocess.time = process.time - q;\n\t\t\t\ttotal += q;\n\t\t\t\tqueue.enqueue(process);\n\t\t\t} else {\n\t\t\t\ttotal += process.time;\n\t\t\t\tSystem.out.println(process.name + \" \" + total);\n\t\t\t}\t\t\t\n\t\t}\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static class Node<E> {
public E value;
public Node<E> next;
public Node(E value) {
this.value = value;
this.next = null;
}
}
static class SimpleQueue<E> {
private Node<E> head;
private Node<E> tail;
int size;
public SimpleQueue() {
size = 0;
head = null;
tail = null;
}
public int getSize() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
public void enqueue(E element) {
Node<E> node = new Node<E>(element);
if (head == null && tail == null) {
head = tail = node;
} else {
tail.next = node;
tail = node;
}
size++;
}
public E dequeue() {
if (isEmpty()) {
return null;
}
E element = head.value;
head = head.next;
if (head == null) {
tail = null;
}
size--;
return element;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[");
Node<E> current = head;
while (current != null) {
sb.append(current.value);
current = current.next;
if (current != null) {
sb.append(", ");
}
}
sb.append("](");
if (tail != null) {
sb.append(tail.value);
}
sb.append(")");
return sb.toString();
}
}
static class Process {
public String name;
public int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
SimpleQueue<Process> queue = new SimpleQueue<Process>();
for (int i = 0; i < n; i++) {
String name = sc.next();
int time = sc.nextInt();
queue.enqueue(new Process(name, time));
}
sc.close();
int total = 0;
while (!queue.isEmpty()) {
Process process = queue.dequeue();
if (process.time > q) {
process.time = process.time - q;
total += q;
queue.enqueue(process);
} else {
total += process.time;
System.out.println(process.name + " " + total);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
42,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
30,
31
],
[
30,
32
],
[
26,
33
],
[
33,
34
],
[
33,
35
],
[
26,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
38,
43
],
[
26,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
49,
51
],
[
26,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
57,
58
],
[
57,
59
],
[
26,
60
],
[
60,
61
],
[
60,
62
],
[
26,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
68,
69
],
[
68,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
63,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
78,
83
],
[
75,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
75,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
94,
96
],
[
75,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
101,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
101,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
97,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
26,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
125,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
136,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
144,
145
],
[
140,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
147,
151
],
[
146,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
152,
158
],
[
158,
159
],
[
159,
160
],
[
158,
161
],
[
161,
162
],
[
162,
163
],
[
152,
164
],
[
164,
165
],
[
165,
166
],
[
164,
167
],
[
152,
168
],
[
168,
169
],
[
169,
170
],
[
168,
171
],
[
152,
172
],
[
172,
173
],
[
173,
174
],
[
146,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
179,
180
],
[
180,
181
],
[
179,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
182,
186
],
[
26,
187
],
[
187,
188
],
[
188,
189
],
[
24,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
192,
196
],
[
196,
197
],
[
192,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
201,
205
],
[
200,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
206,
210
],
[
198,
211
],
[
211,
212
],
[
198,
213
],
[
213,
214
],
[
192,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
218,
219
],
[
192,
220
],
[
220,
221
],
[
220,
222
],
[
222,
223
],
[
223,
224
],
[
192,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
228,
232
],
[
225,
233
],
[
233,
234
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\nimport java.util.Iterator;\nimport java.util.LinkedList;\nimport java.util.List;\n\nclass Main{\n public static void main(String[] args) throws IOException{\n final PrintWriter out = new PrintWriter(System.out);\n final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n final List<process> pl = new LinkedList<process>();\n String[] in = br.readLine().split(\" \");\n final int n = Integer.parseInt(in[0]);\n final int q = Integer.parseInt(in[1]);\n int now = 0;\n for(int i = 0; i<n; i++){\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }\n while(!pl.isEmpty()){\n final Iterator<process> i = pl.iterator();\n while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }\n }\n out.flush();\n }\n}\n\nclass process{\n private final String name;\n private int time;\n process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public final String getName(){\n return name;\n }\n public final int getTime(){\n return time;\n }\n public final void setTime(int time){\n this.time = time;\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.Iterator;",
"Iterator",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"class Main{\n public static void main(String[] args) throws IOException{\n final PrintWriter out = new PrintWriter(System.out);\n final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n final List<process> pl = new LinkedList<process>();\n String[] in = br.readLine().split(\" \");\n final int n = Integer.parseInt(in[0]);\n final int q = Integer.parseInt(in[1]);\n int now = 0;\n for(int i = 0; i<n; i++){\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }\n while(!pl.isEmpty()){\n final Iterator<process> i = pl.iterator();\n while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }\n }\n out.flush();\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n final PrintWriter out = new PrintWriter(System.out);\n final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n final List<process> pl = new LinkedList<process>();\n String[] in = br.readLine().split(\" \");\n final int n = Integer.parseInt(in[0]);\n final int q = Integer.parseInt(in[1]);\n int now = 0;\n for(int i = 0; i<n; i++){\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }\n while(!pl.isEmpty()){\n final Iterator<process> i = pl.iterator();\n while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }\n }\n out.flush();\n }",
"main",
"{\n final PrintWriter out = new PrintWriter(System.out);\n final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n final List<process> pl = new LinkedList<process>();\n String[] in = br.readLine().split(\" \");\n final int n = Integer.parseInt(in[0]);\n final int q = Integer.parseInt(in[1]);\n int now = 0;\n for(int i = 0; i<n; i++){\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }\n while(!pl.isEmpty()){\n final Iterator<process> i = pl.iterator();\n while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }\n }\n out.flush();\n }",
"final PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"final List<process> pl = new LinkedList<process>();",
"pl",
"new LinkedList<process>()",
"String[] in = br.readLine().split(\" \");",
"in",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"final int n = Integer.parseInt(in[0]);",
"n",
"Integer.parseInt(in[0])",
"Integer.parseInt",
"Integer",
"in[0]",
"in",
"0",
"final int q = Integer.parseInt(in[1]);",
"q",
"Integer.parseInt(in[1])",
"Integer.parseInt",
"Integer",
"in[1]",
"in",
"1",
"int now = 0;",
"now",
"0",
"for(int i = 0; i<n; i++){\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }",
"{\n in = br.readLine().split(\" \");\n final String name = in[0];\n final int time = Integer.parseInt(in[1]);\n if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }\n }",
"in = br.readLine().split(\" \")",
"in",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"final String name = in[0];",
"name",
"in[0]",
"in",
"0",
"final int time = Integer.parseInt(in[1]);",
"time",
"Integer.parseInt(in[1])",
"Integer.parseInt",
"Integer",
"in[1]",
"in",
"1",
"if(time<=q){\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }else{\n now += q;\n pl.add(new process(name, time-q));\n }",
"time<=q",
"time",
"q",
"{\n now += time;\n out.print(name);\n out.print(' ');\n out.println(now);\n }",
"now += time",
"now",
"time",
"out.print(name)",
"out.print",
"out",
"name",
"out.print(' ')",
"out.print",
"out",
"' '",
"out.println(now)",
"out.println",
"out",
"now",
"{\n now += q;\n pl.add(new process(name, time-q));\n }",
"now += q",
"now",
"q",
"pl.add(new process(name, time-q))",
"pl.add",
"pl",
"new process(name, time-q)",
"while(!pl.isEmpty()){\n final Iterator<process> i = pl.iterator();\n while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }\n }",
"!pl.isEmpty()",
"pl.isEmpty()",
"pl.isEmpty",
"pl",
"{\n final Iterator<process> i = pl.iterator();\n while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }\n }",
"final Iterator<process> i = pl.iterator();",
"i",
"pl.iterator()",
"pl.iterator",
"pl",
"while(i.hasNext()){\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }",
"i.hasNext()",
"i.hasNext",
"i",
"{\n final process p = i.next();\n if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }\n }",
"final process p = i.next();",
"p",
"i.next()",
"i.next",
"i",
"if(p.getTime()<=q){\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }else{\n now += q;\n p.setTime(p.getTime()-q);\n }",
"p.getTime()<=q",
"p.getTime()",
"p.getTime",
"p",
"q",
"{\n now += p.getTime();\n out.print(p.getName());\n out.print(' ');\n out.println(now);\n i.remove();\n }",
"now += p.getTime()",
"now",
"p.getTime()",
"p.getTime",
"p",
"out.print(p.getName())",
"out.print",
"out",
"p.getName()",
"p.getName",
"p",
"out.print(' ')",
"out.print",
"out",
"' '",
"out.println(now)",
"out.println",
"out",
"now",
"i.remove()",
"i.remove",
"i",
"{\n now += q;\n p.setTime(p.getTime()-q);\n }",
"now += q",
"now",
"q",
"p.setTime(p.getTime()-q)",
"p.setTime",
"p",
"p.getTime()-q",
"p.getTime()",
"p.getTime",
"p",
"q",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"class process{\n private final String name;\n private int time;\n process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public final String getName(){\n return name;\n }\n public final int getTime(){\n return time;\n }\n public final void setTime(int time){\n this.time = time;\n }\n}",
"process",
"private final String name;",
"name",
"private int time;",
"time",
"process(String name, int time){\n this.name = name;\n this.time = time;\n }",
"process",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public final String getName(){\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public final int getTime(){\n return time;\n }",
"getTime",
"{\n return time;\n }",
"return time;",
"time",
"public final void setTime(int time){\n this.time = time;\n }",
"setTime",
"{\n this.time = time;\n }",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
class Main{
public static void main(String[] args) throws IOException{
final PrintWriter out = new PrintWriter(System.out);
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final List<process> pl = new LinkedList<process>();
String[] in = br.readLine().split(" ");
final int n = Integer.parseInt(in[0]);
final int q = Integer.parseInt(in[1]);
int now = 0;
for(int i = 0; i<n; i++){
in = br.readLine().split(" ");
final String name = in[0];
final int time = Integer.parseInt(in[1]);
if(time<=q){
now += time;
out.print(name);
out.print(' ');
out.println(now);
}else{
now += q;
pl.add(new process(name, time-q));
}
}
while(!pl.isEmpty()){
final Iterator<process> i = pl.iterator();
while(i.hasNext()){
final process p = i.next();
if(p.getTime()<=q){
now += p.getTime();
out.print(p.getName());
out.print(' ');
out.println(now);
i.remove();
}else{
now += q;
p.setTime(p.getTime()-q);
}
}
}
out.flush();
}
}
class process{
private final String name;
private int time;
process(String name, int time){
this.name = name;
this.time = time;
}
public final String getName(){
return name;
}
public final int getTime(){
return time;
}
public final void setTime(int time){
this.time = time;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
20,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
0,
18,
13,
13,
13,
0,
13,
13,
41,
13,
17,
42,
40,
2,
13,
13,
30,
41,
13,
4,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
13,
13,
0,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
12,
13,
30,
14,
2,
2,
2,
13,
17,
13,
13,
30,
4,
18,
18,
13,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
12,
13,
30,
41,
13,
17,
14,
2,
13,
13,
30,
4,
18,
18,
13,
13,
17,
30,
0,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
213,
5
],
[
213,
6
],
[
6,
7
],
[
6,
8
],
[
213,
9
],
[
9,
10
],
[
9,
11
],
[
213,
12
],
[
12,
13
],
[
12,
14
],
[
213,
15
],
[
15,
16
],
[
15,
17
],
[
213,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
21,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
21,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
35,
40
],
[
40,
41
],
[
40,
42
],
[
35,
43
],
[
43,
44
],
[
44,
45
],
[
35,
46
],
[
47,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
47,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
58,
59
],
[
58,
60
],
[
47,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
21,
66
],
[
66,
67
],
[
66,
68
],
[
21,
69
],
[
69,
70
],
[
69,
71
],
[
21,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
72,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
77,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
88,
98
],
[
98,
99
],
[
98,
100
],
[
88,
101
],
[
101,
102
],
[
101,
103
],
[
82,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
116,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
116,
121
],
[
19,
122
],
[
122,
123
],
[
213,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
128,
134
],
[
127,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
127,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
142,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
124,
155
],
[
155,
156
],
[
213,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
168,
173
],
[
163,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
177,
179
],
[
174,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
159,
187
],
[
187,
188
],
[
0,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
189,
193
],
[
193,
194
],
[
189,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
197,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
195,
208
],
[
208,
209
],
[
195,
210
],
[
210,
211
],
[
0,
212
],
[
212,
213
],
[
212,
214
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tprivate static int head = 0;// キューの先頭ポインタ\n\tprivate static int tail = 0;// キューの末尾ポイント\n\tprivate static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。\n\tprivate static Process[] queue = new Process[MAX];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t// すべてのプロセスをキューに追加\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}\n\t\ttail = n;\n\t\t// すべてのプロセスが完了する(=キューが空になる)まで実行\n\t\tint elaps = 0; // 経過時間\n\t\twhile (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tprivate static void enqueue(Process p) {\n\t\t// 中身が満タンでないことを判定\n\t\tif ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}\n\t}\n\n\tprivate static Process dequeue() {\n\t\t// 中身が空じゃないことを判定\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}\n\t\treturn ret;\n\n\t}\n\n}\n\nclass Process {\n\tString name;\n\tint time;\n\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tprivate static int head = 0;// キューの先頭ポインタ\n\tprivate static int tail = 0;// キューの末尾ポイント\n\tprivate static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。\n\tprivate static Process[] queue = new Process[MAX];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t// すべてのプロセスをキューに追加\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}\n\t\ttail = n;\n\t\t// すべてのプロセスが完了する(=キューが空になる)まで実行\n\t\tint elaps = 0; // 経過時間\n\t\twhile (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tprivate static void enqueue(Process p) {\n\t\t// 中身が満タンでないことを判定\n\t\tif ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}\n\t}\n\n\tprivate static Process dequeue() {\n\t\t// 中身が空じゃないことを判定\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}\n\t\treturn ret;\n\n\t}\n\n}",
"Main",
"private static int head = 0;// キューの先頭ポインタ",
"head",
"0",
"private static int tail = 0;// キューの末尾ポイント",
"tail",
"0",
"private static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。",
"MAX",
"100005",
"private static Process[] queue = new Process[MAX];",
"queue",
"new Process[MAX]",
"MAX",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t// すべてのプロセスをキューに追加\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}\n\t\ttail = n;\n\t\t// すべてのプロセスが完了する(=キューが空になる)まで実行\n\t\tint elaps = 0; // 経過時間\n\t\twhile (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t// すべてのプロセスをキューに追加\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}\n\t\ttail = n;\n\t\t// すべてのプロセスが完了する(=キューが空になる)まで実行\n\t\tint elaps = 0; // 経過時間\n\t\twhile (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Process p = new Process(name, time);",
"p",
"new Process(name, time)",
"queue[i] = p",
"queue[i]",
"queue",
"i",
"p",
"tail = n",
"tail",
"n",
"int elaps = 0;",
"elaps",
"0",
"while (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}",
"!(head == tail)",
"(head == tail)",
"head",
"tail",
"{\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}",
"Process p = dequeue();",
"p",
"dequeue()",
"dequeue",
"if (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t}",
"p.time = p.time - q",
"p.time",
"p",
"p.time",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"enqueue(p)",
"enqueue",
"p",
"elaps += q",
"elaps",
"q",
"{\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}",
"elaps += p.time",
"elaps",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + elaps)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + elaps",
"p.name + \" \" + elaps",
"p.name",
"p",
"p.name",
"\" \"",
"elaps",
"String[] args",
"args",
"private static void enqueue(Process p) {\n\t\t// 中身が満タンでないことを判定\n\t\tif ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}\n\t}",
"enqueue",
"{\n\t\t// 中身が満タンでないことを判定\n\t\tif ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}\n\t}",
"if ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}",
"(tail + 1) % MAX == head",
"(tail + 1) % MAX",
"(tail + 1)",
"tail",
"1",
"MAX",
"head",
"{\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t}",
"System.err.println(\"エラー(オーバーフロー)\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"エラー(オーバーフロー)\"",
"{\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}",
"queue[tail] = p",
"queue[tail]",
"queue",
"tail",
"p",
"tail = (tail + 1) % MAX",
"tail",
"(tail + 1) % MAX",
"(tail + 1)",
"tail",
"1",
"MAX",
"Process p",
"p",
"private static Process dequeue() {\n\t\t// 中身が空じゃないことを判定\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}\n\t\treturn ret;\n\n\t}",
"dequeue",
"{\n\t\t// 中身が空じゃないことを判定\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}\n\t\treturn ret;\n\n\t}",
"Process ret = null;",
"ret",
"null",
"if (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}",
"head == tail",
"head",
"tail",
"{\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t}",
"System.err.println(\"エラー(アンダーフロー)\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"エラー(アンダーフロー)\"",
"{\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}",
"ret = queue[head]",
"ret",
"queue[head]",
"queue",
"head",
"head = (head + 1) % MAX",
"head",
"(head + 1) % MAX",
"(head + 1)",
"head",
"1",
"MAX",
"return ret;",
"ret",
"class Process {\n\tString name;\n\tint time;\n\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\tprivate static int head = 0;// キューの先頭ポインタ\n\tprivate static int tail = 0;// キューの末尾ポイント\n\tprivate static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。\n\tprivate static Process[] queue = new Process[MAX];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t// すべてのプロセスをキューに追加\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}\n\t\ttail = n;\n\t\t// すべてのプロセスが完了する(=キューが空になる)まで実行\n\t\tint elaps = 0; // 経過時間\n\t\twhile (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tprivate static void enqueue(Process p) {\n\t\t// 中身が満タンでないことを判定\n\t\tif ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}\n\t}\n\n\tprivate static Process dequeue() {\n\t\t// 中身が空じゃないことを判定\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}\n\t\treturn ret;\n\n\t}\n\n}",
"public class Main {\n\tprivate static int head = 0;// キューの先頭ポインタ\n\tprivate static int tail = 0;// キューの末尾ポイント\n\tprivate static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。\n\tprivate static Process[] queue = new Process[MAX];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t// すべてのプロセスをキューに追加\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tProcess p = new Process(name, time);\n\t\t\tqueue[i] = p;\n\t\t}\n\t\ttail = n;\n\t\t// すべてのプロセスが完了する(=キューが空になる)まで実行\n\t\tint elaps = 0; // 経過時間\n\t\twhile (!(head == tail)) {\n\t\t\tProcess p = dequeue();\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time = p.time - q;\n\t\t\t\tenqueue(p);\n\t\t\t\telaps += q;\n\t\t\t} else {\n\t\t\t\telaps += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + elaps);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tprivate static void enqueue(Process p) {\n\t\t// 中身が満タンでないことを判定\n\t\tif ((tail + 1) % MAX == head) {\n\t\t\tSystem.err.println(\"エラー(オーバーフロー)\");\n\t\t} else {\n\t\t\tqueue[tail] = p;\n\t\t\ttail = (tail + 1) % MAX;\n\t\t}\n\t}\n\n\tprivate static Process dequeue() {\n\t\t// 中身が空じゃないことを判定\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"エラー(アンダーフロー)\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % MAX;\n\t\t}\n\t\treturn ret;\n\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
private static int head = 0;// キューの先頭ポインタ
private static int tail = 0;// キューの末尾ポイント
private static final int MAX = 100005; // 制約のプロセス数が10万なので少し多めに。
private static Process[] queue = new Process[MAX];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
// すべてのプロセスをキューに追加
for (int i = 0; i < n; i++) {
String name = sc.next();
int time = sc.nextInt();
Process p = new Process(name, time);
queue[i] = p;
}
tail = n;
// すべてのプロセスが完了する(=キューが空になる)まで実行
int elaps = 0; // 経過時間
while (!(head == tail)) {
Process p = dequeue();
if (p.time > q) {
p.time = p.time - q;
enqueue(p);
elaps += q;
} else {
elaps += p.time;
System.out.println(p.name + " " + elaps);
}
}
}
private static void enqueue(Process p) {
// 中身が満タンでないことを判定
if ((tail + 1) % MAX == head) {
System.err.println("エラー(オーバーフロー)");
} else {
queue[tail] = p;
tail = (tail + 1) % MAX;
}
}
private static Process dequeue() {
// 中身が空じゃないことを判定
Process ret = null;
if (head == tail) {
System.err.println("エラー(アンダーフロー)");
} else {
ret = queue[head];
head = (head + 1) % MAX;
}
return ret;
}
}
class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
17,
12,
13,
30,
14,
40,
4,
18,
36,
30,
0,
18,
13,
13,
13,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
14,
40,
4,
18,
36,
30,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
14,
2,
13,
17,
29,
18,
13,
2,
13,
17,
29,
18,
13,
2,
13,
17,
29,
17,
12,
13,
30,
29,
2,
2,
2,
13,
17,
2,
13,
2,
13,
17,
2,
13,
2,
13,
17,
12,
13,
30,
29,
2,
13,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
18,
13,
13,
0,
18,
36,
13,
18,
13,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
0,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
30,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
4,
18,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
4,
9
],
[
9,
10
],
[
9,
11
],
[
4,
13
],
[
13,
14
],
[
4,
15
],
[
15,
16
],
[
4,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
23,
25
],
[
4,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
29,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
34,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
43,
45
],
[
40,
46
],
[
46,
47
],
[
46,
48
],
[
40,
49
],
[
49,
50
],
[
26,
51
],
[
51,
52
],
[
4,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
56,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
62,
68
],
[
68,
69
],
[
68,
70
],
[
62,
71
],
[
71,
72
],
[
61,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
73,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
56,
89
],
[
89,
90
],
[
4,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
95,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
4,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
0,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
117,
121
],
[
121,
122
],
[
117,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
125,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
123,
136
],
[
136,
137
],
[
123,
138
],
[
138,
139
],
[
117,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
142,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
154,
155
],
[
154,
156
],
[
140,
157
],
[
157,
158
],
[
0,
159
],
[
263,
160
],
[
263,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
163,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
163,
177
],
[
177,
178
],
[
177,
179
],
[
163,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
180,
185
],
[
185,
186
],
[
185,
187
],
[
180,
188
],
[
188,
189
],
[
189,
190
],
[
180,
191
],
[
192,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
192,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
201,
202
],
[
192,
203
],
[
203,
204
],
[
204,
205
],
[
203,
206
],
[
163,
207
],
[
207,
208
],
[
207,
209
],
[
163,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
210,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
218,
219
],
[
219,
220
],
[
215,
221
],
[
221,
222
],
[
222,
223
],
[
222,
224
],
[
221,
225
],
[
215,
226
],
[
226,
227
],
[
227,
228
],
[
228,
229
],
[
228,
230
],
[
227,
231
],
[
226,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
237,
239
],
[
232,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
240,
245
],
[
246,
246
],
[
246,
247
],
[
247,
248
],
[
247,
249
],
[
246,
250
],
[
246,
251
],
[
226,
252
],
[
252,
253
],
[
253,
254
],
[
254,
255
],
[
253,
256
],
[
252,
257
],
[
257,
258
],
[
257,
259
],
[
161,
260
],
[
260,
261
],
[
0,
262
],
[
262,
263
],
[
262,
264
]
] | [
"import java.util.Scanner;\n\nclass Queue{\n static int NUM = 100000;\n Process[] a = new Process[NUM];\n int head;\n int tail;\n\n Queue(){\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process p){\n if(!this.isFull()){\n a[tail] = p;\n if(tail == NUM - 1)\n tail = 0;\n else\n tail++;\n }\n }\n\n Process dequeue(){\n if(!this.isEmpty()){\n if(head == NUM - 1)\n head = 0;\n else\n head++;\n\n if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];\n }\n else\n return null;\n }\n\n boolean isFull(){\n return (head == 0 && tail == NUM-1) || (head == tail+1);\n }\n\n boolean isEmpty(){\n return head == tail;\n }\n\n}\n\nclass Process{\n String name;\n int time;\n Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n Process(Process p){\n this.name = p.name;\n this.time = p.time;\n }\n}\n\npublic class Main{\n public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int q = stdIn.nextInt();\n Queue queue = new Queue();\n\n for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }\n\n int time_sum = 0;\n while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }\n\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Queue{\n static int NUM = 100000;\n Process[] a = new Process[NUM];\n int head;\n int tail;\n\n Queue(){\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process p){\n if(!this.isFull()){\n a[tail] = p;\n if(tail == NUM - 1)\n tail = 0;\n else\n tail++;\n }\n }\n\n Process dequeue(){\n if(!this.isEmpty()){\n if(head == NUM - 1)\n head = 0;\n else\n head++;\n\n if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];\n }\n else\n return null;\n }\n\n boolean isFull(){\n return (head == 0 && tail == NUM-1) || (head == tail+1);\n }\n\n boolean isEmpty(){\n return head == tail;\n }\n\n}",
"Queue",
"static int NUM = 100000;",
"NUM",
"100000",
"Process[] a = new Process[NUM];",
"a",
"new Process[NUM]",
"NUM",
"int head;",
"head",
"int tail;",
"tail",
"Queue(){\n head = 0;\n tail = 0;\n }",
"Queue",
"{\n head = 0;\n tail = 0;\n }",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"void enqueue(Process p){\n if(!this.isFull()){\n a[tail] = p;\n if(tail == NUM - 1)\n tail = 0;\n else\n tail++;\n }\n }",
"enqueue",
"{\n if(!this.isFull()){\n a[tail] = p;\n if(tail == NUM - 1)\n tail = 0;\n else\n tail++;\n }\n }",
"if(!this.isFull()){\n a[tail] = p;\n if(tail == NUM - 1)\n tail = 0;\n else\n tail++;\n }",
"!this.isFull()",
"this.isFull()",
"this.isFull",
"this",
"{\n a[tail] = p;\n if(tail == NUM - 1)\n tail = 0;\n else\n tail++;\n }",
"a[tail] = p",
"a[tail]",
"a",
"tail",
"p",
"if(tail == NUM - 1)\n tail = 0;\n else\n tail++;",
"tail == NUM - 1",
"tail",
"NUM - 1",
"NUM",
"1",
"tail = 0",
"tail",
"0",
"tail++",
"tail",
"Process p",
"p",
"Process dequeue(){\n if(!this.isEmpty()){\n if(head == NUM - 1)\n head = 0;\n else\n head++;\n\n if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];\n }\n else\n return null;\n }",
"dequeue",
"{\n if(!this.isEmpty()){\n if(head == NUM - 1)\n head = 0;\n else\n head++;\n\n if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];\n }\n else\n return null;\n }",
"if(!this.isEmpty()){\n if(head == NUM - 1)\n head = 0;\n else\n head++;\n\n if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];\n }\n else\n return null;",
"!this.isEmpty()",
"this.isEmpty()",
"this.isEmpty",
"this",
"{\n if(head == NUM - 1)\n head = 0;\n else\n head++;\n\n if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];\n }",
"if(head == NUM - 1)\n head = 0;\n else\n head++;",
"head == NUM - 1",
"head",
"NUM - 1",
"NUM",
"1",
"head = 0",
"head",
"0",
"head++",
"head",
"if(head == 0)\n return a[NUM - 1];\n else\n return a[head-1];",
"head == 0",
"head",
"0",
"return a[NUM - 1];",
"a[NUM - 1]",
"a",
"NUM - 1",
"NUM",
"1",
"return a[head-1];",
"a[head-1]",
"a",
"head-1",
"head",
"1",
"return null;",
"null",
"boolean isFull(){\n return (head == 0 && tail == NUM-1) || (head == tail+1);\n }",
"isFull",
"{\n return (head == 0 && tail == NUM-1) || (head == tail+1);\n }",
"return (head == 0 && tail == NUM-1) || (head == tail+1);",
"(head == 0 && tail == NUM-1) || (head == tail+1)",
"(head == 0 && tail == NUM-1)",
"head == 0",
"head",
"0",
"tail == NUM-1",
"tail",
"NUM-1",
"NUM",
"1",
"(head == tail+1)",
"head",
"tail+1",
"tail",
"1",
"boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"class Process{\n String name;\n int time;\n Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n Process(Process p){\n this.name = p.name;\n this.time = p.time;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time){\n this.name = name;\n this.time = time;\n }",
"Process",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"Process(Process p){\n this.name = p.name;\n this.time = p.time;\n }",
"Process",
"{\n this.name = p.name;\n this.time = p.time;\n }",
"this.name = p.name",
"this.name",
"this",
"this.name",
"p.name",
"p",
"p.name",
"this.time = p.time",
"this.time",
"this",
"this.time",
"p.time",
"p",
"p.time",
"Process p",
"p",
"public class Main{\n public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int q = stdIn.nextInt();\n Queue queue = new Queue();\n\n for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }\n\n int time_sum = 0;\n while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }\n\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int q = stdIn.nextInt();\n Queue queue = new Queue();\n\n for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }\n\n int time_sum = 0;\n while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }\n\n }",
"main",
"{\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int q = stdIn.nextInt();\n Queue queue = new Queue();\n\n for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }\n\n int time_sum = 0;\n while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }\n\n }",
"Scanner stdIn = new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"int n = stdIn.nextInt();",
"n",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int q = stdIn.nextInt();",
"q",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"Queue queue = new Queue();",
"queue",
"new Queue()",
"for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }",
"{\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }",
"String name = stdIn.next();",
"name",
"stdIn.next()",
"stdIn.next",
"stdIn",
"int time = stdIn.nextInt();",
"time",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"queue.enqueue(new Process(name, time))",
"queue.enqueue",
"queue",
"new Process(name, time)",
"int time_sum = 0;",
"time_sum",
"0",
"while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }",
"Process p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }",
"p.time <= 0",
"p.time",
"p",
"p.time",
"0",
"{\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }",
"time_sum += (q + p.time)",
"time_sum",
"(q + p.time)",
"q",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + (time_sum))",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + (time_sum)",
"p.name + \" \" + (time_sum)",
"p.name",
"p",
"p.name",
"\" \"",
"(time_sum)",
"{\n queue.enqueue(p);\n time_sum += q;\n }",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"time_sum += q",
"time_sum",
"q",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int q = stdIn.nextInt();\n Queue queue = new Queue();\n\n for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }\n\n int time_sum = 0;\n while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }\n\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner stdIn = new Scanner(System.in);\n int n = stdIn.nextInt();\n int q = stdIn.nextInt();\n Queue queue = new Queue();\n\n for(int i = 0; i < n; i++){\n String name = stdIn.next();\n int time = stdIn.nextInt();\n queue.enqueue(new Process(name, time));\n }\n\n int time_sum = 0;\n while(!queue.isEmpty()){\n Process p = queue.dequeue();\n p.time -= q;\n if(p.time <= 0){\n time_sum += (q + p.time);\n System.out.println(p.name + \" \" + (time_sum));\n }\n else{\n queue.enqueue(p);\n time_sum += q;\n }\n }\n\n }\n}",
"Main"
] | import java.util.Scanner;
class Queue{
static int NUM = 100000;
Process[] a = new Process[NUM];
int head;
int tail;
Queue(){
head = 0;
tail = 0;
}
void enqueue(Process p){
if(!this.isFull()){
a[tail] = p;
if(tail == NUM - 1)
tail = 0;
else
tail++;
}
}
Process dequeue(){
if(!this.isEmpty()){
if(head == NUM - 1)
head = 0;
else
head++;
if(head == 0)
return a[NUM - 1];
else
return a[head-1];
}
else
return null;
}
boolean isFull(){
return (head == 0 && tail == NUM-1) || (head == tail+1);
}
boolean isEmpty(){
return head == tail;
}
}
class Process{
String name;
int time;
Process(String name, int time){
this.name = name;
this.time = time;
}
Process(Process p){
this.name = p.name;
this.time = p.time;
}
}
public class Main{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n = stdIn.nextInt();
int q = stdIn.nextInt();
Queue queue = new Queue();
for(int i = 0; i < n; i++){
String name = stdIn.next();
int time = stdIn.nextInt();
queue.enqueue(new Process(name, time));
}
int time_sum = 0;
while(!queue.isEmpty()){
Process p = queue.dequeue();
p.time -= q;
if(p.time <= 0){
time_sum += (q + p.time);
System.out.println(p.name + " " + (time_sum));
}
else{
queue.enqueue(p);
time_sum += q;
}
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
0,
13,
4,
18,
13,
41,
13,
4,
13,
4,
18,
13,
17,
4,
18,
13,
17,
41,
13,
4,
13,
4,
18,
13,
2,
4,
18,
13,
17,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
4,
18,
13,
17,
41,
13,
4,
13,
4,
18,
13,
2,
4,
18,
13,
17,
17,
4,
18,
13,
20,
41,
13,
17,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
13,
2,
2,
2,
18,
13,
13,
17,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
193,
20
],
[
193,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
23,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
23,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
38,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
23,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
53,
58
],
[
23,
59
],
[
59,
60
],
[
59,
61
],
[
23,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
67,
68
],
[
67,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
62,
73
],
[
74,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
74,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
74,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
97,
102
],
[
74,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
23,
107
],
[
107,
108
],
[
107,
109
],
[
23,
110
],
[
110,
111
],
[
110,
112
],
[
23,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
113,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
118,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
124,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
141,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
140,
146
],
[
141,
147
],
[
124,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
148,
154
],
[
154,
155
],
[
154,
156
],
[
148,
157
],
[
157,
158
],
[
158,
159
],
[
157,
160
],
[
23,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
161,
166
],
[
21,
167
],
[
167,
168
],
[
0,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
169,
173
],
[
173,
174
],
[
169,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
177,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
175,
188
],
[
188,
189
],
[
175,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\nimport static java.lang.Integer.parseInt;\n\n/**\n * Elementary data structures - Queue\n */\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\t// read\n\t\tline = br.readLine();\n\t\tint n = parseInt(line.substring(0, line.indexOf(' ')));\n\t\tint q = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\tDeque<Process> queue = new ArrayDeque<Process>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}\n\n\t\t// solve\n\t\tint elapse = 0;\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t} //end main\n}\n\nclass Process {\n\tString name;\n\tint time;\n\n\tProcess(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import static java.lang.Integer.parseInt;",
"import static java.lang.Integer.parseInt;",
"import static java.lang.Integer.parseInt;",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\t// read\n\t\tline = br.readLine();\n\t\tint n = parseInt(line.substring(0, line.indexOf(' ')));\n\t\tint q = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\tDeque<Process> queue = new ArrayDeque<Process>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}\n\n\t\t// solve\n\t\tint elapse = 0;\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t} //end main\n}",
"Main",
"public static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\t// read\n\t\tline = br.readLine();\n\t\tint n = parseInt(line.substring(0, line.indexOf(' ')));\n\t\tint q = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\tDeque<Process> queue = new ArrayDeque<Process>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}\n\n\t\t// solve\n\t\tint elapse = 0;\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t} //end main",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\t// read\n\t\tline = br.readLine();\n\t\tint n = parseInt(line.substring(0, line.indexOf(' ')));\n\t\tint q = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\tDeque<Process> queue = new ArrayDeque<Process>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}\n\n\t\t// solve\n\t\tint elapse = 0;\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String line;",
"line",
"line = br.readLine()",
"line",
"br.readLine()",
"br.readLine",
"br",
"int n = parseInt(line.substring(0, line.indexOf(' ')));",
"n",
"parseInt(line.substring(0, line.indexOf(' ')))",
"parseInt",
"line.substring(0, line.indexOf(' '))",
"line.substring",
"line",
"0",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"int q = parseInt(line.substring(line.indexOf(' ') + 1));",
"q",
"parseInt(line.substring(line.indexOf(' ') + 1))",
"parseInt",
"line.substring(line.indexOf(' ') + 1)",
"line.substring",
"line",
"line.indexOf(' ') + 1",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"1",
"Deque<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}",
"{\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}",
"line = br.readLine()",
"line",
"br.readLine()",
"br.readLine",
"br",
"String name = line.substring(0, line.indexOf(' '));",
"name",
"line.substring(0, line.indexOf(' '))",
"line.substring",
"line",
"0",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"int time = parseInt(line.substring(line.indexOf(' ') + 1));",
"time",
"parseInt(line.substring(line.indexOf(' ') + 1))",
"parseInt",
"line.substring(line.indexOf(' ') + 1)",
"line.substring",
"line",
"line.indexOf(' ') + 1",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"1",
"queue.offer(new Process(name, time))",
"queue.offer",
"queue",
"new Process(name, time)",
"int elapse = 0;",
"elapse",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"while (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}",
"Process p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"if (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}",
"p.time <= q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t}",
"elapse += p.time",
"elapse",
"p.time",
"p",
"p.time",
"sb.append(p.name + \" \" + elapse + \"\\n\")",
"sb.append",
"sb",
"p.name + \" \" + elapse + \"\\n\"",
"elapse",
"p.name + \" \" + elapse + \"\\n\"",
"p.name",
"p",
"p.name",
"\" \"",
"elapse",
"\"\\n\"",
"{\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"elapse += q",
"elapse",
"q",
"queue.offer(p)",
"queue.offer",
"queue",
"p",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"String[] args",
"args",
"class Process {\n\tString name;\n\tint time;\n\n\tProcess(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\t// read\n\t\tline = br.readLine();\n\t\tint n = parseInt(line.substring(0, line.indexOf(' ')));\n\t\tint q = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\tDeque<Process> queue = new ArrayDeque<Process>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}\n\n\t\t// solve\n\t\tint elapse = 0;\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t} //end main\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString line;\n\n\t\t// read\n\t\tline = br.readLine();\n\t\tint n = parseInt(line.substring(0, line.indexOf(' ')));\n\t\tint q = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\tDeque<Process> queue = new ArrayDeque<Process>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tString name = line.substring(0, line.indexOf(' '));\n\t\t\tint time = parseInt(line.substring(line.indexOf(' ') + 1));\n\t\t\tqueue.offer(new Process(name, time));\n\t\t}\n\n\t\t// solve\n\t\tint elapse = 0;\n\t\tStringBuilder sb = new StringBuilder();\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\telapse += p.time;\n\t\t\t\tsb.append(p.name + \" \" + elapse + \"\\n\");\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t} //end main\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import static java.lang.Integer.parseInt;
/**
* Elementary data structures - Queue
*/
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
// read
line = br.readLine();
int n = parseInt(line.substring(0, line.indexOf(' ')));
int q = parseInt(line.substring(line.indexOf(' ') + 1));
Deque<Process> queue = new ArrayDeque<Process>();
for (int i = 0; i < n; i++) {
line = br.readLine();
String name = line.substring(0, line.indexOf(' '));
int time = parseInt(line.substring(line.indexOf(' ') + 1));
queue.offer(new Process(name, time));
}
// solve
int elapse = 0;
StringBuilder sb = new StringBuilder();
while (!queue.isEmpty()) {
Process p = queue.poll();
if (p.time <= q) {
elapse += p.time;
sb.append(p.name + " " + elapse + "\n");
} else {
p.time -= q;
elapse += q;
queue.offer(p);
}
}
System.out.print(sb);
} //end main
}
class Process {
String name;
int time;
Process(String name, int time) {
this.name = name;
this.time = time;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
13,
41,
13,
20,
41,
13,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
18,
13,
13,
18,
13,
17,
4,
18,
13,
20,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
17,
14,
2,
18,
13,
17,
13,
30,
0,
13,
18,
13,
17,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
18,
13,
17,
17,
13,
17,
30,
0,
13,
13,
0,
18,
13,
17,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
17,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
11,
43
],
[
43,
44
],
[
43,
45
],
[
11,
46
],
[
46,
47
],
[
11,
48
],
[
48,
49
],
[
48,
50
],
[
11,
51
],
[
51,
52
],
[
51,
53
],
[
11,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
54,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
69,
74
],
[
66,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
66,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
11,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
92,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
99,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
105,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
115,
125
],
[
113,
126
],
[
111,
127
],
[
99,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
128,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
11,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
147,
148
],
[
9,
149
],
[
149,
150
]
] | [
"import java.io.*;\nimport java.util.ArrayList;\n\nclass Main {\n public static void main (String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n ArrayList<int[]> processes = new ArrayList<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while (processes.size() > 0) {\n currentProcess = processes.remove(0);\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"class Main {\n public static void main (String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n ArrayList<int[]> processes = new ArrayList<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while (processes.size() > 0) {\n currentProcess = processes.remove(0);\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }\n}",
"Main",
"public static void main (String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n ArrayList<int[]> processes = new ArrayList<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while (processes.size() > 0) {\n currentProcess = processes.remove(0);\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n ArrayList<int[]> processes = new ArrayList<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while (processes.size() > 0) {\n currentProcess = processes.remove(0);\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] input = br.readLine().split(\" \");",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(input[0]);",
"n",
"Integer.parseInt(input[0])",
"Integer.parseInt",
"Integer",
"input[0]",
"input",
"0",
"int q = Integer.parseInt(input[1]);",
"q",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"String[] names = new String[n];",
"names",
"new String[n]",
"n",
"ArrayList<int[]> processes = new ArrayList<int[]>();",
"processes",
"new ArrayList<int[]>()",
"int[] currentProcess;",
"currentProcess",
"int time = 0;",
"time",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }",
"{\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.add(new int[] {i, Integer.parseInt(input[1])});\n }",
"input = br.readLine().split(\" \")",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"names[i] = input[0]",
"names[i]",
"names",
"i",
"input[0]",
"input",
"0",
"processes.add(new int[] {i, Integer.parseInt(input[1])})",
"processes.add",
"processes",
"new int[] {i, Integer.parseInt(input[1])}",
"while (processes.size() > 0) {\n currentProcess = processes.remove(0);\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }\n }",
"processes.size() > 0",
"processes.size()",
"processes.size",
"processes",
"0",
"{\n currentProcess = processes.remove(0);\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }\n }",
"currentProcess = processes.remove(0)",
"currentProcess",
"processes.remove(0)",
"processes.remove",
"processes",
"0",
"if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }",
"currentProcess[1] <= q",
"currentProcess[1]",
"currentProcess",
"1",
"q",
"{\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n }",
"time += currentProcess[1]",
"time",
"currentProcess[1]",
"currentProcess",
"1",
"sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\")",
"sb.append(names[currentProcess[0]]).append(\" \").append(time).append",
"sb.append(names[currentProcess[0]]).append(\" \").append(time)",
"sb.append(names[currentProcess[0]]).append(\" \").append",
"sb.append(names[currentProcess[0]]).append(\" \")",
"sb.append(names[currentProcess[0]]).append",
"sb.append(names[currentProcess[0]])",
"sb.append",
"sb",
"names[currentProcess[0]]",
"names",
"currentProcess[0]",
"currentProcess",
"0",
"\" \"",
"time",
"\"\\n\"",
"{\n time += q;\n currentProcess[1] -= q;\n processes.add(currentProcess);\n }",
"time += q",
"time",
"q",
"currentProcess[1] -= q",
"currentProcess[1]",
"currentProcess",
"1",
"q",
"processes.add(currentProcess)",
"processes.add",
"processes",
"currentProcess",
"System.out.print(sb.toString())",
"System.out.print",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"String[] args",
"args"
] | import java.io.*;
import java.util.ArrayList;
class Main {
public static void main (String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int q = Integer.parseInt(input[1]);
String[] names = new String[n];
ArrayList<int[]> processes = new ArrayList<int[]>();
int[] currentProcess;
int time = 0;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
input = br.readLine().split(" ");
names[i] = input[0];
processes.add(new int[] {i, Integer.parseInt(input[1])});
}
while (processes.size() > 0) {
currentProcess = processes.remove(0);
if (currentProcess[1] <= q) {
time += currentProcess[1];
sb.append(names[currentProcess[0]]).append(" ").append(time).append("\n");
} else {
time += q;
currentProcess[1] -= q;
processes.add(currentProcess);
}
}
System.out.print(sb.toString());
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
11,
1,
41,
13,
17,
40,
4,
18,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
13,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
17,
4,
13,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
20,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
0,
13,
17,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
174,
8
],
[
174,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
11,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
11,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
45,
54
],
[
55,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
55,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
67,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
67,
77
],
[
77,
78
],
[
77,
79
],
[
61,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
80,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
92,
94
],
[
86,
95
],
[
95,
96
],
[
95,
97
],
[
95,
98
],
[
80,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
99,
110
],
[
110,
111
],
[
110,
112
],
[
110,
113
],
[
11,
114
],
[
114,
115
],
[
115,
116
],
[
9,
117
],
[
117,
118
],
[
174,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
128,
129
],
[
128,
130
],
[
121,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
121,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
121,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
119,
145
],
[
145,
146
],
[
119,
147
],
[
147,
148
],
[
0,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
149,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
149,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
163,
164
],
[
163,
165
],
[
159,
166
],
[
166,
167
],
[
166,
168
],
[
157,
169
],
[
169,
170
],
[
157,
171
],
[
171,
172
],
[
0,
173
],
[
173,
174
],
[
173,
175
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tLinkedList<Process> processQueue = new LinkedList<Process>();\n\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\tfor (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}\n \t\n sc.close();\n\t}\n\n\tprivate static void printProcess(Process run, int eTime) {\n\t\tStringBuffer str = new StringBuffer();\n\n\t\tstr.append(run.pName);\n\t\tstr.append(\" \");\n\t\tstr.append(eTime);\n\n\t\tSystem.out.println(str);\n\t}\n}\n\nclass Process {\n\tString pName;\n\tint pRemain;\n\tint eTime;\n\t\n\tProcess(String name, int time) {\n\t\tpName = name;\n\t\tpRemain = time;\n\t\teTime = 0;\n\t}\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tLinkedList<Process> processQueue = new LinkedList<Process>();\n\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\tfor (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}\n \t\n sc.close();\n\t}\n\n\tprivate static void printProcess(Process run, int eTime) {\n\t\tStringBuffer str = new StringBuffer();\n\n\t\tstr.append(run.pName);\n\t\tstr.append(\" \");\n\t\tstr.append(eTime);\n\n\t\tSystem.out.println(str);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tLinkedList<Process> processQueue = new LinkedList<Process>();\n\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\tfor (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}\n \t\n sc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tLinkedList<Process> processQueue = new LinkedList<Process>();\n\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\tfor (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}\n \t\n sc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"LinkedList<Process> processQueue = new LinkedList<Process>();",
"processQueue",
"new LinkedList<Process>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int quantum = sc.nextInt();",
"quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}",
"{\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}",
"processQueue.add(new Process(sc.next(), sc.nextInt()))",
"processQueue.add",
"processQueue",
"new Process(sc.next(), sc.nextInt())",
"for (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}",
"int spendTime = 0;",
"int spendTime = 0;",
"spendTime",
"0",
"!processQueue.isEmpty()",
"processQueue.isEmpty()",
"processQueue.isEmpty",
"processQueue",
"{\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}",
"{\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}",
"Process run = processQueue.remove();",
"run",
"processQueue.remove()",
"processQueue.remove",
"processQueue",
"if (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}",
"run.pRemain > quantum",
"run.pRemain",
"run",
"run.pRemain",
"quantum",
"{\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t}",
"run.pRemain -= quantum",
"run.pRemain",
"run",
"run.pRemain",
"quantum",
"processQueue.add(run)",
"processQueue.add",
"processQueue",
"run",
"spendTime += quantum",
"spendTime",
"quantum",
"if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}",
"run.pRemain == quantum",
"run.pRemain",
"run",
"run.pRemain",
"quantum",
"{\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}",
"run.pRemain -= quantum",
"run.pRemain",
"run",
"run.pRemain",
"quantum",
"spendTime += quantum",
"spendTime",
"quantum",
"printProcess(run, spendTime)",
"printProcess",
"run",
"spendTime",
"{\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}",
"spendTime += run.pRemain",
"spendTime",
"run.pRemain",
"run",
"run.pRemain",
"run.pRemain = 0",
"run.pRemain",
"run",
"run.pRemain",
"0",
"printProcess(run, spendTime)",
"printProcess",
"run",
"spendTime",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"private static void printProcess(Process run, int eTime) {\n\t\tStringBuffer str = new StringBuffer();\n\n\t\tstr.append(run.pName);\n\t\tstr.append(\" \");\n\t\tstr.append(eTime);\n\n\t\tSystem.out.println(str);\n\t}",
"printProcess",
"{\n\t\tStringBuffer str = new StringBuffer();\n\n\t\tstr.append(run.pName);\n\t\tstr.append(\" \");\n\t\tstr.append(eTime);\n\n\t\tSystem.out.println(str);\n\t}",
"StringBuffer str = new StringBuffer();",
"str",
"new StringBuffer()",
"str.append(run.pName)",
"str.append",
"str",
"run.pName",
"run",
"run.pName",
"str.append(\" \")",
"str.append",
"str",
"\" \"",
"str.append(eTime)",
"str.append",
"str",
"eTime",
"System.out.println(str)",
"System.out.println",
"System.out",
"System",
"System.out",
"str",
"Process run",
"run",
"int eTime",
"eTime",
"class Process {\n\tString pName;\n\tint pRemain;\n\tint eTime;\n\t\n\tProcess(String name, int time) {\n\t\tpName = name;\n\t\tpRemain = time;\n\t\teTime = 0;\n\t}\n}",
"Process",
"String pName;",
"pName",
"int pRemain;",
"pRemain",
"int eTime;",
"eTime",
"Process(String name, int time) {\n\t\tpName = name;\n\t\tpRemain = time;\n\t\teTime = 0;\n\t}",
"Process",
"{\n\t\tpName = name;\n\t\tpRemain = time;\n\t\teTime = 0;\n\t}",
"pName = name",
"pName",
"name",
"pRemain = time",
"pRemain",
"time",
"eTime = 0",
"eTime",
"0",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tLinkedList<Process> processQueue = new LinkedList<Process>();\n\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\tfor (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}\n \t\n sc.close();\n\t}\n\n\tprivate static void printProcess(Process run, int eTime) {\n\t\tStringBuffer str = new StringBuffer();\n\n\t\tstr.append(run.pName);\n\t\tstr.append(\" \");\n\t\tstr.append(eTime);\n\n\t\tSystem.out.println(str);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in); \n\n\t\tLinkedList<Process> processQueue = new LinkedList<Process>();\n\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tprocessQueue.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\tfor (int spendTime = 0; !processQueue.isEmpty(); ) {\n\t\t\tProcess run = processQueue.remove();\n\t\t\tif (run.pRemain > quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tprocessQueue.add(run);\n\t\t\t\tspendTime += quantum;\n\t\t\t} else if (run.pRemain == quantum) {\n\t\t\t\trun.pRemain -= quantum;\n\t\t\t\tspendTime += quantum;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t} else {\n\t\t\t\tspendTime += run.pRemain;\n\t\t\t\trun.pRemain = 0;\n\t\t\t\tprintProcess(run, spendTime);\n\t\t\t}\n\t\t}\n \t\n sc.close();\n\t}\n\n\tprivate static void printProcess(Process run, int eTime) {\n\t\tStringBuffer str = new StringBuffer();\n\n\t\tstr.append(run.pName);\n\t\tstr.append(\" \");\n\t\tstr.append(eTime);\n\n\t\tSystem.out.println(str);\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
LinkedList<Process> processQueue = new LinkedList<Process>();
int n = sc.nextInt();
int quantum = sc.nextInt();
for (int i = 0; i < n; i++) {
processQueue.add(new Process(sc.next(), sc.nextInt()));
}
for (int spendTime = 0; !processQueue.isEmpty(); ) {
Process run = processQueue.remove();
if (run.pRemain > quantum) {
run.pRemain -= quantum;
processQueue.add(run);
spendTime += quantum;
} else if (run.pRemain == quantum) {
run.pRemain -= quantum;
spendTime += quantum;
printProcess(run, spendTime);
} else {
spendTime += run.pRemain;
run.pRemain = 0;
printProcess(run, spendTime);
}
}
sc.close();
}
private static void printProcess(Process run, int eTime) {
StringBuffer str = new StringBuffer();
str.append(run.pName);
str.append(" ");
str.append(eTime);
System.out.println(str);
}
}
class Process {
String pName;
int pRemain;
int eTime;
Process(String name, int time) {
pName = name;
pRemain = time;
eTime = 0;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
4,
18,
20,
23,
13,
12,
13,
30,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
4,
18,
13,
13,
12,
13,
30,
41,
13,
17,
42,
17,
30,
41,
13,
4,
18,
13,
14,
2,
13,
17,
3,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
2,
2,
13,
17,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
156,
11
],
[
156,
12
],
[
12,
13
],
[
156,
14
],
[
14,
15
],
[
156,
16
],
[
16,
17
],
[
156,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
18,
24
],
[
24,
25
],
[
156,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
28,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
28,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
28,
42
],
[
42,
43
],
[
42,
44
],
[
28,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
62,
63
],
[
61,
64
],
[
156,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
73,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
90,
100
],
[
100,
101
],
[
100,
102
],
[
84,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
103,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
121,
126
],
[
0,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
127,
131
],
[
131,
132
],
[
127,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
139,
140
],
[
139,
141
],
[
133,
142
],
[
142,
143
],
[
133,
144
],
[
144,
145
],
[
127,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
151,
151
],
[
151,
152
],
[
151,
153
],
[
151,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\tint n,q;\n\tQueue<Process> process;\n\tpublic static void main(String args[]) {\n\t\tnew Main().run();\n\t}\n\tMain() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\t\tprocess = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}\n\t}\n\tvoid run() {\n\t\tint sumTime = 0;\n\t\twhile (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}\n\t}\n}\nclass Process {\n\tString name;\n\tint time;\n\tProcess(String txt, int num) {\n\t\tname = txt;\n\t\ttime = num;\n\t}\n\tpublic String toString() {\n\t\treturn name + \" : \" + time;\n\t}\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tint n,q;\n\tQueue<Process> process;\n\tpublic static void main(String args[]) {\n\t\tnew Main().run();\n\t}\n\tMain() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\t\tprocess = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}\n\t}\n\tvoid run() {\n\t\tint sumTime = 0;\n\t\twhile (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"int n",
"n",
"q;",
"q",
"Queue<Process> process;",
"process",
"public static void main(String args[]) {\n\t\tnew Main().run();\n\t}",
"main",
"{\n\t\tnew Main().run();\n\t}",
"new Main().run()",
"new Main().run",
"new Main()",
"String args[]",
"args",
"Main() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\t\tprocess = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}\n\t}",
"Main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\t\tprocess = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"n = scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"q = scan.nextInt()",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"process = new ArrayDeque<Process>()",
"process",
"new ArrayDeque<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}",
"{\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}",
"Process p = new Process(scan.next(),scan.nextInt());",
"p",
"new Process(scan.next(),scan.nextInt())",
"process.add(p)",
"process.add",
"process",
"p",
"void run() {\n\t\tint sumTime = 0;\n\t\twhile (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}\n\t}",
"run",
"{\n\t\tint sumTime = 0;\n\t\twhile (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}\n\t}",
"int sumTime = 0;",
"sumTime",
"0",
"while (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}",
"Process p = process.poll();",
"p",
"process.poll()",
"process.poll",
"process",
"if (p == null) break;",
"p == null",
"p",
"null",
"break;",
"if (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t}",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"process.add(p)",
"process.add",
"process",
"p",
"sumTime += q",
"sumTime",
"q",
"if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}",
"p.time <= q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}",
"sumTime += p.time",
"sumTime",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + sumTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + sumTime",
"p.name + \" \" + sumTime",
"p.name",
"p",
"p.name",
"\" \"",
"sumTime",
"class Process {\n\tString name;\n\tint time;\n\tProcess(String txt, int num) {\n\t\tname = txt;\n\t\ttime = num;\n\t}\n\tpublic String toString() {\n\t\treturn name + \" : \" + time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String txt, int num) {\n\t\tname = txt;\n\t\ttime = num;\n\t}",
"Process",
"{\n\t\tname = txt;\n\t\ttime = num;\n\t}",
"name = txt",
"name",
"txt",
"time = num",
"time",
"num",
"String txt",
"txt",
"int num",
"num",
"public String toString() {\n\t\treturn name + \" : \" + time;\n\t}",
"toString",
"{\n\t\treturn name + \" : \" + time;\n\t}",
"return name + \" : \" + time;",
"name + \" : \" + time",
"name + \" : \" + time",
"name",
"\" : \"",
"time",
"public class Main {\n\tint n,q;\n\tQueue<Process> process;\n\tpublic static void main(String args[]) {\n\t\tnew Main().run();\n\t}\n\tMain() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\t\tprocess = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}\n\t}\n\tvoid run() {\n\t\tint sumTime = 0;\n\t\twhile (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tint n,q;\n\tQueue<Process> process;\n\tpublic static void main(String args[]) {\n\t\tnew Main().run();\n\t}\n\tMain() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\t\tprocess = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcess p = new Process(scan.next(),scan.nextInt());\n\t\t\tprocess.add(p);\n\t\t}\n\t}\n\tvoid run() {\n\t\tint sumTime = 0;\n\t\twhile (true) {\n\t\t\tProcess p = process.poll();\n\t\t\tif (p == null) break;\n\t\t\tif (p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\tprocess.add(p);\n\t\t\t\tsumTime += q;\n\t\t\t} else if (p.time <= q) {\n\t\t\t\tsumTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + sumTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
int n,q;
Queue<Process> process;
public static void main(String args[]) {
new Main().run();
}
Main() {
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
q = scan.nextInt();
process = new ArrayDeque<Process>();
for (int i = 0; i < n; i++) {
Process p = new Process(scan.next(),scan.nextInt());
process.add(p);
}
}
void run() {
int sumTime = 0;
while (true) {
Process p = process.poll();
if (p == null) break;
if (p.time > q) {
p.time -= q;
process.add(p);
sumTime += q;
} else if (p.time <= q) {
sumTime += p.time;
System.out.println(p.name + " " + sumTime);
}
}
}
}
class Process {
String name;
int time;
Process(String txt, int num) {
name = txt;
time = num;
}
public String toString() {
return name + " : " + time;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
17,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
11,
42
],
[
42,
43
],
[
42,
44
],
[
11,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
60,
65
],
[
57,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
68,
70
],
[
57,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
76,
77
],
[
76,
78
],
[
57,
79
],
[
79,
80
],
[
79,
81
],
[
57,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
11,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
86,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
103,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
103,
113
],
[
113,
114
],
[
113,
115
],
[
97,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
119,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
116,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
9,
138
],
[
138,
139
],
[
0,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
140,
144
],
[
144,
145
],
[
140,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
152,
153
],
[
152,
154
],
[
146,
155
],
[
155,
156
],
[
146,
157
],
[
157,
158
]
] | [
"import java.util.*;\nimport java.lang.*;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n String[] line = sc.nextLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int work = Integer.parseInt(line[1]);\n int sumTime = 0;\n ArrayDeque<Struct> arr = new ArrayDeque<Struct>();\n for(int i = 0; i < n; i++){\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }\n while(!(arr.isEmpty())){\n Struct sb = arr.removeLast();\n if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }\n\n }\n\n\n\n\n }\n}\nclass Struct{\n String name;\n int time;\n public Struct(String n, int t){\n name = n;\n time = t;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"class Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n String[] line = sc.nextLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int work = Integer.parseInt(line[1]);\n int sumTime = 0;\n ArrayDeque<Struct> arr = new ArrayDeque<Struct>();\n for(int i = 0; i < n; i++){\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }\n while(!(arr.isEmpty())){\n Struct sb = arr.removeLast();\n if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }\n\n }\n\n\n\n\n }\n}",
"Main",
"public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n String[] line = sc.nextLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int work = Integer.parseInt(line[1]);\n int sumTime = 0;\n ArrayDeque<Struct> arr = new ArrayDeque<Struct>();\n for(int i = 0; i < n; i++){\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }\n while(!(arr.isEmpty())){\n Struct sb = arr.removeLast();\n if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }\n\n }\n\n\n\n\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n String[] line = sc.nextLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int work = Integer.parseInt(line[1]);\n int sumTime = 0;\n ArrayDeque<Struct> arr = new ArrayDeque<Struct>();\n for(int i = 0; i < n; i++){\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }\n while(!(arr.isEmpty())){\n Struct sb = arr.removeLast();\n if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }\n\n }\n\n\n\n\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String[] line = sc.nextLine().split(\" \");",
"line",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"int n = Integer.parseInt(line[0]);",
"n",
"Integer.parseInt(line[0])",
"Integer.parseInt",
"Integer",
"line[0]",
"line",
"0",
"int work = Integer.parseInt(line[1]);",
"work",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"int sumTime = 0;",
"sumTime",
"0",
"ArrayDeque<Struct> arr = new ArrayDeque<Struct>();",
"arr",
"new ArrayDeque<Struct>()",
"for(int i = 0; i < n; i++){\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }",
"{\n String[] line2 = sc.nextLine().split(\" \");\n String name = line2[0];\n int time = Integer.parseInt(line2[1]);\n Struct s = new Struct(name,time);\n arr.push(s);\n }",
"String[] line2 = sc.nextLine().split(\" \");",
"line2",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"String name = line2[0];",
"name",
"line2[0]",
"line2",
"0",
"int time = Integer.parseInt(line2[1]);",
"time",
"Integer.parseInt(line2[1])",
"Integer.parseInt",
"Integer",
"line2[1]",
"line2",
"1",
"Struct s = new Struct(name,time);",
"s",
"new Struct(name,time)",
"arr.push(s)",
"arr.push",
"arr",
"s",
"while(!(arr.isEmpty())){\n Struct sb = arr.removeLast();\n if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }\n\n }",
"!(arr.isEmpty())",
"(arr.isEmpty())",
"arr.isEmpty",
"arr",
"{\n Struct sb = arr.removeLast();\n if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }\n\n }",
"Struct sb = arr.removeLast();",
"sb",
"arr.removeLast()",
"arr.removeLast",
"arr",
"if(sb.time > work){\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }else{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }",
"sb.time > work",
"sb.time",
"sb",
"sb.time",
"work",
"{\n sb.time-= work;\n arr.push(sb);\n sumTime+= work;\n }",
"sb.time-= work",
"sb.time",
"sb",
"sb.time",
"work",
"arr.push(sb)",
"arr.push",
"arr",
"sb",
"sumTime+= work",
"sumTime",
"work",
"{\n sumTime+=sb.time;\n System.out.print(sb.name + \" \");\n System.out.println(sumTime);\n\n }",
"sumTime+=sb.time",
"sumTime",
"sb.time",
"sb",
"sb.time",
"System.out.print(sb.name + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"sb.name + \" \"",
"sb.name",
"sb",
"sb.name",
"\" \"",
"System.out.println(sumTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"sumTime",
"String args[]",
"args",
"class Struct{\n String name;\n int time;\n public Struct(String n, int t){\n name = n;\n time = t;\n }\n}",
"Struct",
"String name;",
"name",
"int time;",
"time",
"public Struct(String n, int t){\n name = n;\n time = t;\n }",
"Struct",
"{\n name = n;\n time = t;\n }",
"name = n",
"name",
"n",
"time = t",
"time",
"t",
"String n",
"n",
"int t",
"t"
] | import java.util.*;
import java.lang.*;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
String[] line = sc.nextLine().split(" ");
int n = Integer.parseInt(line[0]);
int work = Integer.parseInt(line[1]);
int sumTime = 0;
ArrayDeque<Struct> arr = new ArrayDeque<Struct>();
for(int i = 0; i < n; i++){
String[] line2 = sc.nextLine().split(" ");
String name = line2[0];
int time = Integer.parseInt(line2[1]);
Struct s = new Struct(name,time);
arr.push(s);
}
while(!(arr.isEmpty())){
Struct sb = arr.removeLast();
if(sb.time > work){
sb.time-= work;
arr.push(sb);
sumTime+= work;
}else{
sumTime+=sb.time;
System.out.print(sb.name + " ");
System.out.println(sumTime);
}
}
}
}
class Struct{
String name;
int time;
public Struct(String n, int t){
name = n;
time = t;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
42,
2,
13,
17,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
40,
13,
42,
40,
4,
18,
13,
30,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
41,
13,
2,
4,
18,
13,
13,
41,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
116,
14
],
[
116,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
17,
24
],
[
24,
25
],
[
24,
26
],
[
17,
27
],
[
27,
28
],
[
27,
29
],
[
17,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
17,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
17,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
49,
50
],
[
44,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
54,
55
],
[
55,
56
],
[
44,
57
],
[
57,
58
],
[
17,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
59,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
66,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
77,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
83,
87
],
[
83,
88
],
[
65,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
92,
96
],
[
89,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
100,
101
],
[
89,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
89,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
89,
110
],
[
110,
111
],
[
110,
112
],
[
15,
113
],
[
113,
114
],
[
0,
115
],
[
115,
116
],
[
115,
117
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\nimport java.util.Iterator;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> keys = new LinkedList<>();\n Queue<Integer> values = new LinkedList<>();\n Integer timestamp = 0;\n\n int ceiling = in.nextInt();\n int quantum = in.nextInt();\n while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }\n\n while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }\n }\n}\n\n\n\n\n",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Iterator;",
"Iterator",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> keys = new LinkedList<>();\n Queue<Integer> values = new LinkedList<>();\n Integer timestamp = 0;\n\n int ceiling = in.nextInt();\n int quantum = in.nextInt();\n while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }\n\n while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> keys = new LinkedList<>();\n Queue<Integer> values = new LinkedList<>();\n Integer timestamp = 0;\n\n int ceiling = in.nextInt();\n int quantum = in.nextInt();\n while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }\n\n while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }\n }",
"main",
"{\n Scanner in = new Scanner(System.in);\n Queue<String> keys = new LinkedList<>();\n Queue<Integer> values = new LinkedList<>();\n Integer timestamp = 0;\n\n int ceiling = in.nextInt();\n int quantum = in.nextInt();\n while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }\n\n while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"Queue<String> keys = new LinkedList<>();",
"keys",
"new LinkedList<>()",
"Queue<Integer> values = new LinkedList<>();",
"values",
"new LinkedList<>()",
"Integer timestamp = 0;",
"timestamp",
"0",
"int ceiling = in.nextInt();",
"ceiling",
"in.nextInt()",
"in.nextInt",
"in",
"int quantum = in.nextInt();",
"quantum",
"in.nextInt()",
"in.nextInt",
"in",
"while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }",
"ceiling > 0",
"ceiling",
"0",
"{\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }",
"keys.add(in.next())",
"keys.add",
"keys",
"in.next()",
"in.next",
"in",
"values.add(in.nextInt())",
"values.add",
"values",
"in.nextInt()",
"in.nextInt",
"in",
"--ceiling",
"ceiling",
"while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }",
"!values.isEmpty()",
"values.isEmpty()",
"values.isEmpty",
"values",
"{\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }",
"if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }",
"values.peek() <= quantum",
"values.peek()",
"values.peek",
"values",
"quantum",
"{\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n }",
"timestamp += values.poll()",
"timestamp",
"values.poll()",
"values.poll",
"values",
"System.out.println(keys.poll() + \" \" + timestamp)",
"System.out.println",
"System.out",
"System",
"System.out",
"keys.poll() + \" \" + timestamp",
"keys.poll() + \" \" + timestamp",
"keys.poll()",
"keys.poll",
"keys",
"\" \"",
"timestamp",
"{\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }",
"int temp = values.poll() - quantum;",
"temp",
"values.poll() - quantum",
"values.poll()",
"values.poll",
"values",
"quantum",
"String tempo = keys.poll();",
"tempo",
"keys.poll()",
"keys.poll",
"keys",
"keys.add(tempo)",
"keys.add",
"keys",
"tempo",
"values.add(temp)",
"values.add",
"values",
"temp",
"timestamp += quantum",
"timestamp",
"quantum",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> keys = new LinkedList<>();\n Queue<Integer> values = new LinkedList<>();\n Integer timestamp = 0;\n\n int ceiling = in.nextInt();\n int quantum = in.nextInt();\n while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }\n\n while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> keys = new LinkedList<>();\n Queue<Integer> values = new LinkedList<>();\n Integer timestamp = 0;\n\n int ceiling = in.nextInt();\n int quantum = in.nextInt();\n while (ceiling > 0) {\n keys.add(in.next());\n values.add(in.nextInt());\n --ceiling;\n }\n\n while (!values.isEmpty()) {\n if (values.peek() <= quantum) {\n timestamp += values.poll();\n System.out.println(keys.poll() + \" \" + timestamp);\n } else {\n int temp = values.poll() - quantum;\n String tempo = keys.poll();\n keys.add(tempo);\n values.add(temp);\n timestamp += quantum;\n }\n }\n }\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Iterator;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Queue<String> keys = new LinkedList<>();
Queue<Integer> values = new LinkedList<>();
Integer timestamp = 0;
int ceiling = in.nextInt();
int quantum = in.nextInt();
while (ceiling > 0) {
keys.add(in.next());
values.add(in.nextInt());
--ceiling;
}
while (!values.isEmpty()) {
if (values.peek() <= quantum) {
timestamp += values.poll();
System.out.println(keys.poll() + " " + timestamp);
} else {
int temp = values.poll() - quantum;
String tempo = keys.poll();
keys.add(tempo);
values.add(temp);
timestamp += quantum;
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
41,
13,
41,
13,
41,
13,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
19,
18,
20,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
13,
17,
0,
13,
2,
13,
17,
42,
2,
13,
13,
30,
0,
13,
4,
13,
0,
13,
4,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
13,
12,
13,
30,
29,
8,
2,
13,
13,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
195,
5
],
[
195,
6
],
[
6,
7
],
[
6,
8
],
[
195,
9
],
[
9,
10
],
[
9,
11
],
[
195,
13
],
[
13,
14
],
[
195,
15
],
[
15,
16
],
[
195,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
23,
25
],
[
19,
26
],
[
26,
27
],
[
19,
28
],
[
28,
29
],
[
19,
30
],
[
30,
31
],
[
19,
32
],
[
32,
33
],
[
19,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
19,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
19,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
62,
63
],
[
56,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
71,
72
],
[
56,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
19,
82
],
[
82,
83
],
[
82,
84
],
[
19,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
19,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
94,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
101,
104
],
[
104,
105
],
[
104,
106
],
[
94,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
94,
112
],
[
112,
113
],
[
112,
114
],
[
94,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
115,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
132,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
132,
137
],
[
17,
138
],
[
138,
139
],
[
195,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
142,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
140,
155
],
[
155,
156
],
[
195,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
162,
164
],
[
159,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
159,
172
],
[
172,
173
],
[
195,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
178,
183
],
[
174,
184
],
[
184,
185
],
[
174,
186
],
[
186,
187
],
[
195,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
188,
192
],
[
192,
193
],
[
0,
194
],
[
194,
195
],
[
194,
196
]
] | [
"import java.util.*;\n\npublic class Main \n{\n\tfinal static int MAX=100005;\n\tstatic Pp[] object=new Pp[MAX];\n\tstatic int head,tail;\n\tpublic static void main(String[]args)\n\t{\n\t\t\n\t\tScanner scanner=new Scanner(System.in);\n\t\tint sum=0,c;\n\t\tint q,n;\n\t\tPp u;\n\t\tn=scanner.nextInt();\n\t\tq=scanner.nextInt();\n\n\t\tfor(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}\n\t\t\n\t\thead=1;tail=n+1;\n\t\twhile(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n\t\n\tstatic void enqueue(Pp x)\n\t{\n\t\tobject[tail]=x;\n\t\ttail=(tail+1)%MAX;\n\t\t\n\t}\n\t\n\tstatic Pp dequeue()\n\t{\n\t\tPp x=object[head];\n\t\thead=(head+1)%MAX;\n\t\treturn x;\n\t}\n\t\n\tstatic int min(int a,int b)\n\t{\n\t\treturn a<b?a:b;\n\t}\n\t\n\tpublic class Pp\n\t{\n\t\t String name;\n\t\t int t;\t\t\n\t}\n\t\n\n\n\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main \n{\n\tfinal static int MAX=100005;\n\tstatic Pp[] object=new Pp[MAX];\n\tstatic int head,tail;\n\tpublic static void main(String[]args)\n\t{\n\t\t\n\t\tScanner scanner=new Scanner(System.in);\n\t\tint sum=0,c;\n\t\tint q,n;\n\t\tPp u;\n\t\tn=scanner.nextInt();\n\t\tq=scanner.nextInt();\n\n\t\tfor(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}\n\t\t\n\t\thead=1;tail=n+1;\n\t\twhile(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n\t\n\tstatic void enqueue(Pp x)\n\t{\n\t\tobject[tail]=x;\n\t\ttail=(tail+1)%MAX;\n\t\t\n\t}\n\t\n\tstatic Pp dequeue()\n\t{\n\t\tPp x=object[head];\n\t\thead=(head+1)%MAX;\n\t\treturn x;\n\t}\n\t\n\tstatic int min(int a,int b)\n\t{\n\t\treturn a<b?a:b;\n\t}\n\t\n\tpublic class Pp\n\t{\n\t\t String name;\n\t\t int t;\t\t\n\t}\n\t\n\n\n\n\n}",
"Main",
"final static int MAX=100005;",
"MAX",
"100005",
"static Pp[] object=new Pp[MAX];",
"object",
"new Pp[MAX]",
"MAX",
"static int head",
"head",
"tail;",
"tail",
"public static void main(String[]args)\n\t{\n\t\t\n\t\tScanner scanner=new Scanner(System.in);\n\t\tint sum=0,c;\n\t\tint q,n;\n\t\tPp u;\n\t\tn=scanner.nextInt();\n\t\tq=scanner.nextInt();\n\n\t\tfor(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}\n\t\t\n\t\thead=1;tail=n+1;\n\t\twhile(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t}",
"main",
"{\n\t\t\n\t\tScanner scanner=new Scanner(System.in);\n\t\tint sum=0,c;\n\t\tint q,n;\n\t\tPp u;\n\t\tn=scanner.nextInt();\n\t\tq=scanner.nextInt();\n\n\t\tfor(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}\n\t\t\n\t\thead=1;tail=n+1;\n\t\twhile(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t}",
"Scanner scanner=new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int sum=0",
"sum",
"0",
"c;",
"c",
"int q",
"q",
"n;",
"n",
"Pp u;",
"u",
"n=scanner.nextInt()",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"q=scanner.nextInt()",
"q",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"for(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}",
"int i=1;",
"int i=1;",
"i",
"1",
"i<=n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}",
"{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}",
"object[i]=new Main().new Pp()",
"object[i]",
"object",
"i",
"new Main().new Pp()",
"new Main()",
"new Main()",
"object[i].name=scanner.next()",
"object[i].name",
"object[i]",
"object",
"i",
"object[i].name",
"scanner.next()",
"scanner.next",
"scanner",
"object[i].t=scanner.nextInt()",
"object[i].t",
"object[i]",
"object",
"i",
"object[i].t",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"head=1",
"head",
"1",
"tail=n+1",
"tail",
"n+1",
"n",
"1",
"while(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}",
"head!=tail",
"head",
"tail",
"{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}",
"u=dequeue()",
"u",
"dequeue()",
"dequeue",
"c=min(q,u.t)",
"c",
"min(q,u.t)",
"min",
"q",
"u.t",
"u",
"u.t",
"u.t-=c",
"u.t",
"u",
"u.t",
"c",
"sum+=c",
"sum",
"c",
"if(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}",
"u.t>0",
"u.t",
"u",
"u.t",
"0",
"{\n\t\t\t\tenqueue(u);\n\t\t\t}",
"enqueue(u)",
"enqueue",
"u",
"{\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}",
"System.out.println(u.name+\" \"+sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"u.name+\" \"+sum",
"u.name+\" \"+sum",
"u.name",
"u",
"u.name",
"\" \"",
"sum",
"String[]args",
"args",
"static void enqueue(Pp x)\n\t{\n\t\tobject[tail]=x;\n\t\ttail=(tail+1)%MAX;\n\t\t\n\t}",
"enqueue",
"{\n\t\tobject[tail]=x;\n\t\ttail=(tail+1)%MAX;\n\t\t\n\t}",
"object[tail]=x",
"object[tail]",
"object",
"tail",
"x",
"tail=(tail+1)%MAX",
"tail",
"(tail+1)%MAX",
"(tail+1)",
"tail",
"1",
"MAX",
"Pp x",
"x",
"static Pp dequeue()\n\t{\n\t\tPp x=object[head];\n\t\thead=(head+1)%MAX;\n\t\treturn x;\n\t}",
"dequeue",
"{\n\t\tPp x=object[head];\n\t\thead=(head+1)%MAX;\n\t\treturn x;\n\t}",
"Pp x=object[head];",
"x",
"object[head]",
"object",
"head",
"head=(head+1)%MAX",
"head",
"(head+1)%MAX",
"(head+1)",
"head",
"1",
"MAX",
"return x;",
"x",
"static int min(int a,int b)\n\t{\n\t\treturn a<b?a:b;\n\t}",
"min",
"{\n\t\treturn a<b?a:b;\n\t}",
"return a<b?a:b;",
"a<b?a:b",
"a<b",
"a",
"b",
"a",
"b",
"int a",
"a",
"int b",
"b",
"public class Pp\n\t{\n\t\t String name;\n\t\t int t;\t\t\n\t}",
"Pp",
"String name;",
"name",
"int t;",
"t",
"public class Main \n{\n\tfinal static int MAX=100005;\n\tstatic Pp[] object=new Pp[MAX];\n\tstatic int head,tail;\n\tpublic static void main(String[]args)\n\t{\n\t\t\n\t\tScanner scanner=new Scanner(System.in);\n\t\tint sum=0,c;\n\t\tint q,n;\n\t\tPp u;\n\t\tn=scanner.nextInt();\n\t\tq=scanner.nextInt();\n\n\t\tfor(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}\n\t\t\n\t\thead=1;tail=n+1;\n\t\twhile(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n\t\n\tstatic void enqueue(Pp x)\n\t{\n\t\tobject[tail]=x;\n\t\ttail=(tail+1)%MAX;\n\t\t\n\t}\n\t\n\tstatic Pp dequeue()\n\t{\n\t\tPp x=object[head];\n\t\thead=(head+1)%MAX;\n\t\treturn x;\n\t}\n\t\n\tstatic int min(int a,int b)\n\t{\n\t\treturn a<b?a:b;\n\t}\n\t\n\tpublic class Pp\n\t{\n\t\t String name;\n\t\t int t;\t\t\n\t}\n\t\n\n\n\n\n}",
"public class Main \n{\n\tfinal static int MAX=100005;\n\tstatic Pp[] object=new Pp[MAX];\n\tstatic int head,tail;\n\tpublic static void main(String[]args)\n\t{\n\t\t\n\t\tScanner scanner=new Scanner(System.in);\n\t\tint sum=0,c;\n\t\tint q,n;\n\t\tPp u;\n\t\tn=scanner.nextInt();\n\t\tq=scanner.nextInt();\n\n\t\tfor(int i=1;i<=n;i++ )\n\t\t{\n\t\t\tobject[i]=new Main().new Pp();\n\t\t\tobject[i].name=scanner.next();\n\t\t\tobject[i].t=scanner.nextInt();\n\t\t}\n\t\t\n\t\thead=1;tail=n+1;\n\t\twhile(head!=tail)\n\t\t{\n\t\t\tu=dequeue();\n\t\t\tc=min(q,u.t);\n\t\t\tu.t-=c;\n\t\t\tsum+=c;\n\t\t\tif(u.t>0)\n\t\t\t{\n\t\t\t\tenqueue(u);\n\t\t\t}else {\n\t\t\t\tSystem.out.println(u.name+\" \"+sum);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t\t\n\t}\n\t\n\tstatic void enqueue(Pp x)\n\t{\n\t\tobject[tail]=x;\n\t\ttail=(tail+1)%MAX;\n\t\t\n\t}\n\t\n\tstatic Pp dequeue()\n\t{\n\t\tPp x=object[head];\n\t\thead=(head+1)%MAX;\n\t\treturn x;\n\t}\n\t\n\tstatic int min(int a,int b)\n\t{\n\t\treturn a<b?a:b;\n\t}\n\t\n\tpublic class Pp\n\t{\n\t\t String name;\n\t\t int t;\t\t\n\t}\n\t\n\n\n\n\n}",
"Main"
] | import java.util.*;
public class Main
{
final static int MAX=100005;
static Pp[] object=new Pp[MAX];
static int head,tail;
public static void main(String[]args)
{
Scanner scanner=new Scanner(System.in);
int sum=0,c;
int q,n;
Pp u;
n=scanner.nextInt();
q=scanner.nextInt();
for(int i=1;i<=n;i++ )
{
object[i]=new Main().new Pp();
object[i].name=scanner.next();
object[i].t=scanner.nextInt();
}
head=1;tail=n+1;
while(head!=tail)
{
u=dequeue();
c=min(q,u.t);
u.t-=c;
sum+=c;
if(u.t>0)
{
enqueue(u);
}else {
System.out.println(u.name+" "+sum);
}
}
}
static void enqueue(Pp x)
{
object[tail]=x;
tail=(tail+1)%MAX;
}
static Pp dequeue()
{
Pp x=object[head];
head=(head+1)%MAX;
return x;
}
static int min(int a,int b)
{
return a<b?a:b;
}
public class Pp
{
String name;
int t;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
42,
17,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
17,
3,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
112,
5
],
[
112,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
8,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
44,
45
],
[
45,
46
],
[
40,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
51,
52
],
[
8,
53
],
[
53,
54
],
[
53,
55
],
[
8,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
64,
70
],
[
58,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
58,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
90,
90
],
[
90,
91
],
[
90,
92
],
[
90,
93
],
[
76,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
94,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
94,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
6,
109
],
[
109,
110
],
[
0,
111
],
[
111,
112
],
[
111,
113
]
] | [
"import java.util.*;\npublic class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Queue<String> name_queue = new ArrayDeque<>();\n Queue<Integer> queue = new ArrayDeque<>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }\n int count_time = 0;\n while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Queue<String> name_queue = new ArrayDeque<>();\n Queue<Integer> queue = new ArrayDeque<>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }\n int count_time = 0;\n while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Queue<String> name_queue = new ArrayDeque<>();\n Queue<Integer> queue = new ArrayDeque<>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }\n int count_time = 0;\n while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n Queue<String> name_queue = new ArrayDeque<>();\n Queue<Integer> queue = new ArrayDeque<>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }\n int count_time = 0;\n while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<String> name_queue = new ArrayDeque<>();",
"name_queue",
"new ArrayDeque<>()",
"Queue<Integer> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }",
"{\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }",
"name_queue.add(sc.next())",
"name_queue.add",
"name_queue",
"sc.next()",
"sc.next",
"sc",
"queue.add(sc.nextInt())",
"queue.add",
"queue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count_time = 0;",
"count_time",
"0",
"while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }",
"true",
"{\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }",
"String name = name_queue.poll();",
"name",
"name_queue.poll()",
"name_queue.poll",
"name_queue",
"if(queue.peek() == null)\n break;",
"queue.peek() == null",
"queue.peek()",
"queue.peek",
"queue",
"null",
"break;",
"int num = queue.poll();",
"num",
"queue.poll()",
"queue.poll",
"queue",
"if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }",
"num <= q",
"num",
"q",
"{\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }",
"count_time += num",
"count_time",
"num",
"System.out.println(name + \" \" + count_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + count_time",
"name + \" \" + count_time",
"name",
"\" \"",
"count_time",
"{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }",
"count_time += q",
"count_time",
"q",
"num -= q",
"num",
"q",
"queue.add(num)",
"queue.add",
"queue",
"num",
"name_queue.add(name)",
"name_queue.add",
"name_queue",
"name",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Queue<String> name_queue = new ArrayDeque<>();\n Queue<Integer> queue = new ArrayDeque<>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }\n int count_time = 0;\n while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n Queue<String> name_queue = new ArrayDeque<>();\n Queue<Integer> queue = new ArrayDeque<>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n for(int i = 0 ; i < n ; i++){\n name_queue.add(sc.next());\n queue.add(sc.nextInt());\n }\n int count_time = 0;\n while(true){\n String name = name_queue.poll();\n if(queue.peek() == null)\n break;\n int num = queue.poll();\n if(num <= q){\n count_time += num;\n System.out.println(name + \" \" + count_time);\n }\n else{\n count_time += q;\n num -= q;\n queue.add(num);\n name_queue.add(name);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Queue<String> name_queue = new ArrayDeque<>();
Queue<Integer> queue = new ArrayDeque<>();
int n = sc.nextInt();
int q = sc.nextInt();
for(int i = 0 ; i < n ; i++){
name_queue.add(sc.next());
queue.add(sc.nextInt());
}
int count_time = 0;
while(true){
String name = name_queue.poll();
if(queue.peek() == null)
break;
int num = queue.poll();
if(num <= q){
count_time += num;
System.out.println(name + " " + count_time);
}
else{
count_time += q;
num -= q;
queue.add(num);
name_queue.add(name);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
4,
18,
13,
13,
41,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
20,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
17,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
201,
11
],
[
201,
12
],
[
12,
13
],
[
12,
14
],
[
201,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
17,
23
],
[
23,
24
],
[
17,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
17,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
17,
35
],
[
35,
36
],
[
35,
37
],
[
17,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
50,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
50,
61
],
[
61,
62
],
[
61,
63
],
[
50,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
17,
68
],
[
68,
69
],
[
68,
70
],
[
17,
71
],
[
71,
72
],
[
71,
73
],
[
17,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
74,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
86,
90
],
[
85,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
85,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
108,
112
],
[
101,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
17,
117
],
[
117,
118
],
[
117,
119
],
[
117,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
128,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
128,
132
],
[
128,
133
],
[
133,
134
],
[
134,
135
],
[
15,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
138,
142
],
[
142,
143
],
[
138,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
146,
150
],
[
150,
151
],
[
150,
152
],
[
138,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
155,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
153,
166
],
[
166,
167
],
[
153,
168
],
[
168,
169
],
[
138,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
138,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
175,
183
],
[
183,
184
],
[
138,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
138,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
190,
198
],
[
198,
199
],
[
0,
200
],
[
200,
201
],
[
200,
202
]
] | [
"import java.util.*;\nimport java.io.*;\nimport java.lang.*;\n\npublic class Main {\n static final int INF = 1000000000; \n \n public static void main(String[] args) throws Exception { \n Scanner input = new Scanner(System.in);\n int n, q;\n n = input.nextInt();\n q = input.nextInt(); \n Queue<Process> queue = new ArrayDeque<Process>();\n for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }\n ArrayList<Process> res = new ArrayList<Process>();\n int time = 0;\n while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }\n for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }\n } \n}\n\nclass Process {\n String name;\n int time;\n public Process() {\n name = \"\";\n time = 0;\n }\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n } \n\n public String getName() {\n return name;\n }\n\n public void setName(String name) {\n this.name = name;\n }\n\n public int getTime() {\n return time;\n }\n\n public void setTime(int time) {\n this.time = time;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"public class Main {\n static final int INF = 1000000000; \n \n public static void main(String[] args) throws Exception { \n Scanner input = new Scanner(System.in);\n int n, q;\n n = input.nextInt();\n q = input.nextInt(); \n Queue<Process> queue = new ArrayDeque<Process>();\n for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }\n ArrayList<Process> res = new ArrayList<Process>();\n int time = 0;\n while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }\n for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }\n } \n}",
"Main",
"static final int INF = 1000000000;",
"INF",
"1000000000",
"public static void main(String[] args) throws Exception { \n Scanner input = new Scanner(System.in);\n int n, q;\n n = input.nextInt();\n q = input.nextInt(); \n Queue<Process> queue = new ArrayDeque<Process>();\n for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }\n ArrayList<Process> res = new ArrayList<Process>();\n int time = 0;\n while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }\n for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }\n }",
"main",
"{ \n Scanner input = new Scanner(System.in);\n int n, q;\n n = input.nextInt();\n q = input.nextInt(); \n Queue<Process> queue = new ArrayDeque<Process>();\n for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }\n ArrayList<Process> res = new ArrayList<Process>();\n int time = 0;\n while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }\n for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }\n }",
"Scanner input = new Scanner(System.in);",
"input",
"new Scanner(System.in)",
"int n",
"n",
"q;",
"q",
"n = input.nextInt()",
"n",
"input.nextInt()",
"input.nextInt",
"input",
"q = input.nextInt()",
"q",
"input.nextInt()",
"input.nextInt",
"input",
"Queue<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"++i",
"++i",
"i",
"{\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }",
"{\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }",
"String name = input.next();",
"name",
"input.next()",
"input.next",
"input",
"int time = input.nextInt();",
"time",
"input.nextInt()",
"input.nextInt",
"input",
"Process element = new Process(name, time);",
"element",
"new Process(name, time)",
"queue.add(element)",
"queue.add",
"queue",
"element",
"ArrayList<Process> res = new ArrayList<Process>();",
"res",
"new ArrayList<Process>()",
"int time = 0;",
"time",
"0",
"while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }",
"Process element = queue.poll();",
"element",
"queue.poll()",
"queue.poll",
"queue",
"if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }",
"element.getTime() <= q",
"element.getTime()",
"element.getTime",
"element",
"q",
"{\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n }",
"time += element.getTime()",
"time",
"element.getTime()",
"element.getTime",
"element",
"res.add(new Process(element.getName(), time))",
"res.add",
"res",
"new Process(element.getName(), time)",
"{\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }",
"time += q",
"time",
"q",
"element.setTime(element.getTime() - q)",
"element.setTime",
"element",
"element.getTime() - q",
"element.getTime()",
"element.getTime",
"element",
"q",
"queue.add(element)",
"queue.add",
"queue",
"element",
"for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }",
"Process element",
"res",
"{\n System.out.println(element.getName() + \" \" + element.getTime());\n }",
"{\n System.out.println(element.getName() + \" \" + element.getTime());\n }",
"System.out.println(element.getName() + \" \" + element.getTime())",
"System.out.println",
"System.out",
"System",
"System.out",
"element.getName() + \" \" + element.getTime()",
"element.getName() + \" \" + element.getTime()",
"element.getName()",
"element.getName",
"element",
"\" \"",
"element.getTime()",
"element.getTime",
"element",
"String[] args",
"args",
"class Process {\n String name;\n int time;\n public Process() {\n name = \"\";\n time = 0;\n }\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n } \n\n public String getName() {\n return name;\n }\n\n public void setName(String name) {\n this.name = name;\n }\n\n public int getTime() {\n return time;\n }\n\n public void setTime(int time) {\n this.time = time;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process() {\n name = \"\";\n time = 0;\n }",
"Process",
"{\n name = \"\";\n time = 0;\n }",
"name = \"\"",
"name",
"\"\"",
"time = 0",
"time",
"0",
"public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Process",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public String getName() {\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public void setName(String name) {\n this.name = name;\n }",
"setName",
"{\n this.name = name;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"public int getTime() {\n return time;\n }",
"getTime",
"{\n return time;\n }",
"return time;",
"time",
"public void setTime(int time) {\n this.time = time;\n }",
"setTime",
"{\n this.time = time;\n }",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"public class Main {\n static final int INF = 1000000000; \n \n public static void main(String[] args) throws Exception { \n Scanner input = new Scanner(System.in);\n int n, q;\n n = input.nextInt();\n q = input.nextInt(); \n Queue<Process> queue = new ArrayDeque<Process>();\n for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }\n ArrayList<Process> res = new ArrayList<Process>();\n int time = 0;\n while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }\n for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }\n } \n}",
"public class Main {\n static final int INF = 1000000000; \n \n public static void main(String[] args) throws Exception { \n Scanner input = new Scanner(System.in);\n int n, q;\n n = input.nextInt();\n q = input.nextInt(); \n Queue<Process> queue = new ArrayDeque<Process>();\n for (int i = 0; i < n; ++i) {\n String name = input.next();\n int time = input.nextInt();\n Process element = new Process(name, time);\n queue.add(element);\n }\n ArrayList<Process> res = new ArrayList<Process>();\n int time = 0;\n while (!queue.isEmpty()) {\n Process element = queue.poll();\n if (element.getTime() <= q) {\n time += element.getTime();\n res.add(new Process(element.getName(), time));\n } else {\n time += q;\n element.setTime(element.getTime() - q);\n queue.add(element);\n }\n }\n for (Process element : res) {\n System.out.println(element.getName() + \" \" + element.getTime());\n }\n } \n}",
"Main"
] | import java.util.*;
import java.io.*;
import java.lang.*;
public class Main {
static final int INF = 1000000000;
public static void main(String[] args) throws Exception {
Scanner input = new Scanner(System.in);
int n, q;
n = input.nextInt();
q = input.nextInt();
Queue<Process> queue = new ArrayDeque<Process>();
for (int i = 0; i < n; ++i) {
String name = input.next();
int time = input.nextInt();
Process element = new Process(name, time);
queue.add(element);
}
ArrayList<Process> res = new ArrayList<Process>();
int time = 0;
while (!queue.isEmpty()) {
Process element = queue.poll();
if (element.getTime() <= q) {
time += element.getTime();
res.add(new Process(element.getName(), time));
} else {
time += q;
element.setTime(element.getTime() - q);
queue.add(element);
}
}
for (Process element : res) {
System.out.println(element.getName() + " " + element.getTime());
}
}
}
class Process {
String name;
int time;
public Process() {
name = "";
time = 0;
}
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
42,
17,
30,
14,
2,
13,
13,
30,
14,
2,
2,
4,
18,
0,
13,
4,
18,
13,
13,
13,
17,
30,
0,
13,
4,
18,
13,
4,
18,
13,
20,
4,
18,
13,
13,
40,
13,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
40,
13,
30,
0,
13,
17,
14,
2,
13,
17,
30,
3,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
4,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
13,
17
],
[
12,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
10,
23
],
[
23,
24
],
[
10,
25
],
[
25,
26
],
[
4,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
27,
35
],
[
35,
36
],
[
4,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
4,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
42,
50
],
[
50,
51
],
[
4,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
0,
57
],
[
192,
58
],
[
192,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
61,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
61,
75
],
[
75,
76
],
[
75,
77
],
[
61,
78
],
[
78,
79
],
[
78,
80
],
[
61,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
81,
86
],
[
86,
87
],
[
86,
88
],
[
81,
89
],
[
89,
90
],
[
90,
91
],
[
81,
92
],
[
93,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
61,
98
],
[
98,
99
],
[
98,
100
],
[
61,
101
],
[
101,
102
],
[
101,
103
],
[
61,
104
],
[
104,
105
],
[
61,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
116,
125
],
[
115,
126
],
[
114,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
127,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
127,
141
],
[
141,
142
],
[
114,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
150,
154
],
[
143,
155
],
[
155,
156
],
[
109,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
108,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
165,
166
],
[
61,
167
],
[
167,
168
],
[
167,
169
],
[
167,
170
],
[
171,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
172,
177
],
[
178,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
178,
182
],
[
178,
183
],
[
183,
184
],
[
184,
185
],
[
183,
186
],
[
186,
187
],
[
187,
188
],
[
59,
189
],
[
189,
190
],
[
0,
191
],
[
191,
192
],
[
191,
193
]
] | [
"import java.util.*;\n \nclass process {\n \n private String name;\n private int time;\n \n public process(String name,int time){\n this.name = name;\n this.time = time;\n }\n \n public void setName(String name) {\n this.name = name;\n }\n \n public String getName() {\n return name;\n }\n \n public void setTime(int time) {\n this.time = time;\n }\n \n public int getTime() {\n return time;\n }\n}\n \npublic class Main {\n \n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n ArrayList<process> ar = new ArrayList<process>();\n ArrayList<process> result = new ArrayList<process>();\n \n for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }\n \n int LapsedTime = 0,i = 0;\n process p;\n \n while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }\n for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class process {\n \n private String name;\n private int time;\n \n public process(String name,int time){\n this.name = name;\n this.time = time;\n }\n \n public void setName(String name) {\n this.name = name;\n }\n \n public String getName() {\n return name;\n }\n \n public void setTime(int time) {\n this.time = time;\n }\n \n public int getTime() {\n return time;\n }\n}",
"process",
"private String name;",
"name",
"private int time;",
"time",
"public process(String name,int time){\n this.name = name;\n this.time = time;\n }",
"process",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public void setName(String name) {\n this.name = name;\n }",
"setName",
"{\n this.name = name;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"public String getName() {\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public void setTime(int time) {\n this.time = time;\n }",
"setTime",
"{\n this.time = time;\n }",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"public int getTime() {\n return time;\n }",
"getTime",
"{\n return time;\n }",
"return time;",
"time",
"public class Main {\n \n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n ArrayList<process> ar = new ArrayList<process>();\n ArrayList<process> result = new ArrayList<process>();\n \n for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }\n \n int LapsedTime = 0,i = 0;\n process p;\n \n while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }\n for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n ArrayList<process> ar = new ArrayList<process>();\n ArrayList<process> result = new ArrayList<process>();\n \n for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }\n \n int LapsedTime = 0,i = 0;\n process p;\n \n while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }\n for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }",
"main",
"{\n \n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n ArrayList<process> ar = new ArrayList<process>();\n ArrayList<process> result = new ArrayList<process>();\n \n for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }\n \n int LapsedTime = 0,i = 0;\n process p;\n \n while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }\n for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"ArrayList<process> ar = new ArrayList<process>();",
"ar",
"new ArrayList<process>()",
"ArrayList<process> result = new ArrayList<process>();",
"result",
"new ArrayList<process>()",
"for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }",
"{\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }",
"ar.add(new process(sc.next(),Integer.parseInt(sc.next())))",
"ar.add",
"ar",
"new process(sc.next(),Integer.parseInt(sc.next()))",
"int LapsedTime = 0",
"LapsedTime",
"0",
"i = 0;",
"i",
"0",
"process p;",
"p",
"while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }",
"true",
"{\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }",
"if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }",
"i < n",
"i",
"n",
"{\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n }",
"if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }",
"(p = ar.get(i)).getTime() - q <= 0",
"(p = ar.get(i)).getTime() - q",
"(p = ar.get(i)).getTime()",
"(p = ar.get(i)).getTime",
"(p = ar.get(i))",
"p",
"ar.get(i)",
"ar.get",
"ar",
"i",
"q",
"0",
"{\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n }",
"LapsedTime += p.getTime()",
"LapsedTime",
"p.getTime()",
"p.getTime",
"p",
"result.add(new process(p.getName(),LapsedTime))",
"result.add",
"result",
"new process(p.getName(),LapsedTime)",
"ar.remove(i)",
"ar.remove",
"ar",
"i",
"n--",
"n",
"{\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }",
"LapsedTime += q",
"LapsedTime",
"q",
"p.setTime(p.getTime() - q)",
"p.setTime",
"p",
"p.getTime() - q",
"p.getTime()",
"p.getTime",
"p",
"q",
"i++",
"i",
"{\n i = 0;\n }",
"i = 0",
"i",
"0",
"if (n == 0){\n break;\n }",
"n == 0",
"n",
"0",
"{\n break;\n }",
"break;",
"for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }",
"process r",
"result",
"{\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }",
"{\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }",
"System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()))",
"System.out.println",
"System.out",
"System",
"System.out",
"r.getName() + \" \" + String.valueOf(r.getTime())",
"r.getName() + \" \" + String.valueOf(r.getTime())",
"r.getName()",
"r.getName",
"r",
"\" \"",
"String.valueOf(r.getTime())",
"String.valueOf",
"String",
"r.getTime()",
"r.getTime",
"r",
"String[] args",
"args",
"public class Main {\n \n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n ArrayList<process> ar = new ArrayList<process>();\n ArrayList<process> result = new ArrayList<process>();\n \n for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }\n \n int LapsedTime = 0,i = 0;\n process p;\n \n while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }\n for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"public class Main {\n \n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n ArrayList<process> ar = new ArrayList<process>();\n ArrayList<process> result = new ArrayList<process>();\n \n for (int i = 0; i < n; i++){\n ar.add(new process(sc.next(),Integer.parseInt(sc.next())));\n }\n \n int LapsedTime = 0,i = 0;\n process p;\n \n while(true){\n if(i < n){\n if((p = ar.get(i)).getTime() - q <= 0){\n LapsedTime += p.getTime();\n result.add(new process(p.getName(),LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.setTime(p.getTime() - q);\n i++;\n }\n } else {\n i = 0;\n }\n if (n == 0){\n break;\n }\n }\n for(process r:result) {\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"Main"
] | import java.util.*;
class process {
private String name;
private int time;
public process(String name,int time){
this.name = name;
this.time = time;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setTime(int time) {
this.time = time;
}
public int getTime() {
return time;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
ArrayList<process> ar = new ArrayList<process>();
ArrayList<process> result = new ArrayList<process>();
for (int i = 0; i < n; i++){
ar.add(new process(sc.next(),Integer.parseInt(sc.next())));
}
int LapsedTime = 0,i = 0;
process p;
while(true){
if(i < n){
if((p = ar.get(i)).getTime() - q <= 0){
LapsedTime += p.getTime();
result.add(new process(p.getName(),LapsedTime));
ar.remove(i);
n--;
} else {
LapsedTime += q;
p.setTime(p.getTime() - q);
i++;
}
} else {
i = 0;
}
if (n == 0){
break;
}
}
for(process r:result) {
System.out.println(r.getName() + " " + String.valueOf(r.getTime()));
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
20,
17,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
40,
17,
37,
20,
14,
2,
13,
13,
30,
0,
13,
17,
38,
5,
13,
30,
37,
20,
30,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
29,
40,
17,
29,
18,
13,
40,
13,
12,
13,
30,
41,
13,
4,
13,
42,
4,
13,
13,
30,
0,
13,
4,
13,
41,
13,
20,
42,
40,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
41,
13,
4,
13,
42,
4,
13,
13,
0,
13,
4,
13,
41,
13,
17,
14,
2,
13,
17,
30,
0,
13,
40,
17,
0,
13,
4,
13,
41,
13,
17,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
37,
20,
0,
13,
17,
0,
13,
2,
13,
17,
0,
13,
4,
13,
29,
2,
13,
13,
12,
13,
30,
14,
2,
13,
17,
29,
4,
18,
13,
13,
29,
2,
2,
2,
2,
2,
13,
17,
2,
13,
17,
2,
13,
17,
2,
13,
17,
2,
13,
40,
17,
23,
13,
6,
13,
12,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
368,
23
],
[
368,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
26,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
26,
40
],
[
40,
41
],
[
40,
42
],
[
26,
44
],
[
44,
45
],
[
44,
46
],
[
26,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
53,
54
],
[
53,
55
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
48,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
66,
67
],
[
60,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
73,
74
],
[
26,
75
],
[
75,
76
],
[
75,
77
],
[
26,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
83,
84
],
[
83,
85
],
[
78,
86
],
[
86,
87
],
[
87,
88
],
[
78,
89
],
[
90,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
26,
95
],
[
95,
96
],
[
95,
97
],
[
26,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
98,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
103,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
115,
121
],
[
121,
122
],
[
121,
123
],
[
115,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
109,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
128,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
128,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
128,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
24,
154
],
[
154,
155
],
[
368,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
156,
160
],
[
160,
161
],
[
160,
162
],
[
156,
164
],
[
164,
165
],
[
156,
166
],
[
166,
167
],
[
156,
168
],
[
168,
169
],
[
156,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
170,
178
],
[
178,
179
],
[
156,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
183,
188
],
[
188,
189
],
[
182,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
194,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
202,
203
],
[
198,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
208,
209
],
[
207,
210
],
[
194,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
211,
215
],
[
215,
216
],
[
216,
217
],
[
182,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
221,
222
],
[
156,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
225,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
230,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
225,
239
],
[
239,
240
],
[
239,
241
],
[
225,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
242,
247
],
[
247,
248
],
[
248,
249
],
[
249,
250
],
[
248,
251
],
[
247,
252
],
[
252,
253
],
[
252,
254
],
[
254,
255
],
[
225,
256
],
[
256,
257
],
[
257,
258
],
[
258,
259
],
[
156,
260
],
[
260,
261
],
[
260,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
265,
266
],
[
262,
267
],
[
267,
268
],
[
268,
269
],
[
268,
270
],
[
267,
271
],
[
271,
272
],
[
271,
273
],
[
273,
274
],
[
262,
275
],
[
275,
276
],
[
275,
277
],
[
262,
278
],
[
278,
279
],
[
279,
280
],
[
279,
281
],
[
278,
282
],
[
282,
283
],
[
283,
284
],
[
283,
285
],
[
285,
286
],
[
282,
287
],
[
287,
288
],
[
287,
289
],
[
289,
290
],
[
262,
291
],
[
291,
292
],
[
291,
293
],
[
262,
294
],
[
294,
295
],
[
295,
296
],
[
296,
297
],
[
296,
298
],
[
294,
299
],
[
299,
300
],
[
300,
301
],
[
301,
302
],
[
302,
303
],
[
302,
304
],
[
301,
305
],
[
305,
306
],
[
305,
307
],
[
300,
308
],
[
308,
309
],
[
299,
310
],
[
310,
311
],
[
310,
312
],
[
299,
313
],
[
313,
314
],
[
313,
315
],
[
315,
316
],
[
315,
317
],
[
299,
318
],
[
318,
319
],
[
318,
320
],
[
320,
321
],
[
262,
322
],
[
322,
323
],
[
323,
324
],
[
323,
325
],
[
156,
326
],
[
326,
327
],
[
326,
328
],
[
328,
329
],
[
329,
330
],
[
330,
331
],
[
330,
332
],
[
329,
333
],
[
333,
334
],
[
334,
335
],
[
335,
336
],
[
334,
337
],
[
328,
338
],
[
338,
339
],
[
342,
340
],
[
352,
341
],
[
349,
342
],
[
342,
343
],
[
343,
344
],
[
343,
345
],
[
342,
346
],
[
346,
347
],
[
346,
348
],
[
349,
349
],
[
349,
350
],
[
349,
351
],
[
352,
352
],
[
352,
353
],
[
352,
354
],
[
342,
355
],
[
355,
356
],
[
355,
357
],
[
357,
358
],
[
326,
359
],
[
359,
360
],
[
156,
361
],
[
361,
362
],
[
361,
363
],
[
363,
364
],
[
363,
365
],
[
365,
366
],
[
0,
367
],
[
367,
368
],
[
367,
369
]
] | [
"import java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\nimport java.util.InputMismatchException;\nimport java.util.LinkedList;\nimport java.util.PriorityQueue;\n\n \npublic class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] lefttime = new int[n];\n for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }\n\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for(int i = 0; i < n; i++){\n queue.add(i);\n }\n int nowtime = 0;\n while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.InputMismatchException;",
"InputMismatchException",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.PriorityQueue;",
"PriorityQueue",
"java.util",
"public class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] lefttime = new int[n];\n for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }\n\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for(int i = 0; i < n; i++){\n queue.add(i);\n }\n int nowtime = 0;\n while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] lefttime = new int[n];\n for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }\n\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for(int i = 0; i < n; i++){\n queue.add(i);\n }\n int nowtime = 0;\n while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }\n }",
"main",
"{\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] lefttime = new int[n];\n for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }\n\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for(int i = 0; i < n; i++){\n queue.add(i);\n }\n int nowtime = 0;\n while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }\n }",
"InputReader sc = new InputReader(System.in);",
"sc",
"new InputReader(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"String[] names = new String[n];",
"names",
"new String[n]",
"n",
"int[] lefttime = new int[n];",
"lefttime",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }",
"{\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }",
"names[i] = sc.nextStr()",
"names[i]",
"names",
"i",
"sc.nextStr()",
"sc.nextStr",
"sc",
"lefttime[i] = sc.nextInt()",
"lefttime[i]",
"lefttime",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"LinkedList<Integer> queue = new LinkedList<Integer>();",
"queue",
"new LinkedList<Integer>()",
"for(int i = 0; i < n; i++){\n queue.add(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.add(i);\n }",
"{\n queue.add(i);\n }",
"queue.add(i)",
"queue.add",
"queue",
"i",
"int nowtime = 0;",
"nowtime",
"0",
"while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }",
"int nownum = queue.poll();",
"nownum",
"queue.poll()",
"queue.poll",
"queue",
"if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }",
"lefttime[nownum] > q",
"lefttime[nownum]",
"lefttime",
"nownum",
"q",
"{\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }",
"lefttime[nownum] -= q",
"lefttime[nownum]",
"lefttime",
"nownum",
"q",
"nowtime += q",
"nowtime",
"q",
"queue.add(nownum)",
"queue.add",
"queue",
"nownum",
"{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }",
"nowtime += lefttime[nownum]",
"nowtime",
"lefttime[nownum]",
"lefttime",
"nownum",
"System.out.print(names[nownum])",
"System.out.print",
"System.out",
"System",
"System.out",
"names[nownum]",
"names",
"nownum",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(nowtime)",
"System.out.println",
"System.out",
"System",
"System.out",
"nowtime",
"String[] args",
"args",
" static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }",
"InputReader",
"private InputStream stream;",
"stream",
"private byte[] buf = new byte[1024];",
"buf",
"new byte[1024]",
"1024",
"private int curChar;",
"curChar",
"private int numChars;",
"numChars",
"private SpaceCharFilter filter;",
"filter",
"public InputReader(InputStream stream) {\n this.stream = stream;\n }",
"InputReader",
"{\n this.stream = stream;\n }",
"this.stream = stream",
"this.stream",
"this",
"this.stream",
"stream",
"InputStream stream",
"stream",
"public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }",
"next",
"{\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }",
"if (numChars == -1)\n throw new InputMismatchException();",
"numChars == -1",
"numChars",
"-1",
"1",
"throw new InputMismatchException();",
"new InputMismatchException()",
"if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }",
"curChar >= numChars",
"curChar",
"numChars",
"{\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }",
"curChar = 0",
"curChar",
"0",
"try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }",
"catch (IOException e) {\n throw new InputMismatchException();\n }",
"IOException e",
"{\n throw new InputMismatchException();\n }",
"throw new InputMismatchException();",
"new InputMismatchException()",
"{\n numChars = stream.read(buf);\n }",
"numChars = stream.read(buf)",
"numChars",
"stream.read(buf)",
"stream.read",
"stream",
"buf",
"if (numChars <= 0)\n return -1;",
"numChars <= 0",
"numChars",
"0",
"return -1;",
"-1",
"1",
"return buf[curChar++];",
"buf[curChar++]",
"buf",
"curChar++",
"curChar",
"public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }",
"nextStr",
"{\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }",
"int c = next();",
"c",
"next()",
"next",
"while(isSpaceChar(c)){c = next();}",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{c = next();}",
"c = next()",
"c",
"next()",
"next",
"StringBuffer str = new StringBuffer();",
"str",
"new StringBuffer()",
"do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n str.append((char)c);\n c = next();\n }",
"str.append((char)c)",
"str.append",
"str",
"(char)c",
"c = next()",
"c",
"next()",
"next",
"return str.toString();",
"str.toString()",
"str.toString",
"str",
"public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }",
"nextInt",
"{\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }",
"int c = next();",
"c",
"next()",
"next",
"while (isSpaceChar(c))\n c = next();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c = next()",
"c",
"next()",
"next",
"int sgn = 1;",
"sgn",
"1",
"if (c == '-') {\n sgn = -1;\n c = next();\n }",
"c == '-'",
"c",
"'-'",
"{\n sgn = -1;\n c = next();\n }",
"sgn = -1",
"sgn",
"-1",
"1",
"c = next()",
"c",
"next()",
"next",
"int res = 0;",
"res",
"0",
"do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n }",
"if (c < '0' || c > '9')\n throw new InputMismatchException();",
"c < '0' || c > '9'",
"c < '0'",
"c",
"'0'",
"c > '9'",
"c",
"'9'",
"throw new InputMismatchException();",
"new InputMismatchException()",
"res *= 10",
"res",
"10",
"res += c - '0'",
"res",
"c - '0'",
"c",
"'0'",
"c = next()",
"c",
"next()",
"next",
"return res * sgn;",
"res * sgn",
"res",
"sgn",
"public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }",
"isSpaceChar",
"{\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }",
"if (filter != null)\n return filter.isSpaceChar(c);",
"filter != null",
"filter",
"null",
"return filter.isSpaceChar(c);",
"filter.isSpaceChar(c)",
"filter.isSpaceChar",
"filter",
"c",
"return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;",
"c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1",
"c == '\\t'",
"c == '\\r'",
"c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1",
"c == ' '",
"c",
"' '",
"c == '\\n'",
"c",
"'\\n'",
"c == '\\r'",
"c",
"'\\r'",
"c == '\\t'",
"c",
"'\\t'",
"c == -1",
"c",
"-1",
"1",
"int c",
"c",
"public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }",
"SpaceCharFilter",
"public boolean isSpaceChar(int ch);",
"isSpaceChar",
"int ch",
"ch",
"public class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] lefttime = new int[n];\n for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }\n\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for(int i = 0; i < n; i++){\n queue.add(i);\n }\n int nowtime = 0;\n while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n InputReader sc = new InputReader(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] lefttime = new int[n];\n for(int i = 0; i < n; i++){\n names[i] = sc.nextStr();\n lefttime[i] = sc.nextInt();\n }\n\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for(int i = 0; i < n; i++){\n queue.add(i);\n }\n int nowtime = 0;\n while(!queue.isEmpty()){\n int nownum = queue.poll();\n if(lefttime[nownum] > q){\n lefttime[nownum] -= q;\n nowtime += q;\n queue.add(nownum);\n }else{\n nowtime += lefttime[nownum];\n System.out.print(names[nownum]);\n System.out.print(\" \");\n System.out.println(nowtime);\n }\n }\n }\n \n \n// LinkedList<Integer>[] setsu = new LinkedList[n];\n// for(int i = 0; i < n; i++){\n// setsu[i] = new LinkedList<Integer>();\n// } \n\n //ここからテンプレ\n static class InputReader {\n private InputStream stream;\n private byte[] buf = new byte[1024];\n private int curChar;\n private int numChars;\n private SpaceCharFilter filter;\n\n public InputReader(InputStream stream) {\n this.stream = stream;\n }\n \n public int next() {\n if (numChars == -1)\n throw new InputMismatchException();\n if (curChar >= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n \n public String nextStr() {\n int c = next();\n while(isSpaceChar(c)){c = next();}\n StringBuffer str = new StringBuffer();\n do{\n str.append((char)c);\n c = next();\n }while(!isSpaceChar(c));\n return str.toString();\n }\n\n public int nextInt() {\n int c = next();\n while (isSpaceChar(c))\n c = next();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = next();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = next();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n \n public boolean isSpaceChar(int c) {\n if (filter != null)\n return filter.isSpaceChar(c);\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n \n public interface SpaceCharFilter {\n public boolean isSpaceChar(int ch);\n }\n }\n}",
"Main"
] | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
public class Main {
public static void main(String[] args) {
InputReader sc = new InputReader(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
String[] names = new String[n];
int[] lefttime = new int[n];
for(int i = 0; i < n; i++){
names[i] = sc.nextStr();
lefttime[i] = sc.nextInt();
}
LinkedList<Integer> queue = new LinkedList<Integer>();
for(int i = 0; i < n; i++){
queue.add(i);
}
int nowtime = 0;
while(!queue.isEmpty()){
int nownum = queue.poll();
if(lefttime[nownum] > q){
lefttime[nownum] -= q;
nowtime += q;
queue.add(nownum);
}else{
nowtime += lefttime[nownum];
System.out.print(names[nownum]);
System.out.print(" ");
System.out.println(nowtime);
}
}
}
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
// setsu[i] = new LinkedList<Integer>();
// }
//ここからテンプレ
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int next() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public String nextStr() {
int c = next();
while(isSpaceChar(c)){c = next();}
StringBuffer str = new StringBuffer();
do{
str.append((char)c);
c = next();
}while(!isSpaceChar(c));
return str.toString();
}
public int nextInt() {
int c = next();
while (isSpaceChar(c))
c = next();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = next();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = next();
} while (!isSpaceChar(c));
return res * sgn;
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
20,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
18,
13,
13,
4,
18,
13,
0,
13,
4,
18,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
40,
13,
42,
2,
13,
13,
30,
14,
2,
4,
18,
13,
18,
13,
13,
13,
30,
4,
18,
13,
18,
13,
13,
2,
4,
18,
13,
18,
13,
13,
13,
0,
18,
13,
13,
18,
13,
13,
40,
13,
40,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
40,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
20,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
20,
34
],
[
34,
35
],
[
34,
36
],
[
20,
38
],
[
38,
39
],
[
38,
40
],
[
20,
42
],
[
42,
43
],
[
42,
44
],
[
20,
45
],
[
45,
46
],
[
45,
47
],
[
20,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
51,
53
],
[
20,
54
],
[
54,
55
],
[
54,
56
],
[
20,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
62,
63
],
[
62,
64
],
[
57,
65
],
[
65,
66
],
[
66,
67
],
[
57,
68
],
[
69,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
74,
75
],
[
75,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
80,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
69,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
91,
92
],
[
91,
93
],
[
69,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
69,
101
],
[
101,
102
],
[
20,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
113,
114
],
[
113,
115
],
[
109,
116
],
[
108,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
121,
122
],
[
121,
123
],
[
118,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
128,
129
],
[
128,
130
],
[
124,
131
],
[
117,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
136,
137
],
[
136,
138
],
[
117,
139
],
[
139,
140
],
[
117,
141
],
[
141,
142
],
[
117,
143
],
[
143,
144
],
[
143,
145
],
[
108,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
152,
153
],
[
152,
154
],
[
146,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
161,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
161,
166
],
[
146,
167
],
[
167,
168
],
[
18,
169
],
[
169,
170
]
] | [
"import java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Scanner;\nimport java.util.Stack;\n\nclass Main{\n\tpublic static void main(String args[]) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tString name[]=new String[n];\n\t\t\n\t\tString queue[]=new String[1000000];\n\t\tint head=0, tail=0;\n\t\tint totaltime=0;\n\t\tint now=0;\n\t\tMap<String,Integer> time=new HashMap<String,Integer>();\n\t\t\n\t\tfor(int i=0;i<n;++i) {\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}\n\n\t\twhile(now!=totaltime) {\n\t\t\tif(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}\n\t\t}\n\t\t\n\n\t}\n}\n",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.Map;",
"Map",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Stack;",
"Stack",
"java.util",
"class Main{\n\tpublic static void main(String args[]) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tString name[]=new String[n];\n\t\t\n\t\tString queue[]=new String[1000000];\n\t\tint head=0, tail=0;\n\t\tint totaltime=0;\n\t\tint now=0;\n\t\tMap<String,Integer> time=new HashMap<String,Integer>();\n\t\t\n\t\tfor(int i=0;i<n;++i) {\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}\n\n\t\twhile(now!=totaltime) {\n\t\t\tif(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}\n\t\t}\n\t\t\n\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tString name[]=new String[n];\n\t\t\n\t\tString queue[]=new String[1000000];\n\t\tint head=0, tail=0;\n\t\tint totaltime=0;\n\t\tint now=0;\n\t\tMap<String,Integer> time=new HashMap<String,Integer>();\n\t\t\n\t\tfor(int i=0;i<n;++i) {\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}\n\n\t\twhile(now!=totaltime) {\n\t\t\tif(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}\n\t\t}\n\t\t\n\n\t}",
"main",
"{\n\t\tScanner sc=new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tString name[]=new String[n];\n\t\t\n\t\tString queue[]=new String[1000000];\n\t\tint head=0, tail=0;\n\t\tint totaltime=0;\n\t\tint now=0;\n\t\tMap<String,Integer> time=new HashMap<String,Integer>();\n\t\t\n\t\tfor(int i=0;i<n;++i) {\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}\n\n\t\twhile(now!=totaltime) {\n\t\t\tif(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}\n\t\t}\n\t\t\n\n\t}",
"Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q=sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"String name[]=new String[n];",
"name",
"new String[n]",
"n",
"String queue[]=new String[1000000];",
"queue",
"new String[1000000]",
"1000000",
"int head=0",
"head",
"0",
"tail=0;",
"tail",
"0",
"int totaltime=0;",
"totaltime",
"0",
"int now=0;",
"now",
"0",
"Map<String,Integer> time=new HashMap<String,Integer>();",
"time",
"new HashMap<String,Integer>()",
"for(int i=0;i<n;++i) {\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"++i",
"++i",
"i",
"{\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}",
"{\n\t\t\tname[i]=sc.next();\n\t\t\ttime.put(name[i],sc.nextInt());\n\t\t\ttotaltime+=time.get(name[i]);\n\t\t\tqueue[tail]=name[i];\n\t\t\t++tail;\n\t\t}",
"name[i]=sc.next()",
"name[i]",
"name",
"i",
"sc.next()",
"sc.next",
"sc",
"time.put(name[i],sc.nextInt())",
"time.put",
"time",
"name[i]",
"name",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"totaltime+=time.get(name[i])",
"totaltime",
"time.get(name[i])",
"time.get",
"time",
"name[i]",
"name",
"i",
"queue[tail]=name[i]",
"queue[tail]",
"queue",
"tail",
"name[i]",
"name",
"i",
"++tail",
"tail",
"while(now!=totaltime) {\n\t\t\tif(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}\n\t\t}",
"now!=totaltime",
"now",
"totaltime",
"{\n\t\t\tif(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}\n\t\t}",
"if(time.get(queue[head])>q) {\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}",
"time.get(queue[head])>q",
"time.get(queue[head])",
"time.get",
"time",
"queue[head]",
"queue",
"head",
"q",
"{\n\t\t\t\ttime.put(queue[head], time.get(queue[head])-q);\n\t\t\t\tqueue[tail]=queue[head];\n\t\t\t\t++head;\n\t\t\t\t++tail;\n\t\t\t\tnow+=q;\n\t\t\t}",
"time.put(queue[head], time.get(queue[head])-q)",
"time.put",
"time",
"queue[head]",
"queue",
"head",
"time.get(queue[head])-q",
"time.get(queue[head])",
"time.get",
"time",
"queue[head]",
"queue",
"head",
"q",
"queue[tail]=queue[head]",
"queue[tail]",
"queue",
"tail",
"queue[head]",
"queue",
"head",
"++head",
"head",
"++tail",
"tail",
"now+=q",
"now",
"q",
"{\n\t\t\t\tnow+=time.get(queue[head]);\n\t\t\t\tSystem.out.println(queue[head]+\" \"+now);\n\t\t\t\t++head;\n\t\t\t}",
"now+=time.get(queue[head])",
"now",
"time.get(queue[head])",
"time.get",
"time",
"queue[head]",
"queue",
"head",
"System.out.println(queue[head]+\" \"+now)",
"System.out.println",
"System.out",
"System",
"System.out",
"queue[head]+\" \"+now",
"queue[head]+\" \"+now",
"queue[head]",
"queue",
"head",
"\" \"",
"now",
"++head",
"head",
"String args[]",
"args"
] | import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
class Main{
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int q=sc.nextInt();
String name[]=new String[n];
String queue[]=new String[1000000];
int head=0, tail=0;
int totaltime=0;
int now=0;
Map<String,Integer> time=new HashMap<String,Integer>();
for(int i=0;i<n;++i) {
name[i]=sc.next();
time.put(name[i],sc.nextInt());
totaltime+=time.get(name[i]);
queue[tail]=name[i];
++tail;
}
while(now!=totaltime) {
if(time.get(queue[head])>q) {
time.put(queue[head], time.get(queue[head])-q);
queue[tail]=queue[head];
++head;
++tail;
now+=q;
}
else {
now+=time.get(queue[head]);
System.out.println(queue[head]+" "+now);
++head;
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
4,
18,
13,
13,
42,
2,
4,
18,
13,
17,
30,
14,
2,
18,
4,
18,
13,
13,
13,
30,
41,
13,
4,
18,
13,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
30,
41,
13,
4,
18,
13,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
136,
5
],
[
136,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
40,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
40,
51
],
[
51,
52
],
[
51,
53
],
[
40,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
8,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
59,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
67,
71
],
[
66,
72
],
[
65,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
73,
79
],
[
79,
80
],
[
79,
81
],
[
73,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
73,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
65,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
91,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
91,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
108,
113
],
[
6,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
116,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
128,
130
],
[
122,
131
],
[
131,
132
],
[
122,
133
],
[
133,
134
],
[
0,
135
],
[
135,
136
],
[
135,
137
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tLinkedList<Process> list=new LinkedList<Process>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}\n\t\twhile(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process{\n\tString name;\n\tint time;\n\tProcess(String a,int b){\n\t\tname=a;\n\t\ttime=b;\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tLinkedList<Process> list=new LinkedList<Process>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}\n\t\twhile(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tLinkedList<Process> list=new LinkedList<Process>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}\n\t\twhile(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tLinkedList<Process> list=new LinkedList<Process>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}\n\t\twhile(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc= new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q=sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int t=0;",
"t",
"0",
"LinkedList<Process> list=new LinkedList<Process>();",
"list",
"new LinkedList<Process>()",
"for(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}",
"{\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}",
"String ps=sc.next();",
"ps",
"sc.next()",
"sc.next",
"sc",
"int pt=sc.nextInt();",
"pt",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Process pr=new Process(ps,pt);",
"pr",
"new Process(ps,pt)",
"list.addLast(pr)",
"list.addLast",
"list",
"pr",
"while(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}",
"list.size()>0",
"list.size()",
"list.size",
"list",
"0",
"{\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}",
"if((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}",
"(list.getFirst()).time>q",
"(list.getFirst()).time",
"(list.getFirst())",
"list.getFirst",
"list",
"(list.getFirst()).time",
"q",
"{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}",
"Process x=list.poll();",
"x",
"list.poll()",
"list.poll",
"list",
"t+=q",
"t",
"q",
"x.time-=q",
"x.time",
"x",
"x.time",
"q",
"list.add(x)",
"list.add",
"list",
"x",
"{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}",
"Process x=list.poll();",
"x",
"list.poll()",
"list.poll",
"list",
"t+=x.time",
"t",
"x.time",
"x",
"x.time",
"System.out.println(x.name+\" \"+t)",
"System.out.println",
"System.out",
"System",
"System.out",
"x.name+\" \"+t",
"x.name+\" \"+t",
"x.name",
"x",
"x.name",
"\" \"",
"t",
"String[] args",
"args",
"class Process{\n\tString name;\n\tint time;\n\tProcess(String a,int b){\n\t\tname=a;\n\t\ttime=b;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String a,int b){\n\t\tname=a;\n\t\ttime=b;\n\t}",
"Process",
"{\n\t\tname=a;\n\t\ttime=b;\n\t}",
"name=a",
"name",
"a",
"time=b",
"time",
"b",
"String a",
"a",
"int b",
"b",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tLinkedList<Process> list=new LinkedList<Process>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}\n\t\twhile(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tLinkedList<Process> list=new LinkedList<Process>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString ps=sc.next();\n\t\t\tint pt=sc.nextInt();\n\t\t\tProcess pr=new Process(ps,pt);\n\t\t\tlist.addLast(pr);\n\t\t}\n\t\twhile(list.size()>0){\n\t\t\tif((list.getFirst()).time>q){\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=q;\n\t\t\t\tx.time-=q;\n\t\t\t\tlist.add(x);\t\t\t\t\n\t\t\t}else{\n\t\t\t\tProcess x=list.poll();\n\t\t\t\tt+=x.time;\n\t\t\t\tSystem.out.println(x.name+\" \"+t);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int q=sc.nextInt();
int t=0;
LinkedList<Process> list=new LinkedList<Process>();
for(int i=0;i<n;i++){
String ps=sc.next();
int pt=sc.nextInt();
Process pr=new Process(ps,pt);
list.addLast(pr);
}
while(list.size()>0){
if((list.getFirst()).time>q){
Process x=list.poll();
t+=q;
x.time-=q;
list.add(x);
}else{
Process x=list.poll();
t+=x.time;
System.out.println(x.name+" "+t);
}
}
}
}
class Process{
String name;
int time;
Process(String a,int b){
name=a;
time=b;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
2,
13,
17,
0,
13,
20,
2,
13,
17,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
14,
2,
40,
13,
2,
18,
13,
13,
17,
30,
0,
13,
17,
23,
13,
23,
13,
12,
13,
30,
14,
2,
13,
2,
18,
13,
13,
17,
30,
0,
13,
17,
29,
2,
18,
13,
13,
17,
29,
40,
13,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
18,
13,
13,
23,
13,
12,
13,
30,
29,
18,
13,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
20,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
2,
2,
18,
13,
17,
17,
13,
17,
30,
0,
13,
13,
4,
18,
13,
18,
13,
17,
2,
13,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
41,
13,
4,
18,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
2,
2,
13,
17,
13,
17,
30,
0,
13,
13,
4,
18,
13,
13,
2,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
7,
15
],
[
15,
16
],
[
7,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
23,
24
],
[
23,
25
],
[
19,
26
],
[
26,
27
],
[
26,
28
],
[
29,
30
],
[
29,
31
],
[
17,
32
],
[
32,
33
],
[
7,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
36,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
36,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
47,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
34,
60
],
[
60,
61
],
[
34,
62
],
[
62,
63
],
[
7,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
66,
85
],
[
85,
86
],
[
86,
87
],
[
7,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
7,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
95,
102
],
[
102,
103
],
[
7,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
104,
111
],
[
111,
112
],
[
0,
113
],
[
279,
114
],
[
279,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
123,
128
],
[
117,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
134,
136
],
[
117,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
142,
143
],
[
142,
144
],
[
117,
145
],
[
145,
146
],
[
145,
147
],
[
117,
148
],
[
148,
149
],
[
148,
150
],
[
117,
151
],
[
151,
152
],
[
151,
153
],
[
117,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
159,
160
],
[
159,
161
],
[
154,
162
],
[
162,
163
],
[
163,
164
],
[
154,
165
],
[
166,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
169,
174
],
[
166,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
177,
180
],
[
180,
181
],
[
180,
182
],
[
166,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
191,
192
],
[
192,
193
],
[
191,
194
],
[
196,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
196,
200
],
[
195,
201
],
[
196,
202
],
[
183,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
207,
208
],
[
208,
209
],
[
207,
210
],
[
210,
211
],
[
210,
212
],
[
207,
213
],
[
213,
214
],
[
213,
215
],
[
117,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
216,
221
],
[
221,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
225,
226
],
[
221,
227
],
[
227,
228
],
[
227,
229
],
[
229,
230
],
[
230,
231
],
[
229,
232
],
[
221,
233
],
[
233,
234
],
[
233,
235
],
[
235,
236
],
[
236,
237
],
[
235,
238
],
[
221,
239
],
[
239,
240
],
[
240,
241
],
[
240,
242
],
[
239,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
243,
247
],
[
247,
248
],
[
248,
249
],
[
247,
250
],
[
252,
251
],
[
251,
252
],
[
252,
253
],
[
252,
254
],
[
251,
255
],
[
252,
256
],
[
239,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
257,
261
],
[
261,
262
],
[
262,
263
],
[
261,
264
],
[
261,
265
],
[
265,
266
],
[
265,
267
],
[
117,
268
],
[
268,
269
],
[
269,
270
],
[
270,
271
],
[
270,
272
],
[
268,
273
],
[
273,
274
],
[
274,
275
],
[
115,
276
],
[
276,
277
],
[
0,
278
],
[
278,
279
],
[
278,
280
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\nclass Queue {\n\n\tprivate String[] names;\n\tprivate int[] times;\n\tprivate int head;\n\tprivate int tail;\n\tpublic Queue(int size) {\n\t\tnames = new String[size + 1];\n\t\ttimes = new int[size + 1];\n\t}\n\n\tpublic void enqueue(String name, int time) {\n\t\tnames[tail] = name;\n\t\ttimes[tail] = time;\n\t\tif (tail++ == names.length - 1) {\n\t\t\ttail = 0;\n\t\t}\n\t}\n\n\tpublic int dequeue() {\n\t\tif (head == names.length - 1) {\n\t\t\thead = 0;\n\t\t\treturn names.length - 1;\n\t\t}\n\t\treturn head++;\n\t}\n\n\tpublic boolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\n\tpublic String getName(int index) {\n\t\treturn names[index];\n\t}\n\n\tpublic int getTime(int index) {\n\t\treturn times[index];\n\t}\n}\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] strs = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(strs[0]);\n\t\tint q = Integer.parseInt(strs[1]);\n\t\tQueue queue = new Queue(n);\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint sumTime = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"class Queue {\n\n\tprivate String[] names;\n\tprivate int[] times;\n\tprivate int head;\n\tprivate int tail;\n\tpublic Queue(int size) {\n\t\tnames = new String[size + 1];\n\t\ttimes = new int[size + 1];\n\t}\n\n\tpublic void enqueue(String name, int time) {\n\t\tnames[tail] = name;\n\t\ttimes[tail] = time;\n\t\tif (tail++ == names.length - 1) {\n\t\t\ttail = 0;\n\t\t}\n\t}\n\n\tpublic int dequeue() {\n\t\tif (head == names.length - 1) {\n\t\t\thead = 0;\n\t\t\treturn names.length - 1;\n\t\t}\n\t\treturn head++;\n\t}\n\n\tpublic boolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\n\tpublic String getName(int index) {\n\t\treturn names[index];\n\t}\n\n\tpublic int getTime(int index) {\n\t\treturn times[index];\n\t}\n}",
"Queue",
"private String[] names;",
"names",
"private int[] times;",
"times",
"private int head;",
"head",
"private int tail;",
"tail",
"public Queue(int size) {\n\t\tnames = new String[size + 1];\n\t\ttimes = new int[size + 1];\n\t}",
"Queue",
"{\n\t\tnames = new String[size + 1];\n\t\ttimes = new int[size + 1];\n\t}",
"names = new String[size + 1]",
"names",
"new String[size + 1]",
"size + 1",
"size",
"1",
"times = new int[size + 1]",
"times",
"new int[size + 1]",
"size + 1",
"size",
"1",
"int size",
"size",
"public void enqueue(String name, int time) {\n\t\tnames[tail] = name;\n\t\ttimes[tail] = time;\n\t\tif (tail++ == names.length - 1) {\n\t\t\ttail = 0;\n\t\t}\n\t}",
"enqueue",
"{\n\t\tnames[tail] = name;\n\t\ttimes[tail] = time;\n\t\tif (tail++ == names.length - 1) {\n\t\t\ttail = 0;\n\t\t}\n\t}",
"names[tail] = name",
"names[tail]",
"names",
"tail",
"name",
"times[tail] = time",
"times[tail]",
"times",
"tail",
"time",
"if (tail++ == names.length - 1) {\n\t\t\ttail = 0;\n\t\t}",
"tail++ == names.length - 1",
"tail++",
"tail",
"names.length - 1",
"names.length",
"names",
"names.length",
"1",
"{\n\t\t\ttail = 0;\n\t\t}",
"tail = 0",
"tail",
"0",
"String name",
"name",
"int time",
"time",
"public int dequeue() {\n\t\tif (head == names.length - 1) {\n\t\t\thead = 0;\n\t\t\treturn names.length - 1;\n\t\t}\n\t\treturn head++;\n\t}",
"dequeue",
"{\n\t\tif (head == names.length - 1) {\n\t\t\thead = 0;\n\t\t\treturn names.length - 1;\n\t\t}\n\t\treturn head++;\n\t}",
"if (head == names.length - 1) {\n\t\t\thead = 0;\n\t\t\treturn names.length - 1;\n\t\t}",
"head == names.length - 1",
"head",
"names.length - 1",
"names.length",
"names",
"names.length",
"1",
"{\n\t\t\thead = 0;\n\t\t\treturn names.length - 1;\n\t\t}",
"head = 0",
"head",
"0",
"return names.length - 1;",
"names.length - 1",
"names.length",
"names",
"names.length",
"1",
"return head++;",
"head++",
"head",
"public boolean isEmpty() {\n\t\treturn head == tail;\n\t}",
"isEmpty",
"{\n\t\treturn head == tail;\n\t}",
"return head == tail;",
"head == tail",
"head",
"tail",
"public String getName(int index) {\n\t\treturn names[index];\n\t}",
"getName",
"{\n\t\treturn names[index];\n\t}",
"return names[index];",
"names[index]",
"names",
"index",
"int index",
"index",
"public int getTime(int index) {\n\t\treturn times[index];\n\t}",
"getTime",
"{\n\t\treturn times[index];\n\t}",
"return times[index];",
"times[index]",
"times",
"index",
"int index",
"index",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] strs = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(strs[0]);\n\t\tint q = Integer.parseInt(strs[1]);\n\t\tQueue queue = new Queue(n);\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint sumTime = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] strs = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(strs[0]);\n\t\tint q = Integer.parseInt(strs[1]);\n\t\tQueue queue = new Queue(n);\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint sumTime = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] strs = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(strs[0]);\n\t\tint q = Integer.parseInt(strs[1]);\n\t\tQueue queue = new Queue(n);\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint sumTime = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] strs = br.readLine().split(\" \");",
"strs",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(strs[0]);",
"n",
"Integer.parseInt(strs[0])",
"Integer.parseInt",
"Integer",
"strs[0]",
"strs",
"0",
"int q = Integer.parseInt(strs[1]);",
"q",
"Integer.parseInt(strs[1])",
"Integer.parseInt",
"Integer",
"strs[1]",
"strs",
"1",
"Queue queue = new Queue(n);",
"queue",
"new Queue(n)",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int sumTime = 0;",
"sumTime",
"0",
"for (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}",
"{\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}",
"strs = br.readLine().split(\" \")",
"strs",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int time = Integer.parseInt(strs[1]);",
"time",
"Integer.parseInt(strs[1])",
"Integer.parseInt",
"Integer",
"strs[1]",
"strs",
"1",
"if (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t}",
"sumTime += time",
"sumTime",
"time",
"sb.append(strs[0] + \" \" + sumTime + \"\\n\")",
"sb.append",
"sb",
"strs[0] + \" \" + sumTime + \"\\n\"",
"sumTime",
"strs[0] + \" \" + sumTime + \"\\n\"",
"strs[0]",
"strs",
"0",
"\" \"",
"sumTime",
"\"\\n\"",
"{\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}",
"sumTime += q",
"sumTime",
"q",
"queue.enqueue(strs[0], time - q)",
"queue.enqueue",
"queue",
"strs[0]",
"strs",
"0",
"time - q",
"time",
"q",
"while (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}",
"int entryIdx = queue.dequeue();",
"entryIdx",
"queue.dequeue()",
"queue.dequeue",
"queue",
"String name = queue.getName(entryIdx);",
"name",
"queue.getName(entryIdx)",
"queue.getName",
"queue",
"entryIdx",
"int time = queue.getTime(entryIdx);",
"time",
"queue.getTime(entryIdx)",
"queue.getTime",
"queue",
"entryIdx",
"if (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t}",
"sumTime += time",
"sumTime",
"time",
"sb.append(name + \" \" + sumTime + \"\\n\")",
"sb.append",
"sb",
"name + \" \" + sumTime + \"\\n\"",
"sumTime",
"name + \" \" + sumTime + \"\\n\"",
"name",
"\" \"",
"sumTime",
"\"\\n\"",
"{\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}",
"sumTime += \tq",
"sumTime",
"q",
"queue.enqueue(name, time - q)",
"queue.enqueue",
"queue",
"name",
"time - q",
"time",
"q",
"System.out.print(sb.toString())",
"System.out.print",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] strs = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(strs[0]);\n\t\tint q = Integer.parseInt(strs[1]);\n\t\tQueue queue = new Queue(n);\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint sumTime = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] strs = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(strs[0]);\n\t\tint q = Integer.parseInt(strs[1]);\n\t\tQueue queue = new Queue(n);\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint sumTime = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tstrs = br.readLine().split(\" \");\n\t\t\tint time = Integer.parseInt(strs[1]);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(strs[0] + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += q;\n\t\t\t\tqueue.enqueue(strs[0], time - q);\n\t\t\t}\n\t\t}\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint entryIdx = queue.dequeue();\n\t\t\tString name = queue.getName(entryIdx);\n\t\t\tint time = queue.getTime(entryIdx);\n\t\t\tif (time <= q) {\n\t\t\t\tsumTime += time;\n\t\t\t\tsb.append(name + \" \" + sumTime + \"\\n\");\n\t\t\t} else {\n\t\t\t\tsumTime += \tq;\n\t\t\t\tqueue.enqueue(name, time - q);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
class Queue {
private String[] names;
private int[] times;
private int head;
private int tail;
public Queue(int size) {
names = new String[size + 1];
times = new int[size + 1];
}
public void enqueue(String name, int time) {
names[tail] = name;
times[tail] = time;
if (tail++ == names.length - 1) {
tail = 0;
}
}
public int dequeue() {
if (head == names.length - 1) {
head = 0;
return names.length - 1;
}
return head++;
}
public boolean isEmpty() {
return head == tail;
}
public String getName(int index) {
return names[index];
}
public int getTime(int index) {
return times[index];
}
}
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] strs = br.readLine().split(" ");
int n = Integer.parseInt(strs[0]);
int q = Integer.parseInt(strs[1]);
Queue queue = new Queue(n);
StringBuilder sb = new StringBuilder();
int sumTime = 0;
for (int i = 0; i < n; i++) {
strs = br.readLine().split(" ");
int time = Integer.parseInt(strs[1]);
if (time <= q) {
sumTime += time;
sb.append(strs[0] + " " + sumTime + "\n");
} else {
sumTime += q;
queue.enqueue(strs[0], time - q);
}
}
while (!queue.isEmpty()) {
int entryIdx = queue.dequeue();
String name = queue.getName(entryIdx);
int time = queue.getTime(entryIdx);
if (time <= q) {
sumTime += time;
sb.append(name + " " + sumTime + "\n");
} else {
sumTime += q;
queue.enqueue(name, time - q);
}
}
System.out.print(sb.toString());
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
2,
18,
13,
13,
13,
17,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
4,
13,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
150,
11
],
[
150,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
17,
19
],
[
14,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
20,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
25,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
32,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
39,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
39,
53
],
[
53,
54
],
[
53,
55
],
[
31,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
59,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
68,
73
],
[
12,
74
],
[
74,
75
],
[
12,
76
],
[
76,
77
],
[
150,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
80,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
80,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
80,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
102,
103
],
[
102,
104
],
[
97,
105
],
[
105,
106
],
[
106,
107
],
[
97,
108
],
[
109,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
80,
114
],
[
114,
115
],
[
114,
116
],
[
114,
117
],
[
80,
118
],
[
118,
119
],
[
119,
120
],
[
78,
121
],
[
121,
122
],
[
0,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
123,
127
],
[
127,
128
],
[
123,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
131,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
129,
142
],
[
142,
143
],
[
129,
144
],
[
144,
145
],
[
123,
146
],
[
146,
147
],
[
146,
148
],
[
0,
149
],
[
149,
150
],
[
149,
151
]
] | [
"import java.util.Scanner;\nimport java.util.Queue;\nimport java.util.LinkedList;\n\n// ALDS1_3_B\npublic class Main {\n\tpublic static void calc(Queue<Info> qu, int q) {\n\t\tInfo info;\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Info> qu = new LinkedList<Info>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}\n\t\tcalc(qu, q);\n\t\tsc.close();\n\t}\n}\n\nclass Info {\n\tString name;\n\tint time;\n\tInfo(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tInfo() {}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"public class Main {\n\tpublic static void calc(Queue<Info> qu, int q) {\n\t\tInfo info;\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Info> qu = new LinkedList<Info>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}\n\t\tcalc(qu, q);\n\t\tsc.close();\n\t}\n}",
"Main",
"public static void calc(Queue<Info> qu, int q) {\n\t\tInfo info;\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"calc",
"{\n\t\tInfo info;\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"Info info;",
"info",
"int time = 0;",
"time",
"0",
"while (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}",
"!qu.isEmpty()",
"qu.isEmpty()",
"qu.isEmpty",
"qu",
"{\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}",
"info = qu.remove()",
"info",
"qu.remove()",
"qu.remove",
"qu",
"if (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}",
"info.time - q > 0",
"info.time - q",
"info.time",
"info",
"info.time",
"q",
"0",
"{\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t}",
"info.time = info.time - q",
"info.time",
"info",
"info.time",
"info.time - q",
"info.time",
"info",
"info.time",
"q",
"qu.add(info)",
"qu.add",
"qu",
"info",
"time += q",
"time",
"q",
"{\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}",
"time += info.time",
"time",
"info.time",
"info",
"info.time",
"System.out.println(info.name + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"info.name + \" \" + time",
"info.name + \" \" + time",
"info.name",
"info",
"info.name",
"\" \"",
"time",
"Queue<Info> qu",
"qu",
"int q",
"q",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Info> qu = new LinkedList<Info>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}\n\t\tcalc(qu, q);\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Info> qu = new LinkedList<Info>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}\n\t\tcalc(qu, q);\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<Info> qu = new LinkedList<Info>();",
"qu",
"new LinkedList<Info>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}",
"{\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}",
"qu.add(new Info(sc.next(), sc.nextInt()))",
"qu.add",
"qu",
"new Info(sc.next(), sc.nextInt())",
"calc(qu, q)",
"calc",
"qu",
"q",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"class Info {\n\tString name;\n\tint time;\n\tInfo(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tInfo() {}\n}",
"Info",
"String name;",
"name",
"int time;",
"time",
"Info(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Info",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"Info() {}",
"Info",
"{}",
"public class Main {\n\tpublic static void calc(Queue<Info> qu, int q) {\n\t\tInfo info;\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Info> qu = new LinkedList<Info>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}\n\t\tcalc(qu, q);\n\t\tsc.close();\n\t}\n}",
"public class Main {\n\tpublic static void calc(Queue<Info> qu, int q) {\n\t\tInfo info;\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tinfo = qu.remove();\n\t\t\tif (info.time - q > 0) {\n\t\t\t\tinfo.time = info.time - q;\n\t\t\t\tqu.add(info);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += info.time;\n\t\t\t\tSystem.out.println(info.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Info> qu = new LinkedList<Info>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqu.add(new Info(sc.next(), sc.nextInt()));\n\t\t}\n\t\tcalc(qu, q);\n\t\tsc.close();\n\t}\n}",
"Main"
] | import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
// ALDS1_3_B
public class Main {
public static void calc(Queue<Info> qu, int q) {
Info info;
int time = 0;
while (!qu.isEmpty()) {
info = qu.remove();
if (info.time - q > 0) {
info.time = info.time - q;
qu.add(info);
time += q;
} else {
time += info.time;
System.out.println(info.name + " " + time);
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Queue<Info> qu = new LinkedList<Info>();
int n = sc.nextInt();
int q = sc.nextInt();
for (int i = 0; i < n; i++) {
qu.add(new Info(sc.next(), sc.nextInt()));
}
calc(qu, q);
sc.close();
}
}
class Info {
String name;
int time;
Info(String name, int time) {
this.name = name;
this.time = time;
}
Info() {}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
0,
18,
36,
13,
4,
18,
13,
0,
18,
36,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
18,
36,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
17,
14,
2,
18,
13,
13,
18,
36,
13,
30,
0,
18,
13,
13,
2,
13,
18,
13,
13,
4,
18,
13,
20,
0,
13,
18,
13,
13,
30,
0,
18,
13,
13,
18,
36,
13,
4,
18,
13,
20,
0,
13,
18,
36,
13,
4,
18,
13,
17,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
12,
13,
30,
41,
13,
20,
4,
18,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
7,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
17,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
17,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
28,
32
],
[
15,
33
],
[
33,
34
],
[
15,
35
],
[
35,
36
],
[
15,
37
],
[
37,
38
],
[
0,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
39,
43
],
[
43,
44
],
[
39,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
47,
65
],
[
65,
66
],
[
65,
67
],
[
47,
68
],
[
68,
69
],
[
68,
70
],
[
47,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
71,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
78,
80
],
[
71,
81
],
[
81,
82
],
[
82,
83
],
[
71,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
47,
90
],
[
90,
91
],
[
90,
92
],
[
47,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
93,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
98,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
110,
111
],
[
110,
112
],
[
105,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
113,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
113,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
129,
131
],
[
105,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
137,
138
],
[
137,
139
],
[
132,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
132,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
146,
148
],
[
98,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
47,
153
],
[
153,
154
],
[
153,
155
],
[
153,
156
],
[
157,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
164,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
164,
169
],
[
169,
170
],
[
169,
171
],
[
39,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
174,
178
],
[
178,
179
],
[
179,
180
],
[
172,
181
],
[
181,
182
]
] | [
"import java.util.ArrayList;\nimport java.util.Scanner;\n\nclass Process {\n String name;\n int time;\n int finishTime;\n\n Process(String name, int time, int finishTime) {\n this.name = name;\n this.time = time;\n this.finishTime = finishTime;\n }\n}\n\nclass Main {\n\n int size;\n int quantum;\n\n public void go() {\n Scanner sc = new Scanner(System.in);\n this.size = sc.nextInt();\n this.quantum = sc.nextInt();\n ArrayList<Process> list = new ArrayList<Process>();\n ArrayList<Process> finishList = new ArrayList<Process>();\n for (int i = 0; i < this.size; i++) {\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }\n\n int time = 0;\n while (!list.isEmpty()) {\n Process currentProcess = list.get(0);\n // finish\n if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }\n list.remove(0);\n }\n for (Process process : finishList) {\n System.out.println(process.name + \" \" + process.finishTime);\n }\n }\n\n public static void main(String[] args) {\n Main cui = new Main();\n cui.go();\n }\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Process {\n String name;\n int time;\n int finishTime;\n\n Process(String name, int time, int finishTime) {\n this.name = name;\n this.time = time;\n this.finishTime = finishTime;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"int finishTime;",
"finishTime",
"Process(String name, int time, int finishTime) {\n this.name = name;\n this.time = time;\n this.finishTime = finishTime;\n }",
"Process",
"{\n this.name = name;\n this.time = time;\n this.finishTime = finishTime;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"this.finishTime = finishTime",
"this.finishTime",
"this",
"this.finishTime",
"finishTime",
"String name",
"name",
"int time",
"time",
"int finishTime",
"finishTime",
"class Main {\n\n int size;\n int quantum;\n\n public void go() {\n Scanner sc = new Scanner(System.in);\n this.size = sc.nextInt();\n this.quantum = sc.nextInt();\n ArrayList<Process> list = new ArrayList<Process>();\n ArrayList<Process> finishList = new ArrayList<Process>();\n for (int i = 0; i < this.size; i++) {\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }\n\n int time = 0;\n while (!list.isEmpty()) {\n Process currentProcess = list.get(0);\n // finish\n if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }\n list.remove(0);\n }\n for (Process process : finishList) {\n System.out.println(process.name + \" \" + process.finishTime);\n }\n }\n\n public static void main(String[] args) {\n Main cui = new Main();\n cui.go();\n }\n}",
"Main",
"int size;",
"size",
"int quantum;",
"quantum",
"public void go() {\n Scanner sc = new Scanner(System.in);\n this.size = sc.nextInt();\n this.quantum = sc.nextInt();\n ArrayList<Process> list = new ArrayList<Process>();\n ArrayList<Process> finishList = new ArrayList<Process>();\n for (int i = 0; i < this.size; i++) {\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }\n\n int time = 0;\n while (!list.isEmpty()) {\n Process currentProcess = list.get(0);\n // finish\n if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }\n list.remove(0);\n }\n for (Process process : finishList) {\n System.out.println(process.name + \" \" + process.finishTime);\n }\n }",
"go",
"{\n Scanner sc = new Scanner(System.in);\n this.size = sc.nextInt();\n this.quantum = sc.nextInt();\n ArrayList<Process> list = new ArrayList<Process>();\n ArrayList<Process> finishList = new ArrayList<Process>();\n for (int i = 0; i < this.size; i++) {\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }\n\n int time = 0;\n while (!list.isEmpty()) {\n Process currentProcess = list.get(0);\n // finish\n if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }\n list.remove(0);\n }\n for (Process process : finishList) {\n System.out.println(process.name + \" \" + process.finishTime);\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"this.size = sc.nextInt()",
"this.size",
"this",
"this.size",
"sc.nextInt()",
"sc.nextInt",
"sc",
"this.quantum = sc.nextInt()",
"this.quantum",
"this",
"this.quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"ArrayList<Process> list = new ArrayList<Process>();",
"list",
"new ArrayList<Process>()",
"ArrayList<Process> finishList = new ArrayList<Process>();",
"finishList",
"new ArrayList<Process>()",
"for (int i = 0; i < this.size; i++) {\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < this.size",
"i",
"this.size",
"this",
"this.size",
"i++",
"i++",
"i",
"{\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }",
"{\n list.add(new Process(sc.next(), sc.nextInt(), 0));\n }",
"list.add(new Process(sc.next(), sc.nextInt(), 0))",
"list.add",
"list",
"new Process(sc.next(), sc.nextInt(), 0)",
"int time = 0;",
"time",
"0",
"while (!list.isEmpty()) {\n Process currentProcess = list.get(0);\n // finish\n if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }\n list.remove(0);\n }",
"!list.isEmpty()",
"list.isEmpty()",
"list.isEmpty",
"list",
"{\n Process currentProcess = list.get(0);\n // finish\n if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }\n list.remove(0);\n }",
"Process currentProcess = list.get(0);",
"currentProcess",
"list.get(0)",
"list.get",
"list",
"0",
"if (currentProcess.time <= this.quantum) {\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n } else {\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }",
"currentProcess.time <= this.quantum",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"this.quantum",
"this",
"this.quantum",
"{\n currentProcess.finishTime = time + currentProcess.time;\n finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += currentProcess.time;\n }",
"currentProcess.finishTime = time + currentProcess.time",
"currentProcess.finishTime",
"currentProcess",
"currentProcess.finishTime",
"time + currentProcess.time",
"time",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime))",
"finishList.add",
"finishList",
"new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime)",
"time += currentProcess.time",
"time",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"{\n currentProcess.time -= this.quantum;\n list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));\n time += this.quantum;\n }",
"currentProcess.time -= this.quantum",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"this.quantum",
"this",
"this.quantum",
"list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime))",
"list.add",
"list",
"new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime)",
"time += this.quantum",
"time",
"this.quantum",
"this",
"this.quantum",
"list.remove(0)",
"list.remove",
"list",
"0",
"for (Process process : finishList) {\n System.out.println(process.name + \" \" + process.finishTime);\n }",
"Process process",
"finishList",
"{\n System.out.println(process.name + \" \" + process.finishTime);\n }",
"{\n System.out.println(process.name + \" \" + process.finishTime);\n }",
"System.out.println(process.name + \" \" + process.finishTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + process.finishTime",
"process.name + \" \" + process.finishTime",
"process.name",
"process",
"process.name",
"\" \"",
"process.finishTime",
"process",
"process.finishTime",
"public static void main(String[] args) {\n Main cui = new Main();\n cui.go();\n }",
"main",
"{\n Main cui = new Main();\n cui.go();\n }",
"Main cui = new Main();",
"cui",
"new Main()",
"cui.go()",
"cui.go",
"cui",
"String[] args",
"args"
] | import java.util.ArrayList;
import java.util.Scanner;
class Process {
String name;
int time;
int finishTime;
Process(String name, int time, int finishTime) {
this.name = name;
this.time = time;
this.finishTime = finishTime;
}
}
class Main {
int size;
int quantum;
public void go() {
Scanner sc = new Scanner(System.in);
this.size = sc.nextInt();
this.quantum = sc.nextInt();
ArrayList<Process> list = new ArrayList<Process>();
ArrayList<Process> finishList = new ArrayList<Process>();
for (int i = 0; i < this.size; i++) {
list.add(new Process(sc.next(), sc.nextInt(), 0));
}
int time = 0;
while (!list.isEmpty()) {
Process currentProcess = list.get(0);
// finish
if (currentProcess.time <= this.quantum) {
currentProcess.finishTime = time + currentProcess.time;
finishList.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));
time += currentProcess.time;
} else {
currentProcess.time -= this.quantum;
list.add(new Process(currentProcess.name, currentProcess.time, currentProcess.finishTime));
time += this.quantum;
}
list.remove(0);
}
for (Process process : finishList) {
System.out.println(process.name + " " + process.finishTime);
}
}
public static void main(String[] args) {
Main cui = new Main();
cui.go();
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
12,
13,
30,
4,
18,
20,
23,
13,
12,
13,
30,
0,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
40,
17,
0,
13,
20,
17,
12,
13,
30,
40,
13,
0,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
40,
13,
29,
13,
12,
13,
30,
29,
2,
13,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
4,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
188,
5
],
[
188,
6
],
[
6,
7
],
[
188,
8
],
[
8,
9
],
[
8,
10
],
[
188,
11
],
[
11,
12
],
[
11,
13
],
[
13,
14
],
[
14,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
188,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
21,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
21,
35
],
[
35,
36
],
[
35,
37
],
[
21,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
21,
58
],
[
58,
59
],
[
58,
60
],
[
21,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
61,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
66,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
90,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
90,
95
],
[
72,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
96,
102
],
[
102,
103
],
[
102,
104
],
[
96,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
0,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
109,
113
],
[
113,
114
],
[
109,
115
],
[
115,
116
],
[
109,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
119,
127
],
[
127,
128
],
[
127,
129
],
[
109,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
131,
141
],
[
141,
142
],
[
109,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
148,
150
],
[
145,
151
],
[
151,
152
],
[
145,
153
],
[
153,
154
],
[
109,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
0,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
162,
166
],
[
166,
167
],
[
162,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
170,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
170,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
168,
183
],
[
183,
184
],
[
168,
185
],
[
185,
186
],
[
0,
187
],
[
187,
188
],
[
187,
189
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n public Main() {\n }\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }\n\n }\n}\n\nclass MyQueue {\n private int top;\n private int tail;\n private Object[] arr;\n\n public MyQueue() {\n top = 0;\n tail = -1;\n arr = new Object[1000000];\n }\n\n public void enqueue(Object o) {\n tail++;\n arr[tail] = o;\n }\n\n public Object dequeue() {\n Object r = arr[top];\n top++;\n return r;\n }\n\n public boolean isEmpty() {\n return top > tail;\n }\n}\n\nclass Query {\n String name;\n int time;\n\n public Query(String name, int time) {\n super();\n this.name = name;\n this.time = time;\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public Main() {\n }\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }\n\n }\n}",
"Main",
"private Scanner sc;",
"sc",
"public Main() {\n }",
"Main",
"{\n }",
"public static void main(String[] args) {\n new Main().solve();\n }",
"main",
"{\n new Main().solve();\n }",
"new Main().solve()",
"new Main().solve",
"new Main()",
"String[] args",
"args",
"private void solve() {\n sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }\n\n }",
"solve",
"{\n sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }\n\n }",
"sc = new Scanner(System.in)",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"MyQueue queue = new MyQueue();",
"queue",
"new MyQueue()",
"for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }",
"{\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }",
"Query qry = new Query(sc.next(), sc.nextInt());",
"qry",
"new Query(sc.next(), sc.nextInt())",
"queue.enqueue(qry)",
"queue.enqueue",
"queue",
"qry",
"int sum = 0;",
"sum",
"0",
"while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }",
"Query now = (Query) queue.dequeue();",
"now",
"(Query) queue.dequeue()",
"queue.dequeue",
"queue",
"if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }",
"now.time <= q",
"now.time",
"now",
"now.time",
"q",
"{\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n }",
"sum += now.time",
"sum",
"now.time",
"now",
"now.time",
"System.out.println(now.name + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"now.name + \" \" + sum",
"now.name + \" \" + sum",
"now.name",
"now",
"now.name",
"\" \"",
"sum",
"{\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }",
"now.time -= q",
"now.time",
"now",
"now.time",
"q",
"sum += q",
"sum",
"q",
"queue.enqueue(now)",
"queue.enqueue",
"queue",
"now",
"class MyQueue {\n private int top;\n private int tail;\n private Object[] arr;\n\n public MyQueue() {\n top = 0;\n tail = -1;\n arr = new Object[1000000];\n }\n\n public void enqueue(Object o) {\n tail++;\n arr[tail] = o;\n }\n\n public Object dequeue() {\n Object r = arr[top];\n top++;\n return r;\n }\n\n public boolean isEmpty() {\n return top > tail;\n }\n}",
"MyQueue",
"private int top;",
"top",
"private int tail;",
"tail",
"private Object[] arr;",
"arr",
"public MyQueue() {\n top = 0;\n tail = -1;\n arr = new Object[1000000];\n }",
"MyQueue",
"{\n top = 0;\n tail = -1;\n arr = new Object[1000000];\n }",
"top = 0",
"top",
"0",
"tail = -1",
"tail",
"-1",
"1",
"arr = new Object[1000000]",
"arr",
"new Object[1000000]",
"1000000",
"public void enqueue(Object o) {\n tail++;\n arr[tail] = o;\n }",
"enqueue",
"{\n tail++;\n arr[tail] = o;\n }",
"tail++",
"tail",
"arr[tail] = o",
"arr[tail]",
"arr",
"tail",
"o",
"Object o",
"o",
"public Object dequeue() {\n Object r = arr[top];\n top++;\n return r;\n }",
"dequeue",
"{\n Object r = arr[top];\n top++;\n return r;\n }",
"Object r = arr[top];",
"r",
"arr[top]",
"arr",
"top",
"top++",
"top",
"return r;",
"r",
"public boolean isEmpty() {\n return top > tail;\n }",
"isEmpty",
"{\n return top > tail;\n }",
"return top > tail;",
"top > tail",
"top",
"tail",
"class Query {\n String name;\n int time;\n\n public Query(String name, int time) {\n super();\n this.name = name;\n this.time = time;\n }\n}",
"Query",
"String name;",
"name",
"int time;",
"time",
"public Query(String name, int time) {\n super();\n this.name = name;\n this.time = time;\n }",
"Query",
"{\n super();\n this.name = name;\n this.time = time;\n }",
"super()",
"super",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n public Main() {\n }\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }\n\n }\n}",
"public class Main {\n\n public Main() {\n }\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n Query qry = new Query(sc.next(), sc.nextInt());\n queue.enqueue(qry);\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n Query now = (Query) queue.dequeue();\n if (now.time <= q) {\n sum += now.time;\n System.out.println(now.name + \" \" + sum);\n } else {\n now.time -= q;\n sum += q;\n queue.enqueue(now);\n }\n }\n\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public Main() {
}
private Scanner sc;
public static void main(String[] args) {
new Main().solve();
}
private void solve() {
sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
MyQueue queue = new MyQueue();
for (int i = 0; i < n; i++) {
Query qry = new Query(sc.next(), sc.nextInt());
queue.enqueue(qry);
}
int sum = 0;
while (!queue.isEmpty()) {
Query now = (Query) queue.dequeue();
if (now.time <= q) {
sum += now.time;
System.out.println(now.name + " " + sum);
} else {
now.time -= q;
sum += q;
queue.enqueue(now);
}
}
}
}
class MyQueue {
private int top;
private int tail;
private Object[] arr;
public MyQueue() {
top = 0;
tail = -1;
arr = new Object[1000000];
}
public void enqueue(Object o) {
tail++;
arr[tail] = o;
}
public Object dequeue() {
Object r = arr[top];
top++;
return r;
}
public boolean isEmpty() {
return top > tail;
}
}
class Query {
String name;
int time;
public Query(String name, int time) {
super();
this.name = name;
this.time = time;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
4,
13,
4,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
13,
13,
4,
13,
13,
41,
13,
17,
11,
1,
30,
30,
41,
13,
4,
13,
41,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
2,
13,
13,
4,
13,
13,
4,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
17,
13,
4,
18,
18,
13,
13,
17,
13,
14,
2,
4,
13,
4,
13,
3,
23,
13,
12,
13,
30,
0,
13,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
4,
13,
4,
18,
18,
13,
13,
17,
17,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
14,
4,
13,
4,
18,
18,
13,
13,
17,
17,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
29,
13,
12,
13,
30,
0,
13,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
4,
13,
4,
18,
18,
13,
13,
17,
17,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
14,
4,
13,
4,
18,
18,
13,
13,
17,
17,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
316,
5
],
[
316,
6
],
[
6,
7
],
[
6,
8
],
[
316,
9
],
[
9,
10
],
[
9,
11
],
[
316,
12
],
[
12,
13
],
[
12,
14
],
[
316,
16
],
[
16,
17
],
[
16,
18
],
[
316,
20
],
[
20,
21
],
[
316,
22
],
[
22,
23
],
[
316,
24
],
[
24,
25
],
[
316,
26
],
[
26,
27
],
[
316,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
33,
34
],
[
30,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
30,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
30,
45
],
[
45,
46
],
[
45,
47
],
[
30,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
61,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
61,
72
],
[
72,
73
],
[
72,
74
],
[
61,
75
],
[
75,
76
],
[
75,
77
],
[
30,
78
],
[
78,
79
],
[
78,
80
],
[
30,
81
],
[
81,
82
],
[
81,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
84,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
84,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
97,
106
],
[
106,
107
],
[
106,
108
],
[
97,
109
],
[
109,
110
],
[
109,
111
],
[
93,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
116,
122
],
[
112,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
123,
128
],
[
123,
129
],
[
112,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
130,
136
],
[
28,
137
],
[
137,
138
],
[
316,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
316,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
316,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
316,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
168,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
171,
176
],
[
171,
177
],
[
167,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
167,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
183,
189
],
[
189,
190
],
[
189,
191
],
[
183,
192
],
[
192,
193
],
[
165,
194
],
[
194,
195
],
[
316,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
199,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
202,
207
],
[
202,
208
],
[
198,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
211,
213
],
[
198,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
215,
219
],
[
214,
220
],
[
220,
221
],
[
220,
222
],
[
214,
223
],
[
223,
224
],
[
198,
225
],
[
225,
226
],
[
316,
227
],
[
227,
228
],
[
227,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
232,
233
],
[
232,
234
],
[
316,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
316,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
248,
249
],
[
249,
250
],
[
249,
251
],
[
248,
252
],
[
316,
253
],
[
253,
254
],
[
253,
255
],
[
255,
256
],
[
256,
257
],
[
257,
258
],
[
256,
259
],
[
259,
260
],
[
260,
261
],
[
261,
262
],
[
261,
263
],
[
259,
264
],
[
259,
265
],
[
255,
266
],
[
266,
267
],
[
267,
268
],
[
267,
269
],
[
266,
270
],
[
255,
271
],
[
271,
272
],
[
272,
273
],
[
273,
274
],
[
273,
275
],
[
272,
276
],
[
271,
277
],
[
277,
278
],
[
277,
279
],
[
271,
280
],
[
280,
281
],
[
253,
282
],
[
282,
283
],
[
316,
284
],
[
284,
285
],
[
284,
286
],
[
286,
287
],
[
287,
288
],
[
288,
289
],
[
287,
290
],
[
290,
291
],
[
291,
292
],
[
292,
293
],
[
292,
294
],
[
290,
295
],
[
290,
296
],
[
286,
297
],
[
297,
298
],
[
297,
299
],
[
299,
300
],
[
299,
301
],
[
286,
302
],
[
302,
303
],
[
303,
304
],
[
304,
305
],
[
304,
306
],
[
303,
307
],
[
302,
308
],
[
308,
309
],
[
308,
310
],
[
302,
311
],
[
311,
312
],
[
286,
313
],
[
313,
314
],
[
0,
315
],
[
315,
316
],
[
315,
317
]
] | [
"import java.util.*;\n\npublic class Main{\n\tprivate static final Scanner scan = new Scanner(System.in);\n\tprivate static final int MAX = 100_001;\n\tprivate static String[] P = new String[MAX];\n\tprivate static int[] Q = new int[MAX];\n\tprivate static int head, tail;\n\tprivate static int headQ, tailQ;\n\n\tpublic static void main(String[] args){\n\n\t\tinitialize();\n\t\tinitializeQ();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tString[] p = new String[n];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}\n\t\tint total = 0;\n\t\tfor(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void initializeQ(){\n\t\theadQ = tailQ = 0;\n\t}\n\tprivate static boolean isEmptyQ(){\n\t\treturn headQ == tailQ;\n\t}\n\tprivate static boolean isFullQ(){\n\t\treturn headQ == (tailQ + 1) % MAX;\n\t}\n\tpublic static void enqueueQ(int y){\n\t\tif(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tQ[tailQ] = y;\n\t\tif(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;\n\t}\n\tpublic static int dequeueQ(){\n\t\tif(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tint y = Q[headQ];\n\t\tif(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;\n\t\treturn y;\n\t}\n\n\tprivate static void initialize(){\n\t\thead = tail = 0;\n\t}\n\tprivate static boolean isEmpty(){\n\t\treturn head == tail;\n\t}\n\tprivate static boolean isFull(){\n\t\treturn head == (tail + 1) % MAX;\n\t}\n\tpublic static void enqueue(String x){\n\t\tif(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tP[tail] = x;\n\t\tif(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;\n\t}\n\tpublic static String dequeue(){\n\t\tif(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tString x = P[head];\n\t\tif(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;\n\t\treturn x;\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tprivate static final Scanner scan = new Scanner(System.in);\n\tprivate static final int MAX = 100_001;\n\tprivate static String[] P = new String[MAX];\n\tprivate static int[] Q = new int[MAX];\n\tprivate static int head, tail;\n\tprivate static int headQ, tailQ;\n\n\tpublic static void main(String[] args){\n\n\t\tinitialize();\n\t\tinitializeQ();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tString[] p = new String[n];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}\n\t\tint total = 0;\n\t\tfor(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void initializeQ(){\n\t\theadQ = tailQ = 0;\n\t}\n\tprivate static boolean isEmptyQ(){\n\t\treturn headQ == tailQ;\n\t}\n\tprivate static boolean isFullQ(){\n\t\treturn headQ == (tailQ + 1) % MAX;\n\t}\n\tpublic static void enqueueQ(int y){\n\t\tif(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tQ[tailQ] = y;\n\t\tif(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;\n\t}\n\tpublic static int dequeueQ(){\n\t\tif(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tint y = Q[headQ];\n\t\tif(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;\n\t\treturn y;\n\t}\n\n\tprivate static void initialize(){\n\t\thead = tail = 0;\n\t}\n\tprivate static boolean isEmpty(){\n\t\treturn head == tail;\n\t}\n\tprivate static boolean isFull(){\n\t\treturn head == (tail + 1) % MAX;\n\t}\n\tpublic static void enqueue(String x){\n\t\tif(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tP[tail] = x;\n\t\tif(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;\n\t}\n\tpublic static String dequeue(){\n\t\tif(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tString x = P[head];\n\t\tif(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;\n\t\treturn x;\n\t}\n}",
"Main",
"private static final Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"private static final int MAX = 100_001;",
"MAX",
"100_001",
"private static String[] P = new String[MAX];",
"P",
"new String[MAX]",
"MAX",
"private static int[] Q = new int[MAX];",
"Q",
"new int[MAX]",
"MAX",
"private static int head",
"head",
"tail;",
"tail",
"private static int headQ",
"headQ",
"tailQ;",
"tailQ",
"public static void main(String[] args){\n\n\t\tinitialize();\n\t\tinitializeQ();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tString[] p = new String[n];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}\n\t\tint total = 0;\n\t\tfor(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\n\t\tinitialize();\n\t\tinitializeQ();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tString[] p = new String[n];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}\n\t\tint total = 0;\n\t\tfor(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"initialize()",
"initialize",
"initializeQ()",
"initializeQ",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"String[] p = new String[n];",
"p",
"new String[n]",
"n",
"for(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}",
"{\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}",
"String s = scan.next();",
"s",
"scan.next()",
"scan.next",
"scan",
"int m = scan.nextInt();",
"m",
"scan.nextInt()",
"scan.nextInt",
"scan",
"enqueue(s)",
"enqueue",
"s",
"enqueueQ(m)",
"enqueueQ",
"m",
"int total = 0;",
"total",
"0",
"for(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
";",
"{\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"{\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"String s = dequeue();",
"s",
"dequeue()",
"dequeue",
"int m = dequeueQ();",
"m",
"dequeueQ()",
"dequeueQ",
"if(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}",
"m >q",
"m",
"q",
"{\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}",
"total += q",
"total",
"q",
"m = m - q",
"m",
"m - q",
"m",
"q",
"enqueue(s)",
"enqueue",
"s",
"enqueueQ(m)",
"enqueueQ",
"m",
"{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}",
"total += m",
"total",
"m",
"System.out.printf(\"%s \", s)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s \"",
"s",
"System.out.printf(\"%d\\n\", total)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%d\\n\"",
"total",
"if(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;",
"isEmpty() && isEmptyQ()",
"isEmpty()",
"isEmpty",
"isEmptyQ()",
"isEmptyQ",
"break;",
"String[] args",
"args",
"private static void initializeQ(){\n\t\theadQ = tailQ = 0;\n\t}",
"initializeQ",
"{\n\t\theadQ = tailQ = 0;\n\t}",
"headQ = tailQ = 0",
"headQ",
"tailQ = 0",
"tailQ",
"0",
"private static boolean isEmptyQ(){\n\t\treturn headQ == tailQ;\n\t}",
"isEmptyQ",
"{\n\t\treturn headQ == tailQ;\n\t}",
"return headQ == tailQ;",
"headQ == tailQ",
"headQ",
"tailQ",
"private static boolean isFullQ(){\n\t\treturn headQ == (tailQ + 1) % MAX;\n\t}",
"isFullQ",
"{\n\t\treturn headQ == (tailQ + 1) % MAX;\n\t}",
"return headQ == (tailQ + 1) % MAX;",
"headQ == (tailQ + 1) % MAX",
"headQ",
"(tailQ + 1) % MAX",
"(tailQ + 1)",
"tailQ",
"1",
"MAX",
"public static void enqueueQ(int y){\n\t\tif(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tQ[tailQ] = y;\n\t\tif(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;\n\t}",
"enqueueQ",
"{\n\t\tif(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tQ[tailQ] = y;\n\t\tif(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;\n\t}",
"if(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");",
"isFullQ()",
"isFullQ",
"System.out.printf(\"%s\\n\", \"???????????????????????§???\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s\\n\"",
"\"???????????????????????§???\"",
"Q[tailQ] = y",
"Q[tailQ]",
"Q",
"tailQ",
"y",
"if(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;",
"tailQ + 1 == MAX",
"tailQ + 1",
"tailQ",
"1",
"MAX",
"tailQ = 0",
"tailQ",
"0",
"tailQ++",
"tailQ",
"int y",
"y",
"public static int dequeueQ(){\n\t\tif(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tint y = Q[headQ];\n\t\tif(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;\n\t\treturn y;\n\t}",
"dequeueQ",
"{\n\t\tif(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tint y = Q[headQ];\n\t\tif(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;\n\t\treturn y;\n\t}",
"if(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");",
"isEmptyQ()",
"isEmptyQ",
"System.out.printf(\"%s\\n\", \"??¢????????????????????§???\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s\\n\"",
"\"??¢????????????????????§???\"",
"int y = Q[headQ];",
"y",
"Q[headQ]",
"Q",
"headQ",
"if(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;",
"headQ + 1 == MAX",
"headQ + 1",
"headQ",
"1",
"MAX",
"headQ = 0",
"headQ",
"0",
"headQ++",
"headQ",
"return y;",
"y",
"private static void initialize(){\n\t\thead = tail = 0;\n\t}",
"initialize",
"{\n\t\thead = tail = 0;\n\t}",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"private static boolean isEmpty(){\n\t\treturn head == tail;\n\t}",
"isEmpty",
"{\n\t\treturn head == tail;\n\t}",
"return head == tail;",
"head == tail",
"head",
"tail",
"private static boolean isFull(){\n\t\treturn head == (tail + 1) % MAX;\n\t}",
"isFull",
"{\n\t\treturn head == (tail + 1) % MAX;\n\t}",
"return head == (tail + 1) % MAX;",
"head == (tail + 1) % MAX",
"head",
"(tail + 1) % MAX",
"(tail + 1)",
"tail",
"1",
"MAX",
"public static void enqueue(String x){\n\t\tif(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tP[tail] = x;\n\t\tif(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;\n\t}",
"enqueue",
"{\n\t\tif(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tP[tail] = x;\n\t\tif(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;\n\t}",
"if(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");",
"isFull()",
"isFull",
"System.out.printf(\"%s\\n\", \"???????????????????????§???\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s\\n\"",
"\"???????????????????????§???\"",
"P[tail] = x",
"P[tail]",
"P",
"tail",
"x",
"if(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;",
"tail + 1 == MAX",
"tail + 1",
"tail",
"1",
"MAX",
"tail = 0",
"tail",
"0",
"tail++",
"tail",
"String x",
"x",
"public static String dequeue(){\n\t\tif(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tString x = P[head];\n\t\tif(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;\n\t\treturn x;\n\t}",
"dequeue",
"{\n\t\tif(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tString x = P[head];\n\t\tif(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;\n\t\treturn x;\n\t}",
"if(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");",
"isEmpty()",
"isEmpty",
"System.out.printf(\"%s\\n\", \"??¢????????????????????§???\")",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s\\n\"",
"\"??¢????????????????????§???\"",
"String x = P[head];",
"x",
"P[head]",
"P",
"head",
"if(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;",
"head + 1 == MAX",
"head + 1",
"head",
"1",
"MAX",
"head = 0",
"head",
"0",
"head++",
"head",
"return x;",
"x",
"public class Main{\n\tprivate static final Scanner scan = new Scanner(System.in);\n\tprivate static final int MAX = 100_001;\n\tprivate static String[] P = new String[MAX];\n\tprivate static int[] Q = new int[MAX];\n\tprivate static int head, tail;\n\tprivate static int headQ, tailQ;\n\n\tpublic static void main(String[] args){\n\n\t\tinitialize();\n\t\tinitializeQ();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tString[] p = new String[n];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}\n\t\tint total = 0;\n\t\tfor(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void initializeQ(){\n\t\theadQ = tailQ = 0;\n\t}\n\tprivate static boolean isEmptyQ(){\n\t\treturn headQ == tailQ;\n\t}\n\tprivate static boolean isFullQ(){\n\t\treturn headQ == (tailQ + 1) % MAX;\n\t}\n\tpublic static void enqueueQ(int y){\n\t\tif(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tQ[tailQ] = y;\n\t\tif(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;\n\t}\n\tpublic static int dequeueQ(){\n\t\tif(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tint y = Q[headQ];\n\t\tif(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;\n\t\treturn y;\n\t}\n\n\tprivate static void initialize(){\n\t\thead = tail = 0;\n\t}\n\tprivate static boolean isEmpty(){\n\t\treturn head == tail;\n\t}\n\tprivate static boolean isFull(){\n\t\treturn head == (tail + 1) % MAX;\n\t}\n\tpublic static void enqueue(String x){\n\t\tif(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tP[tail] = x;\n\t\tif(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;\n\t}\n\tpublic static String dequeue(){\n\t\tif(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tString x = P[head];\n\t\tif(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;\n\t\treturn x;\n\t}\n}",
"public class Main{\n\tprivate static final Scanner scan = new Scanner(System.in);\n\tprivate static final int MAX = 100_001;\n\tprivate static String[] P = new String[MAX];\n\tprivate static int[] Q = new int[MAX];\n\tprivate static int head, tail;\n\tprivate static int headQ, tailQ;\n\n\tpublic static void main(String[] args){\n\n\t\tinitialize();\n\t\tinitializeQ();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tString[] p = new String[n];\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tString s = scan.next();\n\t\t\tint m = scan.nextInt();\n\t\t\tenqueue(s);\n\t\t\tenqueueQ(m);\n\t\t}\n\t\tint total = 0;\n\t\tfor(;;){\n\t\t\tString s = dequeue();\n\t\t\tint m = dequeueQ();\n\t\t\tif(m >q){\n\t\t\t\ttotal += q;\n\t\t\t\tm = m - q;\n\t\t\t\tenqueue(s);\n\t\t\t\tenqueueQ(m);\n\t\t\t}else{\n\t\t\t\ttotal += m;\n\t\t\t\tSystem.out.printf(\"%s \", s);\n\t\t\t\tSystem.out.printf(\"%d\\n\", total);\n\t\t\t\tif(isEmpty() && isEmptyQ())\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static void initializeQ(){\n\t\theadQ = tailQ = 0;\n\t}\n\tprivate static boolean isEmptyQ(){\n\t\treturn headQ == tailQ;\n\t}\n\tprivate static boolean isFullQ(){\n\t\treturn headQ == (tailQ + 1) % MAX;\n\t}\n\tpublic static void enqueueQ(int y){\n\t\tif(isFullQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tQ[tailQ] = y;\n\t\tif(tailQ + 1 == MAX)\n\t\t\ttailQ = 0;\n\t\telse\n\t\t\ttailQ++;\n\t}\n\tpublic static int dequeueQ(){\n\t\tif(isEmptyQ())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tint y = Q[headQ];\n\t\tif(headQ + 1 == MAX)\n\t\t\theadQ = 0;\n\t\telse\n\t\t\theadQ++;\n\t\treturn y;\n\t}\n\n\tprivate static void initialize(){\n\t\thead = tail = 0;\n\t}\n\tprivate static boolean isEmpty(){\n\t\treturn head == tail;\n\t}\n\tprivate static boolean isFull(){\n\t\treturn head == (tail + 1) % MAX;\n\t}\n\tpublic static void enqueue(String x){\n\t\tif(isFull())\n\t\t\tSystem.out.printf(\"%s\\n\", \"???????????????????????§???\");\n\t\tP[tail] = x;\n\t\tif(tail + 1 == MAX)\n\t\t\ttail = 0;\n\t\telse\n\t\t\ttail++;\n\t}\n\tpublic static String dequeue(){\n\t\tif(isEmpty())\n\t\t\tSystem.out.printf(\"%s\\n\", \"??¢????????????????????§???\");\n\t\tString x = P[head];\n\t\tif(head + 1 == MAX)\n\t\t\thead = 0;\n\t\telse\n\t\t\thead++;\n\t\treturn x;\n\t}\n}",
"Main"
] | import java.util.*;
public class Main{
private static final Scanner scan = new Scanner(System.in);
private static final int MAX = 100_001;
private static String[] P = new String[MAX];
private static int[] Q = new int[MAX];
private static int head, tail;
private static int headQ, tailQ;
public static void main(String[] args){
initialize();
initializeQ();
int n = scan.nextInt();
int q = scan.nextInt();
String[] p = new String[n];
for(int i = 0; i < n; i++){
String s = scan.next();
int m = scan.nextInt();
enqueue(s);
enqueueQ(m);
}
int total = 0;
for(;;){
String s = dequeue();
int m = dequeueQ();
if(m >q){
total += q;
m = m - q;
enqueue(s);
enqueueQ(m);
}else{
total += m;
System.out.printf("%s ", s);
System.out.printf("%d\n", total);
if(isEmpty() && isEmptyQ())
break;
}
}
}
private static void initializeQ(){
headQ = tailQ = 0;
}
private static boolean isEmptyQ(){
return headQ == tailQ;
}
private static boolean isFullQ(){
return headQ == (tailQ + 1) % MAX;
}
public static void enqueueQ(int y){
if(isFullQ())
System.out.printf("%s\n", "???????????????????????§???");
Q[tailQ] = y;
if(tailQ + 1 == MAX)
tailQ = 0;
else
tailQ++;
}
public static int dequeueQ(){
if(isEmptyQ())
System.out.printf("%s\n", "??¢????????????????????§???");
int y = Q[headQ];
if(headQ + 1 == MAX)
headQ = 0;
else
headQ++;
return y;
}
private static void initialize(){
head = tail = 0;
}
private static boolean isEmpty(){
return head == tail;
}
private static boolean isFull(){
return head == (tail + 1) % MAX;
}
public static void enqueue(String x){
if(isFull())
System.out.printf("%s\n", "???????????????????????§???");
P[tail] = x;
if(tail + 1 == MAX)
tail = 0;
else
tail++;
}
public static String dequeue(){
if(isEmpty())
System.out.printf("%s\n", "??¢????????????????????§???");
String x = P[head];
if(head + 1 == MAX)
head = 0;
else
head++;
return x;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
41,
13,
41,
13,
38,
5,
13,
30,
30,
42,
2,
0,
13,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
20,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
31,
32
],
[
31,
33
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
14,
42
],
[
42,
43
],
[
42,
44
],
[
14,
45
],
[
45,
46
],
[
45,
47
],
[
14,
48
],
[
48,
49
],
[
48,
50
],
[
14,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
66,
71
],
[
63,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
63,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
84,
86
],
[
14,
87
],
[
87,
88
],
[
14,
89
],
[
89,
90
],
[
14,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
97,
103
],
[
96,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
114,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
126,
126
],
[
126,
127
],
[
126,
128
],
[
126,
129
],
[
110,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
130,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
138,
140
],
[
130,
141
],
[
141,
142
],
[
142,
143
],
[
141,
144
],
[
130,
145
],
[
145,
146
],
[
146,
147
],
[
145,
148
],
[
12,
149
],
[
149,
150
]
] | [
"import java.io.*;\nimport java.util.Arrays;\nimport java.util.*;\n\nclass Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] fst = (br.readLine()).split(\" \");\n\t\tint n = Integer.parseInt(fst[0]);\n\t\tint quan = Integer.parseInt(fst[1]);\n\t\tint sumtime = 0;\n\t\tDeque<Integer> stackint = new ArrayDeque<Integer>();\n\t\tDeque<String> stackst = new ArrayDeque<String>();\n\t\tfor ( int i = 0; i<n ; i++ ) {\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}\n\t\tint a;\n\t\tString b;\n\t\ttry{\n\t\t\t\t// System.out.println(\"a\");\n\n\t\t\twhile((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}catch (NullPointerException e){\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.*;",
"util.*",
"java",
"class Main{\n\tpublic static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] fst = (br.readLine()).split(\" \");\n\t\tint n = Integer.parseInt(fst[0]);\n\t\tint quan = Integer.parseInt(fst[1]);\n\t\tint sumtime = 0;\n\t\tDeque<Integer> stackint = new ArrayDeque<Integer>();\n\t\tDeque<String> stackst = new ArrayDeque<String>();\n\t\tfor ( int i = 0; i<n ; i++ ) {\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}\n\t\tint a;\n\t\tString b;\n\t\ttry{\n\t\t\t\t// System.out.println(\"a\");\n\n\t\t\twhile((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}catch (NullPointerException e){\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] fst = (br.readLine()).split(\" \");\n\t\tint n = Integer.parseInt(fst[0]);\n\t\tint quan = Integer.parseInt(fst[1]);\n\t\tint sumtime = 0;\n\t\tDeque<Integer> stackint = new ArrayDeque<Integer>();\n\t\tDeque<String> stackst = new ArrayDeque<String>();\n\t\tfor ( int i = 0; i<n ; i++ ) {\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}\n\t\tint a;\n\t\tString b;\n\t\ttry{\n\t\t\t\t// System.out.println(\"a\");\n\n\t\t\twhile((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}catch (NullPointerException e){\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] fst = (br.readLine()).split(\" \");\n\t\tint n = Integer.parseInt(fst[0]);\n\t\tint quan = Integer.parseInt(fst[1]);\n\t\tint sumtime = 0;\n\t\tDeque<Integer> stackint = new ArrayDeque<Integer>();\n\t\tDeque<String> stackst = new ArrayDeque<String>();\n\t\tfor ( int i = 0; i<n ; i++ ) {\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}\n\t\tint a;\n\t\tString b;\n\t\ttry{\n\t\t\t\t// System.out.println(\"a\");\n\n\t\t\twhile((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}catch (NullPointerException e){\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] fst = (br.readLine()).split(\" \");",
"fst",
"(br.readLine()).split(\" \")",
"(br.readLine()).split",
"(br.readLine())",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(fst[0]);",
"n",
"Integer.parseInt(fst[0])",
"Integer.parseInt",
"Integer",
"fst[0]",
"fst",
"0",
"int quan = Integer.parseInt(fst[1]);",
"quan",
"Integer.parseInt(fst[1])",
"Integer.parseInt",
"Integer",
"fst[1]",
"fst",
"1",
"int sumtime = 0;",
"sumtime",
"0",
"Deque<Integer> stackint = new ArrayDeque<Integer>();",
"stackint",
"new ArrayDeque<Integer>()",
"Deque<String> stackst = new ArrayDeque<String>();",
"stackst",
"new ArrayDeque<String>()",
"for ( int i = 0; i<n ; i++ ) {\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}",
"{\n\t\t\tString[] st = (br.readLine()).split(\" \");\n\t\t\tstackst.addLast(st[0]);\n\t\t\tstackint.addLast(Integer.parseInt(st[1]));\n\t\t}",
"String[] st = (br.readLine()).split(\" \");",
"st",
"(br.readLine()).split(\" \")",
"(br.readLine()).split",
"(br.readLine())",
"br.readLine",
"br",
"\" \"",
"stackst.addLast(st[0])",
"stackst.addLast",
"stackst",
"st[0]",
"st",
"0",
"stackint.addLast(Integer.parseInt(st[1]))",
"stackint.addLast",
"stackint",
"Integer.parseInt(st[1])",
"Integer.parseInt",
"Integer",
"st[1]",
"st",
"1",
"int a;",
"a",
"String b;",
"b",
"try{\n\t\t\t\t// System.out.println(\"a\");\n\n\t\t\twhile((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}catch (NullPointerException e){\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}",
"catch (NullPointerException e){\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}",
"NullPointerException e",
"{\n\t\t\t\t// System.out.println(\"d\");\n\n\t\t}",
"{\n\t\t\t\t// System.out.println(\"a\");\n\n\t\t\twhile((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"while((a = stackint.pollFirst()) > 0){\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}",
"(a = stackint.pollFirst()) > 0",
"(a = stackint.pollFirst())",
"a",
"stackint.pollFirst()",
"stackint.pollFirst",
"stackint",
"0",
"{\n\t\t\t\tb = stackst.pollFirst();\n\t\t\t\tif ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}\n\t\t\t}",
"b = stackst.pollFirst()",
"b",
"stackst.pollFirst()",
"stackst.pollFirst",
"stackst",
"if ( a <= quan) {\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}else{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}",
"a <= quan",
"a",
"quan",
"{\n\t\t\t\t\tsumtime = sumtime + a;\n\t\t\t\t// System.out.println(\"b\");\n\n\t\t\t\t\tSystem.out.println(b + \" \" + sumtime);\n\t\t\t\t}",
"sumtime = sumtime + a",
"sumtime",
"sumtime + a",
"sumtime",
"a",
"System.out.println(b + \" \" + sumtime)",
"System.out.println",
"System.out",
"System",
"System.out",
"b + \" \" + sumtime",
"b + \" \" + sumtime",
"b",
"\" \"",
"sumtime",
"{\n\t\t\t\t\tsumtime = sumtime + quan;\n\t\t\t\t\ta = a - quan;\n\t\t\t\t\tstackint.addLast(a);\n\t\t\t\t// System.out.println(\"c\");\n\n\t\t\t\t\tstackst.addLast(b);\n\t\t\t\t}",
"sumtime = sumtime + quan",
"sumtime",
"sumtime + quan",
"sumtime",
"quan",
"a = a - quan",
"a",
"a - quan",
"a",
"quan",
"stackint.addLast(a)",
"stackint.addLast",
"stackint",
"a",
"stackst.addLast(b)",
"stackst.addLast",
"stackst",
"b",
"String[] args",
"args"
] | import java.io.*;
import java.util.Arrays;
import java.util.*;
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] fst = (br.readLine()).split(" ");
int n = Integer.parseInt(fst[0]);
int quan = Integer.parseInt(fst[1]);
int sumtime = 0;
Deque<Integer> stackint = new ArrayDeque<Integer>();
Deque<String> stackst = new ArrayDeque<String>();
for ( int i = 0; i<n ; i++ ) {
String[] st = (br.readLine()).split(" ");
stackst.addLast(st[0]);
stackint.addLast(Integer.parseInt(st[1]));
}
int a;
String b;
try{
// System.out.println("a");
while((a = stackint.pollFirst()) > 0){
b = stackst.pollFirst();
if ( a <= quan) {
sumtime = sumtime + a;
// System.out.println("b");
System.out.println(b + " " + sumtime);
}else{
sumtime = sumtime + quan;
a = a - quan;
stackint.addLast(a);
// System.out.println("c");
stackst.addLast(b);
}
}
}catch (NullPointerException e){
// System.out.println("d");
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
4,
18,
13,
30,
4,
18,
13,
20,
0,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
17,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
199,
8
],
[
199,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
44,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
11,
50
],
[
50,
51
],
[
50,
52
],
[
11,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
58,
59
],
[
58,
60
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
69,
70
],
[
69,
71
],
[
11,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
78,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
78,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
78,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
98,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
112,
116
],
[
112,
117
],
[
117,
118
],
[
118,
119
],
[
94,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
120,
125
],
[
125,
126
],
[
125,
127
],
[
9,
128
],
[
128,
129
],
[
199,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
130,
134
],
[
134,
135
],
[
130,
136
],
[
136,
137
],
[
136,
138
],
[
130,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
130,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
130,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
130,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
154,
162
],
[
162,
163
],
[
130,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
164,
172
],
[
172,
173
],
[
130,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
176,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
176,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
174,
192
],
[
192,
193
],
[
174,
194
],
[
194,
195
],
[
174,
196
],
[
196,
197
],
[
0,
198
],
[
198,
199
],
[
198,
200
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Scanner;\n\n\npublic class Main {\n\n\tstatic class MyProcess {\n\n\t\tString qName;\n\t\tint needTime;\n\t\tint finTime = 0;\n\n\t\tpublic int getFinTime() {\n\t\t\treturn finTime;\n\t\t}\n\n\t\tpublic String getqName() {\n\t\t\treturn qName;\n\t\t}\n\n\t\tpublic int getNeedTime() {\n\t\t\treturn needTime;\n\t\t}\n\n\t\tpublic void setNeedTime(int needTime) {\n\t\t\tthis.needTime = needTime;\n\t\t}\n\n\t\tpublic void setFinTime(int finTime) {\n\t\t\tthis.finTime = finTime;\n\t\t}\n\n\t\tMyProcess(String qName, int needTime, int finTime) {\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}\n\n\t}\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), qTime = sc.nextInt();\n\t\tint totalTime = 0;\n\n\t\tMyProcess[] mps = new MyProcess[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}\n\n\t\tjava.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}\n\n\t\twhile (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}\n\t}\n\n\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tstatic class MyProcess {\n\n\t\tString qName;\n\t\tint needTime;\n\t\tint finTime = 0;\n\n\t\tpublic int getFinTime() {\n\t\t\treturn finTime;\n\t\t}\n\n\t\tpublic String getqName() {\n\t\t\treturn qName;\n\t\t}\n\n\t\tpublic int getNeedTime() {\n\t\t\treturn needTime;\n\t\t}\n\n\t\tpublic void setNeedTime(int needTime) {\n\t\t\tthis.needTime = needTime;\n\t\t}\n\n\t\tpublic void setFinTime(int finTime) {\n\t\t\tthis.finTime = finTime;\n\t\t}\n\n\t\tMyProcess(String qName, int needTime, int finTime) {\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}\n\n\t}\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), qTime = sc.nextInt();\n\t\tint totalTime = 0;\n\n\t\tMyProcess[] mps = new MyProcess[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}\n\n\t\tjava.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}\n\n\t\twhile (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}\n\t}\n\n\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), qTime = sc.nextInt();\n\t\tint totalTime = 0;\n\n\t\tMyProcess[] mps = new MyProcess[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}\n\n\t\tjava.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}\n\n\t\twhile (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), qTime = sc.nextInt();\n\t\tint totalTime = 0;\n\n\t\tMyProcess[] mps = new MyProcess[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}\n\n\t\tjava.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}\n\n\t\twhile (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"qTime = sc.nextInt();",
"qTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int totalTime = 0;",
"totalTime",
"0",
"MyProcess[] mps = new MyProcess[n];",
"mps",
"new MyProcess[n]",
"n",
"for (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}",
"{\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}",
"mps[i] = new MyProcess(sc.next(), sc.nextInt(), 0)",
"mps[i]",
"mps",
"i",
"new MyProcess(sc.next(), sc.nextInt(), 0)",
"java.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();",
"q",
"new ArrayDeque<MyProcess>()",
"for (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tq.add(mps[i]);\n\t\t}",
"{\n\t\t\tq.add(mps[i]);\n\t\t}",
"q.add(mps[i])",
"q.add",
"q",
"mps[i]",
"mps",
"i",
"while (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}",
"q.peek() != null",
"q.peek()",
"q.peek",
"q",
"null",
"{\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}",
"MyProcess mp = q.poll();",
"mp",
"q.poll()",
"q.poll",
"q",
"int needTime = mp.getNeedTime();",
"needTime",
"mp.getNeedTime()",
"mp.getNeedTime",
"mp",
"String pName = mp.getqName();",
"pName",
"mp.getqName()",
"mp.getqName",
"mp",
"if (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}",
"needTime <= qTime",
"needTime",
"qTime",
"{\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t}",
"totalTime += needTime",
"totalTime",
"needTime",
"mp.setFinTime(totalTime)",
"mp.setFinTime",
"mp",
"totalTime",
"System.out.println(mp.getqName() +\" \"+ mp.getFinTime())",
"System.out.println",
"System.out",
"System",
"System.out",
"mp.getqName() +\" \"+ mp.getFinTime()",
"mp.getqName() +\" \"+ mp.getFinTime()",
"mp.getqName()",
"mp.getqName",
"mp",
"\" \"",
"mp.getFinTime()",
"mp.getFinTime",
"mp",
"{\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}",
"q.add(new MyProcess(pName, needTime - qTime, 0))",
"q.add",
"q",
"new MyProcess(pName, needTime - qTime, 0)",
"totalTime += qTime",
"totalTime",
"qTime",
"String[] args",
"args",
"static class MyProcess {\n\n\t\tString qName;\n\t\tint needTime;\n\t\tint finTime = 0;\n\n\t\tpublic int getFinTime() {\n\t\t\treturn finTime;\n\t\t}\n\n\t\tpublic String getqName() {\n\t\t\treturn qName;\n\t\t}\n\n\t\tpublic int getNeedTime() {\n\t\t\treturn needTime;\n\t\t}\n\n\t\tpublic void setNeedTime(int needTime) {\n\t\t\tthis.needTime = needTime;\n\t\t}\n\n\t\tpublic void setFinTime(int finTime) {\n\t\t\tthis.finTime = finTime;\n\t\t}\n\n\t\tMyProcess(String qName, int needTime, int finTime) {\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}\n\n\t}",
"MyProcess",
"String qName;",
"qName",
"int needTime;",
"needTime",
"int finTime = 0;",
"finTime",
"0",
"public int getFinTime() {\n\t\t\treturn finTime;\n\t\t}",
"getFinTime",
"{\n\t\t\treturn finTime;\n\t\t}",
"return finTime;",
"finTime",
"public String getqName() {\n\t\t\treturn qName;\n\t\t}",
"getqName",
"{\n\t\t\treturn qName;\n\t\t}",
"return qName;",
"qName",
"public int getNeedTime() {\n\t\t\treturn needTime;\n\t\t}",
"getNeedTime",
"{\n\t\t\treturn needTime;\n\t\t}",
"return needTime;",
"needTime",
"public void setNeedTime(int needTime) {\n\t\t\tthis.needTime = needTime;\n\t\t}",
"setNeedTime",
"{\n\t\t\tthis.needTime = needTime;\n\t\t}",
"this.needTime = needTime",
"this.needTime",
"this",
"this.needTime",
"needTime",
"int needTime",
"needTime",
"public void setFinTime(int finTime) {\n\t\t\tthis.finTime = finTime;\n\t\t}",
"setFinTime",
"{\n\t\t\tthis.finTime = finTime;\n\t\t}",
"this.finTime = finTime",
"this.finTime",
"this",
"this.finTime",
"finTime",
"int finTime",
"finTime",
"MyProcess(String qName, int needTime, int finTime) {\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}",
"MyProcess",
"{\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}",
"this.qName = qName",
"this.qName",
"this",
"this.qName",
"qName",
"this.needTime = needTime",
"this.needTime",
"this",
"this.needTime",
"needTime",
"this.finTime = finTime",
"this.finTime",
"this",
"this.finTime",
"finTime",
"String qName",
"qName",
"int needTime",
"needTime",
"int finTime",
"finTime",
"public class Main {\n\n\tstatic class MyProcess {\n\n\t\tString qName;\n\t\tint needTime;\n\t\tint finTime = 0;\n\n\t\tpublic int getFinTime() {\n\t\t\treturn finTime;\n\t\t}\n\n\t\tpublic String getqName() {\n\t\t\treturn qName;\n\t\t}\n\n\t\tpublic int getNeedTime() {\n\t\t\treturn needTime;\n\t\t}\n\n\t\tpublic void setNeedTime(int needTime) {\n\t\t\tthis.needTime = needTime;\n\t\t}\n\n\t\tpublic void setFinTime(int finTime) {\n\t\t\tthis.finTime = finTime;\n\t\t}\n\n\t\tMyProcess(String qName, int needTime, int finTime) {\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}\n\n\t}\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), qTime = sc.nextInt();\n\t\tint totalTime = 0;\n\n\t\tMyProcess[] mps = new MyProcess[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}\n\n\t\tjava.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}\n\n\t\twhile (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}\n\t}\n\n\n}",
"public class Main {\n\n\tstatic class MyProcess {\n\n\t\tString qName;\n\t\tint needTime;\n\t\tint finTime = 0;\n\n\t\tpublic int getFinTime() {\n\t\t\treturn finTime;\n\t\t}\n\n\t\tpublic String getqName() {\n\t\t\treturn qName;\n\t\t}\n\n\t\tpublic int getNeedTime() {\n\t\t\treturn needTime;\n\t\t}\n\n\t\tpublic void setNeedTime(int needTime) {\n\t\t\tthis.needTime = needTime;\n\t\t}\n\n\t\tpublic void setFinTime(int finTime) {\n\t\t\tthis.finTime = finTime;\n\t\t}\n\n\t\tMyProcess(String qName, int needTime, int finTime) {\n\t\t\tthis.qName = qName;\n\t\t\tthis.needTime = needTime;\n\t\t\tthis.finTime = finTime;\n\n\t\t}\n\n\t}\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt(), qTime = sc.nextInt();\n\t\tint totalTime = 0;\n\n\t\tMyProcess[] mps = new MyProcess[n];\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tmps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);\n\t\t}\n\n\t\tjava.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tq.add(mps[i]);\n\t\t}\n\n\t\twhile (q.peek() != null) {\n\t\t\tMyProcess mp = q.poll();\n\t\t\tint needTime = mp.getNeedTime();\n\t\t\tString pName = mp.getqName();\n\t\t\tif (needTime <= qTime) {\n\t\t\t\ttotalTime += needTime;\n\t\t\t\tmp.setFinTime(totalTime);\n\t\t\t\tSystem.out.println(mp.getqName() +\" \"+ mp.getFinTime());\n\t\t\t} else {\n\t\t\t\tq.add(new MyProcess(pName, needTime - qTime, 0));\n\t\t\t\ttotalTime += qTime;\n\t\t\t}\n\t\t}\n\t}\n\n\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Scanner;
public class Main {
static class MyProcess {
String qName;
int needTime;
int finTime = 0;
public int getFinTime() {
return finTime;
}
public String getqName() {
return qName;
}
public int getNeedTime() {
return needTime;
}
public void setNeedTime(int needTime) {
this.needTime = needTime;
}
public void setFinTime(int finTime) {
this.finTime = finTime;
}
MyProcess(String qName, int needTime, int finTime) {
this.qName = qName;
this.needTime = needTime;
this.finTime = finTime;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), qTime = sc.nextInt();
int totalTime = 0;
MyProcess[] mps = new MyProcess[n];
for (int i = 0; i < n; i++) {
mps[i] = new MyProcess(sc.next(), sc.nextInt(), 0);
}
java.util.Queue<MyProcess> q = new ArrayDeque<MyProcess>();
for (int i = 0; i < n; i++) {
q.add(mps[i]);
}
while (q.peek() != null) {
MyProcess mp = q.poll();
int needTime = mp.getNeedTime();
String pName = mp.getqName();
if (needTime <= qTime) {
totalTime += needTime;
mp.setFinTime(totalTime);
System.out.println(mp.getqName() +" "+ mp.getFinTime());
} else {
q.add(new MyProcess(pName, needTime - qTime, 0));
totalTime += qTime;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
18,
13,
13,
14,
2,
13,
13,
30,
0,
18,
13,
13,
2,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
142,
11
],
[
142,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
14,
58
],
[
58,
59
],
[
58,
60
],
[
14,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
61,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
66,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
66,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
86,
88
],
[
81,
89
],
[
89,
90
],
[
89,
91
],
[
81,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
77,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
108,
113
],
[
12,
114
],
[
114,
115
],
[
142,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
116,
121
],
[
121,
122
],
[
121,
123
],
[
116,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
126,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
124,
137
],
[
137,
138
],
[
124,
139
],
[
139,
140
],
[
0,
141
],
[
141,
142
],
[
141,
143
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main{\n static class Pair {\n int quan=0;\n String val=\"\";\n Pair(int x , String y){\n this.quan = x;\n this.val = y;\n }\n }\n\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n Queue<Pair> q = new LinkedList<>();\n for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }\n\n int elapse = 0;\n while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }\n\n\n\n\n }\n\n}\n",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n static class Pair {\n int quan=0;\n String val=\"\";\n Pair(int x , String y){\n this.quan = x;\n this.val = y;\n }\n }\n\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n Queue<Pair> q = new LinkedList<>();\n for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }\n\n int elapse = 0;\n while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }\n\n\n\n\n }\n\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n Queue<Pair> q = new LinkedList<>();\n for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }\n\n int elapse = 0;\n while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }\n\n\n\n\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n Queue<Pair> q = new LinkedList<>();\n for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }\n\n int elapse = 0;\n while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }\n\n\n\n\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int Q = sc.nextInt();",
"Q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Pair> q = new LinkedList<>();",
"q",
"new LinkedList<>()",
"for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }",
"{\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int quantum = sc.nextInt();",
"quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q.add(new Pair(quantum,name))",
"q.add",
"q",
"new Pair(quantum,name)",
"int elapse = 0;",
"elapse",
"0",
"while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }",
"Pair current = q.poll();",
"current",
"q.poll()",
"q.poll",
"q",
"int qu = current.quan;",
"qu",
"current.quan",
"current",
"current.quan",
"if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }",
"qu > Q",
"qu",
"Q",
"{\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }",
"current.quan = qu-Q",
"current.quan",
"current",
"current.quan",
"qu-Q",
"qu",
"Q",
"elapse+=Q",
"elapse",
"Q",
"q.add(current)",
"q.add",
"q",
"current",
"{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }",
"elapse+=current.quan",
"elapse",
"current.quan",
"current",
"current.quan",
"System.out.println(current.val +\" \"+elapse)",
"System.out.println",
"System.out",
"System",
"System.out",
"current.val +\" \"+elapse",
"current.val +\" \"+elapse",
"current.val",
"current",
"current.val",
"\" \"",
"elapse",
"String[] args",
"args",
"static class Pair {\n int quan=0;\n String val=\"\";\n Pair(int x , String y){\n this.quan = x;\n this.val = y;\n }\n }",
"Pair",
"int quan=0;",
"quan",
"0",
"String val=\"\";",
"val",
"\"\"",
"Pair(int x , String y){\n this.quan = x;\n this.val = y;\n }",
"Pair",
"{\n this.quan = x;\n this.val = y;\n }",
"this.quan = x",
"this.quan",
"this",
"this.quan",
"x",
"this.val = y",
"this.val",
"this",
"this.val",
"y",
"int x",
"x",
"String y",
"y",
"public class Main{\n static class Pair {\n int quan=0;\n String val=\"\";\n Pair(int x , String y){\n this.quan = x;\n this.val = y;\n }\n }\n\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n Queue<Pair> q = new LinkedList<>();\n for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }\n\n int elapse = 0;\n while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }\n\n\n\n\n }\n\n}",
"public class Main{\n static class Pair {\n int quan=0;\n String val=\"\";\n Pair(int x , String y){\n this.quan = x;\n this.val = y;\n }\n }\n\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int N = sc.nextInt();\n int Q = sc.nextInt();\n Queue<Pair> q = new LinkedList<>();\n for (int i = 0; i < N; i++) {\n String name = sc.next();\n int quantum = sc.nextInt();\n q.add(new Pair(quantum,name));\n }\n\n int elapse = 0;\n while(!q.isEmpty()){\n Pair current = q.poll();\n int qu = current.quan;\n if(qu > Q){\n current.quan = qu-Q;\n elapse+=Q;\n q.add(current);\n }else{\n elapse+=current.quan;\n System.out.println(current.val +\" \"+elapse);\n }\n }\n\n\n\n\n }\n\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main{
static class Pair {
int quan=0;
String val="";
Pair(int x , String y){
this.quan = x;
this.val = y;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int Q = sc.nextInt();
Queue<Pair> q = new LinkedList<>();
for (int i = 0; i < N; i++) {
String name = sc.next();
int quantum = sc.nextInt();
q.add(new Pair(quantum,name));
}
int elapse = 0;
while(!q.isEmpty()){
Pair current = q.poll();
int qu = current.quan;
if(qu > Q){
current.quan = qu-Q;
elapse+=Q;
q.add(current);
}else{
elapse+=current.quan;
System.out.println(current.val +" "+elapse);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
14,
2,
4,
18,
13,
13,
13,
30,
0,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
13,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
8,
2,
13,
4,
18,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
13,
2,
4,
18,
13,
13,
13,
0,
13,
8,
2,
40,
13,
4,
18,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
140,
8
],
[
140,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
11,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
37,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
49,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
49,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
60,
61
],
[
11,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
70,
75
],
[
69,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
76,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
83,
93
],
[
76,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
76,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
76,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
104,
111
],
[
69,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
116,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
120,
125
],
[
112,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
132,
133
],
[
133,
134
],
[
128,
135
],
[
128,
136
],
[
9,
137
],
[
137,
138
],
[
0,
139
],
[
139,
140
],
[
139,
141
]
] | [
"import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint total = 0;\n\t\tint count = 0;\n\n\t\tArrayList<Integer> time = new ArrayList<>();\n\t\tArrayList<String> name = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint total = 0;\n\t\tint count = 0;\n\n\t\tArrayList<Integer> time = new ArrayList<>();\n\t\tArrayList<String> name = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint total = 0;\n\t\tint count = 0;\n\n\t\tArrayList<Integer> time = new ArrayList<>();\n\t\tArrayList<String> name = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint total = 0;\n\t\tint count = 0;\n\n\t\tArrayList<Integer> time = new ArrayList<>();\n\t\tArrayList<String> name = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int total = 0;",
"total",
"0",
"int count = 0;",
"count",
"0",
"ArrayList<Integer> time = new ArrayList<>();",
"time",
"new ArrayList<>()",
"ArrayList<String> name = new ArrayList<>();",
"name",
"new ArrayList<>()",
"for (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}",
"name.add(sc.next())",
"name.add",
"name",
"sc.next()",
"sc.next",
"sc",
"time.add(sc.nextInt())",
"time.add",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}",
"time.size() != 0",
"time.size()",
"time.size",
"time",
"0",
"{\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}",
"if (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}",
"time.get(count) <= q",
"time.get(count)",
"time.get",
"time",
"count",
"q",
"{\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t}",
"total += time.get(count)",
"total",
"time.get(count)",
"time.get",
"time",
"count",
"System.out.printf(\"%s %d\\n\", name.get(count), total)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"name.get(count)",
"name.get",
"name",
"count",
"total",
"time.remove(count)",
"time.remove",
"time",
"count",
"name.remove(count)",
"name.remove",
"name",
"count",
"count = count >= name.size() ? 0 : count",
"count",
"count >= name.size() ? 0 : count",
"count >= name.size()",
"count",
"name.size()",
"name.size",
"name",
"0",
"count",
"{\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}",
"total += q",
"total",
"q",
"time.set(count, time.get(count) - q)",
"time.set",
"time",
"count",
"time.get(count) - q",
"time.get(count)",
"time.get",
"time",
"count",
"q",
"count = ++count >= name.size() ? 0 : count",
"count",
"++count >= name.size() ? 0 : count",
"++count >= name.size()",
"++count",
"count",
"name.size()",
"name.size",
"name",
"0",
"count",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint total = 0;\n\t\tint count = 0;\n\n\t\tArrayList<Integer> time = new ArrayList<>();\n\t\tArrayList<String> name = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint total = 0;\n\t\tint count = 0;\n\n\t\tArrayList<Integer> time = new ArrayList<>();\n\t\tArrayList<String> name = new ArrayList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tif (time.get(count) <= q) {\n\t\t\t\ttotal += time.get(count);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", name.get(count), total);\n\t\t\t\ttime.remove(count);\n\t\t\t\tname.remove(count);\n\t\t\t\tcount = count >= name.size() ? 0 : count;\n\t\t\t} else {\n\t\t\t\ttotal += q;\n\t\t\t\ttime.set(count, time.get(count) - q);\n\t\t\t\tcount = ++count >= name.size() ? 0 : count;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n}",
"Main"
] | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
int total = 0;
int count = 0;
ArrayList<Integer> time = new ArrayList<>();
ArrayList<String> name = new ArrayList<>();
for (int i = 0; i < n; i++) {
name.add(sc.next());
time.add(sc.nextInt());
}
while (time.size() != 0) {
if (time.get(count) <= q) {
total += time.get(count);
System.out.printf("%s %d\n", name.get(count), total);
time.remove(count);
name.remove(count);
count = count >= name.size() ? 0 : count;
} else {
total += q;
time.set(count, time.get(count) - q);
count = ++count >= name.size() ? 0 : count;
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
41,
13,
20,
38,
5,
13,
30,
4,
18,
18,
13,
13,
13,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
18,
13,
13,
20,
4,
13,
18,
13,
13,
41,
13,
17,
42,
2,
0,
13,
4,
13,
17,
30,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
41,
13,
4,
18,
13,
4,
18,
13,
2,
13,
13,
4,
13,
13,
12,
13,
30,
14,
2,
13,
17,
30,
0,
13,
13,
0,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
18,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
17,
30,
41,
13,
13,
0,
13,
18,
13,
13,
0,
18,
13,
13,
17,
29,
13,
29,
17,
12,
13,
30,
41,
13,
13,
42,
2,
13,
17,
30,
4,
18,
18,
13,
13,
13,
0,
13,
18,
13,
13,
12,
13,
30,
20,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
0,
13,
13,
23,
13,
12,
13,
30,
29,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
4,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
13,
14
],
[
12,
15
],
[
15,
16
],
[
15,
17
],
[
12,
18
],
[
18,
19
],
[
18,
20
],
[
12,
21
],
[
21,
22
],
[
12,
23
],
[
23,
24
],
[
12,
25
],
[
25,
26
],
[
25,
27
],
[
12,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
28,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
41,
46
],
[
38,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
52,
54
],
[
38,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
60,
62
],
[
38,
63
],
[
63,
64
],
[
63,
65
],
[
38,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
72,
73
],
[
72,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
67,
78
],
[
79,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
82,
87
],
[
79,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
79,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
12,
98
],
[
98,
99
],
[
98,
100
],
[
12,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
102,
107
],
[
101,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
110,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
127,
127
],
[
127,
128
],
[
127,
129
],
[
127,
130
],
[
109,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
131,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
143,
144
],
[
143,
145
],
[
131,
146
],
[
146,
147
],
[
146,
148
],
[
4,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
160,
161
],
[
160,
162
],
[
152,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
163,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
171,
173
],
[
149,
174
],
[
174,
175
],
[
4,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
189,
191
],
[
183,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
183,
197
],
[
197,
198
],
[
178,
199
],
[
199,
200
],
[
4,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
212,
217
],
[
211,
218
],
[
218,
219
],
[
218,
220
],
[
220,
221
],
[
220,
222
],
[
4,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
223,
227
],
[
227,
228
],
[
0,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
229,
233
],
[
233,
234
],
[
229,
235
],
[
235,
236
],
[
229,
237
],
[
237,
238
],
[
237,
239
],
[
239,
240
],
[
240,
241
],
[
241,
242
],
[
241,
243
],
[
240,
244
],
[
239,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
245,
249
],
[
237,
250
],
[
250,
251
],
[
237,
252
],
[
252,
253
],
[
229,
254
],
[
254,
255
],
[
254,
256
],
[
256,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
229,
261
],
[
261,
262
],
[
261,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
265,
267
],
[
264,
268
],
[
261,
269
],
[
269,
270
],
[
229,
271
],
[
271,
272
],
[
271,
273
],
[
273,
274
],
[
274,
275
],
[
274,
276
],
[
271,
277
],
[
277,
278
],
[
229,
279
],
[
279,
280
],
[
279,
281
],
[
281,
282
],
[
282,
283
]
] | [
"import java.io.*;\n\nclass Main{\n\tprivate Node first, last;\n\n\tpublic Main(){\n\t\tint n, limit = 0, timeSt = 0;\n\t\tString[] tmp;\n\t\tNode[] process;\n\n\t\tBufferedReader br = \n\t\t\tnew BufferedReader(new InputStreamReader(System.in), 1);\n\t\ttry{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tn = Integer.parseInt(tmp[0]);\n\t\t\tlimit = Integer.parseInt(tmp[1]);\n\t\t\tprocess = new Node[n];\n\n\t\t\tfor(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}\n\n\t\t}catch(IOException e){\n\t\t\tSystem.out.println(e);\n\t\t}\n\t\tNode node = null;\n\t\twhile( (node = dequeue()) != null){\n\t\t\tif( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid enqueue(Node p){\n\t\tif(first == null){\n\t\t\tlast = p;\n\t\t\tfirst = last; \n\t\t} else{\n\t\t\tlast.next = p;\n\t\t\tlast = last.next;\n\t\t}\n\t}\n\tNode dequeue(){\n\t\tif(first != null){\n\t\t\tNode tmp = first;\n\t\t\tfirst = first.next;\n\t\t\ttmp.next = null;\n\t\t\treturn tmp;\n\t\t}\n\t\treturn null;\n\t}\n\n\tvoid printQueue(){\n\t\tNode n = first;\n\t\twhile(n != null){\n\t\t\tSystem.out.println(n);\n\t\t\tn = n.next;\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args){\n\t\tnew Main();\n\t}\n}\n\nclass Node{\n\tprivate String name;\n\tprivate int time;\n\tNode next;\n\n\tNode(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tint getTime(){\n\t\treturn this.time;\n\t}\n\tvoid setTime(int time){\n\t\tthis.time = time;\n\t}\n\tvoid setNext(Node n){\n\t\tnext = n;\n\t}\n\t@Override\n\tpublic String toString(){\n\t\treturn name;\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"class Main{\n\tprivate Node first, last;\n\n\tpublic Main(){\n\t\tint n, limit = 0, timeSt = 0;\n\t\tString[] tmp;\n\t\tNode[] process;\n\n\t\tBufferedReader br = \n\t\t\tnew BufferedReader(new InputStreamReader(System.in), 1);\n\t\ttry{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tn = Integer.parseInt(tmp[0]);\n\t\t\tlimit = Integer.parseInt(tmp[1]);\n\t\t\tprocess = new Node[n];\n\n\t\t\tfor(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}\n\n\t\t}catch(IOException e){\n\t\t\tSystem.out.println(e);\n\t\t}\n\t\tNode node = null;\n\t\twhile( (node = dequeue()) != null){\n\t\t\tif( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid enqueue(Node p){\n\t\tif(first == null){\n\t\t\tlast = p;\n\t\t\tfirst = last; \n\t\t} else{\n\t\t\tlast.next = p;\n\t\t\tlast = last.next;\n\t\t}\n\t}\n\tNode dequeue(){\n\t\tif(first != null){\n\t\t\tNode tmp = first;\n\t\t\tfirst = first.next;\n\t\t\ttmp.next = null;\n\t\t\treturn tmp;\n\t\t}\n\t\treturn null;\n\t}\n\n\tvoid printQueue(){\n\t\tNode n = first;\n\t\twhile(n != null){\n\t\t\tSystem.out.println(n);\n\t\t\tn = n.next;\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args){\n\t\tnew Main();\n\t}\n}",
"Main",
"private Node first",
"first",
"last;",
"last",
"public Main(){\n\t\tint n, limit = 0, timeSt = 0;\n\t\tString[] tmp;\n\t\tNode[] process;\n\n\t\tBufferedReader br = \n\t\t\tnew BufferedReader(new InputStreamReader(System.in), 1);\n\t\ttry{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tn = Integer.parseInt(tmp[0]);\n\t\t\tlimit = Integer.parseInt(tmp[1]);\n\t\t\tprocess = new Node[n];\n\n\t\t\tfor(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}\n\n\t\t}catch(IOException e){\n\t\t\tSystem.out.println(e);\n\t\t}\n\t\tNode node = null;\n\t\twhile( (node = dequeue()) != null){\n\t\t\tif( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}\n\t\t}\n\t}",
"Main",
"{\n\t\tint n, limit = 0, timeSt = 0;\n\t\tString[] tmp;\n\t\tNode[] process;\n\n\t\tBufferedReader br = \n\t\t\tnew BufferedReader(new InputStreamReader(System.in), 1);\n\t\ttry{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tn = Integer.parseInt(tmp[0]);\n\t\t\tlimit = Integer.parseInt(tmp[1]);\n\t\t\tprocess = new Node[n];\n\n\t\t\tfor(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}\n\n\t\t}catch(IOException e){\n\t\t\tSystem.out.println(e);\n\t\t}\n\t\tNode node = null;\n\t\twhile( (node = dequeue()) != null){\n\t\t\tif( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}\n\t\t}\n\t}",
"int n",
"n",
"limit = 0",
"limit",
"0",
"timeSt = 0;",
"timeSt",
"0",
"String[] tmp;",
"tmp",
"Node[] process;",
"process",
"BufferedReader br = \n\t\t\tnew BufferedReader(new InputStreamReader(System.in), 1);",
"br",
"new BufferedReader(new InputStreamReader(System.in), 1)",
"try{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tn = Integer.parseInt(tmp[0]);\n\t\t\tlimit = Integer.parseInt(tmp[1]);\n\t\t\tprocess = new Node[n];\n\n\t\t\tfor(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}\n\n\t\t}catch(IOException e){\n\t\t\tSystem.out.println(e);\n\t\t}",
"catch(IOException e){\n\t\t\tSystem.out.println(e);\n\t\t}",
"IOException e",
"{\n\t\t\tSystem.out.println(e);\n\t\t}",
"System.out.println(e)",
"System.out.println",
"System.out",
"System",
"System.out",
"e",
"{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tn = Integer.parseInt(tmp[0]);\n\t\t\tlimit = Integer.parseInt(tmp[1]);\n\t\t\tprocess = new Node[n];\n\n\t\t\tfor(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}\n\n\t\t}",
"tmp = br.readLine().split(\" \")",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"n = Integer.parseInt(tmp[0])",
"n",
"Integer.parseInt(tmp[0])",
"Integer.parseInt",
"Integer",
"tmp[0]",
"tmp",
"0",
"limit = Integer.parseInt(tmp[1])",
"limit",
"Integer.parseInt(tmp[1])",
"Integer.parseInt",
"Integer",
"tmp[1]",
"tmp",
"1",
"process = new Node[n]",
"process",
"new Node[n]",
"n",
"for(int i=0; i < n; i++){\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}",
"{\n\t\t\t\ttmp = br.readLine().split(\" \");\n\t\t\t\tprocess[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]));\n\t\t\t\tenqueue(process[i]);\n\t\t\t}",
"tmp = br.readLine().split(\" \")",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"process[i] = \n\t\t\t\t\tnew Node(tmp[0], Integer.parseInt(tmp[1]))",
"process[i]",
"process",
"i",
"new Node(tmp[0], Integer.parseInt(tmp[1]))",
"enqueue(process[i])",
"enqueue",
"process[i]",
"process",
"i",
"Node node = null;",
"node",
"null",
"while( (node = dequeue()) != null){\n\t\t\tif( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}\n\t\t}",
"(node = dequeue()) != null",
"(node = dequeue())",
"node",
"dequeue()",
"dequeue",
"null",
"{\n\t\t\tif( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}\n\t\t}",
"if( node.getTime() <= limit){\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}else{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}",
"node.getTime() <= limit",
"node.getTime()",
"node.getTime",
"node",
"limit",
"{\n\t\t\t\ttimeSt += node.getTime(); \n\t\t\t\tSystem.out.println(node+\" \"+timeSt);\n\t\t\t}",
"timeSt += node.getTime()",
"timeSt",
"node.getTime()",
"node.getTime",
"node",
"System.out.println(node+\" \"+timeSt)",
"System.out.println",
"System.out",
"System",
"System.out",
"node+\" \"+timeSt",
"node+\" \"+timeSt",
"node",
"\" \"",
"timeSt",
"{\n\t\t\t\ttimeSt += limit;\n\t\t\t\tint t = node.getTime();\n\t\t\t\tnode.setTime(t - limit);\n\t\t\t\tenqueue(node);\n\t\t\t}",
"timeSt += limit",
"timeSt",
"limit",
"int t = node.getTime();",
"t",
"node.getTime()",
"node.getTime",
"node",
"node.setTime(t - limit)",
"node.setTime",
"node",
"t - limit",
"t",
"limit",
"enqueue(node)",
"enqueue",
"node",
"void enqueue(Node p){\n\t\tif(first == null){\n\t\t\tlast = p;\n\t\t\tfirst = last; \n\t\t} else{\n\t\t\tlast.next = p;\n\t\t\tlast = last.next;\n\t\t}\n\t}",
"enqueue",
"{\n\t\tif(first == null){\n\t\t\tlast = p;\n\t\t\tfirst = last; \n\t\t} else{\n\t\t\tlast.next = p;\n\t\t\tlast = last.next;\n\t\t}\n\t}",
"if(first == null){\n\t\t\tlast = p;\n\t\t\tfirst = last; \n\t\t} else{\n\t\t\tlast.next = p;\n\t\t\tlast = last.next;\n\t\t}",
"first == null",
"first",
"null",
"{\n\t\t\tlast = p;\n\t\t\tfirst = last; \n\t\t}",
"last = p",
"last",
"p",
"first = last",
"first",
"last",
"{\n\t\t\tlast.next = p;\n\t\t\tlast = last.next;\n\t\t}",
"last.next = p",
"last.next",
"last",
"last.next",
"p",
"last = last.next",
"last",
"last.next",
"last",
"last.next",
"Node p",
"p",
"Node dequeue(){\n\t\tif(first != null){\n\t\t\tNode tmp = first;\n\t\t\tfirst = first.next;\n\t\t\ttmp.next = null;\n\t\t\treturn tmp;\n\t\t}\n\t\treturn null;\n\t}",
"dequeue",
"{\n\t\tif(first != null){\n\t\t\tNode tmp = first;\n\t\t\tfirst = first.next;\n\t\t\ttmp.next = null;\n\t\t\treturn tmp;\n\t\t}\n\t\treturn null;\n\t}",
"if(first != null){\n\t\t\tNode tmp = first;\n\t\t\tfirst = first.next;\n\t\t\ttmp.next = null;\n\t\t\treturn tmp;\n\t\t}",
"first != null",
"first",
"null",
"{\n\t\t\tNode tmp = first;\n\t\t\tfirst = first.next;\n\t\t\ttmp.next = null;\n\t\t\treturn tmp;\n\t\t}",
"Node tmp = first;",
"tmp",
"first",
"first = first.next",
"first",
"first.next",
"first",
"first.next",
"tmp.next = null",
"tmp.next",
"tmp",
"tmp.next",
"null",
"return tmp;",
"tmp",
"return null;",
"null",
"void printQueue(){\n\t\tNode n = first;\n\t\twhile(n != null){\n\t\t\tSystem.out.println(n);\n\t\t\tn = n.next;\n\t\t}\n\t}",
"printQueue",
"{\n\t\tNode n = first;\n\t\twhile(n != null){\n\t\t\tSystem.out.println(n);\n\t\t\tn = n.next;\n\t\t}\n\t}",
"Node n = first;",
"n",
"first",
"while(n != null){\n\t\t\tSystem.out.println(n);\n\t\t\tn = n.next;\n\t\t}",
"n != null",
"n",
"null",
"{\n\t\t\tSystem.out.println(n);\n\t\t\tn = n.next;\n\t\t}",
"System.out.println(n)",
"System.out.println",
"System.out",
"System",
"System.out",
"n",
"n = n.next",
"n",
"n.next",
"n",
"n.next",
"public static void main(String[] args){\n\t\tnew Main();\n\t}",
"main",
"{\n\t\tnew Main();\n\t}",
"new Main()",
"String[] args",
"args",
"class Node{\n\tprivate String name;\n\tprivate int time;\n\tNode next;\n\n\tNode(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tint getTime(){\n\t\treturn this.time;\n\t}\n\tvoid setTime(int time){\n\t\tthis.time = time;\n\t}\n\tvoid setNext(Node n){\n\t\tnext = n;\n\t}\n\t@Override\n\tpublic String toString(){\n\t\treturn name;\n\t}\n}",
"Node",
"private String name;",
"name",
"private int time;",
"time",
"Node next;",
"next",
"Node(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Node",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"int getTime(){\n\t\treturn this.time;\n\t}",
"getTime",
"{\n\t\treturn this.time;\n\t}",
"return this.time;",
"this.time",
"this",
"this.time",
"void setTime(int time){\n\t\tthis.time = time;\n\t}",
"setTime",
"{\n\t\tthis.time = time;\n\t}",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"void setNext(Node n){\n\t\tnext = n;\n\t}",
"setNext",
"{\n\t\tnext = n;\n\t}",
"next = n",
"next",
"n",
"Node n",
"n",
"@Override\n\tpublic String toString(){\n\t\treturn name;\n\t}",
"toString",
"{\n\t\treturn name;\n\t}",
"return name;",
"name"
] | import java.io.*;
class Main{
private Node first, last;
public Main(){
int n, limit = 0, timeSt = 0;
String[] tmp;
Node[] process;
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in), 1);
try{
tmp = br.readLine().split(" ");
n = Integer.parseInt(tmp[0]);
limit = Integer.parseInt(tmp[1]);
process = new Node[n];
for(int i=0; i < n; i++){
tmp = br.readLine().split(" ");
process[i] =
new Node(tmp[0], Integer.parseInt(tmp[1]));
enqueue(process[i]);
}
}catch(IOException e){
System.out.println(e);
}
Node node = null;
while( (node = dequeue()) != null){
if( node.getTime() <= limit){
timeSt += node.getTime();
System.out.println(node+" "+timeSt);
}else{
timeSt += limit;
int t = node.getTime();
node.setTime(t - limit);
enqueue(node);
}
}
}
void enqueue(Node p){
if(first == null){
last = p;
first = last;
} else{
last.next = p;
last = last.next;
}
}
Node dequeue(){
if(first != null){
Node tmp = first;
first = first.next;
tmp.next = null;
return tmp;
}
return null;
}
void printQueue(){
Node n = first;
while(n != null){
System.out.println(n);
n = n.next;
}
}
public static void main(String[] args){
new Main();
}
}
class Node{
private String name;
private int time;
Node next;
Node(String name, int time){
this.name = name;
this.time = time;
}
int getTime(){
return this.time;
}
void setTime(int time){
this.time = time;
}
void setNext(Node n){
next = n;
}
@Override
public String toString(){
return name;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
20,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
13,
41,
13,
17,
11,
1,
40,
4,
18,
13,
30,
30,
41,
13,
4,
18,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
4,
18,
13,
13,
9,
4,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
29,
32
],
[
32,
33
],
[
33,
34
],
[
20,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
37,
40
],
[
40,
41
],
[
41,
42
],
[
20,
43
],
[
43,
44
],
[
44,
45
],
[
20,
46
],
[
46,
47
],
[
46,
48
],
[
20,
50
],
[
50,
51
],
[
50,
52
],
[
20,
54
],
[
54,
55
],
[
54,
56
],
[
20,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
62,
63
],
[
62,
64
],
[
57,
65
],
[
65,
66
],
[
66,
67
],
[
57,
68
],
[
69,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
69,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
88,
89
],
[
69,
90
],
[
90,
91
],
[
91,
92
],
[
69,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
20,
97
],
[
97,
98
],
[
97,
99
],
[
20,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
100,
106
],
[
107,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
107,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
107,
118
],
[
118,
119
],
[
118,
120
],
[
107,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
139,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
139,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
127,
148
],
[
107,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
18,
153
],
[
153,
154
]
] | [
"\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.Queue;\nimport java.util.Scanner;\nimport java.util.concurrent.ConcurrentLinkedQueue;\n\nclass Main {\n\n\t/*\n\t * 最初は10番目のテストケースでTLEになったのがショックでした\n\t */\n\n\tpublic static void main(String[] args) throws Exception {\n\t\t//入力と準備\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tScanner scanner = new Scanner(br.readLine());\n\t\tint n = Integer.parseInt(scanner.next());\n\t\tint quantum = Integer.parseInt(scanner.next());\n\t\tscanner.close();\n\t\tString name[] = new String[n];\n\t\tint time[] = new int[n];\n\t\tQueue<Integer> queue = new ConcurrentLinkedQueue<Integer>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}\n\t\tint currentTime = 0;\n\t\t//順に処理\n\t\tfor(;!queue.isEmpty();) {\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}\n\n\t}\n\n}\n\n",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.concurrent.ConcurrentLinkedQueue;",
"ConcurrentLinkedQueue",
"java.util.concurrent",
"class Main {\n\n\t/*\n\t * 最初は10番目のテストケースでTLEになったのがショックでした\n\t */\n\n\tpublic static void main(String[] args) throws Exception {\n\t\t//入力と準備\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tScanner scanner = new Scanner(br.readLine());\n\t\tint n = Integer.parseInt(scanner.next());\n\t\tint quantum = Integer.parseInt(scanner.next());\n\t\tscanner.close();\n\t\tString name[] = new String[n];\n\t\tint time[] = new int[n];\n\t\tQueue<Integer> queue = new ConcurrentLinkedQueue<Integer>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}\n\t\tint currentTime = 0;\n\t\t//順に処理\n\t\tfor(;!queue.isEmpty();) {\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\t//入力と準備\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tScanner scanner = new Scanner(br.readLine());\n\t\tint n = Integer.parseInt(scanner.next());\n\t\tint quantum = Integer.parseInt(scanner.next());\n\t\tscanner.close();\n\t\tString name[] = new String[n];\n\t\tint time[] = new int[n];\n\t\tQueue<Integer> queue = new ConcurrentLinkedQueue<Integer>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}\n\t\tint currentTime = 0;\n\t\t//順に処理\n\t\tfor(;!queue.isEmpty();) {\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}\n\n\t}",
"main",
"{\n\t\t//入力と準備\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tScanner scanner = new Scanner(br.readLine());\n\t\tint n = Integer.parseInt(scanner.next());\n\t\tint quantum = Integer.parseInt(scanner.next());\n\t\tscanner.close();\n\t\tString name[] = new String[n];\n\t\tint time[] = new int[n];\n\t\tQueue<Integer> queue = new ConcurrentLinkedQueue<Integer>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}\n\t\tint currentTime = 0;\n\t\t//順に処理\n\t\tfor(;!queue.isEmpty();) {\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}\n\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"Scanner scanner = new Scanner(br.readLine());",
"scanner",
"new Scanner(br.readLine())",
"int n = Integer.parseInt(scanner.next());",
"n",
"Integer.parseInt(scanner.next())",
"Integer.parseInt",
"Integer",
"scanner.next()",
"scanner.next",
"scanner",
"int quantum = Integer.parseInt(scanner.next());",
"quantum",
"Integer.parseInt(scanner.next())",
"Integer.parseInt",
"Integer",
"scanner.next()",
"scanner.next",
"scanner",
"scanner.close()",
"scanner.close",
"scanner",
"String name[] = new String[n];",
"name",
"new String[n]",
"n",
"int time[] = new int[n];",
"time",
"new int[n]",
"n",
"Queue<Integer> queue = new ConcurrentLinkedQueue<Integer>();",
"queue",
"new ConcurrentLinkedQueue<Integer>()",
"for(int i=0; i<n; i++) {\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}",
"{\n\t\t\tscanner = new Scanner(br.readLine());\n\t\t\tname[i] = scanner.next();\n\t\t\ttime[i] = Integer.parseInt(scanner.next());\n\t\t\tscanner.close();\n\t\t\tqueue.add(i);\n\t\t}",
"scanner = new Scanner(br.readLine())",
"scanner",
"new Scanner(br.readLine())",
"name[i] = scanner.next()",
"name[i]",
"name",
"i",
"scanner.next()",
"scanner.next",
"scanner",
"time[i] = Integer.parseInt(scanner.next())",
"time[i]",
"time",
"i",
"Integer.parseInt(scanner.next())",
"Integer.parseInt",
"Integer",
"scanner.next()",
"scanner.next",
"scanner",
"scanner.close()",
"scanner.close",
"scanner",
"queue.add(i)",
"queue.add",
"queue",
"i",
"int currentTime = 0;",
"currentTime",
"0",
"for(;!queue.isEmpty();) {\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}",
";",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}",
"{\n\t\t\tInteger taskNo = queue.poll();\n\t\t\ttime[taskNo] -= quantum;\n\t\t\tcurrentTime += quantum;\n\t\t\tif(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tqueue.add(taskNo);\n\t\t}",
"Integer taskNo = queue.poll();",
"taskNo",
"queue.poll()",
"queue.poll",
"queue",
"time[taskNo] -= quantum",
"time[taskNo]",
"time",
"taskNo",
"quantum",
"currentTime += quantum",
"currentTime",
"quantum",
"if(time[taskNo] <= 0) {\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}",
"time[taskNo] <= 0",
"time[taskNo]",
"time",
"taskNo",
"0",
"{\n\t\t\t\tcurrentTime += time[taskNo];//超過しているので戻す\n\t\t\t\tSystem.out.println(name[taskNo]+\" \"+String.valueOf(currentTime));\n\t\t\t\tcontinue;\n\t\t\t}",
"currentTime += time[taskNo]",
"currentTime",
"time[taskNo]",
"time",
"taskNo",
"System.out.println(name[taskNo]+\" \"+String.valueOf(currentTime))",
"System.out.println",
"System.out",
"System",
"System.out",
"name[taskNo]+\" \"+String.valueOf(currentTime)",
"name[taskNo]+\" \"+String.valueOf(currentTime)",
"name[taskNo]",
"name",
"taskNo",
"\" \"",
"String.valueOf(currentTime)",
"String.valueOf",
"String",
"currentTime",
"continue;",
"queue.add(taskNo)",
"queue.add",
"queue",
"taskNo",
"String[] args",
"args"
] |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.ConcurrentLinkedQueue;
class Main {
/*
* 最初は10番目のテストケースでTLEになったのがショックでした
*/
public static void main(String[] args) throws Exception {
//入力と準備
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Scanner scanner = new Scanner(br.readLine());
int n = Integer.parseInt(scanner.next());
int quantum = Integer.parseInt(scanner.next());
scanner.close();
String name[] = new String[n];
int time[] = new int[n];
Queue<Integer> queue = new ConcurrentLinkedQueue<Integer>();
for(int i=0; i<n; i++) {
scanner = new Scanner(br.readLine());
name[i] = scanner.next();
time[i] = Integer.parseInt(scanner.next());
scanner.close();
queue.add(i);
}
int currentTime = 0;
//順に処理
for(;!queue.isEmpty();) {
Integer taskNo = queue.poll();
time[taskNo] -= quantum;
currentTime += quantum;
if(time[taskNo] <= 0) {
currentTime += time[taskNo];//超過しているので戻す
System.out.println(name[taskNo]+" "+String.valueOf(currentTime));
continue;
}
queue.add(taskNo);
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
4,
18,
20,
23,
13,
12,
13,
30,
0,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
4,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
136,
8
],
[
136,
9
],
[
9,
10
],
[
136,
11
],
[
11,
12
],
[
11,
13
],
[
13,
14
],
[
14,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
136,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
25,
27
],
[
21,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
21,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
21,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
21,
55
],
[
55,
56
],
[
55,
57
],
[
21,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
58,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
63,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
71,
75
],
[
75,
76
],
[
75,
77
],
[
63,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
63,
83
],
[
83,
84
],
[
83,
85
],
[
63,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
86,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
104,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
104,
109
],
[
0,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
110,
114
],
[
114,
115
],
[
110,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
118,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
116,
131
],
[
131,
132
],
[
116,
133
],
[
133,
134
],
[
0,
135
],
[
135,
136
],
[
135,
137
]
] | [
"\nimport java.util.ArrayDeque;\nimport java.util.Scanner;\n\npublic class Main {\n\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }\n }\n}\n\nclass q1_3 {\n String name;\n int time;\n\n public q1_3(String name, int time) {\n super();\n this.name = name;\n this.time = time;\n }\n\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }\n }\n}",
"Main",
"private Scanner sc;",
"sc",
"public static void main(String[] args) {\n new Main().solve();\n }",
"main",
"{\n new Main().solve();\n }",
"new Main().solve()",
"new Main().solve",
"new Main()",
"String[] args",
"args",
"private void solve() {\n sc = new Scanner(System.in);\n java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }\n }",
"solve",
"{\n sc = new Scanner(System.in);\n java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }\n }",
"sc = new Scanner(System.in)",
"sc",
"new Scanner(System.in)",
"java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();",
"queue",
"new ArrayDeque<q1_3>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }",
"{\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }",
"queue.offer(new q1_3(sc.next(), sc.nextInt()))",
"queue.offer",
"queue",
"new q1_3(sc.next(), sc.nextInt())",
"int sum = 0;",
"sum",
"0",
"while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }",
"q1_3 now = queue.poll();",
"now",
"queue.poll()",
"queue.poll",
"queue",
"int d = Math.min(q, now.time);",
"d",
"Math.min(q, now.time)",
"Math.min",
"Math",
"q",
"now.time",
"now",
"now.time",
"now.time -= d",
"now.time",
"now",
"now.time",
"d",
"sum += d",
"sum",
"d",
"if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }",
"now.time > 0",
"now.time",
"now",
"now.time",
"0",
"{\n queue.offer(now);\n }",
"queue.offer(now)",
"queue.offer",
"queue",
"now",
"{\n\n System.out.println(now.name + \" \" + sum);\n }",
"System.out.println(now.name + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"now.name + \" \" + sum",
"now.name + \" \" + sum",
"now.name",
"now",
"now.name",
"\" \"",
"sum",
"class q1_3 {\n String name;\n int time;\n\n public q1_3(String name, int time) {\n super();\n this.name = name;\n this.time = time;\n }\n\n}",
"q1_3",
"String name;",
"name",
"int time;",
"time",
"public q1_3(String name, int time) {\n super();\n this.name = name;\n this.time = time;\n }",
"q1_3",
"{\n super();\n this.name = name;\n this.time = time;\n }",
"super()",
"super",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }\n }\n}",
"public class Main {\n\n\n private Scanner sc;\n\n public static void main(String[] args) {\n new Main().solve();\n }\n\n private void solve() {\n sc = new Scanner(System.in);\n java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n for (int i = 0; i < n; i++) {\n queue.offer(new q1_3(sc.next(), sc.nextInt()));\n }\n int sum = 0;\n while (!queue.isEmpty()) {\n q1_3 now = queue.poll();\n int d = Math.min(q, now.time);\n now.time -= d;\n sum += d;\n if (now.time > 0) {\n queue.offer(now);\n } else {\n\n System.out.println(now.name + \" \" + sum);\n }\n }\n }\n}",
"Main"
] |
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main {
private Scanner sc;
public static void main(String[] args) {
new Main().solve();
}
private void solve() {
sc = new Scanner(System.in);
java.util.Queue<q1_3> queue = new ArrayDeque<q1_3>();
int n = sc.nextInt();
int q = sc.nextInt();
for (int i = 0; i < n; i++) {
queue.offer(new q1_3(sc.next(), sc.nextInt()));
}
int sum = 0;
while (!queue.isEmpty()) {
q1_3 now = queue.poll();
int d = Math.min(q, now.time);
now.time -= d;
sum += d;
if (now.time > 0) {
queue.offer(now);
} else {
System.out.println(now.name + " " + sum);
}
}
}
}
class q1_3 {
String name;
int time;
public q1_3(String name, int time) {
super();
this.name = name;
this.time = time;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
20,
17,
41,
13,
20,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
40,
13,
30,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
30,
3,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
174,
5
],
[
174,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
8,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
44,
45
],
[
45,
46
],
[
40,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
51,
52
],
[
8,
53
],
[
53,
54
],
[
53,
55
],
[
8,
56
],
[
56,
57
],
[
56,
58
],
[
8,
59
],
[
59,
60
],
[
59,
61
],
[
8,
63
],
[
63,
64
],
[
63,
65
],
[
8,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
67,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
72,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
72,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
72,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
72,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
97,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
97,
111
],
[
111,
112
],
[
93,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
118,
119
],
[
114,
120
],
[
113,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
124,
125
],
[
125,
126
],
[
121,
127
],
[
127,
128
],
[
127,
129
],
[
113,
130
],
[
130,
131
],
[
130,
132
],
[
8,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
140,
142
],
[
133,
143
],
[
143,
144
],
[
144,
145
],
[
133,
146
],
[
147,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
148,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
161,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
161,
166
],
[
166,
167
],
[
166,
168
],
[
148,
169
],
[
169,
170
],
[
6,
171
],
[
171,
172
],
[
0,
173
],
[
173,
174
],
[
173,
175
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n ArrayList<String> name = new ArrayList<>();\n ArrayList<Integer> time = new ArrayList<>();\n\n int numberProc = inp.nextInt();\n int quantity = inp.nextInt();\n\n for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }\n\n int finalCount = 0;\n\n int finalplaceholder = 0;\n\n String[] finalName = new String[100005];\n int[] finalTime = new int[100005];\n\n while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }\n\n for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n ArrayList<String> name = new ArrayList<>();\n ArrayList<Integer> time = new ArrayList<>();\n\n int numberProc = inp.nextInt();\n int quantity = inp.nextInt();\n\n for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }\n\n int finalCount = 0;\n\n int finalplaceholder = 0;\n\n String[] finalName = new String[100005];\n int[] finalTime = new int[100005];\n\n while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }\n\n for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n ArrayList<String> name = new ArrayList<>();\n ArrayList<Integer> time = new ArrayList<>();\n\n int numberProc = inp.nextInt();\n int quantity = inp.nextInt();\n\n for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }\n\n int finalCount = 0;\n\n int finalplaceholder = 0;\n\n String[] finalName = new String[100005];\n int[] finalTime = new int[100005];\n\n while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }\n\n for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }\n }",
"main",
"{\n Scanner inp = new Scanner(System.in);\n\n ArrayList<String> name = new ArrayList<>();\n ArrayList<Integer> time = new ArrayList<>();\n\n int numberProc = inp.nextInt();\n int quantity = inp.nextInt();\n\n for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }\n\n int finalCount = 0;\n\n int finalplaceholder = 0;\n\n String[] finalName = new String[100005];\n int[] finalTime = new int[100005];\n\n while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }\n\n for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }\n }",
"Scanner inp = new Scanner(System.in);",
"inp",
"new Scanner(System.in)",
"ArrayList<String> name = new ArrayList<>();",
"name",
"new ArrayList<>()",
"ArrayList<Integer> time = new ArrayList<>();",
"time",
"new ArrayList<>()",
"int numberProc = inp.nextInt();",
"numberProc",
"inp.nextInt()",
"inp.nextInt",
"inp",
"int quantity = inp.nextInt();",
"quantity",
"inp.nextInt()",
"inp.nextInt",
"inp",
"for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numberProc",
"i",
"numberProc",
"i++",
"i++",
"i",
"{\n name.add(inp.next());\n time.add(inp.nextInt());\n }",
"{\n name.add(inp.next());\n time.add(inp.nextInt());\n }",
"name.add(inp.next())",
"name.add",
"name",
"inp.next()",
"inp.next",
"inp",
"time.add(inp.nextInt())",
"time.add",
"time",
"inp.nextInt()",
"inp.nextInt",
"inp",
"int finalCount = 0;",
"finalCount",
"0",
"int finalplaceholder = 0;",
"finalplaceholder",
"0",
"String[] finalName = new String[100005];",
"finalName",
"new String[100005]",
"100005",
"int[] finalTime = new int[100005];",
"finalTime",
"new int[100005]",
"100005",
"while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }",
"!name.isEmpty()",
"name.isEmpty()",
"name.isEmpty",
"name",
"{\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }",
"String tempholdName = name.get(0);",
"tempholdName",
"name.get(0)",
"name.get",
"name",
"0",
"int tempholdTime = time.get(0);",
"tempholdTime",
"time.get(0)",
"time.get",
"time",
"0",
"name.remove(0)",
"name.remove",
"name",
"0",
"time.remove(0)",
"time.remove",
"time",
"0",
"if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }",
"tempholdTime <= quantity",
"tempholdTime",
"quantity",
"{\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n }",
"finalCount += tempholdTime",
"finalCount",
"tempholdTime",
"finalName[finalplaceholder] = tempholdName",
"finalName[finalplaceholder]",
"finalName",
"finalplaceholder",
"tempholdName",
"finalTime[finalplaceholder] = finalCount",
"finalTime[finalplaceholder]",
"finalTime",
"finalplaceholder",
"finalCount",
"finalplaceholder++",
"finalplaceholder",
"{\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }",
"name.add(name.size(), tempholdName)",
"name.add",
"name",
"name.size()",
"name.size",
"name",
"tempholdName",
"time.add(time.size(), (tempholdTime-quantity))",
"time.add",
"time",
"time.size()",
"time.size",
"time",
"(tempholdTime-quantity)",
"tempholdTime",
"quantity",
"finalCount += quantity",
"finalCount",
"quantity",
"for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < finalName.length",
"i",
"finalName.length",
"finalName",
"finalName.length",
"i++",
"i++",
"i",
"{\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }",
"{\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }",
"if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }",
"finalName[i] != null",
"finalName[i]",
"finalName",
"i",
"null",
"{\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n }",
"System.out.println(finalName[i] + \" \" + finalTime[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"finalName[i] + \" \" + finalTime[i]",
"finalName[i] + \" \" + finalTime[i]",
"finalName[i]",
"finalName",
"i",
"\" \"",
"finalTime[i]",
"finalTime",
"i",
"{\n break;\n }",
"break;",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n ArrayList<String> name = new ArrayList<>();\n ArrayList<Integer> time = new ArrayList<>();\n\n int numberProc = inp.nextInt();\n int quantity = inp.nextInt();\n\n for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }\n\n int finalCount = 0;\n\n int finalplaceholder = 0;\n\n String[] finalName = new String[100005];\n int[] finalTime = new int[100005];\n\n while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }\n\n for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner inp = new Scanner(System.in);\n\n ArrayList<String> name = new ArrayList<>();\n ArrayList<Integer> time = new ArrayList<>();\n\n int numberProc = inp.nextInt();\n int quantity = inp.nextInt();\n\n for (int i = 0; i < numberProc; i++) {\n name.add(inp.next());\n time.add(inp.nextInt());\n }\n\n int finalCount = 0;\n\n int finalplaceholder = 0;\n\n String[] finalName = new String[100005];\n int[] finalTime = new int[100005];\n\n while (!name.isEmpty()) {\n String tempholdName = name.get(0);\n int tempholdTime = time.get(0);\n\n name.remove(0);\n time.remove(0);\n\n if (tempholdTime <= quantity) {\n finalCount += tempholdTime;\n\n finalName[finalplaceholder] = tempholdName;\n finalTime[finalplaceholder] = finalCount;\n\n finalplaceholder++;\n } else {\n name.add(name.size(), tempholdName);\n time.add(time.size(), (tempholdTime-quantity));\n\n finalCount += quantity;\n }\n }\n\n for (int i = 0; i < finalName.length; i++) {\n if (finalName[i] != null) {\n System.out.println(finalName[i] + \" \" + finalTime[i]);\n } else {\n break;\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
ArrayList<String> name = new ArrayList<>();
ArrayList<Integer> time = new ArrayList<>();
int numberProc = inp.nextInt();
int quantity = inp.nextInt();
for (int i = 0; i < numberProc; i++) {
name.add(inp.next());
time.add(inp.nextInt());
}
int finalCount = 0;
int finalplaceholder = 0;
String[] finalName = new String[100005];
int[] finalTime = new int[100005];
while (!name.isEmpty()) {
String tempholdName = name.get(0);
int tempholdTime = time.get(0);
name.remove(0);
time.remove(0);
if (tempholdTime <= quantity) {
finalCount += tempholdTime;
finalName[finalplaceholder] = tempholdName;
finalTime[finalplaceholder] = finalCount;
finalplaceholder++;
} else {
name.add(name.size(), tempholdName);
time.add(time.size(), (tempholdTime-quantity));
finalCount += quantity;
}
}
for (int i = 0; i < finalName.length; i++) {
if (finalName[i] != null) {
System.out.println(finalName[i] + " " + finalTime[i]);
} else {
break;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
2,
4,
18,
13,
13,
14,
2,
13,
17,
30,
0,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
4,
18,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
198,
11
],
[
198,
12
],
[
12,
13
],
[
198,
14
],
[
14,
15
],
[
198,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
18,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
24,
28
],
[
16,
29
],
[
29,
30
],
[
16,
31
],
[
31,
32
],
[
198,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
198,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
38,
46
],
[
46,
47
],
[
198,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
198,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
53,
61
],
[
61,
62
],
[
198,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
69,
71
],
[
65,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
65,
77
],
[
77,
78
],
[
77,
79
],
[
65,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
85,
86
],
[
86,
87
],
[
65,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
94,
95
],
[
65,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
96,
101
],
[
101,
102
],
[
101,
103
],
[
96,
104
],
[
104,
105
],
[
105,
106
],
[
96,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
108,
114
],
[
114,
115
],
[
114,
116
],
[
108,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
108,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
127,
128
],
[
128,
129
],
[
108,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
65,
134
],
[
134,
135
],
[
134,
136
],
[
65,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
137,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
146,
147
],
[
142,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
150,
154
],
[
142,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
159,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
159,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
175,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
175,
179
],
[
175,
180
],
[
180,
181
],
[
181,
182
],
[
155,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
187,
188
],
[
188,
189
],
[
187,
190
],
[
183,
191
],
[
191,
192
],
[
192,
193
],
[
191,
194
],
[
63,
195
],
[
195,
196
],
[
0,
197
],
[
197,
198
],
[
197,
199
]
] | [
"\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tprivate String name;\n\tprivate int q;\n\n\t//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete\n\tpublic Main(String name, int q) {\n\t\tthis.name = name;\n\t\tthis.q = q;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic int getQ() {\n\t\treturn q;\t\n\t}\n\n\tpublic void setQ(int q) {\n\t\tthis.q = q;\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tQueue<Main> queue = new LinkedList<Main>();\n\t\t\n\t\t//scan first line to get number of processes and the universal quantum\n\t\tString firstLine = in.nextLine();\n\t\tScanner first = new Scanner(firstLine);\n\t\tint items = Integer.parseInt(first.next());\n\t\tint quantum = Integer.parseInt(first.next());\n\n\t\t//create queue with data from file\n\t\tfor(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}\n\t\t\n\t\tint turnCounter = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}\n\t}\n}\n",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tprivate String name;\n\tprivate int q;\n\n\t//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete\n\tpublic Main(String name, int q) {\n\t\tthis.name = name;\n\t\tthis.q = q;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic int getQ() {\n\t\treturn q;\t\n\t}\n\n\tpublic void setQ(int q) {\n\t\tthis.q = q;\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tQueue<Main> queue = new LinkedList<Main>();\n\t\t\n\t\t//scan first line to get number of processes and the universal quantum\n\t\tString firstLine = in.nextLine();\n\t\tScanner first = new Scanner(firstLine);\n\t\tint items = Integer.parseInt(first.next());\n\t\tint quantum = Integer.parseInt(first.next());\n\n\t\t//create queue with data from file\n\t\tfor(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}\n\t\t\n\t\tint turnCounter = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"private String name;",
"name",
"private int q;",
"q",
"//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete\n\tpublic Main(String name, int q) {\n\t\tthis.name = name;\n\t\tthis.q = q;\n\t}",
"Main",
"{\n\t\tthis.name = name;\n\t\tthis.q = q;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.q = q",
"this.q",
"this",
"this.q",
"q",
"String name",
"name",
"int q",
"q",
"public String getName() {\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public void setName(String name) {\n\t\tthis.name = name;\n\t}",
"setName",
"{\n\t\tthis.name = name;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"public int getQ() {\n\t\treturn q;\t\n\t}",
"getQ",
"{\n\t\treturn q;\t\n\t}",
"return q;",
"q",
"public void setQ(int q) {\n\t\tthis.q = q;\n\t}",
"setQ",
"{\n\t\tthis.q = q;\n\t}",
"this.q = q",
"this.q",
"this",
"this.q",
"q",
"int q",
"q",
"public static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tQueue<Main> queue = new LinkedList<Main>();\n\t\t\n\t\t//scan first line to get number of processes and the universal quantum\n\t\tString firstLine = in.nextLine();\n\t\tScanner first = new Scanner(firstLine);\n\t\tint items = Integer.parseInt(first.next());\n\t\tint quantum = Integer.parseInt(first.next());\n\n\t\t//create queue with data from file\n\t\tfor(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}\n\t\t\n\t\tint turnCounter = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tQueue<Main> queue = new LinkedList<Main>();\n\t\t\n\t\t//scan first line to get number of processes and the universal quantum\n\t\tString firstLine = in.nextLine();\n\t\tScanner first = new Scanner(firstLine);\n\t\tint items = Integer.parseInt(first.next());\n\t\tint quantum = Integer.parseInt(first.next());\n\n\t\t//create queue with data from file\n\t\tfor(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}\n\t\t\n\t\tint turnCounter = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"Queue<Main> queue = new LinkedList<Main>();",
"queue",
"new LinkedList<Main>()",
"String firstLine = in.nextLine();",
"firstLine",
"in.nextLine()",
"in.nextLine",
"in",
"Scanner first = new Scanner(firstLine);",
"first",
"new Scanner(firstLine)",
"int items = Integer.parseInt(first.next());",
"items",
"Integer.parseInt(first.next())",
"Integer.parseInt",
"Integer",
"first.next()",
"first.next",
"first",
"int quantum = Integer.parseInt(first.next());",
"quantum",
"Integer.parseInt(first.next())",
"Integer.parseInt",
"Integer",
"first.next()",
"first.next",
"first",
"for(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < items",
"i",
"items",
"i++",
"i++",
"i",
"{\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}",
"{\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}",
"String line = in.nextLine();",
"line",
"in.nextLine()",
"in.nextLine",
"in",
"Scanner linereader = new Scanner(line);",
"linereader",
"new Scanner(line)",
"String itemName = linereader.next();",
"itemName",
"linereader.next()",
"linereader.next",
"linereader",
"int itemQ = Integer.parseInt(linereader.next());",
"itemQ",
"Integer.parseInt(linereader.next())",
"Integer.parseInt",
"Integer",
"linereader.next()",
"linereader.next",
"linereader",
"queue.add(new Main(itemName, itemQ))",
"queue.add",
"queue",
"new Main(itemName, itemQ)",
"int turnCounter = 0;",
"turnCounter",
"0",
"while(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}",
"Main next = queue.remove();",
"next",
"queue.remove()",
"queue.remove",
"queue",
"int qCheck = next.getQ() - quantum;",
"qCheck",
"next.getQ() - quantum",
"next.getQ()",
"next.getQ",
"next",
"quantum",
"if(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}",
"qCheck <= 0",
"qCheck",
"0",
"{\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}",
"turnCounter+= next.getQ()",
"turnCounter",
"next.getQ()",
"next.getQ",
"next",
"next.setQ(turnCounter)",
"next.setQ",
"next",
"turnCounter",
"System.out.println(next.getName() + \" \" + next.getQ())",
"System.out.println",
"System.out",
"System",
"System.out",
"next.getName() + \" \" + next.getQ()",
"next.getName() + \" \" + next.getQ()",
"next.getName()",
"next.getName",
"next",
"\" \"",
"next.getQ()",
"next.getQ",
"next",
"{\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}",
"turnCounter += quantum",
"turnCounter",
"quantum",
"next.setQ(qCheck)",
"next.setQ",
"next",
"qCheck",
"queue.add(next)",
"queue.add",
"queue",
"next",
"String[] args",
"args",
"public class Main {\n\t\n\tprivate String name;\n\tprivate int q;\n\n\t//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete\n\tpublic Main(String name, int q) {\n\t\tthis.name = name;\n\t\tthis.q = q;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic int getQ() {\n\t\treturn q;\t\n\t}\n\n\tpublic void setQ(int q) {\n\t\tthis.q = q;\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tQueue<Main> queue = new LinkedList<Main>();\n\t\t\n\t\t//scan first line to get number of processes and the universal quantum\n\t\tString firstLine = in.nextLine();\n\t\tScanner first = new Scanner(firstLine);\n\t\tint items = Integer.parseInt(first.next());\n\t\tint quantum = Integer.parseInt(first.next());\n\n\t\t//create queue with data from file\n\t\tfor(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}\n\t\t\n\t\tint turnCounter = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\t\n\tprivate String name;\n\tprivate int q;\n\n\t//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete\n\tpublic Main(String name, int q) {\n\t\tthis.name = name;\n\t\tthis.q = q;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic int getQ() {\n\t\treturn q;\t\n\t}\n\n\tpublic void setQ(int q) {\n\t\tthis.q = q;\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tQueue<Main> queue = new LinkedList<Main>();\n\t\t\n\t\t//scan first line to get number of processes and the universal quantum\n\t\tString firstLine = in.nextLine();\n\t\tScanner first = new Scanner(firstLine);\n\t\tint items = Integer.parseInt(first.next());\n\t\tint quantum = Integer.parseInt(first.next());\n\n\t\t//create queue with data from file\n\t\tfor(int i = 0; i < items; i++) {\n\t\t\tString line = in.nextLine();\n\t\t\tScanner linereader = new Scanner(line);\n\t\t\t\n\t\t\tString itemName = linereader.next();\n\t\t\tint itemQ = Integer.parseInt(linereader.next());\n\t\t\t\n\t\t\tqueue.add(new Main(itemName, itemQ));\n\t\t}\n\t\t\n\t\tint turnCounter = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tMain next = queue.remove();\n\t\t\tint qCheck = next.getQ() - quantum;\n\t\t\t\n\t\t\t//if item completes\n\t\t\tif(qCheck <= 0) {\n\t\t\t\tturnCounter+= next.getQ();\n\t\t\t\tnext.setQ(turnCounter);\n\t\t\t\tSystem.out.println(next.getName() + \" \" + next.getQ());\n\t\t\t}\n\t\t\t//else if it has time remaining\n\t\t\telse {\n\t\t\t\tturnCounter += quantum;\n\t\t\t\tnext.setQ(qCheck);\n\t\t\t\tqueue.add(next);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] |
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
private String name;
private int q;
//construct a pair object to keep track of each process's quantum, and a bool to check if it is complete
public Main(String name, int q) {
this.name = name;
this.q = q;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getQ() {
return q;
}
public void setQ(int q) {
this.q = q;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Queue<Main> queue = new LinkedList<Main>();
//scan first line to get number of processes and the universal quantum
String firstLine = in.nextLine();
Scanner first = new Scanner(firstLine);
int items = Integer.parseInt(first.next());
int quantum = Integer.parseInt(first.next());
//create queue with data from file
for(int i = 0; i < items; i++) {
String line = in.nextLine();
Scanner linereader = new Scanner(line);
String itemName = linereader.next();
int itemQ = Integer.parseInt(linereader.next());
queue.add(new Main(itemName, itemQ));
}
int turnCounter = 0;
while(!queue.isEmpty()) {
Main next = queue.remove();
int qCheck = next.getQ() - quantum;
//if item completes
if(qCheck <= 0) {
turnCounter+= next.getQ();
next.setQ(turnCounter);
System.out.println(next.getName() + " " + next.getQ());
}
//else if it has time remaining
else {
turnCounter += quantum;
next.setQ(qCheck);
queue.add(next);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
40,
17,
0,
13,
40,
17,
0,
13,
13,
0,
13,
20,
13,
23,
13,
12,
13,
30,
0,
13,
17,
0,
18,
13,
2,
13,
13,
13,
23,
13,
12,
13,
30,
0,
13,
17,
29,
18,
13,
2,
13,
13,
12,
13,
30,
14,
2,
13,
13,
29,
17,
29,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
38,
5,
13,
30,
4,
18,
13,
30,
41,
13,
17,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
18,
13,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
10,
14
],
[
14,
15
],
[
10,
16
],
[
16,
17
],
[
10,
18
],
[
18,
19
],
[
10,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
22,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
22,
31
],
[
31,
32
],
[
31,
33
],
[
22,
34
],
[
34,
35
],
[
34,
36
],
[
20,
38
],
[
38,
39
],
[
10,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
46,
52
],
[
40,
53
],
[
53,
54
],
[
10,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
10,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
74,
75
],
[
70,
76
],
[
76,
77
],
[
0,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
78,
82
],
[
82,
83
],
[
78,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
84,
97
],
[
97,
98
],
[
84,
99
],
[
99,
100
],
[
0,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
105,
111
],
[
111,
112
],
[
105,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
113,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
126,
131
],
[
120,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
137,
138
],
[
137,
139
],
[
120,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
145,
146
],
[
145,
147
],
[
120,
148
],
[
148,
149
],
[
148,
150
],
[
120,
151
],
[
151,
152
],
[
151,
153
],
[
120,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
159,
160
],
[
159,
161
],
[
154,
162
],
[
162,
163
],
[
163,
164
],
[
154,
165
],
[
166,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
169,
174
],
[
166,
175
],
[
175,
176
],
[
176,
177
],
[
175,
178
],
[
120,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
179,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
184,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
192,
194
],
[
191,
195
],
[
190,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
199,
200
],
[
199,
201
],
[
196,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
202,
207
],
[
202,
208
],
[
208,
209
],
[
208,
210
],
[
202,
211
],
[
190,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
216,
217
],
[
217,
218
],
[
217,
219
],
[
216,
220
],
[
212,
221
],
[
221,
222
],
[
222,
223
],
[
221,
224
],
[
103,
225
],
[
225,
226
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nclass Que {\n int head, tail, length;\n Node[] Narray;\n\n public Que(int inputN) {\n head = -1;\n tail = -1;\n length = inputN;\n Narray = new Node[inputN];\n }\n\n public void enQue(Node node) {\n tail += 1;\n Narray[tail % length] = node;\n }\n\n public Node deQue() {\n head += 1;\n return Narray[head % length];\n }\n\n public boolean isEmpty() {\n if (head == tail)\n return true;\n else\n return false;\n }\n}\n\nclass Node {\n String pName;\n public int time;\n\n public Node(String pName, int time) {\n this.pName = pName;\n this.time = time;\n }\n}\n\nclass Main {\n public static void main(String[] args) {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] inputData;\n String[] nodeData;\n\n try {\n int totalTime = 0;\n inputData = br.readLine().split(\" \");\n int n = Integer.parseInt(inputData[0]);\n int limitTime = Integer.parseInt(inputData[1]);\n Que q = new Que(n);\n Node tmpNode = null;\n for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }\n while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"class Que {\n int head, tail, length;\n Node[] Narray;\n\n public Que(int inputN) {\n head = -1;\n tail = -1;\n length = inputN;\n Narray = new Node[inputN];\n }\n\n public void enQue(Node node) {\n tail += 1;\n Narray[tail % length] = node;\n }\n\n public Node deQue() {\n head += 1;\n return Narray[head % length];\n }\n\n public boolean isEmpty() {\n if (head == tail)\n return true;\n else\n return false;\n }\n}",
"Que",
"int head",
"head",
"tail",
"tail",
"length;",
"length",
"Node[] Narray;",
"Narray",
"public Que(int inputN) {\n head = -1;\n tail = -1;\n length = inputN;\n Narray = new Node[inputN];\n }",
"Que",
"{\n head = -1;\n tail = -1;\n length = inputN;\n Narray = new Node[inputN];\n }",
"head = -1",
"head",
"-1",
"1",
"tail = -1",
"tail",
"-1",
"1",
"length = inputN",
"length",
"inputN",
"Narray = new Node[inputN]",
"Narray",
"new Node[inputN]",
"inputN",
"int inputN",
"inputN",
"public void enQue(Node node) {\n tail += 1;\n Narray[tail % length] = node;\n }",
"enQue",
"{\n tail += 1;\n Narray[tail % length] = node;\n }",
"tail += 1",
"tail",
"1",
"Narray[tail % length] = node",
"Narray[tail % length]",
"Narray",
"tail % length",
"tail",
"length",
"node",
"Node node",
"node",
"public Node deQue() {\n head += 1;\n return Narray[head % length];\n }",
"deQue",
"{\n head += 1;\n return Narray[head % length];\n }",
"head += 1",
"head",
"1",
"return Narray[head % length];",
"Narray[head % length]",
"Narray",
"head % length",
"head",
"length",
"public boolean isEmpty() {\n if (head == tail)\n return true;\n else\n return false;\n }",
"isEmpty",
"{\n if (head == tail)\n return true;\n else\n return false;\n }",
"if (head == tail)\n return true;\n else\n return false;",
"head == tail",
"head",
"tail",
"return true;",
"true",
"return false;",
"false",
"class Node {\n String pName;\n public int time;\n\n public Node(String pName, int time) {\n this.pName = pName;\n this.time = time;\n }\n}",
"Node",
"String pName;",
"pName",
"public int time;",
"time",
"public Node(String pName, int time) {\n this.pName = pName;\n this.time = time;\n }",
"Node",
"{\n this.pName = pName;\n this.time = time;\n }",
"this.pName = pName",
"this.pName",
"this",
"this.pName",
"pName",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String pName",
"pName",
"int time",
"time",
"class Main {\n public static void main(String[] args) {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] inputData;\n String[] nodeData;\n\n try {\n int totalTime = 0;\n inputData = br.readLine().split(\" \");\n int n = Integer.parseInt(inputData[0]);\n int limitTime = Integer.parseInt(inputData[1]);\n Que q = new Que(n);\n Node tmpNode = null;\n for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }\n while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] inputData;\n String[] nodeData;\n\n try {\n int totalTime = 0;\n inputData = br.readLine().split(\" \");\n int n = Integer.parseInt(inputData[0]);\n int limitTime = Integer.parseInt(inputData[1]);\n Que q = new Que(n);\n Node tmpNode = null;\n for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }\n while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] inputData;\n String[] nodeData;\n\n try {\n int totalTime = 0;\n inputData = br.readLine().split(\" \");\n int n = Integer.parseInt(inputData[0]);\n int limitTime = Integer.parseInt(inputData[1]);\n Que q = new Que(n);\n Node tmpNode = null;\n for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }\n while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] inputData;",
"inputData",
"String[] nodeData;",
"nodeData",
"try {\n int totalTime = 0;\n inputData = br.readLine().split(\" \");\n int n = Integer.parseInt(inputData[0]);\n int limitTime = Integer.parseInt(inputData[1]);\n Que q = new Que(n);\n Node tmpNode = null;\n for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }\n while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }\n } catch (IOException e) {\n e.printStackTrace();\n }",
"catch (IOException e) {\n e.printStackTrace();\n }",
"IOException e",
"{\n e.printStackTrace();\n }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n int totalTime = 0;\n inputData = br.readLine().split(\" \");\n int n = Integer.parseInt(inputData[0]);\n int limitTime = Integer.parseInt(inputData[1]);\n Que q = new Que(n);\n Node tmpNode = null;\n for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }\n while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }\n }",
"int totalTime = 0;",
"totalTime",
"0",
"inputData = br.readLine().split(\" \")",
"inputData",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(inputData[0]);",
"n",
"Integer.parseInt(inputData[0])",
"Integer.parseInt",
"Integer",
"inputData[0]",
"inputData",
"0",
"int limitTime = Integer.parseInt(inputData[1]);",
"limitTime",
"Integer.parseInt(inputData[1])",
"Integer.parseInt",
"Integer",
"inputData[1]",
"inputData",
"1",
"Que q = new Que(n);",
"q",
"new Que(n)",
"Node tmpNode = null;",
"tmpNode",
"null",
"for (int i = 0; i < n; i++) {\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }",
"{\n nodeData = br.readLine().split(\" \");\n q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));\n }",
"nodeData = br.readLine().split(\" \")",
"nodeData",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])))",
"q.enQue",
"q",
"new Node(nodeData[0], Integer.parseInt(nodeData[1]))",
"while (!q.isEmpty()) {\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n tmpNode = q.deQue();\n if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }\n }",
"tmpNode = q.deQue()",
"tmpNode",
"q.deQue()",
"q.deQue",
"q",
"if (tmpNode.time <= limitTime) {\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n } else {\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }",
"tmpNode.time <= limitTime",
"tmpNode.time",
"tmpNode",
"tmpNode.time",
"limitTime",
"{\n totalTime += tmpNode.time;\n System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime);\n }",
"totalTime += tmpNode.time",
"totalTime",
"tmpNode.time",
"tmpNode",
"tmpNode.time",
"System.out.printf(\"%s %d\\n\", tmpNode.pName, totalTime)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"tmpNode.pName",
"tmpNode",
"tmpNode.pName",
"totalTime",
"{\n totalTime += limitTime;\n tmpNode.time -= limitTime;\n q.enQue(tmpNode);\n }",
"totalTime += limitTime",
"totalTime",
"limitTime",
"tmpNode.time -= limitTime",
"tmpNode.time",
"tmpNode",
"tmpNode.time",
"limitTime",
"q.enQue(tmpNode)",
"q.enQue",
"q",
"tmpNode",
"String[] args",
"args"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Que {
int head, tail, length;
Node[] Narray;
public Que(int inputN) {
head = -1;
tail = -1;
length = inputN;
Narray = new Node[inputN];
}
public void enQue(Node node) {
tail += 1;
Narray[tail % length] = node;
}
public Node deQue() {
head += 1;
return Narray[head % length];
}
public boolean isEmpty() {
if (head == tail)
return true;
else
return false;
}
}
class Node {
String pName;
public int time;
public Node(String pName, int time) {
this.pName = pName;
this.time = time;
}
}
class Main {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] inputData;
String[] nodeData;
try {
int totalTime = 0;
inputData = br.readLine().split(" ");
int n = Integer.parseInt(inputData[0]);
int limitTime = Integer.parseInt(inputData[1]);
Que q = new Que(n);
Node tmpNode = null;
for (int i = 0; i < n; i++) {
nodeData = br.readLine().split(" ");
q.enQue(new Node(nodeData[0], Integer.parseInt(nodeData[1])));
}
while (!q.isEmpty()) {
tmpNode = q.deQue();
if (tmpNode.time <= limitTime) {
totalTime += tmpNode.time;
System.out.printf("%s %d\n", tmpNode.pName, totalTime);
} else {
totalTime += limitTime;
tmpNode.time -= limitTime;
q.enQue(tmpNode);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
20,
12,
13,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
12,
13,
30,
42,
17,
30,
0,
13,
4,
18,
13,
14,
2,
13,
17,
3,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
13,
30,
0,
13,
13,
0,
13,
4,
18,
13,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
12,
13,
30,
42,
17,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
2,
13,
17,
2,
13,
17,
3,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
12,
13,
30,
41,
13,
20,
4,
18,
13,
4,
18,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
179,
5
],
[
179,
6
],
[
6,
7
],
[
6,
8
],
[
179,
9
],
[
9,
10
],
[
179,
11
],
[
11,
12
],
[
179,
13
],
[
13,
14
],
[
13,
15
],
[
179,
16
],
[
16,
17
],
[
179,
18
],
[
18,
19
],
[
179,
20
],
[
20,
21
],
[
20,
22
],
[
179,
23
],
[
23,
24
],
[
23,
25
],
[
179,
26
],
[
26,
27
],
[
26,
28
],
[
179,
29
],
[
29,
30
],
[
29,
31
],
[
179,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
34,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
34,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
61,
62
],
[
62,
63
],
[
57,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
67,
68
],
[
68,
69
],
[
179,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
75,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
75,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
90,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
90,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
86,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
114,
115
],
[
107,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
119,
120
],
[
119,
121
],
[
107,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
179,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
131,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
131,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
142,
150
],
[
131,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
157,
157
],
[
157,
158
],
[
157,
159
],
[
157,
160
],
[
179,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
167,
168
],
[
168,
169
],
[
163,
170
],
[
170,
171
],
[
171,
172
],
[
163,
173
],
[
173,
174
],
[
174,
175
],
[
161,
176
],
[
176,
177
],
[
0,
178
],
[
178,
179
],
[
178,
180
]
] | [
"import java.util.*;\npublic class Main {\n\t\n\tScanner sc = new Scanner(System.in);\n\tint n,q;\n\tint nowtime=0;\n\tInteger process;\n\tString name;\n\t\n\tQueue<String> jobname = new ArrayDeque<String>();\n\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\n\tQueue<String> finishjob = new ArrayDeque<String>();\n\tQueue<Integer> finish = new ArrayDeque<Integer>();\n\t\n\tpublic void input() {\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}\n\t}\n\t\n\tpublic void queue() {\n\t\twhile(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic void output() {\n\t\twhile(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tMain obj = new Main();\n\t\tobj.input();\n\t\tobj.queue();\n\t\tobj.output();\n\t}\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\t\n\tScanner sc = new Scanner(System.in);\n\tint n,q;\n\tint nowtime=0;\n\tInteger process;\n\tString name;\n\t\n\tQueue<String> jobname = new ArrayDeque<String>();\n\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\n\tQueue<String> finishjob = new ArrayDeque<String>();\n\tQueue<Integer> finish = new ArrayDeque<Integer>();\n\t\n\tpublic void input() {\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}\n\t}\n\t\n\tpublic void queue() {\n\t\twhile(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic void output() {\n\t\twhile(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tMain obj = new Main();\n\t\tobj.input();\n\t\tobj.queue();\n\t\tobj.output();\n\t}\n}",
"Main",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n",
"n",
"q;",
"q",
"int nowtime=0;",
"nowtime",
"0",
"Integer process;",
"process",
"String name;",
"name",
"Queue<String> jobname = new ArrayDeque<String>();",
"jobname",
"new ArrayDeque<String>()",
"Queue<Integer> queue = new ArrayDeque<Integer>();",
"queue",
"new ArrayDeque<Integer>()",
"Queue<String> finishjob = new ArrayDeque<String>();",
"finishjob",
"new ArrayDeque<String>()",
"Queue<Integer> finish = new ArrayDeque<Integer>();",
"finish",
"new ArrayDeque<Integer>()",
"public void input() {\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}\n\t}",
"input",
"{\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}\n\t}",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = sc.nextInt()",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}",
"{\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}",
"jobname.add( sc.next() )",
"jobname.add",
"jobname",
"sc.next()",
"sc.next",
"sc",
"queue.add( sc.nextInt() )",
"queue.add",
"queue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"public void queue() {\n\t\twhile(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}\n\t}",
"queue",
"{\n\t\twhile(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}\n\t}",
"while(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}",
"process = queue.poll()",
"process",
"queue.poll()",
"queue.poll",
"queue",
"if(process == null) break; //キューがnullなら終了",
"process == null",
"process",
"null",
"break; //キューがnullなら終了",
"if(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}",
"q >= process",
"q",
"process",
"{ //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}",
"nowtime += process",
"nowtime",
"process",
"name = jobname.poll()",
"name",
"jobname.poll()",
"jobname.poll",
"jobname",
"finish.add(nowtime)",
"finish.add",
"finish",
"nowtime",
"finishjob.add(name)",
"finishjob.add",
"finishjob",
"name",
"{ //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}",
"nowtime += q",
"nowtime",
"q",
"name = jobname.poll()",
"name",
"jobname.poll()",
"jobname.poll",
"jobname",
"queue.add( process-q )",
"queue.add",
"queue",
"process-q",
"process",
"q",
"jobname.add(name)",
"jobname.add",
"jobname",
"name",
"public void output() {\n\t\twhile(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}\n\t}",
"output",
"{\n\t\twhile(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}\n\t}",
"while(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}",
"true",
"{\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}",
"name = finishjob.poll()",
"name",
"finishjob.poll()",
"finishjob.poll",
"finishjob",
"process = finish.poll()",
"process",
"finish.poll()",
"finish.poll",
"finish",
"if(name == null || process == null) break;",
"name == null || process == null",
"name == null",
"name",
"null",
"process == null",
"process",
"null",
"break;",
"System.out.println(name+\" \"+process)",
"System.out.println",
"System.out",
"System",
"System.out",
"name+\" \"+process",
"name+\" \"+process",
"name",
"\" \"",
"process",
"public static void main(String[] args) {\n\t\tMain obj = new Main();\n\t\tobj.input();\n\t\tobj.queue();\n\t\tobj.output();\n\t}",
"main",
"{\n\t\tMain obj = new Main();\n\t\tobj.input();\n\t\tobj.queue();\n\t\tobj.output();\n\t}",
"Main obj = new Main();",
"obj",
"new Main()",
"obj.input()",
"obj.input",
"obj",
"obj.queue()",
"obj.queue",
"obj",
"obj.output()",
"obj.output",
"obj",
"String[] args",
"args",
"public class Main {\n\t\n\tScanner sc = new Scanner(System.in);\n\tint n,q;\n\tint nowtime=0;\n\tInteger process;\n\tString name;\n\t\n\tQueue<String> jobname = new ArrayDeque<String>();\n\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\n\tQueue<String> finishjob = new ArrayDeque<String>();\n\tQueue<Integer> finish = new ArrayDeque<Integer>();\n\t\n\tpublic void input() {\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}\n\t}\n\t\n\tpublic void queue() {\n\t\twhile(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic void output() {\n\t\twhile(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tMain obj = new Main();\n\t\tobj.input();\n\t\tobj.queue();\n\t\tobj.output();\n\t}\n}",
"public class Main {\n\t\n\tScanner sc = new Scanner(System.in);\n\tint n,q;\n\tint nowtime=0;\n\tInteger process;\n\tString name;\n\t\n\tQueue<String> jobname = new ArrayDeque<String>();\n\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\n\tQueue<String> finishjob = new ArrayDeque<String>();\n\tQueue<Integer> finish = new ArrayDeque<Integer>();\n\t\n\tpublic void input() {\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tjobname.add( sc.next() );\n\t\t\tqueue.add( sc.nextInt() );\n\t\t}\n\t}\n\t\n\tpublic void queue() {\n\t\twhile(true) {\n\t\t\tprocess = queue.poll();\n\t\t\tif(process == null) break; //キューがnullなら終了\n\t\t\tif(q >= process) { //プロセスの終了\n\t\t\t\tnowtime += process;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tfinish.add(nowtime);\n\t\t\t\tfinishjob.add(name);\n\t\t\t}else { //タイムクオンタムを超えた\n\t\t\t\tnowtime += q;\n\t\t\t\tname = jobname.poll();\n\t\t\t\tqueue.add( process-q );\n\t\t\t\tjobname.add(name);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic void output() {\n\t\twhile(true) {\n\t\t\tname = finishjob.poll();\n\t\t\tprocess = finish.poll();\n\t\t\tif(name == null || process == null) break;\n\t\t\tSystem.out.println(name+\" \"+process);\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tMain obj = new Main();\n\t\tobj.input();\n\t\tobj.queue();\n\t\tobj.output();\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
int n,q;
int nowtime=0;
Integer process;
String name;
Queue<String> jobname = new ArrayDeque<String>();
Queue<Integer> queue = new ArrayDeque<Integer>();
Queue<String> finishjob = new ArrayDeque<String>();
Queue<Integer> finish = new ArrayDeque<Integer>();
public void input() {
n = sc.nextInt();
q = sc.nextInt();
for(int i=0; i<n; i++) {
jobname.add( sc.next() );
queue.add( sc.nextInt() );
}
}
public void queue() {
while(true) {
process = queue.poll();
if(process == null) break; //キューがnullなら終了
if(q >= process) { //プロセスの終了
nowtime += process;
name = jobname.poll();
finish.add(nowtime);
finishjob.add(name);
}else { //タイムクオンタムを超えた
nowtime += q;
name = jobname.poll();
queue.add( process-q );
jobname.add(name);
}
}
}
public void output() {
while(true) {
name = finishjob.poll();
process = finish.poll();
if(name == null || process == null) break;
System.out.println(name+" "+process);
}
}
public static void main(String[] args) {
Main obj = new Main();
obj.input();
obj.queue();
obj.output();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
4,
18,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
4,
18,
13,
13,
0,
13,
4,
18,
13,
4,
18,
13,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
131,
11
],
[
131,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
14,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
14,
37
],
[
37,
38
],
[
38,
39
],
[
14,
40
],
[
40,
41
],
[
40,
42
],
[
14,
43
],
[
43,
44
],
[
43,
45
],
[
14,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
46,
54
],
[
54,
55
],
[
55,
56
],
[
46,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
58,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
58,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
14,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
77,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
82,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
82,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
107,
109
],
[
107,
110
],
[
93,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
111,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
111,
125
],
[
125,
126
],
[
125,
127
],
[
12,
128
],
[
128,
129
],
[
0,
130
],
[
130,
131
],
[
130,
132
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main{\t\n\npublic static void main(String[] args) {\n\t\tQueue<Integer> time = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint input = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tint timestamp = 0;\n\t\tsc.nextLine();\n\t\tString p = \"\";\n\t\tint t = 0;\n\t\tfor (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}\n\t\t\n\t\twhile(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\t\n\npublic static void main(String[] args) {\n\t\tQueue<Integer> time = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint input = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tint timestamp = 0;\n\t\tsc.nextLine();\n\t\tString p = \"\";\n\t\tint t = 0;\n\t\tfor (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}\n\t\t\n\t\twhile(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tQueue<Integer> time = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint input = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tint timestamp = 0;\n\t\tsc.nextLine();\n\t\tString p = \"\";\n\t\tint t = 0;\n\t\tfor (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}\n\t\t\n\t\twhile(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"main",
"{\n\t\tQueue<Integer> time = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint input = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tint timestamp = 0;\n\t\tsc.nextLine();\n\t\tString p = \"\";\n\t\tint t = 0;\n\t\tfor (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}\n\t\t\n\t\twhile(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"Queue<Integer> time = new LinkedList<Integer>();",
"time",
"new LinkedList<Integer>()",
"Queue<String> name = new LinkedList<String>();",
"name",
"new LinkedList<String>()",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int input = sc.nextInt();",
"input",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int quantum = sc.nextInt();",
"quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int timestamp = 0;",
"timestamp",
"0",
"sc.nextLine()",
"sc.nextLine",
"sc",
"String p = \"\";",
"p",
"\"\"",
"int t = 0;",
"t",
"0",
"for (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}",
"int i =0;",
"int i =0;",
"i",
"0",
"i< input",
"i",
"input",
"i++",
"i++",
"i",
"{ ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}",
"{ ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}",
"p = sc.next()",
"p",
"sc.next()",
"sc.next",
"sc",
"name.add(p)",
"name.add",
"name",
"p",
"t = sc.nextInt()",
"t",
"sc.nextInt()",
"sc.nextInt",
"sc",
"time.add(t)",
"time.add",
"time",
"t",
"while(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}",
"!name.isEmpty()",
"name.isEmpty()",
"name.isEmpty",
"name",
"{\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}",
"String a = name.poll();",
"a",
"name.poll()",
"name.poll",
"name",
"int ti = time.poll();",
"ti",
"time.poll()",
"time.poll",
"time",
"if( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}",
"ti <= quantum",
"ti",
"quantum",
"{\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}",
"timestamp += ti",
"timestamp",
"ti",
"System.out.println(a + \" \" + timestamp)",
"System.out.println",
"System.out",
"System",
"System.out",
"a + \" \" + timestamp",
"a + \" \" + timestamp",
"a",
"\" \"",
"timestamp",
"{\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}",
"ti = ti - quantum",
"ti",
"ti - quantum",
"ti",
"quantum",
"name.add(a)",
"name.add",
"name",
"a",
"time.add(ti)",
"time.add",
"time",
"ti",
"timestamp += quantum",
"timestamp",
"quantum",
"String[] args",
"args",
"public class Main{\t\n\npublic static void main(String[] args) {\n\t\tQueue<Integer> time = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint input = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tint timestamp = 0;\n\t\tsc.nextLine();\n\t\tString p = \"\";\n\t\tint t = 0;\n\t\tfor (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}\n\t\t\n\t\twhile(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}",
"public class Main{\t\n\npublic static void main(String[] args) {\n\t\tQueue<Integer> time = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tint input = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\t\tint timestamp = 0;\n\t\tsc.nextLine();\n\t\tString p = \"\";\n\t\tint t = 0;\n\t\tfor (int i =0; i< input; i++) { ////// p1 = p, 500 = t\n\t\t p = sc.next();\n\t\t name.add(p);\n\t\t t = sc.nextInt();\n\t\t time.add(t);\n\n\t\t}\n\t\t\n\t\twhile(!name.isEmpty()) {\n\t\t\tString a = name.poll();\n\t\t\tint ti = time.poll();\n\t\t\tif( ti <= quantum) {\n\t\t\t\ttimestamp += ti;\n\t\t\t\tSystem.out.println(a + \" \" + timestamp);\n\t\t\t\n\t\t\t\t\n\t\t\t}\n\t\t\telse {\n\t\t\t\tti = ti - quantum;\n\t\t\t\tname.add(a);\n\t\t\t\ttime.add(ti);\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Queue<Integer> time = new LinkedList<Integer>();
Queue<String> name = new LinkedList<String>();
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
int quantum = sc.nextInt();
int timestamp = 0;
sc.nextLine();
String p = "";
int t = 0;
for (int i =0; i< input; i++) { ////// p1 = p, 500 = t
p = sc.next();
name.add(p);
t = sc.nextInt();
time.add(t);
}
while(!name.isEmpty()) {
String a = name.poll();
int ti = time.poll();
if( ti <= quantum) {
timestamp += ti;
System.out.println(a + " " + timestamp);
}
else {
ti = ti - quantum;
name.add(a);
time.add(ti);
timestamp += quantum;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
18,
13,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
125,
11
],
[
125,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
31
],
[
31,
32
],
[
31,
33
],
[
14,
35
],
[
35,
36
],
[
35,
37
],
[
14,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
63,
64
],
[
64,
65
],
[
51,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
14,
70
],
[
70,
71
],
[
71,
72
],
[
14,
73
],
[
73,
74
],
[
73,
75
],
[
14,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
76,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
99,
105
],
[
105,
106
],
[
105,
107
],
[
99,
108
],
[
87,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
109,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
12,
122
],
[
122,
123
],
[
0,
124
],
[
124,
125
],
[
124,
126
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n \npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Integer> task = new ArrayDeque<>();\n String[] name = new String[n];\n int[] time = new int[n];\n for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }\n \n sc.close();\n \n int t = 0;\n while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }\n }\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Integer> task = new ArrayDeque<>();\n String[] name = new String[n];\n int[] time = new int[n];\n for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }\n \n sc.close();\n \n int t = 0;\n while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Integer> task = new ArrayDeque<>();\n String[] name = new String[n];\n int[] time = new int[n];\n for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }\n \n sc.close();\n \n int t = 0;\n while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Integer> task = new ArrayDeque<>();\n String[] name = new String[n];\n int[] time = new int[n];\n for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }\n \n sc.close();\n \n int t = 0;\n while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Integer> task = new ArrayDeque<>();",
"task",
"new ArrayDeque<>()",
"String[] name = new String[n];",
"name",
"new String[n]",
"n",
"int[] time = new int[n];",
"time",
"new int[n]",
"n",
"for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }",
"name[i] = sc.next()",
"name[i]",
"name",
"i",
"sc.next()",
"sc.next",
"sc",
"time[i] = sc.nextInt()",
"time[i]",
"time",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"task.add(i)",
"task.add",
"task",
"i",
"sc.close()",
"sc.close",
"sc",
"int t = 0;",
"t",
"0",
"while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }",
"!task.isEmpty()",
"task.isEmpty()",
"task.isEmpty",
"task",
"{\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }",
"int i = task.poll();",
"i",
"task.poll()",
"task.poll",
"task",
"if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }",
"time[i] <= q",
"time[i]",
"time",
"i",
"q",
"{\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }",
"t += time[i]",
"t",
"time[i]",
"time",
"i",
"System.out.printf(\"%s %d\\n\", name[i], t)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"name[i]",
"name",
"i",
"t",
"{\n t += q;\n time[i] -= q;\n task.add(i);\n }",
"t += q",
"t",
"q",
"time[i] -= q",
"time[i]",
"time",
"i",
"q",
"task.add(i)",
"task.add",
"task",
"i",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Integer> task = new ArrayDeque<>();\n String[] name = new String[n];\n int[] time = new int[n];\n for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }\n \n sc.close();\n \n int t = 0;\n while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Integer> task = new ArrayDeque<>();\n String[] name = new String[n];\n int[] time = new int[n];\n for(int i = 0; i < n; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n task.add(i);\n }\n \n sc.close();\n \n int t = 0;\n while(!task.isEmpty()) {\n int i = task.poll();\n if(time[i] <= q) {\n t += time[i];\n System.out.printf(\"%s %d\\n\", name[i], t);\n }else {\n t += q;\n time[i] -= q;\n task.add(i);\n }\n }\n }\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Queue<Integer> task = new ArrayDeque<>();
String[] name = new String[n];
int[] time = new int[n];
for(int i = 0; i < n; i++) {
name[i] = sc.next();
time[i] = sc.nextInt();
task.add(i);
}
sc.close();
int t = 0;
while(!task.isEmpty()) {
int i = task.poll();
if(time[i] <= q) {
t += time[i];
System.out.printf("%s %d\n", name[i], t);
}else {
t += q;
time[i] -= q;
task.add(i);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
13,
20,
2,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
0,
13,
17,
0,
13,
13,
42,
2,
13,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
13,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
2,
13,
17,
29,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
2,
13,
17,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
13,
29,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
4,
10
],
[
10,
11
],
[
4,
12
],
[
12,
13
],
[
4,
14
],
[
14,
15
],
[
4,
16
],
[
16,
17
],
[
4,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
20,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
20,
34
],
[
34,
35
],
[
34,
36
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
40,
45
],
[
45,
46
],
[
45,
47
],
[
40,
48
],
[
48,
49
],
[
49,
50
],
[
40,
51
],
[
52,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
20,
58
],
[
58,
59
],
[
58,
60
],
[
20,
61
],
[
61,
62
],
[
61,
63
],
[
20,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
68,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
68,
86
],
[
86,
87
],
[
86,
88
],
[
68,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
89,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
100,
106
],
[
106,
107
],
[
106,
108
],
[
100,
109
],
[
18,
110
],
[
110,
111
],
[
4,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
114,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
126,
128
],
[
114,
129
],
[
129,
130
],
[
4,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
133,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
145,
147
],
[
131,
148
],
[
148,
149
],
[
4,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
157,
158
],
[
158,
159
],
[
152,
160
],
[
160,
161
],
[
150,
162
],
[
162,
163
],
[
150,
164
],
[
164,
165
],
[
0,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
166,
170
],
[
170,
171
],
[
166,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
174,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
172,
185
],
[
185,
186
],
[
172,
187
],
[
187,
188
]
] | [
"import java.util.Scanner;\n\nclass Main {\n static int n;\n static int q;\n static int head;\n static int tail;\n static Process[] a;\n static int elaps;\n\n public static void main(String[] args) {\n final Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n q = sc.nextInt();\n a = new Process[n + 1];\n\n for (int i = 0; i < n; i++) {\n a[i] = new Process(sc.next(), sc.nextInt());\n }\n\n head = 0;\n tail = n;\n\n while(head != tail) {\n Process p = dequeue();\n int time = getMin(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }\n\n public static Process dequeue() {\n Process p = a[head];\n head = (head + 1) % (n + 1);\n return p;\n }\n\n public static void enqueue(Process p) {\n a[tail] = p;\n tail = (tail + 1) % (n + 1);\n }\n\n public static int getMin(int a, int b) {\n if (a > b) {\n return b;\n }\n return a;\n }\n}\n\nclass Process {\n String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n static int n;\n static int q;\n static int head;\n static int tail;\n static Process[] a;\n static int elaps;\n\n public static void main(String[] args) {\n final Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n q = sc.nextInt();\n a = new Process[n + 1];\n\n for (int i = 0; i < n; i++) {\n a[i] = new Process(sc.next(), sc.nextInt());\n }\n\n head = 0;\n tail = n;\n\n while(head != tail) {\n Process p = dequeue();\n int time = getMin(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }\n\n public static Process dequeue() {\n Process p = a[head];\n head = (head + 1) % (n + 1);\n return p;\n }\n\n public static void enqueue(Process p) {\n a[tail] = p;\n tail = (tail + 1) % (n + 1);\n }\n\n public static int getMin(int a, int b) {\n if (a > b) {\n return b;\n }\n return a;\n }\n}",
"Main",
"static int n;",
"n",
"static int q;",
"q",
"static int head;",
"head",
"static int tail;",
"tail",
"static Process[] a;",
"a",
"static int elaps;",
"elaps",
"public static void main(String[] args) {\n final Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n q = sc.nextInt();\n a = new Process[n + 1];\n\n for (int i = 0; i < n; i++) {\n a[i] = new Process(sc.next(), sc.nextInt());\n }\n\n head = 0;\n tail = n;\n\n while(head != tail) {\n Process p = dequeue();\n int time = getMin(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }",
"main",
"{\n final Scanner sc = new Scanner(System.in);\n n = sc.nextInt();\n q = sc.nextInt();\n a = new Process[n + 1];\n\n for (int i = 0; i < n; i++) {\n a[i] = new Process(sc.next(), sc.nextInt());\n }\n\n head = 0;\n tail = n;\n\n while(head != tail) {\n Process p = dequeue();\n int time = getMin(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }",
"final Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = sc.nextInt()",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"a = new Process[n + 1]",
"a",
"new Process[n + 1]",
"n + 1",
"n",
"1",
"for (int i = 0; i < n; i++) {\n a[i] = new Process(sc.next(), sc.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n a[i] = new Process(sc.next(), sc.nextInt());\n }",
"{\n a[i] = new Process(sc.next(), sc.nextInt());\n }",
"a[i] = new Process(sc.next(), sc.nextInt())",
"a[i]",
"a",
"i",
"new Process(sc.next(), sc.nextInt())",
"head = 0",
"head",
"0",
"tail = n",
"tail",
"n",
"while(head != tail) {\n Process p = dequeue();\n int time = getMin(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }",
"head != tail",
"head",
"tail",
"{\n Process p = dequeue();\n int time = getMin(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }",
"Process p = dequeue();",
"p",
"dequeue()",
"dequeue",
"int time = getMin(p.time, q);",
"time",
"getMin(p.time, q)",
"getMin",
"p.time",
"p",
"p.time",
"q",
"p.time -= time",
"p.time",
"p",
"p.time",
"time",
"elaps += time",
"elaps",
"time",
"if (p.time > 0) {\n enqueue(p);\n } else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }",
"p.time > 0",
"p.time",
"p",
"p.time",
"0",
"{\n enqueue(p);\n }",
"enqueue(p)",
"enqueue",
"p",
"{\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }",
"System.out.printf(\"%s %d\\n\", p.name, elaps)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"p.name",
"p",
"p.name",
"elaps",
"String[] args",
"args",
"public static Process dequeue() {\n Process p = a[head];\n head = (head + 1) % (n + 1);\n return p;\n }",
"dequeue",
"{\n Process p = a[head];\n head = (head + 1) % (n + 1);\n return p;\n }",
"Process p = a[head];",
"p",
"a[head]",
"a",
"head",
"head = (head + 1) % (n + 1)",
"head",
"(head + 1) % (n + 1)",
"(head + 1)",
"head",
"1",
"(n + 1)",
"n",
"1",
"return p;",
"p",
"public static void enqueue(Process p) {\n a[tail] = p;\n tail = (tail + 1) % (n + 1);\n }",
"enqueue",
"{\n a[tail] = p;\n tail = (tail + 1) % (n + 1);\n }",
"a[tail] = p",
"a[tail]",
"a",
"tail",
"p",
"tail = (tail + 1) % (n + 1)",
"tail",
"(tail + 1) % (n + 1)",
"(tail + 1)",
"tail",
"1",
"(n + 1)",
"n",
"1",
"Process p",
"p",
"public static int getMin(int a, int b) {\n if (a > b) {\n return b;\n }\n return a;\n }",
"getMin",
"{\n if (a > b) {\n return b;\n }\n return a;\n }",
"if (a > b) {\n return b;\n }",
"a > b",
"a",
"b",
"{\n return b;\n }",
"return b;",
"b",
"return a;",
"a",
"int a",
"a",
"int b",
"b",
"class Process {\n String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Process",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time"
] | import java.util.Scanner;
class Main {
static int n;
static int q;
static int head;
static int tail;
static Process[] a;
static int elaps;
public static void main(String[] args) {
final Scanner sc = new Scanner(System.in);
n = sc.nextInt();
q = sc.nextInt();
a = new Process[n + 1];
for (int i = 0; i < n; i++) {
a[i] = new Process(sc.next(), sc.nextInt());
}
head = 0;
tail = n;
while(head != tail) {
Process p = dequeue();
int time = getMin(p.time, q);
p.time -= time;
elaps += time;
if (p.time > 0) {
enqueue(p);
} else {
System.out.printf("%s %d\n", p.name, elaps);
}
}
}
public static Process dequeue() {
Process p = a[head];
head = (head + 1) % (n + 1);
return p;
}
public static void enqueue(Process p) {
a[tail] = p;
tail = (tail + 1) % (n + 1);
}
public static int getMin(int a, int b) {
if (a > b) {
return b;
}
return a;
}
}
class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
41,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
42,
2,
4,
18,
13,
17,
30,
14,
2,
18,
4,
18,
13,
13,
13,
30,
0,
13,
18,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
13,
17,
13,
4,
18,
13,
30,
0,
13,
13,
0,
13,
4,
18,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
8,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
30,
35
],
[
35,
36
],
[
35,
37
],
[
30,
38
],
[
38,
39
],
[
39,
40
],
[
30,
41
],
[
42,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
42,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
42,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
58,
62
],
[
57,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
66,
70
],
[
65,
71
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
75,
79
],
[
72,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
86,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
87,
91
],
[
86,
92
],
[
86,
93
],
[
72,
94
],
[
94,
95
],
[
95,
96
],
[
64,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
97,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
97,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
97,
115
],
[
115,
116
],
[
116,
117
],
[
6,
118
],
[
118,
119
],
[
0,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
120,
124
],
[
124,
125
],
[
120,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
128,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
126,
139
],
[
139,
140
],
[
126,
141
],
[
141,
142
]
] | [
"import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt(); //プロセス数\n int q = sc.nextInt(); //クオンタム\n int R_time = 0; //実時間\n\n ArrayDeque<Proc> queue = new ArrayDeque<>(); //キュー\n Proc tmp;\n\n for(int i = 0;i < n;i++){\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }\n\n while(queue.size() > 0){\n //クオンタム以下\n if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }\n }\n }\n}\n\nclass Proc{\n String name;\n int num;\n\n Proc(String name,int num){\n this.name = name;\n this.num = num;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class Main{\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt(); //プロセス数\n int q = sc.nextInt(); //クオンタム\n int R_time = 0; //実時間\n\n ArrayDeque<Proc> queue = new ArrayDeque<>(); //キュー\n Proc tmp;\n\n for(int i = 0;i < n;i++){\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }\n\n while(queue.size() > 0){\n //クオンタム以下\n if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }\n }\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt(); //プロセス数\n int q = sc.nextInt(); //クオンタム\n int R_time = 0; //実時間\n\n ArrayDeque<Proc> queue = new ArrayDeque<>(); //キュー\n Proc tmp;\n\n for(int i = 0;i < n;i++){\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }\n\n while(queue.size() > 0){\n //クオンタム以下\n if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt(); //プロセス数\n int q = sc.nextInt(); //クオンタム\n int R_time = 0; //実時間\n\n ArrayDeque<Proc> queue = new ArrayDeque<>(); //キュー\n Proc tmp;\n\n for(int i = 0;i < n;i++){\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }\n\n while(queue.size() > 0){\n //クオンタム以下\n if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int R_time = 0;",
"R_time",
"0",
"ArrayDeque<Proc> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"Proc tmp;",
"tmp",
"for(int i = 0;i < n;i++){\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }",
"{\n String name = sc.next(); //プロセス名\n int P_time = sc.nextInt(); //プロセス時間\n queue.add(new Proc(name,P_time));\n }",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int P_time = sc.nextInt();",
"P_time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"queue.add(new Proc(name,P_time))",
"queue.add",
"queue",
"new Proc(name,P_time)",
"while(queue.size() > 0){\n //クオンタム以下\n if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n //クオンタム以下\n if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }\n }",
"if(queue.getFirst().num <= q){\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }\n else{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }",
"queue.getFirst().num <= q",
"queue.getFirst().num",
"queue.getFirst()",
"queue.getFirst",
"queue",
"queue.getFirst().num",
"q",
"{\n R_time += queue.getFirst().num;\n System.out.println(queue.getFirst().name+\" \"+R_time);\n queue.removeFirst();\n }",
"R_time += queue.getFirst().num",
"R_time",
"queue.getFirst().num",
"queue.getFirst()",
"queue.getFirst",
"queue",
"queue.getFirst().num",
"System.out.println(queue.getFirst().name+\" \"+R_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"queue.getFirst().name+\" \"+R_time",
"queue.getFirst().name+\" \"+R_time",
"queue.getFirst().name",
"queue.getFirst()",
"queue.getFirst",
"queue",
"queue.getFirst().name",
"\" \"",
"R_time",
"queue.removeFirst()",
"queue.removeFirst",
"queue",
"{\n R_time += q;\n tmp = queue.getFirst(); //先頭をコピー\n tmp.num -= q; //プロセス時間からクオンタムを引く\n queue.addLast(tmp); //先頭を末尾に\n queue.removeFirst(); //先頭削除\n }",
"R_time += q",
"R_time",
"q",
"tmp = queue.getFirst()",
"tmp",
"queue.getFirst()",
"queue.getFirst",
"queue",
"tmp.num -= q",
"tmp.num",
"tmp",
"tmp.num",
"q",
"queue.addLast(tmp)",
"queue.addLast",
"queue",
"tmp",
"queue.removeFirst()",
"queue.removeFirst",
"queue",
"String[] args",
"args",
"class Proc{\n String name;\n int num;\n\n Proc(String name,int num){\n this.name = name;\n this.num = num;\n }\n}",
"Proc",
"String name;",
"name",
"int num;",
"num",
"Proc(String name,int num){\n this.name = name;\n this.num = num;\n }",
"Proc",
"{\n this.name = name;\n this.num = num;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.num = num",
"this.num",
"this",
"this.num",
"num",
"String name",
"name",
"int num",
"num"
] | import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); //プロセス数
int q = sc.nextInt(); //クオンタム
int R_time = 0; //実時間
ArrayDeque<Proc> queue = new ArrayDeque<>(); //キュー
Proc tmp;
for(int i = 0;i < n;i++){
String name = sc.next(); //プロセス名
int P_time = sc.nextInt(); //プロセス時間
queue.add(new Proc(name,P_time));
}
while(queue.size() > 0){
//クオンタム以下
if(queue.getFirst().num <= q){
R_time += queue.getFirst().num;
System.out.println(queue.getFirst().name+" "+R_time);
queue.removeFirst();
}
else{
R_time += q;
tmp = queue.getFirst(); //先頭をコピー
tmp.num -= q; //プロセス時間からクオンタムを引く
queue.addLast(tmp); //先頭を末尾に
queue.removeFirst(); //先頭削除
}
}
}
}
class Proc{
String name;
int num;
Proc(String name,int num){
this.name = name;
this.num = num;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
0,
13,
4,
18,
13,
0,
13,
20,
0,
13,
4,
18,
13,
4,
18,
13,
0,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
20,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
157,
11
],
[
157,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
14,
19
],
[
19,
20
],
[
19,
21
],
[
14,
22
],
[
22,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
14,
27
],
[
27,
28
],
[
27,
29
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
14,
33
],
[
33,
34
],
[
14,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
14,
40
],
[
40,
41
],
[
40,
42
],
[
14,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
49,
50
],
[
14,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
57,
58
],
[
14,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
59,
67
],
[
67,
68
],
[
68,
69
],
[
59,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
77,
79
],
[
71,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
83,
84
],
[
84,
85
],
[
71,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
93,
94
],
[
14,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
95,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
100,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
100,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
115,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
115,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
131,
133
],
[
111,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
137,
139
],
[
134,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
145,
146
],
[
145,
147
],
[
134,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
12,
154
],
[
154,
155
],
[
0,
156
],
[
156,
157
],
[
156,
158
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tint numberOfProcesses;\n\t\tint quantum;\n\t\tint clock = 0;\n\t\tString line;\n\t\t\n\t\tQueue<String> taskQueue = new LinkedList<String>();\n\t\tQueue<Integer> timeQueue = new LinkedList<Integer>();\n\t\t\n\t\tScanner keyboard = new Scanner(System.in);\n\t\tScanner input;\n\t\t\n\t\tline = keyboard.nextLine();\n\t\t\n\t\tinput = new Scanner(line);\n\t\t\n\t\tnumberOfProcesses = Integer.parseInt(input.next());\n\t\tquantum = Integer.parseInt(input.next());\n\t\t\n\t\tfor(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}\n\t\t\n\t\twhile(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tint numberOfProcesses;\n\t\tint quantum;\n\t\tint clock = 0;\n\t\tString line;\n\t\t\n\t\tQueue<String> taskQueue = new LinkedList<String>();\n\t\tQueue<Integer> timeQueue = new LinkedList<Integer>();\n\t\t\n\t\tScanner keyboard = new Scanner(System.in);\n\t\tScanner input;\n\t\t\n\t\tline = keyboard.nextLine();\n\t\t\n\t\tinput = new Scanner(line);\n\t\t\n\t\tnumberOfProcesses = Integer.parseInt(input.next());\n\t\tquantum = Integer.parseInt(input.next());\n\t\t\n\t\tfor(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}\n\t\t\n\t\twhile(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t\n\t\tint numberOfProcesses;\n\t\tint quantum;\n\t\tint clock = 0;\n\t\tString line;\n\t\t\n\t\tQueue<String> taskQueue = new LinkedList<String>();\n\t\tQueue<Integer> timeQueue = new LinkedList<Integer>();\n\t\t\n\t\tScanner keyboard = new Scanner(System.in);\n\t\tScanner input;\n\t\t\n\t\tline = keyboard.nextLine();\n\t\t\n\t\tinput = new Scanner(line);\n\t\t\n\t\tnumberOfProcesses = Integer.parseInt(input.next());\n\t\tquantum = Integer.parseInt(input.next());\n\t\t\n\t\tfor(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}\n\t\t\n\t\twhile(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}",
"main",
"{\n\t\t\n\t\tint numberOfProcesses;\n\t\tint quantum;\n\t\tint clock = 0;\n\t\tString line;\n\t\t\n\t\tQueue<String> taskQueue = new LinkedList<String>();\n\t\tQueue<Integer> timeQueue = new LinkedList<Integer>();\n\t\t\n\t\tScanner keyboard = new Scanner(System.in);\n\t\tScanner input;\n\t\t\n\t\tline = keyboard.nextLine();\n\t\t\n\t\tinput = new Scanner(line);\n\t\t\n\t\tnumberOfProcesses = Integer.parseInt(input.next());\n\t\tquantum = Integer.parseInt(input.next());\n\t\t\n\t\tfor(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}\n\t\t\n\t\twhile(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}",
"int numberOfProcesses;",
"numberOfProcesses",
"int quantum;",
"quantum",
"int clock = 0;",
"clock",
"0",
"String line;",
"line",
"Queue<String> taskQueue = new LinkedList<String>();",
"taskQueue",
"new LinkedList<String>()",
"Queue<Integer> timeQueue = new LinkedList<Integer>();",
"timeQueue",
"new LinkedList<Integer>()",
"Scanner keyboard = new Scanner(System.in);",
"keyboard",
"new Scanner(System.in)",
"Scanner input;",
"input",
"line = keyboard.nextLine()",
"line",
"keyboard.nextLine()",
"keyboard.nextLine",
"keyboard",
"input = new Scanner(line)",
"input",
"new Scanner(line)",
"numberOfProcesses = Integer.parseInt(input.next())",
"numberOfProcesses",
"Integer.parseInt(input.next())",
"Integer.parseInt",
"Integer",
"input.next()",
"input.next",
"input",
"quantum = Integer.parseInt(input.next())",
"quantum",
"Integer.parseInt(input.next())",
"Integer.parseInt",
"Integer",
"input.next()",
"input.next",
"input",
"for(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numberOfProcesses",
"i",
"numberOfProcesses",
"i++",
"i++",
"i",
"{\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}",
"{\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}",
"line = keyboard.nextLine()",
"line",
"keyboard.nextLine()",
"keyboard.nextLine",
"keyboard",
"input = new Scanner(line)",
"input",
"new Scanner(line)",
"taskQueue.add(input.next())",
"taskQueue.add",
"taskQueue",
"input.next()",
"input.next",
"input",
"timeQueue.add(Integer.parseInt(input.next()))",
"timeQueue.add",
"timeQueue",
"Integer.parseInt(input.next())",
"Integer.parseInt",
"Integer",
"input.next()",
"input.next",
"input",
"while(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}",
"!taskQueue.isEmpty()",
"taskQueue.isEmpty()",
"taskQueue.isEmpty",
"taskQueue",
"{\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}",
"String currentTask = taskQueue.remove();",
"currentTask",
"taskQueue.remove()",
"taskQueue.remove",
"taskQueue",
"int currentTime = timeQueue.remove();",
"currentTime",
"timeQueue.remove()",
"timeQueue.remove",
"timeQueue",
"if(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}",
"currentTime > quantum",
"currentTime",
"quantum",
"{\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}",
"currentTime = currentTime - quantum",
"currentTime",
"currentTime - quantum",
"currentTime",
"quantum",
"taskQueue.add(currentTask)",
"taskQueue.add",
"taskQueue",
"currentTask",
"timeQueue.add(currentTime)",
"timeQueue.add",
"timeQueue",
"currentTime",
"clock = clock + quantum",
"clock",
"clock + quantum",
"clock",
"quantum",
"{\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}",
"clock = clock + currentTime",
"clock",
"clock + currentTime",
"clock",
"currentTime",
"System.out.print(currentTask + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"currentTask + \" \"",
"currentTask",
"\" \"",
"System.out.println(clock)",
"System.out.println",
"System.out",
"System",
"System.out",
"clock",
"String[] args",
"args",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tint numberOfProcesses;\n\t\tint quantum;\n\t\tint clock = 0;\n\t\tString line;\n\t\t\n\t\tQueue<String> taskQueue = new LinkedList<String>();\n\t\tQueue<Integer> timeQueue = new LinkedList<Integer>();\n\t\t\n\t\tScanner keyboard = new Scanner(System.in);\n\t\tScanner input;\n\t\t\n\t\tline = keyboard.nextLine();\n\t\t\n\t\tinput = new Scanner(line);\n\t\t\n\t\tnumberOfProcesses = Integer.parseInt(input.next());\n\t\tquantum = Integer.parseInt(input.next());\n\t\t\n\t\tfor(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}\n\t\t\n\t\twhile(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n\n}",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\t\n\t\tint numberOfProcesses;\n\t\tint quantum;\n\t\tint clock = 0;\n\t\tString line;\n\t\t\n\t\tQueue<String> taskQueue = new LinkedList<String>();\n\t\tQueue<Integer> timeQueue = new LinkedList<Integer>();\n\t\t\n\t\tScanner keyboard = new Scanner(System.in);\n\t\tScanner input;\n\t\t\n\t\tline = keyboard.nextLine();\n\t\t\n\t\tinput = new Scanner(line);\n\t\t\n\t\tnumberOfProcesses = Integer.parseInt(input.next());\n\t\tquantum = Integer.parseInt(input.next());\n\t\t\n\t\tfor(int i = 0; i < numberOfProcesses; i++) {\n\t\t\tline = keyboard.nextLine();\n\t\t\tinput = new Scanner(line);\n\t\t\t\n\t\t\ttaskQueue.add(input.next());\n\t\t\ttimeQueue.add(Integer.parseInt(input.next()));\n\t\t}\n\t\t\n\t\twhile(!taskQueue.isEmpty()) {\n\t\t\t\n\t\t\tString currentTask = taskQueue.remove();\n\t\t\tint currentTime = timeQueue.remove();\n\t\t\t\n\t\t\tif(currentTime > quantum) {\n\t\t\t\tcurrentTime = currentTime - quantum;\n\t\t\t\t\n\t\t\t\ttaskQueue.add(currentTask);\n\t\t\t\ttimeQueue.add(currentTime);\n\t\t\t\t\n\t\t\t\tclock = clock + quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\t\n\t\t\t\tclock = clock + currentTime;\n\t\t\t\t\n\t\t\t\tSystem.out.print(currentTask + \" \");\n\t\t\t\tSystem.out.println(clock);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int numberOfProcesses;
int quantum;
int clock = 0;
String line;
Queue<String> taskQueue = new LinkedList<String>();
Queue<Integer> timeQueue = new LinkedList<Integer>();
Scanner keyboard = new Scanner(System.in);
Scanner input;
line = keyboard.nextLine();
input = new Scanner(line);
numberOfProcesses = Integer.parseInt(input.next());
quantum = Integer.parseInt(input.next());
for(int i = 0; i < numberOfProcesses; i++) {
line = keyboard.nextLine();
input = new Scanner(line);
taskQueue.add(input.next());
timeQueue.add(Integer.parseInt(input.next()));
}
while(!taskQueue.isEmpty()) {
String currentTask = taskQueue.remove();
int currentTime = timeQueue.remove();
if(currentTime > quantum) {
currentTime = currentTime - quantum;
taskQueue.add(currentTask);
timeQueue.add(currentTime);
clock = clock + quantum;
}
else {
clock = clock + currentTime;
System.out.print(currentTask + " ");
System.out.println(clock);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
2,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
110,
5
],
[
110,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
48,
49
],
[
43,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
8,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
62,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
62,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
77,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
85,
86
],
[
85,
87
],
[
77,
88
],
[
88,
89
],
[
88,
90
],
[
73,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
98,
98
],
[
98,
99
],
[
98,
100
],
[
98,
101
],
[
101,
102
],
[
101,
103
],
[
91,
104
],
[
104,
105
],
[
104,
106
],
[
6,
107
],
[
107,
108
],
[
0,
109
],
[
109,
110
],
[
109,
111
]
] | [
"import java.util.*;\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner cin=new Scanner(System.in);\n\t\t\n\t\tint n=cin.nextInt(),q=cin.nextInt(),TIME=0;\n\t\tQueue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}\n\t\t\n\t\twhile(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner cin=new Scanner(System.in);\n\t\t\n\t\tint n=cin.nextInt(),q=cin.nextInt(),TIME=0;\n\t\tQueue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}\n\t\t\n\t\twhile(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner cin=new Scanner(System.in);\n\t\t\n\t\tint n=cin.nextInt(),q=cin.nextInt(),TIME=0;\n\t\tQueue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}\n\t\t\n\t\twhile(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"main",
"{\n\t\tScanner cin=new Scanner(System.in);\n\t\t\n\t\tint n=cin.nextInt(),q=cin.nextInt(),TIME=0;\n\t\tQueue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}\n\t\t\n\t\twhile(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"Scanner cin=new Scanner(System.in);",
"cin",
"new Scanner(System.in)",
"int n=cin.nextInt()",
"n",
"cin.nextInt()",
"cin.nextInt",
"cin",
"q=cin.nextInt()",
"q",
"cin.nextInt()",
"cin.nextInt",
"cin",
"TIME=0;",
"TIME",
"0",
"Queue<String> name=new ArrayDeque<>();",
"name",
"new ArrayDeque<>()",
"Queue<Integer>time=new ArrayDeque<>();",
"time",
"new ArrayDeque<>()",
"for(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}",
"{\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}",
"name.add(cin.next())",
"name.add",
"name",
"cin.next()",
"cin.next",
"cin",
"time.add(cin.nextInt())",
"time.add",
"time",
"cin.nextInt()",
"cin.nextInt",
"cin",
"while(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}",
"name.peek()!=null",
"name.peek()",
"name.peek",
"name",
"null",
"{\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}",
"String str=name.remove();",
"str",
"name.remove()",
"name.remove",
"name",
"int t=time.remove();",
"t",
"time.remove()",
"time.remove",
"time",
"if(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}",
"t>q",
"t",
"q",
"{\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}",
"name.add(str)",
"name.add",
"name",
"str",
"time.add(t-q)",
"time.add",
"time",
"t-q",
"t",
"q",
"TIME+=q",
"TIME",
"q",
"{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}",
"System.out.println(str+\" \"+(TIME+t))",
"System.out.println",
"System.out",
"System",
"System.out",
"str+\" \"+(TIME+t)",
"str+\" \"+(TIME+t)",
"str",
"\" \"",
"(TIME+t)",
"TIME",
"t",
"TIME+=t",
"TIME",
"t",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner cin=new Scanner(System.in);\n\t\t\n\t\tint n=cin.nextInt(),q=cin.nextInt(),TIME=0;\n\t\tQueue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}\n\t\t\n\t\twhile(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner cin=new Scanner(System.in);\n\t\t\n\t\tint n=cin.nextInt(),q=cin.nextInt(),TIME=0;\n\t\tQueue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tname.add(cin.next());time.add(cin.nextInt());\n\t\t}\n\t\t\n\t\twhile(name.peek()!=null) {\n\t\t\tString str=name.remove();int t=time.remove();\n\t\t\tif(t>q) {\n\t\t\t\tname.add(str);time.add(t-q);\n\t\t\t\tTIME+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tSystem.out.println(str+\" \"+(TIME+t));\n\t\t\t\tTIME+=t;\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
int n=cin.nextInt(),q=cin.nextInt(),TIME=0;
Queue<String> name=new ArrayDeque<>();Queue<Integer>time=new ArrayDeque<>();
for(int i=0;i<n;i++) {
name.add(cin.next());time.add(cin.nextInt());
}
while(name.peek()!=null) {
String str=name.remove();int t=time.remove();
if(t>q) {
name.add(str);time.add(t-q);
TIME+=q;
}
else{
System.out.println(str+" "+(TIME+t));
TIME+=t;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
0,
13,
13,
14,
2,
0,
18,
13,
13,
2,
18,
13,
13,
13,
17,
30,
4,
18,
13,
13,
9,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
160,
17
],
[
160,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
26,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
20,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
66,
71
],
[
63,
72
],
[
72,
73
],
[
72,
74
],
[
63,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
20,
79
],
[
79,
80
],
[
79,
81
],
[
20,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
88,
94
],
[
94,
95
],
[
94,
96
],
[
88,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
98,
108
],
[
97,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
109,
114
],
[
88,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
88,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
126,
131
],
[
18,
132
],
[
132,
133
],
[
160,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
134,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
144,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
142,
155
],
[
155,
156
],
[
142,
157
],
[
157,
158
],
[
0,
159
],
[
159,
160
],
[
159,
161
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.LinkedList;\nimport java.util.Queue;\n\npublic class Main {\n private final static class Process {\n public String name = null;\n public int pt = 0;\n\n public Process(String name, int pt) {\n this.name = name;\n this.pt = pt;\n }\n}\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] fr = br.readLine().split(\"\\\\s\");\n int elm = Integer.parseInt(fr[0]);\n int qat = Integer.parseInt(fr[1]);\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }\n int rt = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }\n\n }\n \n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n private final static class Process {\n public String name = null;\n public int pt = 0;\n\n public Process(String name, int pt) {\n this.name = name;\n this.pt = pt;\n }\n}\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] fr = br.readLine().split(\"\\\\s\");\n int elm = Integer.parseInt(fr[0]);\n int qat = Integer.parseInt(fr[1]);\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }\n int rt = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }\n\n }\n \n}",
"Main",
"public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] fr = br.readLine().split(\"\\\\s\");\n int elm = Integer.parseInt(fr[0]);\n int qat = Integer.parseInt(fr[1]);\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }\n int rt = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }\n\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] fr = br.readLine().split(\"\\\\s\");\n int elm = Integer.parseInt(fr[0]);\n int qat = Integer.parseInt(fr[1]);\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }\n int rt = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }\n\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] fr = br.readLine().split(\"\\\\s\");",
"fr",
"br.readLine().split(\"\\\\s\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s\"",
"int elm = Integer.parseInt(fr[0]);",
"elm",
"Integer.parseInt(fr[0])",
"Integer.parseInt",
"Integer",
"fr[0]",
"fr",
"0",
"int qat = Integer.parseInt(fr[1]);",
"qat",
"Integer.parseInt(fr[1])",
"Integer.parseInt",
"Integer",
"fr[1]",
"fr",
"1",
"Queue<Process> que = new LinkedList<Process>();",
"que",
"new LinkedList<Process>()",
"for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < elm",
"i",
"elm",
"i++",
"i++",
"i",
"{\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }",
"{\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }",
"String[] str = br.readLine().split(\"\\\\s\");",
"str",
"br.readLine().split(\"\\\\s\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s\"",
"Process process = new Process(str[0],\n Integer.parseInt(str[1]));",
"process",
"new Process(str[0],\n Integer.parseInt(str[1]))",
"que.offer(process)",
"que.offer",
"que",
"process",
"int rt = 0;",
"rt",
"0",
"while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }",
"que.size() > 0",
"que.size()",
"que.size",
"que",
"0",
"{\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }",
"Process process = que.poll();",
"process",
"que.poll()",
"que.poll",
"que",
"rt += qat",
"rt",
"qat",
"if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }",
"(process.pt = process.pt - qat) > 0",
"(process.pt = process.pt - qat)",
"process.pt",
"process",
"process.pt",
"process.pt - qat",
"process.pt",
"process",
"process.pt",
"qat",
"0",
"{\n que.offer(process);\n continue; \n }",
"que.offer(process)",
"que.offer",
"que",
"process",
"continue;",
"rt += process.pt",
"rt",
"process.pt",
"process",
"process.pt",
"System.out.println(process.name + \" \" + rt)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + rt",
"process.name + \" \" + rt",
"process.name",
"process",
"process.name",
"\" \"",
"rt",
"String args[]",
"args",
"private final static class Process {\n public String name = null;\n public int pt = 0;\n\n public Process(String name, int pt) {\n this.name = name;\n this.pt = pt;\n }\n}",
"Process",
"public String name = null;",
"name",
"null",
"public int pt = 0;",
"pt",
"0",
"public Process(String name, int pt) {\n this.name = name;\n this.pt = pt;\n }",
"Process",
"{\n this.name = name;\n this.pt = pt;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.pt = pt",
"this.pt",
"this",
"this.pt",
"pt",
"String name",
"name",
"int pt",
"pt",
"public class Main {\n private final static class Process {\n public String name = null;\n public int pt = 0;\n\n public Process(String name, int pt) {\n this.name = name;\n this.pt = pt;\n }\n}\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] fr = br.readLine().split(\"\\\\s\");\n int elm = Integer.parseInt(fr[0]);\n int qat = Integer.parseInt(fr[1]);\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }\n int rt = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }\n\n }\n \n}",
"public class Main {\n private final static class Process {\n public String name = null;\n public int pt = 0;\n\n public Process(String name, int pt) {\n this.name = name;\n this.pt = pt;\n }\n}\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] fr = br.readLine().split(\"\\\\s\");\n int elm = Integer.parseInt(fr[0]);\n int qat = Integer.parseInt(fr[1]);\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elm; i++) {\n String[] str = br.readLine().split(\"\\\\s\");\n Process process = new Process(str[0],\n Integer.parseInt(str[1]));\n que.offer(process);\n }\n int rt = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n rt += qat;\n if ((process.pt = process.pt - qat) > 0) {\n que.offer(process);\n continue; \n }\n rt += process.pt;\n System.out.println(process.name + \" \" + rt);\n }\n\n }\n \n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
private final static class Process {
public String name = null;
public int pt = 0;
public Process(String name, int pt) {
this.name = name;
this.pt = pt;
}
}
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] fr = br.readLine().split("\\s");
int elm = Integer.parseInt(fr[0]);
int qat = Integer.parseInt(fr[1]);
Queue<Process> que = new LinkedList<Process>();
for (int i = 0; i < elm; i++) {
String[] str = br.readLine().split("\\s");
Process process = new Process(str[0],
Integer.parseInt(str[1]));
que.offer(process);
}
int rt = 0;
while (que.size() > 0) {
Process process = que.poll();
rt += qat;
if ((process.pt = process.pt - qat) > 0) {
que.offer(process);
continue;
}
rt += process.pt;
System.out.println(process.name + " " + rt);
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
41,
13,
41,
13,
17,
42,
2,
0,
13,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
112,
8
],
[
112,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
11,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
48,
49
],
[
43,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
11,
56
],
[
56,
57
],
[
11,
58
],
[
58,
59
],
[
11,
60
],
[
60,
61
],
[
60,
62
],
[
11,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
64,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
81,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
81,
92
],
[
92,
93
],
[
92,
94
],
[
77,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
105,
105
],
[
105,
106
],
[
105,
107
],
[
105,
108
],
[
9,
109
],
[
109,
110
],
[
0,
111
],
[
111,
112
],
[
111,
113
]
] | [
"import java.io.*;\nimport java.util.*;\n\npublic class Main\n{\n public static void main(String[] args)\n {\n Deque<String> name = new ArrayDeque<String>();\n Deque<Integer> time = new ArrayDeque<Integer>();\n Scanner scan = new Scanner(System.in);\n\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }\n\n String process_name;\n int process_time;\n int elapsed_time = 0;\n while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main\n{\n public static void main(String[] args)\n {\n Deque<String> name = new ArrayDeque<String>();\n Deque<Integer> time = new ArrayDeque<Integer>();\n Scanner scan = new Scanner(System.in);\n\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }\n\n String process_name;\n int process_time;\n int elapsed_time = 0;\n while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args)\n {\n Deque<String> name = new ArrayDeque<String>();\n Deque<Integer> time = new ArrayDeque<Integer>();\n Scanner scan = new Scanner(System.in);\n\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }\n\n String process_name;\n int process_time;\n int elapsed_time = 0;\n while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }\n }",
"main",
"{\n Deque<String> name = new ArrayDeque<String>();\n Deque<Integer> time = new ArrayDeque<Integer>();\n Scanner scan = new Scanner(System.in);\n\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }\n\n String process_name;\n int process_time;\n int elapsed_time = 0;\n while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }\n }",
"Deque<String> name = new ArrayDeque<String>();",
"name",
"new ArrayDeque<String>()",
"Deque<Integer> time = new ArrayDeque<Integer>();",
"time",
"new ArrayDeque<Integer>()",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int quantum = scan.nextInt();",
"quantum",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }",
"{\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }",
"name.offerLast(scan.next())",
"name.offerLast",
"name",
"scan.next()",
"scan.next",
"scan",
"time.offerLast(scan.nextInt())",
"time.offerLast",
"time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"String process_name;",
"process_name",
"int process_time;",
"process_time",
"int elapsed_time = 0;",
"elapsed_time",
"0",
"while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }",
"(process_name = name.pollFirst())!=null",
"(process_name = name.pollFirst())",
"process_name",
"name.pollFirst()",
"name.pollFirst",
"name",
"null",
"{\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }",
"process_time = time.pollFirst()",
"process_time",
"time.pollFirst()",
"time.pollFirst",
"time",
"if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }",
"process_time > quantum",
"process_time",
"quantum",
"{\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }",
"name.offerLast(process_name)",
"name.offerLast",
"name",
"process_name",
"time.offerLast(process_time - quantum)",
"time.offerLast",
"time",
"process_time - quantum",
"process_time",
"quantum",
"elapsed_time += quantum",
"elapsed_time",
"quantum",
"{\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }",
"elapsed_time += process_time",
"elapsed_time",
"process_time",
"System.out.println(process_name + \" \" + elapsed_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"process_name + \" \" + elapsed_time",
"process_name + \" \" + elapsed_time",
"process_name",
"\" \"",
"elapsed_time",
"String[] args",
"args",
"public class Main\n{\n public static void main(String[] args)\n {\n Deque<String> name = new ArrayDeque<String>();\n Deque<Integer> time = new ArrayDeque<Integer>();\n Scanner scan = new Scanner(System.in);\n\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }\n\n String process_name;\n int process_time;\n int elapsed_time = 0;\n while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }\n }\n}",
"public class Main\n{\n public static void main(String[] args)\n {\n Deque<String> name = new ArrayDeque<String>();\n Deque<Integer> time = new ArrayDeque<Integer>();\n Scanner scan = new Scanner(System.in);\n\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n for(int i=0; i<n; i++)\n {\n name.offerLast(scan.next());\n time.offerLast(scan.nextInt());\n }\n\n String process_name;\n int process_time;\n int elapsed_time = 0;\n while((process_name = name.pollFirst())!=null)\n {\n process_time = time.pollFirst();\n if(process_time > quantum)\n {\n name.offerLast(process_name);\n time.offerLast(process_time - quantum);\n elapsed_time += quantum;\n }\n else\n {\n elapsed_time += process_time;\n System.out.println(process_name + \" \" + elapsed_time);\n }\n }\n }\n}",
"Main"
] | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Deque<String> name = new ArrayDeque<String>();
Deque<Integer> time = new ArrayDeque<Integer>();
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int quantum = scan.nextInt();
for(int i=0; i<n; i++)
{
name.offerLast(scan.next());
time.offerLast(scan.nextInt());
}
String process_name;
int process_time;
int elapsed_time = 0;
while((process_name = name.pollFirst())!=null)
{
process_time = time.pollFirst();
if(process_time > quantum)
{
name.offerLast(process_name);
time.offerLast(process_time - quantum);
elapsed_time += quantum;
}
else
{
elapsed_time += process_time;
System.out.println(process_name + " " + elapsed_time);
}
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
38,
5,
13,
30,
4,
18,
13,
5,
13,
30,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
2,
13,
4,
18,
13,
13,
4,
18,
13,
20,
30,
0,
13,
2,
13,
13,
4,
18,
13,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
13,
2,
13,
13,
14,
2,
13,
17,
29,
17,
29,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
218,
14
],
[
218,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
17,
24
],
[
24,
25
],
[
24,
26
],
[
17,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
27,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
27,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
43,
48
],
[
40,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
54,
55
],
[
54,
56
],
[
40,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
62,
64
],
[
40,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
65,
70
],
[
70,
71
],
[
70,
72
],
[
65,
73
],
[
73,
74
],
[
74,
75
],
[
65,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
80,
85
],
[
77,
86
],
[
86,
87
],
[
86,
88
],
[
77,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
40,
93
],
[
93,
94
],
[
93,
95
],
[
40,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
97,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
102,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
102,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
122,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
122,
127
],
[
118,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
114,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
40,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
143,
147
],
[
142,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
148,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
160,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
160,
164
],
[
160,
165
],
[
165,
166
],
[
166,
167
],
[
15,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
170,
174
],
[
174,
175
],
[
170,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
182,
183
],
[
182,
184
],
[
176,
185
],
[
185,
186
],
[
176,
187
],
[
187,
188
],
[
170,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
170,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
170,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
204,
206
],
[
201,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
211
],
[
211,
212
],
[
201,
213
],
[
213,
214
],
[
199,
215
],
[
215,
216
],
[
0,
217
],
[
217,
218
],
[
217,
219
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Task> q = new ArrayDeque<Task>();\n\t\tArrayDeque<Task> ans = new ArrayDeque<Task>();\n\t\t\n\t\ttry {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n\nclass Task {\n\tprivate int time;\n\tprivate String name;\n\t\n\tpublic Task(int t, String n) {\n\t\ttime = t;\n\t\tname = n;\n\t}\n\t\n\tpublic int getTIme() {\n\t\treturn time;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\tpublic boolean minusTime(int t) {\n\t\ttime = time - t;\n\t\tif (time <= 0) return true;\n\t\treturn false;\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Task> q = new ArrayDeque<Task>();\n\t\tArrayDeque<Task> ans = new ArrayDeque<Task>();\n\t\t\n\t\ttry {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Task> q = new ArrayDeque<Task>();\n\t\tArrayDeque<Task> ans = new ArrayDeque<Task>();\n\t\t\n\t\ttry {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Task> q = new ArrayDeque<Task>();\n\t\tArrayDeque<Task> ans = new ArrayDeque<Task>();\n\t\t\n\t\ttry {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"BufferedReader in = new BufferedReader(new InputStreamReader(System.in));",
"in",
"new BufferedReader(new InputStreamReader(System.in))",
"ArrayDeque<Task> q = new ArrayDeque<Task>();",
"q",
"new ArrayDeque<Task>()",
"ArrayDeque<Task> ans = new ArrayDeque<Task>();",
"ans",
"new ArrayDeque<Task>()",
"try {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"NumberFormatException e",
"{\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"IOException e",
"{\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t}",
"String[] param = in.readLine().split(\" \");",
"param",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"int lim = Integer.parseInt(param[0]);",
"lim",
"Integer.parseInt(param[0])",
"Integer.parseInt",
"Integer",
"param[0]",
"param",
"0",
"int time = Integer.parseInt(param[1]);",
"time",
"Integer.parseInt(param[1])",
"Integer.parseInt",
"Integer",
"param[1]",
"param",
"1",
"for (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < lim",
"i",
"lim",
"i++",
"i++",
"i",
"{\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}",
"{\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}",
"param = in.readLine().split(\" \")",
"param",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"Task t = new Task(Integer.parseInt(param[1]), param[0]);",
"t",
"new Task(Integer.parseInt(param[1]), param[0])",
"q.add(t)",
"q.add",
"q",
"t",
"int past = 0;",
"past",
"0",
"while (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}",
"q.isEmpty() == false",
"q.isEmpty()",
"q.isEmpty",
"q",
"false",
"{\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}",
"Task tmp = q.remove();",
"tmp",
"q.remove()",
"q.remove",
"q",
"boolean flag = tmp.minusTime(time);",
"flag",
"tmp.minusTime(time)",
"tmp.minusTime",
"tmp",
"time",
"if (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}",
"flag == true",
"flag",
"true",
"{\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t}",
"past = past + tmp.getTIme() + time",
"past",
"past + tmp.getTIme() + time",
"past + tmp.getTIme() + time",
"past",
"tmp.getTIme()",
"tmp.getTIme",
"tmp",
"time",
"ans.add(new Task(past, tmp.getName()))",
"ans.add",
"ans",
"new Task(past, tmp.getName())",
"{\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}",
"past = past + time",
"past",
"past + time",
"past",
"time",
"q.add(tmp)",
"q.add",
"q",
"tmp",
"while (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}",
"ans.isEmpty() == false",
"ans.isEmpty()",
"ans.isEmpty",
"ans",
"false",
"{\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}",
"Task tmp = ans.remove();",
"tmp",
"ans.remove()",
"ans.remove",
"ans",
"System.out.println(tmp.getName() + \" \" + tmp.getTIme())",
"System.out.println",
"System.out",
"System",
"System.out",
"tmp.getName() + \" \" + tmp.getTIme()",
"tmp.getName() + \" \" + tmp.getTIme()",
"tmp.getName()",
"tmp.getName",
"tmp",
"\" \"",
"tmp.getTIme()",
"tmp.getTIme",
"tmp",
"String[] args",
"args",
"class Task {\n\tprivate int time;\n\tprivate String name;\n\t\n\tpublic Task(int t, String n) {\n\t\ttime = t;\n\t\tname = n;\n\t}\n\t\n\tpublic int getTIme() {\n\t\treturn time;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\tpublic boolean minusTime(int t) {\n\t\ttime = time - t;\n\t\tif (time <= 0) return true;\n\t\treturn false;\n\t}\n}",
"Task",
"private int time;",
"time",
"private String name;",
"name",
"public Task(int t, String n) {\n\t\ttime = t;\n\t\tname = n;\n\t}",
"Task",
"{\n\t\ttime = t;\n\t\tname = n;\n\t}",
"time = t",
"time",
"t",
"name = n",
"name",
"n",
"int t",
"t",
"String n",
"n",
"public int getTIme() {\n\t\treturn time;\n\t}",
"getTIme",
"{\n\t\treturn time;\n\t}",
"return time;",
"time",
"public String getName() {\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public boolean minusTime(int t) {\n\t\ttime = time - t;\n\t\tif (time <= 0) return true;\n\t\treturn false;\n\t}",
"minusTime",
"{\n\t\ttime = time - t;\n\t\tif (time <= 0) return true;\n\t\treturn false;\n\t}",
"time = time - t",
"time",
"time - t",
"time",
"t",
"if (time <= 0) return true;",
"time <= 0",
"time",
"0",
"return true;",
"true",
"return false;",
"false",
"int t",
"t",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Task> q = new ArrayDeque<Task>();\n\t\tArrayDeque<Task> ans = new ArrayDeque<Task>();\n\t\t\n\t\ttry {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tBufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Task> q = new ArrayDeque<Task>();\n\t\tArrayDeque<Task> ans = new ArrayDeque<Task>();\n\t\t\n\t\ttry {\n\t\t\tString[] param = in.readLine().split(\" \");\n\t\t\tint lim = Integer.parseInt(param[0]);\n\t\t\tint time = Integer.parseInt(param[1]);\n\t\t\t\n\t\t\tfor (int i = 0; i < lim; i++) {\n\t\t\t\tparam = in.readLine().split(\" \");\n\t\t\t\t\n\t\t\t\tTask t = new Task(Integer.parseInt(param[1]), param[0]);\n\t\t\t\tq.add(t);\n\t\t\t}\n\t\t\t\n\t\t\tint past = 0;\n\t\t\twhile (q.isEmpty() == false) {\n\t\t\t\tTask tmp = q.remove();\n\t\t\t\tboolean flag = tmp.minusTime(time);\n\t\t\t\t\n\t\t\t\tif (flag == true) {\n\t\t\t\t\tpast = past + tmp.getTIme() + time;\n\t\t\t\t\tans.add(new Task(past, tmp.getName()));\n\t\t\t\t} else {\n\t\t\t\t\tpast = past + time;\n\t\t\t\t\tq.add(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\twhile (ans.isEmpty() == false) {\n\t\t\t\tTask tmp = ans.remove();\n\t\t\t\tSystem.out.println(tmp.getName() + \" \" + tmp.getTIme());\n\t\t\t}\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO Auto-generated catch block\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
public class Main {
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
ArrayDeque<Task> q = new ArrayDeque<Task>();
ArrayDeque<Task> ans = new ArrayDeque<Task>();
try {
String[] param = in.readLine().split(" ");
int lim = Integer.parseInt(param[0]);
int time = Integer.parseInt(param[1]);
for (int i = 0; i < lim; i++) {
param = in.readLine().split(" ");
Task t = new Task(Integer.parseInt(param[1]), param[0]);
q.add(t);
}
int past = 0;
while (q.isEmpty() == false) {
Task tmp = q.remove();
boolean flag = tmp.minusTime(time);
if (flag == true) {
past = past + tmp.getTIme() + time;
ans.add(new Task(past, tmp.getName()));
} else {
past = past + time;
q.add(tmp);
}
}
while (ans.isEmpty() == false) {
Task tmp = ans.remove();
System.out.println(tmp.getName() + " " + tmp.getTIme());
}
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class Task {
private int time;
private String name;
public Task(int t, String n) {
time = t;
name = n;
}
public int getTIme() {
return time;
}
public String getName() {
return name;
}
public boolean minusTime(int t) {
time = time - t;
if (time <= 0) return true;
return false;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
12,
13,
30,
0,
13,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
30,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
23,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
30,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
29,
13,
12,
13,
30,
14,
2,
13,
17,
30,
29,
18,
13,
2,
13,
17,
30,
29,
18,
13,
2,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
13,
2,
13,
13,
13,
42,
40,
4,
13,
30,
0,
13,
4,
13,
0,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
13,
2,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
257,
5
],
[
257,
6
],
[
6,
7
],
[
6,
8
],
[
257,
9
],
[
9,
10
],
[
9,
11
],
[
257,
12
],
[
12,
13
],
[
12,
14
],
[
257,
15
],
[
15,
16
],
[
15,
17
],
[
257,
19
],
[
19,
20
],
[
19,
21
],
[
257,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
257,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
257,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
257,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
55,
56
],
[
56,
57
],
[
52,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
58,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
69,
79
],
[
79,
80
],
[
80,
81
],
[
49,
82
],
[
82,
83
],
[
49,
84
],
[
84,
85
],
[
257,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
101,
111
],
[
111,
112
],
[
112,
113
],
[
95,
114
],
[
114,
115
],
[
257,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
119,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
257,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
146,
147
],
[
139,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
139,
153
],
[
153,
154
],
[
153,
155
],
[
139,
156
],
[
156,
157
],
[
156,
158
],
[
139,
159
],
[
159,
160
],
[
159,
161
],
[
139,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
162,
167
],
[
167,
168
],
[
167,
169
],
[
162,
170
],
[
170,
171
],
[
171,
172
],
[
162,
173
],
[
174,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
174,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
174,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
185,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
189,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
193,
198
],
[
199,
199
],
[
199,
200
],
[
199,
201
],
[
199,
202
],
[
185,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
207,
208
],
[
207,
209
],
[
209,
210
],
[
209,
211
],
[
207,
212
],
[
139,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
213,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
220,
221
],
[
217,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
217,
226
],
[
226,
227
],
[
227,
228
],
[
227,
229
],
[
226,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
230,
234
],
[
234,
235
],
[
235,
236
],
[
236,
237
],
[
236,
238
],
[
234,
239
],
[
240,
240
],
[
240,
241
],
[
240,
242
],
[
240,
243
],
[
226,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
248,
249
],
[
248,
250
],
[
250,
251
],
[
250,
252
],
[
248,
253
],
[
137,
254
],
[
254,
255
],
[
0,
256
],
[
256,
257
],
[
256,
258
]
] | [
"import java.util.*;\n\npublic class Main {\n static int head = 0;\n static int tail = 0;\n static int max = 100000;\n static int[] queue = new int[max];\n static String[] str = new String[max];\n\n public static void initialize() {\n head = tail = 0;\n }\n public static boolean isEmpty() {\n return head == tail;\n }\n public static boolean isFull() {\n return head == (tail + 1) % max;\n }\n public static void enqueue(int x, String s) {\n if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }\n }\n public static int dequeue() {\n if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }\n }\n public static String destr() {\n if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n String s = \"\";\n int a = 0;\n int time = 0;\n for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n static int head = 0;\n static int tail = 0;\n static int max = 100000;\n static int[] queue = new int[max];\n static String[] str = new String[max];\n\n public static void initialize() {\n head = tail = 0;\n }\n public static boolean isEmpty() {\n return head == tail;\n }\n public static boolean isFull() {\n return head == (tail + 1) % max;\n }\n public static void enqueue(int x, String s) {\n if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }\n }\n public static int dequeue() {\n if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }\n }\n public static String destr() {\n if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n String s = \"\";\n int a = 0;\n int time = 0;\n for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n }\n}",
"Main",
"static int head = 0;",
"head",
"0",
"static int tail = 0;",
"tail",
"0",
"static int max = 100000;",
"max",
"100000",
"static int[] queue = new int[max];",
"queue",
"new int[max]",
"max",
"static String[] str = new String[max];",
"str",
"new String[max]",
"max",
"public static void initialize() {\n head = tail = 0;\n }",
"initialize",
"{\n head = tail = 0;\n }",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"public static boolean isEmpty() {\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"public static boolean isFull() {\n return head == (tail + 1) % max;\n }",
"isFull",
"{\n return head == (tail + 1) % max;\n }",
"return head == (tail + 1) % max;",
"head == (tail + 1) % max",
"head",
"(tail + 1) % max",
"(tail + 1)",
"tail",
"1",
"max",
"public static void enqueue(int x, String s) {\n if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }\n }",
"enqueue",
"{\n if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }\n }",
"if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }",
"isFull()",
"isFull",
"{\n throw new IllegalArgumentException(\"オーバーフロー\");\n }",
"throw new IllegalArgumentException(\"オーバーフロー\");",
"new IllegalArgumentException(\"オーバーフロー\")",
"{\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }",
"queue[tail] = x",
"queue[tail]",
"queue",
"tail",
"x",
"str[tail] = s",
"str[tail]",
"str",
"tail",
"s",
"if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }",
"tail + 1 == max",
"tail + 1",
"tail",
"1",
"max",
"{\n tail = 0;\n }",
"tail = 0",
"tail",
"0",
"{\n tail++;\n }",
"tail++",
"tail",
"int x",
"x",
"String s",
"s",
"public static int dequeue() {\n if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }\n }",
"dequeue",
"{\n if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }\n }",
"if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }",
"isEmpty()",
"isEmpty",
"{\n throw new IllegalArgumentException(\"アンダーフロー\");\n }",
"throw new IllegalArgumentException(\"アンダーフロー\");",
"new IllegalArgumentException(\"アンダーフロー\")",
"{\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }",
"int x = queue[head];",
"x",
"queue[head]",
"queue",
"head",
"if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }",
"head + 1 == max",
"head + 1",
"head",
"1",
"max",
"{\n head = 0;\n }",
"head = 0",
"head",
"0",
"{\n head++;\n }",
"head++",
"head",
"return x;",
"x",
"public static String destr() {\n if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }\n }",
"destr",
"{\n if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }\n }",
"if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }",
"head == 0",
"head",
"0",
"{\n return str[max - 1];\n }",
"return str[max - 1];",
"str[max - 1]",
"str",
"max - 1",
"max",
"1",
"{\n return str[head - 1];\n }",
"return str[head - 1];",
"str[head - 1]",
"str",
"head - 1",
"head",
"1",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n String s = \"\";\n int a = 0;\n int time = 0;\n for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n String s = \"\";\n int a = 0;\n int time = 0;\n for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"String s = \"\";",
"s",
"\"\"",
"int a = 0;",
"a",
"0",
"int time = 0;",
"time",
"0",
"for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }",
"{\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }",
"s = sc.next()",
"s",
"sc.next()",
"sc.next",
"sc",
"a = sc.nextInt()",
"a",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }",
"a <= q",
"a",
"q",
"{\n time += a;\n System.out.println(s + \" \" + time);\n }",
"time += a",
"time",
"a",
"System.out.println(s + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"s + \" \" + time",
"s + \" \" + time",
"s",
"\" \"",
"time",
"{\n time += q;\n enqueue(a - q, s);\n }",
"time += q",
"time",
"q",
"enqueue(a - q, s)",
"enqueue",
"a - q",
"a",
"q",
"s",
"while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }",
"a = dequeue()",
"a",
"dequeue()",
"dequeue",
"s = destr()",
"s",
"destr()",
"destr",
"if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }",
"a <= q",
"a",
"q",
"{\n time += a;\n System.out.println(s + \" \" + time);\n }",
"time += a",
"time",
"a",
"System.out.println(s + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"s + \" \" + time",
"s + \" \" + time",
"s",
"\" \"",
"time",
"{\n time += q;\n enqueue(a - q, s);\n }",
"time += q",
"time",
"q",
"enqueue(a - q, s)",
"enqueue",
"a - q",
"a",
"q",
"s",
"String[] args",
"args",
"public class Main {\n static int head = 0;\n static int tail = 0;\n static int max = 100000;\n static int[] queue = new int[max];\n static String[] str = new String[max];\n\n public static void initialize() {\n head = tail = 0;\n }\n public static boolean isEmpty() {\n return head == tail;\n }\n public static boolean isFull() {\n return head == (tail + 1) % max;\n }\n public static void enqueue(int x, String s) {\n if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }\n }\n public static int dequeue() {\n if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }\n }\n public static String destr() {\n if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n String s = \"\";\n int a = 0;\n int time = 0;\n for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n }\n}",
"public class Main {\n static int head = 0;\n static int tail = 0;\n static int max = 100000;\n static int[] queue = new int[max];\n static String[] str = new String[max];\n\n public static void initialize() {\n head = tail = 0;\n }\n public static boolean isEmpty() {\n return head == tail;\n }\n public static boolean isFull() {\n return head == (tail + 1) % max;\n }\n public static void enqueue(int x, String s) {\n if(isFull()) {\n throw new IllegalArgumentException(\"オーバーフロー\");\n } else {\n queue[tail] = x;\n str[tail] = s;\n if(tail + 1 == max) {\n tail = 0;\n } else {\n tail++;\n }\n }\n }\n public static int dequeue() {\n if(isEmpty()) {\n throw new IllegalArgumentException(\"アンダーフロー\");\n } else {\n int x = queue[head];\n if(head + 1 == max) {\n head = 0;\n } else {\n head++;\n }\n return x;\n }\n }\n public static String destr() {\n if(head == 0) {\n return str[max - 1];\n } else {\n return str[head - 1];\n }\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n String s = \"\";\n int a = 0;\n int time = 0;\n for(int i = 0; i < n; i++) {\n s = sc.next();\n a = sc.nextInt();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n while(!isEmpty()) {\n a = dequeue();\n s = destr();\n if(a <= q) {\n time += a;\n System.out.println(s + \" \" + time);\n } else {\n time += q;\n enqueue(a - q, s);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
static int head = 0;
static int tail = 0;
static int max = 100000;
static int[] queue = new int[max];
static String[] str = new String[max];
public static void initialize() {
head = tail = 0;
}
public static boolean isEmpty() {
return head == tail;
}
public static boolean isFull() {
return head == (tail + 1) % max;
}
public static void enqueue(int x, String s) {
if(isFull()) {
throw new IllegalArgumentException("オーバーフロー");
} else {
queue[tail] = x;
str[tail] = s;
if(tail + 1 == max) {
tail = 0;
} else {
tail++;
}
}
}
public static int dequeue() {
if(isEmpty()) {
throw new IllegalArgumentException("アンダーフロー");
} else {
int x = queue[head];
if(head + 1 == max) {
head = 0;
} else {
head++;
}
return x;
}
}
public static String destr() {
if(head == 0) {
return str[max - 1];
} else {
return str[head - 1];
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
String s = "";
int a = 0;
int time = 0;
for(int i = 0; i < n; i++) {
s = sc.next();
a = sc.nextInt();
if(a <= q) {
time += a;
System.out.println(s + " " + time);
} else {
time += q;
enqueue(a - q, s);
}
}
while(!isEmpty()) {
a = dequeue();
s = destr();
if(a <= q) {
time += a;
System.out.println(s + " " + time);
} else {
time += q;
enqueue(a - q, s);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
13,
41,
13,
20,
41,
13,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
18,
13,
13,
18,
13,
17,
4,
18,
13,
20,
42,
2,
0,
13,
4,
18,
13,
17,
30,
14,
2,
18,
13,
17,
13,
30,
0,
13,
18,
13,
17,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
18,
13,
17,
17,
13,
17,
30,
0,
13,
13,
0,
18,
13,
17,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
17,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
11,
43
],
[
43,
44
],
[
43,
45
],
[
11,
46
],
[
46,
47
],
[
11,
48
],
[
48,
49
],
[
48,
50
],
[
11,
51
],
[
51,
52
],
[
51,
53
],
[
11,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
54,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
69,
74
],
[
66,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
66,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
11,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
87,
93
],
[
86,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
101,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
111,
121
],
[
109,
122
],
[
107,
123
],
[
95,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
124,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
11,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
142,
143
],
[
143,
144
],
[
9,
145
],
[
145,
146
]
] | [
"import java.io.*;\nimport java.util.concurrent.LinkedBlockingQueue;\n\nclass Main {\n public static void main (String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while ((currentProcess = processes.poll()) != null) {\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.concurrent.LinkedBlockingQueue;",
"LinkedBlockingQueue",
"java.util.concurrent",
"class Main {\n public static void main (String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while ((currentProcess = processes.poll()) != null) {\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }\n}",
"Main",
"public static void main (String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while ((currentProcess = processes.poll()) != null) {\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n \n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n String[] names = new String[n];\n LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();\n int[] currentProcess;\n int time = 0;\n StringBuilder sb = new StringBuilder();\n\n for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }\n\n while ((currentProcess = processes.poll()) != null) {\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }\n }\n System.out.print(sb.toString());\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] input = br.readLine().split(\" \");",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(input[0]);",
"n",
"Integer.parseInt(input[0])",
"Integer.parseInt",
"Integer",
"input[0]",
"input",
"0",
"int q = Integer.parseInt(input[1]);",
"q",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"String[] names = new String[n];",
"names",
"new String[n]",
"n",
"LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();",
"processes",
"new LinkedBlockingQueue<int[]>()",
"int[] currentProcess;",
"currentProcess",
"int time = 0;",
"time",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for (int i = 0; i < n; i++) {\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }",
"{\n input = br.readLine().split(\" \");\n names[i] = input[0];\n processes.offer(new int[] {i, Integer.parseInt(input[1])});\n }",
"input = br.readLine().split(\" \")",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"names[i] = input[0]",
"names[i]",
"names",
"i",
"input[0]",
"input",
"0",
"processes.offer(new int[] {i, Integer.parseInt(input[1])})",
"processes.offer",
"processes",
"new int[] {i, Integer.parseInt(input[1])}",
"while ((currentProcess = processes.poll()) != null) {\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }\n }",
"(currentProcess = processes.poll()) != null",
"(currentProcess = processes.poll())",
"currentProcess",
"processes.poll()",
"processes.poll",
"processes",
"null",
"{\n if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }\n }",
"if (currentProcess[1] <= q) {\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n } else {\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }",
"currentProcess[1] <= q",
"currentProcess[1]",
"currentProcess",
"1",
"q",
"{\n time += currentProcess[1];\n sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\");\n }",
"time += currentProcess[1]",
"time",
"currentProcess[1]",
"currentProcess",
"1",
"sb.append(names[currentProcess[0]]).append(\" \").append(time).append(\"\\n\")",
"sb.append(names[currentProcess[0]]).append(\" \").append(time).append",
"sb.append(names[currentProcess[0]]).append(\" \").append(time)",
"sb.append(names[currentProcess[0]]).append(\" \").append",
"sb.append(names[currentProcess[0]]).append(\" \")",
"sb.append(names[currentProcess[0]]).append",
"sb.append(names[currentProcess[0]])",
"sb.append",
"sb",
"names[currentProcess[0]]",
"names",
"currentProcess[0]",
"currentProcess",
"0",
"\" \"",
"time",
"\"\\n\"",
"{\n time += q;\n currentProcess[1] -= q;\n processes.offer(currentProcess);\n }",
"time += q",
"time",
"q",
"currentProcess[1] -= q",
"currentProcess[1]",
"currentProcess",
"1",
"q",
"processes.offer(currentProcess)",
"processes.offer",
"processes",
"currentProcess",
"System.out.print(sb.toString())",
"System.out.print",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"String[] args",
"args"
] | import java.io.*;
import java.util.concurrent.LinkedBlockingQueue;
class Main {
public static void main (String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int q = Integer.parseInt(input[1]);
String[] names = new String[n];
LinkedBlockingQueue<int[]> processes = new LinkedBlockingQueue<int[]>();
int[] currentProcess;
int time = 0;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
input = br.readLine().split(" ");
names[i] = input[0];
processes.offer(new int[] {i, Integer.parseInt(input[1])});
}
while ((currentProcess = processes.poll()) != null) {
if (currentProcess[1] <= q) {
time += currentProcess[1];
sb.append(names[currentProcess[0]]).append(" ").append(time).append("\n");
} else {
time += q;
currentProcess[1] -= q;
processes.offer(currentProcess);
}
}
System.out.print(sb.toString());
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
41,
13,
2,
4,
18,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
29,
18,
36,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
20,
2,
13,
17,
0,
18,
36,
13,
17,
0,
18,
36,
13,
17,
0,
18,
36,
13,
2,
13,
17,
23,
13,
12,
13,
30,
0,
18,
18,
36,
13,
18,
36,
13,
13,
14,
2,
2,
18,
36,
13,
17,
18,
36,
13,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
23,
13,
12,
13,
30,
41,
13,
18,
18,
36,
13,
18,
36,
13,
14,
2,
2,
18,
36,
13,
17,
18,
36,
13,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
29,
13,
12,
13,
30,
14,
2,
18,
36,
13,
18,
36,
13,
30,
29,
17,
29,
17,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
306,
11
],
[
306,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
20,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
31,
32
],
[
31,
33
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
14,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
14,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
60,
65
],
[
57,
66
],
[
66,
67
],
[
66,
68
],
[
57,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
14,
73
],
[
73,
74
],
[
73,
75
],
[
14,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
76,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
88,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
105,
109
],
[
105,
110
],
[
87,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
114,
118
],
[
111,
119
],
[
119,
120
],
[
119,
121
],
[
111,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
111,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
12,
130
],
[
130,
131
],
[
306,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
132,
136
],
[
136,
137
],
[
132,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
140,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
146,
150
],
[
138,
151
],
[
151,
152
],
[
138,
153
],
[
153,
154
],
[
132,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
155,
163
],
[
163,
164
],
[
132,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
132,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
306,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
179,
183
],
[
183,
184
],
[
179,
185
],
[
185,
186
],
[
179,
187
],
[
187,
188
],
[
179,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
197,
198
],
[
197,
199
],
[
191,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
200,
204
],
[
191,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
205,
209
],
[
191,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
210,
214
],
[
214,
215
],
[
214,
216
],
[
189,
217
],
[
217,
218
],
[
179,
219
],
[
219,
220
],
[
219,
221
],
[
221,
222
],
[
222,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
223,
227
],
[
227,
228
],
[
227,
229
],
[
222,
230
],
[
221,
231
],
[
231,
232
],
[
232,
233
],
[
233,
234
],
[
234,
235
],
[
234,
236
],
[
233,
237
],
[
232,
238
],
[
238,
239
],
[
238,
240
],
[
231,
241
],
[
241,
242
],
[
242,
243
],
[
243,
244
],
[
243,
245
],
[
242,
246
],
[
231,
247
],
[
247,
248
],
[
248,
249
],
[
249,
250
],
[
249,
251
],
[
219,
252
],
[
252,
253
],
[
179,
254
],
[
254,
255
],
[
254,
256
],
[
256,
257
],
[
257,
258
],
[
257,
259
],
[
259,
260
],
[
260,
261
],
[
260,
262
],
[
259,
263
],
[
263,
264
],
[
263,
265
],
[
256,
266
],
[
266,
267
],
[
267,
268
],
[
268,
269
],
[
269,
270
],
[
269,
271
],
[
268,
272
],
[
267,
273
],
[
273,
274
],
[
273,
275
],
[
266,
276
],
[
276,
277
],
[
277,
278
],
[
278,
279
],
[
278,
280
],
[
277,
281
],
[
266,
282
],
[
282,
283
],
[
283,
284
],
[
284,
285
],
[
284,
286
],
[
256,
287
],
[
287,
288
],
[
179,
289
],
[
289,
290
],
[
289,
291
],
[
291,
292
],
[
292,
293
],
[
293,
294
],
[
294,
295
],
[
294,
296
],
[
293,
297
],
[
297,
298
],
[
297,
299
],
[
292,
300
],
[
300,
301
],
[
301,
302
],
[
291,
303
],
[
303,
304
],
[
0,
305
],
[
305,
306
],
[
305,
307
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static class Process {\n\t\tprivate String name;\n\t\tprivate int time;\n\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn this.name;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn this.time;\n\t\t}\n\t}\n\n\tpublic static class Queue {\n\t\tprivate Process[] data;\n\t\tprivate int head;\n\t\tprivate int tail;\n\t\tprivate int max;\n\n\t\tpublic Queue (int processNum) {\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}\n\n\t\tpublic void enqueue(Process process) {\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}\n\n\t\tpublic boolean isEmpty() {\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] premise = br.readLine().split(\" \");\n\n\t\tint processNum =Integer.parseInt(premise[0]);\n\n\t\tQueue queue = new Queue(processNum);\n\n\t\tint q = Integer.parseInt(premise[1]);\n\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}\n\n\t\tint progressTime = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic static class Process {\n\t\tprivate String name;\n\t\tprivate int time;\n\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn this.name;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn this.time;\n\t\t}\n\t}\n\n\tpublic static class Queue {\n\t\tprivate Process[] data;\n\t\tprivate int head;\n\t\tprivate int tail;\n\t\tprivate int max;\n\n\t\tpublic Queue (int processNum) {\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}\n\n\t\tpublic void enqueue(Process process) {\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}\n\n\t\tpublic boolean isEmpty() {\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] premise = br.readLine().split(\" \");\n\n\t\tint processNum =Integer.parseInt(premise[0]);\n\n\t\tQueue queue = new Queue(processNum);\n\n\t\tint q = Integer.parseInt(premise[1]);\n\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}\n\n\t\tint progressTime = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] premise = br.readLine().split(\" \");\n\n\t\tint processNum =Integer.parseInt(premise[0]);\n\n\t\tQueue queue = new Queue(processNum);\n\n\t\tint q = Integer.parseInt(premise[1]);\n\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}\n\n\t\tint progressTime = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] premise = br.readLine().split(\" \");\n\n\t\tint processNum =Integer.parseInt(premise[0]);\n\n\t\tQueue queue = new Queue(processNum);\n\n\t\tint q = Integer.parseInt(premise[1]);\n\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}\n\n\t\tint progressTime = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] premise = br.readLine().split(\" \");",
"premise",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int processNum =Integer.parseInt(premise[0]);",
"processNum",
"Integer.parseInt(premise[0])",
"Integer.parseInt",
"Integer",
"premise[0]",
"premise",
"0",
"Queue queue = new Queue(processNum);",
"queue",
"new Queue(processNum)",
"int q = Integer.parseInt(premise[1]);",
"q",
"Integer.parseInt(premise[1])",
"Integer.parseInt",
"Integer",
"premise[1]",
"premise",
"1",
"for(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < processNum",
"i",
"processNum",
"i++",
"i++",
"i",
"{\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}",
"{\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}",
"String[] processString = br.readLine().split(\" \");",
"processString",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"Process process = new Process(processString[0], Integer.parseInt(processString[1]));",
"process",
"new Process(processString[0], Integer.parseInt(processString[1]))",
"queue.enqueue(process)",
"queue.enqueue",
"queue",
"process",
"int progressTime = 0;",
"progressTime",
"0",
"while(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}",
"Process process = queue.dequeue();",
"process",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}",
"process.getTime() <= q",
"process.getTime()",
"process.getTime",
"process",
"q",
"{\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t}",
"progressTime += process.getTime()",
"progressTime",
"process.getTime()",
"process.getTime",
"process",
"System.out.println(process.getName() + \" \" + progressTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.getName() + \" \" + progressTime",
"process.getName() + \" \" + progressTime",
"process.getName()",
"process.getName",
"process",
"\" \"",
"progressTime",
"{\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}",
"int processingTime = process.getTime() - q;",
"processingTime",
"process.getTime() - q",
"process.getTime()",
"process.getTime",
"process",
"q",
"progressTime += q",
"progressTime",
"q",
"process.setTime(processingTime)",
"process.setTime",
"process",
"processingTime",
"queue.enqueue(process)",
"queue.enqueue",
"queue",
"process",
"String[] args",
"args",
"public static class Process {\n\t\tprivate String name;\n\t\tprivate int time;\n\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn this.name;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn this.time;\n\t\t}\n\t}",
"Process",
"private String name;",
"name",
"private int time;",
"time",
"public Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"Process",
"{\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}",
"setTime",
"{\n\t\t\tthis.time = time;\n\t\t}",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"public String getName() {\n\t\t\treturn this.name;\n\t\t}",
"getName",
"{\n\t\t\treturn this.name;\n\t\t}",
"return this.name;",
"this.name",
"this",
"this.name",
"public int getTime() {\n\t\t\treturn this.time;\n\t\t}",
"getTime",
"{\n\t\t\treturn this.time;\n\t\t}",
"return this.time;",
"this.time",
"this",
"this.time",
"public static class Queue {\n\t\tprivate Process[] data;\n\t\tprivate int head;\n\t\tprivate int tail;\n\t\tprivate int max;\n\n\t\tpublic Queue (int processNum) {\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}\n\n\t\tpublic void enqueue(Process process) {\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}\n\n\t\tpublic boolean isEmpty() {\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}",
"Queue",
"private Process[] data;",
"data",
"private int head;",
"head",
"private int tail;",
"tail",
"private int max;",
"max",
"public Queue (int processNum) {\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}",
"Queue",
"{\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}",
"this.data = new Process[processNum + 1]",
"this.data",
"this",
"this.data",
"new Process[processNum + 1]",
"processNum + 1",
"processNum",
"1",
"this.head = 0",
"this.head",
"this",
"this.head",
"0",
"this.tail = 0",
"this.tail",
"this",
"this.tail",
"0",
"this.max = processNum + 1",
"this.max",
"this",
"this.max",
"processNum + 1",
"processNum",
"1",
"int processNum",
"processNum",
"public void enqueue(Process process) {\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}",
"enqueue",
"{\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}",
"this.data[this.tail] = process",
"this.data[this.tail]",
"this.data",
"this",
"this.data",
"this.tail",
"this",
"this.tail",
"process",
"if(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}",
"this.tail + 1 == this.max",
"this.tail + 1",
"this.tail",
"this",
"this.tail",
"1",
"this.max",
"this",
"this.max",
"{\n\t\t\t\tthis.tail = 0;\n\t\t\t}",
"this.tail = 0",
"this.tail",
"this",
"this.tail",
"0",
"{\n\t\t\t\tthis.tail++;\n\t\t\t}",
"this.tail++",
"this.tail",
"this",
"this.tail",
"Process process",
"process",
"public Process dequeue() {\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}",
"dequeue",
"{\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}",
"Process process = this.data[this.head];",
"process",
"this.data[this.head]",
"this.data",
"this",
"this.data",
"this.head",
"this",
"this.head",
"if(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}",
"this.head + 1 == this.max",
"this.head + 1",
"this.head",
"this",
"this.head",
"1",
"this.max",
"this",
"this.max",
"{\n\t\t\t\tthis.head = 0;\n\t\t\t}",
"this.head = 0",
"this.head",
"this",
"this.head",
"0",
"{\n\t\t\t\tthis.head++;\n\t\t\t}",
"this.head++",
"this.head",
"this",
"this.head",
"return process;",
"process",
"public boolean isEmpty() {\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}",
"isEmpty",
"{\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}",
"if(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}",
"this.tail == this.head",
"this.tail",
"this",
"this.tail",
"this.head",
"this",
"this.head",
"{\n\t\t\t\treturn true;\n\t\t\t}",
"return true;",
"true",
"return false;",
"false",
"public class Main {\n\n\tpublic static class Process {\n\t\tprivate String name;\n\t\tprivate int time;\n\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn this.name;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn this.time;\n\t\t}\n\t}\n\n\tpublic static class Queue {\n\t\tprivate Process[] data;\n\t\tprivate int head;\n\t\tprivate int tail;\n\t\tprivate int max;\n\n\t\tpublic Queue (int processNum) {\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}\n\n\t\tpublic void enqueue(Process process) {\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}\n\n\t\tpublic boolean isEmpty() {\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] premise = br.readLine().split(\" \");\n\n\t\tint processNum =Integer.parseInt(premise[0]);\n\n\t\tQueue queue = new Queue(processNum);\n\n\t\tint q = Integer.parseInt(premise[1]);\n\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}\n\n\t\tint progressTime = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\n\tpublic static class Process {\n\t\tprivate String name;\n\t\tprivate int time;\n\n\t\tpublic Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn this.name;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn this.time;\n\t\t}\n\t}\n\n\tpublic static class Queue {\n\t\tprivate Process[] data;\n\t\tprivate int head;\n\t\tprivate int tail;\n\t\tprivate int max;\n\n\t\tpublic Queue (int processNum) {\n\t\t\tthis.data = new Process[processNum + 1];\n\t\t\tthis.head = 0;\n\t\t\tthis.tail = 0;\n\t\t\tthis.max = processNum + 1;\n\t\t}\n\n\t\tpublic void enqueue(Process process) {\n\t\t\tthis.data[this.tail] = process;\n\t\t\tif(this.tail + 1 == this.max) {\n\t\t\t\tthis.tail = 0;\n\t\t\t} else {\n\t\t\t\tthis.tail++;\n\t\t\t}\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tProcess process = this.data[this.head];\n\t\t\tif(this.head + 1 == this.max) {\n\t\t\t\tthis.head = 0;\n\t\t\t} else {\n\t\t\t\tthis.head++;\n\t\t\t}\n\t\t\treturn process;\n\t\t}\n\n\t\tpublic boolean isEmpty() {\n\t\t\tif(this.tail == this.head) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] premise = br.readLine().split(\" \");\n\n\t\tint processNum =Integer.parseInt(premise[0]);\n\n\t\tQueue queue = new Queue(processNum);\n\n\t\tint q = Integer.parseInt(premise[1]);\n\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tString[] processString = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(processString[0], Integer.parseInt(processString[1]));\n\t\t\tqueue.enqueue(process);\n\t\t}\n\n\t\tint progressTime = 0;\n\t\twhile(!queue.isEmpty()) {\n\t\t\tProcess process = queue.dequeue();\n\n\t\t\tif(process.getTime() <= q) {\n\t\t\t\tprogressTime += process.getTime();\n\t\t\t\tSystem.out.println(process.getName() + \" \" + progressTime);\n\t\t\t} else {\n\n\t\t\t\t// ?????????????????????1??\\???????????´???\n\t\t\t\tint processingTime = process.getTime() - q;\n\n\t\t\t\tprogressTime += q;\n\n\t\t\t\tprocess.setTime(processingTime);\n\t\t\t\tqueue.enqueue(process);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static class Process {
private String name;
private int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public void setTime(int time) {
this.time = time;
}
public String getName() {
return this.name;
}
public int getTime() {
return this.time;
}
}
public static class Queue {
private Process[] data;
private int head;
private int tail;
private int max;
public Queue (int processNum) {
this.data = new Process[processNum + 1];
this.head = 0;
this.tail = 0;
this.max = processNum + 1;
}
public void enqueue(Process process) {
this.data[this.tail] = process;
if(this.tail + 1 == this.max) {
this.tail = 0;
} else {
this.tail++;
}
}
public Process dequeue() {
Process process = this.data[this.head];
if(this.head + 1 == this.max) {
this.head = 0;
} else {
this.head++;
}
return process;
}
public boolean isEmpty() {
if(this.tail == this.head) {
return true;
}
return false;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] premise = br.readLine().split(" ");
int processNum =Integer.parseInt(premise[0]);
Queue queue = new Queue(processNum);
int q = Integer.parseInt(premise[1]);
for(int i = 0; i < processNum; i++) {
String[] processString = br.readLine().split(" ");
Process process = new Process(processString[0], Integer.parseInt(processString[1]));
queue.enqueue(process);
}
int progressTime = 0;
while(!queue.isEmpty()) {
Process process = queue.dequeue();
if(process.getTime() <= q) {
progressTime += process.getTime();
System.out.println(process.getName() + " " + progressTime);
} else {
// ?????????????????????1??\???????????´???
int processingTime = process.getTime() - q;
progressTime += q;
process.setTime(processingTime);
queue.enqueue(process);
}
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
18,
13,
13,
41,
13,
20,
17,
41,
13,
17,
41,
13,
17,
12,
13,
30,
14,
2,
13,
13,
30,
29,
17,
30,
0,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
30,
29,
17,
29,
17,
12,
13,
30,
14,
4,
13,
29,
18,
13,
40,
13,
29,
40,
17,
12,
13,
30,
29,
2,
2,
17,
13,
2,
13,
17,
23,
13,
12,
13,
30,
42,
2,
4,
13,
40,
4,
13,
18,
13,
13,
40,
13,
12,
13,
30,
4,
13,
29,
4,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
20,
41,
13,
4,
13,
42,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
296,
17
],
[
296,
18
],
[
18,
19
],
[
18,
20
],
[
296,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
23,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
23,
34
],
[
34,
35
],
[
34,
36
],
[
23,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
37,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
49,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
49,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
23,
64
],
[
64,
65
],
[
64,
66
],
[
23,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
67,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
84,
90
],
[
90,
91
],
[
90,
92
],
[
84,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
78,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
109,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
109,
114
],
[
21,
115
],
[
115,
116
],
[
296,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
117,
121
],
[
121,
122
],
[
117,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
125,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
123,
136
],
[
136,
137
],
[
123,
138
],
[
138,
139
],
[
296,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
140,
147
],
[
147,
148
],
[
147,
149
],
[
140,
151
],
[
151,
152
],
[
151,
153
],
[
140,
154
],
[
154,
155
],
[
154,
156
],
[
140,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
164,
165
],
[
165,
166
],
[
160,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
171,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
181,
184
],
[
167,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
185,
189
],
[
189,
190
],
[
190,
191
],
[
159,
192
],
[
192,
193
],
[
140,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
197,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
197,
205
],
[
205,
206
],
[
206,
207
],
[
140,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
216,
217
],
[
216,
218
],
[
208,
219
],
[
219,
220
],
[
140,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
225,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
231,
233
],
[
224,
234
],
[
234,
235
],
[
140,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
239,
240
],
[
238,
241
],
[
241,
242
],
[
242,
243
],
[
140,
244
],
[
244,
245
],
[
244,
246
],
[
246,
247
],
[
247,
248
],
[
248,
249
],
[
249,
250
],
[
247,
251
],
[
251,
252
],
[
246,
253
],
[
253,
254
],
[
253,
255
],
[
246,
256
],
[
256,
257
],
[
256,
258
],
[
258,
259
],
[
246,
260
],
[
260,
261
],
[
261,
262
],
[
261,
263
],
[
260,
264
],
[
264,
265
],
[
265,
266
],
[
266,
267
],
[
265,
268
],
[
264,
269
],
[
269,
270
],
[
269,
271
],
[
271,
272
],
[
246,
273
],
[
273,
274
],
[
274,
275
],
[
275,
276
],
[
140,
277
],
[
277,
278
],
[
277,
279
],
[
279,
280
],
[
280,
281
],
[
281,
282
],
[
282,
283
],
[
281,
284
],
[
284,
285
],
[
140,
286
],
[
286,
287
],
[
286,
288
],
[
288,
289
],
[
289,
290
],
[
290,
291
],
[
291,
292
],
[
290,
293
],
[
293,
294
],
[
0,
295
],
[
295,
296
],
[
295,
297
]
] | [
"import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.LinkedList;\nimport java.util.NoSuchElementException;\nimport java.util.Queue;\n\npublic class Main {\n\tprivate static FastScanner sc = new FastScanner();\n\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<Process> que = new LinkedList<>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess(String name, int time){\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t}\n\t\n\tstatic class FastScanner {\n\t private final InputStream in = System.in;\n\t private final byte[] buffer = new byte[1024];\n\t private int ptr = 0;\n\t private int buflen = 0;\n\t private boolean hasNextByte() {\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }\n\t private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n\t private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n\t private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n\t public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n\t public String next() {\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\t public int nextInt(){\n\t \treturn Integer.parseInt(next());\n\t }\n\t}\n\n}",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.NoSuchElementException;",
"NoSuchElementException",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\tprivate static FastScanner sc = new FastScanner();\n\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<Process> que = new LinkedList<>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess(String name, int time){\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t}\n\t\n\tstatic class FastScanner {\n\t private final InputStream in = System.in;\n\t private final byte[] buffer = new byte[1024];\n\t private int ptr = 0;\n\t private int buflen = 0;\n\t private boolean hasNextByte() {\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }\n\t private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n\t private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n\t private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n\t public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n\t public String next() {\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\t public int nextInt(){\n\t \treturn Integer.parseInt(next());\n\t }\n\t}\n\n}",
"Main",
"private static FastScanner sc = new FastScanner();",
"sc",
"new FastScanner()",
"public static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<Process> que = new LinkedList<>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<Process> que = new LinkedList<>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}\n\t}",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Process> que = new LinkedList<>();",
"que",
"new LinkedList<>()",
"for(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"que.add(new Process(name, time))",
"que.add",
"que",
"new Process(name, time)",
"int timer = 0;",
"timer",
"0",
"while(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}",
"Process p = que.poll();",
"p",
"que.poll()",
"que.poll",
"que",
"if(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t}",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"timer += q",
"timer",
"q",
"que.add(p)",
"que.add",
"que",
"p",
"{\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}",
"timer += p.time",
"timer",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + timer)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + timer",
"p.name + \" \" + timer",
"p.name",
"p",
"p.name",
"\" \"",
"timer",
"String[] args",
"args",
"static class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess(String name, int time){\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time){\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"Process",
"{\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"static class FastScanner {\n\t private final InputStream in = System.in;\n\t private final byte[] buffer = new byte[1024];\n\t private int ptr = 0;\n\t private int buflen = 0;\n\t private boolean hasNextByte() {\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }\n\t private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n\t private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n\t private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n\t public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n\t public String next() {\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\t public int nextInt(){\n\t \treturn Integer.parseInt(next());\n\t }\n\t}",
"FastScanner",
"private final InputStream in = System.in;",
"in",
"System.in",
"System",
"System.in",
"private final byte[] buffer = new byte[1024];",
"buffer",
"new byte[1024]",
"1024",
"private int ptr = 0;",
"ptr",
"0",
"private int buflen = 0;",
"buflen",
"0",
"private boolean hasNextByte() {\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }",
"hasNextByte",
"{\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }",
"if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }",
"ptr < buflen",
"ptr",
"buflen",
"{\n\t return true;\n\t }",
"return true;",
"true",
"{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }",
"ptr = 0",
"ptr",
"0",
"try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"catch (IOException e) {\n\t e.printStackTrace();\n\t }",
"IOException e",
"{\n\t e.printStackTrace();\n\t }",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t buflen = in.read(buffer);\n\t }",
"buflen = in.read(buffer)",
"buflen",
"in.read(buffer)",
"in.read",
"in",
"buffer",
"if (buflen <= 0) {\n\t return false;\n\t }",
"buflen <= 0",
"buflen",
"0",
"{\n\t return false;\n\t }",
"return false;",
"false",
"return true;",
"true",
"private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}",
"readByte",
"{ if (hasNextByte()) return buffer[ptr++]; else return -1;}",
"if (hasNextByte()) return buffer[ptr++]; else return -1;",
"hasNextByte()",
"hasNextByte",
"return buffer[ptr++];",
"buffer[ptr++]",
"buffer",
"ptr++",
"ptr",
"return -1;",
"-1",
"1",
"private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}",
"isPrintableChar",
"{ return 33 <= c && c <= 126;}",
"return 33 <= c && c <= 126;",
"33 <= c && c <= 126",
"33 <= c",
"33",
"c",
"c <= 126",
"c",
"126",
"int c",
"c",
"private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}",
"skipUnprintable",
"{ while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}",
"while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;",
"hasNextByte() && !isPrintableChar(buffer[ptr])",
"hasNextByte()",
"hasNextByte",
"!isPrintableChar(buffer[ptr])",
"isPrintableChar(buffer[ptr])",
"isPrintableChar",
"buffer[ptr]",
"buffer",
"ptr",
"ptr++",
"ptr",
"public boolean hasNext() { skipUnprintable(); return hasNextByte();}",
"hasNext",
"{ skipUnprintable(); return hasNextByte();}",
"skipUnprintable()",
"skipUnprintable",
"return hasNextByte();",
"hasNextByte()",
"hasNextByte",
"public String next() {\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }",
"next",
"{\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }",
"if (!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int b = readByte();",
"b",
"readByte()",
"readByte",
"while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }",
"isPrintableChar(b)",
"isPrintableChar",
"b",
"{\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }",
"sb.appendCodePoint(b)",
"sb.appendCodePoint",
"sb",
"b",
"b = readByte()",
"b",
"readByte()",
"readByte",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"public long nextLong() {\n\t return Long.parseLong(next());\n\t }",
"nextLong",
"{\n\t return Long.parseLong(next());\n\t }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public int nextInt(){\n\t \treturn Integer.parseInt(next());\n\t }",
"nextInt",
"{\n\t \treturn Integer.parseInt(next());\n\t }",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"public class Main {\n\tprivate static FastScanner sc = new FastScanner();\n\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<Process> que = new LinkedList<>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess(String name, int time){\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t}\n\t\n\tstatic class FastScanner {\n\t private final InputStream in = System.in;\n\t private final byte[] buffer = new byte[1024];\n\t private int ptr = 0;\n\t private int buflen = 0;\n\t private boolean hasNextByte() {\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }\n\t private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n\t private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n\t private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n\t public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n\t public String next() {\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\t public int nextInt(){\n\t \treturn Integer.parseInt(next());\n\t }\n\t}\n\n}",
"public class Main {\n\tprivate static FastScanner sc = new FastScanner();\n\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<Process> que = new LinkedList<>();\n\t\tfor(int i=0; i<n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!que.isEmpty()) {\n\t\t\tProcess p = que.poll();\n\t\t\tif(p.time > q) {\n\t\t\t\tp.time -= q;\n\t\t\t\ttimer += q;\n\t\t\t\tque.add(p);\n\t\t\t} else {\n\t\t\t\ttimer += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + timer);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess(String name, int time){\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t}\n\t\n\tstatic class FastScanner {\n\t private final InputStream in = System.in;\n\t private final byte[] buffer = new byte[1024];\n\t private int ptr = 0;\n\t private int buflen = 0;\n\t private boolean hasNextByte() {\n\t if (ptr < buflen) {\n\t return true;\n\t }else{\n\t ptr = 0;\n\t try {\n\t buflen = in.read(buffer);\n\t } catch (IOException e) {\n\t e.printStackTrace();\n\t }\n\t if (buflen <= 0) {\n\t return false;\n\t }\n\t }\n\t return true;\n\t }\n\t private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}\n\t private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}\n\t private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}\n\t public boolean hasNext() { skipUnprintable(); return hasNextByte();}\n\t public String next() {\n\t if (!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb = new StringBuilder();\n\t int b = readByte();\n\t while(isPrintableChar(b)) {\n\t sb.appendCodePoint(b);\n\t b = readByte();\n\t }\n\t return sb.toString();\n\t }\n\t public long nextLong() {\n\t return Long.parseLong(next());\n\t }\n\t public int nextInt(){\n\t \treturn Integer.parseInt(next());\n\t }\n\t}\n\n}",
"Main"
] | import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Queue;
public class Main {
private static FastScanner sc = new FastScanner();
public static void main(String[] args) {
int n = sc.nextInt();
int q = sc.nextInt();
Queue<Process> que = new LinkedList<>();
for(int i=0; i<n; i++) {
String name = sc.next();
int time = sc.nextInt();
que.add(new Process(name, time));
}
int timer = 0;
while(!que.isEmpty()) {
Process p = que.poll();
if(p.time > q) {
p.time -= q;
timer += q;
que.add(p);
} else {
timer += p.time;
System.out.println(p.name + " " + timer);
}
}
}
static class Process {
String name;
int time;
Process(String name, int time){
this.name = name;
this.time = time;
}
}
static class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
public boolean hasNext() { skipUnprintable(); return hasNextByte();}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
return Long.parseLong(next());
}
public int nextInt(){
return Integer.parseInt(next());
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
40,
17,
0,
13,
20,
13,
23,
13,
12,
13,
30,
0,
13,
2,
2,
13,
17,
13,
0,
18,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
13,
23,
13,
12,
13,
30,
0,
18,
18,
13,
13,
13,
13,
23,
13,
12,
13,
30,
29,
18,
18,
13,
13,
13,
12,
13,
30,
29,
18,
18,
13,
13,
13,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
42,
2,
13,
13,
30,
14,
2,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
0,
13,
4,
18,
13,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
0,
13,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
0,
13,
4,
18,
13,
13,
4,
18,
13,
13,
13,
29,
23,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
4,
18,
13,
13,
13,
0,
13,
18,
13,
13,
4,
13,
13,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
4,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
13,
14
],
[
13,
15
],
[
12,
16
],
[
16,
17
],
[
16,
18
],
[
10,
19
],
[
19,
20
],
[
10,
21
],
[
21,
22
],
[
0,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
23,
27
],
[
27,
28
],
[
23,
29
],
[
29,
30
],
[
23,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
33,
41
],
[
41,
42
],
[
41,
43
],
[
31,
45
],
[
45,
46
],
[
23,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
47,
62
],
[
62,
63
],
[
47,
64
],
[
64,
65
],
[
23,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
68,
81
],
[
81,
82
],
[
66,
83
],
[
83,
84
],
[
23,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
88,
94
],
[
85,
95
],
[
95,
96
],
[
23,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
23,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
0,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
119,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
131,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
146,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
146,
150
],
[
146,
151
],
[
136,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
154,
157
],
[
130,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
159,
163
],
[
158,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
164,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
170,
175
],
[
176,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
176,
180
],
[
176,
181
],
[
164,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
184,
187
],
[
158,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
188,
192
],
[
192,
193
],
[
193,
194
],
[
192,
195
],
[
188,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
198,
201
],
[
188,
202
],
[
202,
203
],
[
203,
204
],
[
202,
205
],
[
202,
206
],
[
119,
207
],
[
117,
208
],
[
208,
209
],
[
117,
210
],
[
210,
211
],
[
117,
212
],
[
212,
213
],
[
117,
214
],
[
214,
215
],
[
115,
216
],
[
216,
217
],
[
216,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
218,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
225,
226
],
[
218,
227
],
[
227,
228
],
[
227,
229
],
[
229,
230
],
[
230,
231
],
[
218,
232
],
[
232,
233
],
[
232,
234
],
[
218,
235
],
[
235,
236
],
[
235,
237
],
[
218,
238
],
[
238,
239
],
[
239,
240
],
[
240,
241
],
[
240,
242
],
[
238,
243
],
[
243,
244
],
[
243,
245
],
[
238,
246
],
[
246,
247
],
[
247,
248
],
[
238,
249
],
[
250,
250
],
[
250,
251
],
[
251,
252
],
[
251,
253
],
[
250,
254
],
[
254,
255
],
[
255,
256
],
[
254,
257
],
[
254,
258
],
[
250,
259
],
[
259,
260
],
[
259,
261
],
[
261,
262
],
[
261,
263
],
[
218,
264
],
[
264,
265
],
[
264,
266
],
[
264,
267
],
[
264,
268
],
[
264,
269
],
[
216,
270
],
[
270,
271
]
] | [
"import java.util.Scanner;\n\nclass Work {\n\tString name;\n\tint time;\n\t\n\tWork(String n,int t){\n\t\tname=n; time=t;\n\t}\n\t\n}\n\nclass Queue {\n\tint head;\n\tint tail;\n\tWork[] a;\n\t\n\t/*コンストラクタ*/\n\tQueue(int n){\n\t\thead=0; tail=-1; a=new Work[n];\n\t}\n\t\n\tvoid enqueue(Work x,int n){\n\t\ttail=(tail+1)%n;\n\t\ta[tail]=x;\n\t}\n\t\n\tWork dequeue(int n){\n\t\tWork temp=a[head];\n\t\thead=(head+1)%n;\n\t\treturn temp;\n\t}\n\t\n\tvoid decrease(int t){\n\t\ta[head].time-=t;\n\t}\n\t\n\tint getTime(){\n\t\treturn a[head].time;\n\t}\n\t\n\tString getName(){\n\t\treturn a[head].name;\n\t}\n\t\n}\n\nclass Main {\n\t\n\tstatic void solve(Queue Q,int n,int q,int sum){\n\t\tint time=0;\n\t\tWork temp;\n\t\t\n\t\twhile(time != sum){\n\t\t\tif(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn;\n\t}\n\t\t\n\t\n\t\n\tpublic static void main(String[] args){\n\t\tScanner scan=new Scanner(System.in);\n\t\t\n\t\tint n=scan.nextInt();\n\t\tint q=scan.nextInt();\n\t\tint sum=0;\n\t\tQueue Q=new Queue(n);\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}\n\t\t\n\t\tsolve(Q,n,q,sum);\n\t\t\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Work {\n\tString name;\n\tint time;\n\t\n\tWork(String n,int t){\n\t\tname=n; time=t;\n\t}\n\t\n}",
"Work",
"String name;",
"name",
"int time;",
"time",
"Work(String n,int t){\n\t\tname=n; time=t;\n\t}",
"Work",
"{\n\t\tname=n; time=t;\n\t}",
"name=n",
"name",
"n",
"time=t",
"time",
"t",
"String n",
"n",
"int t",
"t",
"class Queue {\n\tint head;\n\tint tail;\n\tWork[] a;\n\t\n\t/*コンストラクタ*/\n\tQueue(int n){\n\t\thead=0; tail=-1; a=new Work[n];\n\t}\n\t\n\tvoid enqueue(Work x,int n){\n\t\ttail=(tail+1)%n;\n\t\ta[tail]=x;\n\t}\n\t\n\tWork dequeue(int n){\n\t\tWork temp=a[head];\n\t\thead=(head+1)%n;\n\t\treturn temp;\n\t}\n\t\n\tvoid decrease(int t){\n\t\ta[head].time-=t;\n\t}\n\t\n\tint getTime(){\n\t\treturn a[head].time;\n\t}\n\t\n\tString getName(){\n\t\treturn a[head].name;\n\t}\n\t\n}",
"Queue",
"int head;",
"head",
"int tail;",
"tail",
"Work[] a;",
"a",
"/*コンストラクタ*/\n\tQueue(int n){\n\t\thead=0; tail=-1; a=new Work[n];\n\t}",
"Queue",
"{\n\t\thead=0; tail=-1; a=new Work[n];\n\t}",
"head=0",
"head",
"0",
"tail=-1",
"tail",
"-1",
"1",
"a=new Work[n]",
"a",
"new Work[n]",
"n",
"int n",
"n",
"void enqueue(Work x,int n){\n\t\ttail=(tail+1)%n;\n\t\ta[tail]=x;\n\t}",
"enqueue",
"{\n\t\ttail=(tail+1)%n;\n\t\ta[tail]=x;\n\t}",
"tail=(tail+1)%n",
"tail",
"(tail+1)%n",
"(tail+1)",
"tail",
"1",
"n",
"a[tail]=x",
"a[tail]",
"a",
"tail",
"x",
"Work x",
"x",
"int n",
"n",
"Work dequeue(int n){\n\t\tWork temp=a[head];\n\t\thead=(head+1)%n;\n\t\treturn temp;\n\t}",
"dequeue",
"{\n\t\tWork temp=a[head];\n\t\thead=(head+1)%n;\n\t\treturn temp;\n\t}",
"Work temp=a[head];",
"temp",
"a[head]",
"a",
"head",
"head=(head+1)%n",
"head",
"(head+1)%n",
"(head+1)",
"head",
"1",
"n",
"return temp;",
"temp",
"int n",
"n",
"void decrease(int t){\n\t\ta[head].time-=t;\n\t}",
"decrease",
"{\n\t\ta[head].time-=t;\n\t}",
"a[head].time-=t",
"a[head].time",
"a[head]",
"a",
"head",
"a[head].time",
"t",
"int t",
"t",
"int getTime(){\n\t\treturn a[head].time;\n\t}",
"getTime",
"{\n\t\treturn a[head].time;\n\t}",
"return a[head].time;",
"a[head].time",
"a[head]",
"a",
"head",
"a[head].time",
"String getName(){\n\t\treturn a[head].name;\n\t}",
"getName",
"{\n\t\treturn a[head].name;\n\t}",
"return a[head].name;",
"a[head].name",
"a[head]",
"a",
"head",
"a[head].name",
"class Main {\n\t\n\tstatic void solve(Queue Q,int n,int q,int sum){\n\t\tint time=0;\n\t\tWork temp;\n\t\t\n\t\twhile(time != sum){\n\t\t\tif(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn;\n\t}\n\t\t\n\t\n\t\n\tpublic static void main(String[] args){\n\t\tScanner scan=new Scanner(System.in);\n\t\t\n\t\tint n=scan.nextInt();\n\t\tint q=scan.nextInt();\n\t\tint sum=0;\n\t\tQueue Q=new Queue(n);\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}\n\t\t\n\t\tsolve(Q,n,q,sum);\n\t\t\n\t}\n}",
"Main",
"static void solve(Queue Q,int n,int q,int sum){\n\t\tint time=0;\n\t\tWork temp;\n\t\t\n\t\twhile(time != sum){\n\t\t\tif(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn;\n\t}",
"solve",
"{\n\t\tint time=0;\n\t\tWork temp;\n\t\t\n\t\twhile(time != sum){\n\t\t\tif(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn;\n\t}",
"int time=0;",
"time",
"0",
"Work temp;",
"temp",
"while(time != sum){\n\t\t\tif(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}\n\t\t}",
"time != sum",
"time",
"sum",
"{\n\t\t\tif(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}\n\t\t}",
"if(Q.getTime() == q){\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}",
"Q.getTime() == q",
"Q.getTime()",
"Q.getTime",
"Q",
"q",
"{\n\t\t\t\ttime+=q;\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}",
"time+=q",
"time",
"q",
"System.out.println(Q.getName() + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"Q.getName() + \" \" + time",
"Q.getName() + \" \" + time",
"Q.getName()",
"Q.getName",
"Q",
"\" \"",
"time",
"temp=Q.dequeue(n)",
"temp",
"Q.dequeue(n)",
"Q.dequeue",
"Q",
"n",
"if(Q.getTime() < q){\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}",
"Q.getTime() < q",
"Q.getTime()",
"Q.getTime",
"Q",
"q",
"{\n\t\t\t\ttime+=Q.getTime();\n\t\t\t\tSystem.out.println(Q.getName() + \" \" + time);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t}",
"time+=Q.getTime()",
"time",
"Q.getTime()",
"Q.getTime",
"Q",
"System.out.println(Q.getName() + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"Q.getName() + \" \" + time",
"Q.getName() + \" \" + time",
"Q.getName()",
"Q.getName",
"Q",
"\" \"",
"time",
"temp=Q.dequeue(n)",
"temp",
"Q.dequeue(n)",
"Q.dequeue",
"Q",
"n",
"{\n\t\t\t\ttime+=q;\n\t\t\t\tQ.decrease(q);\n\t\t\t\ttemp=Q.dequeue(n);\n\t\t\t\tQ.enqueue(temp,n);\n\t\t\t}",
"time+=q",
"time",
"q",
"Q.decrease(q)",
"Q.decrease",
"Q",
"q",
"temp=Q.dequeue(n)",
"temp",
"Q.dequeue(n)",
"Q.dequeue",
"Q",
"n",
"Q.enqueue(temp,n)",
"Q.enqueue",
"Q",
"temp",
"n",
"return;",
"Queue Q",
"Q",
"int n",
"n",
"int q",
"q",
"int sum",
"sum",
"public static void main(String[] args){\n\t\tScanner scan=new Scanner(System.in);\n\t\t\n\t\tint n=scan.nextInt();\n\t\tint q=scan.nextInt();\n\t\tint sum=0;\n\t\tQueue Q=new Queue(n);\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}\n\t\t\n\t\tsolve(Q,n,q,sum);\n\t\t\n\t}",
"main",
"{\n\t\tScanner scan=new Scanner(System.in);\n\t\t\n\t\tint n=scan.nextInt();\n\t\tint q=scan.nextInt();\n\t\tint sum=0;\n\t\tQueue Q=new Queue(n);\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}\n\t\t\n\t\tsolve(Q,n,q,sum);\n\t\t\n\t}",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n=scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q=scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int sum=0;",
"sum",
"0",
"Queue Q=new Queue(n);",
"Q",
"new Queue(n)",
"for(int i=0;i<n;i++){\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}",
"{\n\t\t\tWork temp=new Work(scan.next(),scan.nextInt());\n\t\t\tQ.enqueue(temp,n);\n\t\t\tsum+=temp.time;\n\t\t}",
"Work temp=new Work(scan.next(),scan.nextInt());",
"temp",
"new Work(scan.next(),scan.nextInt())",
"Q.enqueue(temp,n)",
"Q.enqueue",
"Q",
"temp",
"n",
"sum+=temp.time",
"sum",
"temp.time",
"temp",
"temp.time",
"solve(Q,n,q,sum)",
"solve",
"Q",
"n",
"q",
"sum",
"String[] args",
"args"
] | import java.util.Scanner;
class Work {
String name;
int time;
Work(String n,int t){
name=n; time=t;
}
}
class Queue {
int head;
int tail;
Work[] a;
/*コンストラクタ*/
Queue(int n){
head=0; tail=-1; a=new Work[n];
}
void enqueue(Work x,int n){
tail=(tail+1)%n;
a[tail]=x;
}
Work dequeue(int n){
Work temp=a[head];
head=(head+1)%n;
return temp;
}
void decrease(int t){
a[head].time-=t;
}
int getTime(){
return a[head].time;
}
String getName(){
return a[head].name;
}
}
class Main {
static void solve(Queue Q,int n,int q,int sum){
int time=0;
Work temp;
while(time != sum){
if(Q.getTime() == q){
time+=q;
System.out.println(Q.getName() + " " + time);
temp=Q.dequeue(n);
}
else if(Q.getTime() < q){
time+=Q.getTime();
System.out.println(Q.getName() + " " + time);
temp=Q.dequeue(n);
}
else {
time+=q;
Q.decrease(q);
temp=Q.dequeue(n);
Q.enqueue(temp,n);
}
}
return;
}
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int q=scan.nextInt();
int sum=0;
Queue Q=new Queue(n);
for(int i=0;i<n;i++){
Work temp=new Work(scan.next(),scan.nextInt());
Q.enqueue(temp,n);
sum+=temp.time;
}
solve(Q,n,q,sum);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
4,
18,
13,
13,
4,
18,
13,
41,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
13,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
4,
18,
13,
17,
30,
4,
18,
13,
2,
2,
4,
18,
13,
17,
13,
30,
4,
18,
13,
2,
2,
2,
4,
18,
13,
17,
13,
17,
30,
0,
13,
13,
41,
13,
2,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
187,
11
],
[
187,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
14,
51
],
[
51,
52
],
[
52,
53
],
[
14,
54
],
[
54,
55
],
[
54,
56
],
[
14,
57
],
[
57,
58
],
[
57,
59
],
[
14,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
61,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
66,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
85,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
95,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
95,
99
],
[
95,
100
],
[
84,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
107,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
107,
111
],
[
106,
112
],
[
107,
113
],
[
72,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
120,
124
],
[
114,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
114,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
14,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
138,
139
],
[
139,
140
],
[
12,
141
],
[
141,
142
],
[
0,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
143,
147
],
[
147,
148
],
[
143,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
151,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
149,
162
],
[
162,
163
],
[
149,
164
],
[
164,
165
],
[
143,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
143,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
143,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
176,
184
],
[
184,
185
],
[
0,
186
],
[
186,
187
],
[
186,
188
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Data> queue = new ArrayDeque<Data>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}\n\t\tscan.close();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t}\n}\n\nclass Data{\n\tString name;\n\tint time;\n\tpublic Data(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Data> queue = new ArrayDeque<Data>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}\n\t\tscan.close();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Data> queue = new ArrayDeque<Data>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}\n\t\tscan.close();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Data> queue = new ArrayDeque<Data>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}\n\t\tscan.close();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Queue<Data> queue = new ArrayDeque<Data>();",
"queue",
"new ArrayDeque<Data>()",
"for(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}",
"{\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}",
"Data d = new Data(scan.next(), scan.nextInt());",
"d",
"new Data(scan.next(), scan.nextInt())",
"queue.add(d)",
"queue.add",
"queue",
"d",
"scan.close()",
"scan.close",
"scan",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int time = 0;",
"time",
"0",
"while(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}",
"queue.size() != 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}",
"Data d = queue.poll();",
"d",
"queue.poll()",
"queue.poll",
"queue",
"if(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}",
"q >= d.getTime()",
"q",
"d.getTime()",
"d.getTime",
"d",
"{\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}",
"time += d.getTime()",
"time",
"d.getTime()",
"d.getTime",
"d",
"if(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}",
"queue.size() == 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}",
"sb.append(d.getName() + \" \" + time)",
"sb.append",
"sb",
"d.getName() + \" \" + time",
"d.getName() + \" \" + time",
"d.getName()",
"d.getName",
"d",
"\" \"",
"time",
"{\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}",
"sb.append(d.getName() + \" \" + time + \"\\n\")",
"sb.append",
"sb",
"d.getName() + \" \" + time + \"\\n\"",
"time",
"d.getName() + \" \" + time + \"\\n\"",
"d.getName()",
"d.getName",
"d",
"\" \"",
"time",
"\"\\n\"",
"{\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}",
"time += q",
"time",
"q",
"int res = d.getTime() - q;",
"res",
"d.getTime() - q",
"d.getTime()",
"d.getTime",
"d",
"q",
"d.setTime(res)",
"d.setTime",
"d",
"res",
"queue.add(d)",
"queue.add",
"queue",
"d",
"System.out.println(sb.toString())",
"System.out.println",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"String[] args",
"args",
"class Data{\n\tString name;\n\tint time;\n\tpublic Data(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n}",
"Data",
"String name;",
"name",
"int time;",
"time",
"public Data(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Data",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public String getName() {\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public int getTime() {\n\t\treturn time;\n\t}",
"getTime",
"{\n\t\treturn time;\n\t}",
"return time;",
"time",
"public void setTime(int time) {\n\t\tthis.time = time;\n\t}",
"setTime",
"{\n\t\tthis.time = time;\n\t}",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Data> queue = new ArrayDeque<Data>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}\n\t\tscan.close();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t}\n}",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Data> queue = new ArrayDeque<Data>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tData d = new Data(scan.next(), scan.nextInt());\n\t\t\tqueue.add(d);\n\t\t}\n\t\tscan.close();\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tData d = queue.poll();\n\t\t\tif(q >= d.getTime()) {\n\t\t\t\ttime += d.getTime();\n\t\t\t\tif(queue.size() == 0) {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time);\n\t\t\t\t}else {\n\t\t\t\t\tsb.append(d.getName() + \" \" + time + \"\\n\");\n\t\t\t\t}\n\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tint res = d.getTime() - q;\n\t\t\t\td.setTime(res);\n\t\t\t\tqueue.add(d);\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(sb.toString());\n\t}\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int q = scan.nextInt();
Queue<Data> queue = new ArrayDeque<Data>();
for(int i = 0; i < n; i++) {
Data d = new Data(scan.next(), scan.nextInt());
queue.add(d);
}
scan.close();
StringBuilder sb = new StringBuilder();
int time = 0;
while(queue.size() != 0) {
Data d = queue.poll();
if(q >= d.getTime()) {
time += d.getTime();
if(queue.size() == 0) {
sb.append(d.getName() + " " + time);
}else {
sb.append(d.getName() + " " + time + "\n");
}
}else {
time += q;
int res = d.getTime() - q;
d.setTime(res);
queue.add(d);
}
}
System.out.println(sb.toString());
}
}
class Data{
String name;
int time;
public Data(String name, int time) {
this.name = name;
this.time = time;
}
public String getName() {
return name;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
0,
13,
4,
18,
4,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
20,
13,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
17,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
20,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
13,
2,
13,
17,
30,
0,
13,
17,
30,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
0,
13,
17,
30,
40,
13,
29,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
17,
30,
29,
17
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
14,
25
],
[
25,
26
],
[
14,
27
],
[
27,
28
],
[
27,
29
],
[
14,
30
],
[
30,
31
],
[
14,
32
],
[
32,
33
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
36,
41
],
[
14,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
47,
49
],
[
14,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
55,
56
],
[
55,
57
],
[
14,
58
],
[
58,
59
],
[
58,
60
],
[
14,
62
],
[
62,
63
],
[
62,
64
],
[
14,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
71,
72
],
[
71,
73
],
[
66,
74
],
[
74,
75
],
[
75,
76
],
[
66,
77
],
[
78,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
81,
86
],
[
78,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
78,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
101,
102
],
[
101,
103
],
[
78,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
14,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
108,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
113,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
119,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
125,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
119,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
138,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
138,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
155,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
155,
160
],
[
12,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
168,
169
],
[
168,
170
],
[
163,
171
],
[
171,
172
],
[
171,
173
],
[
163,
174
],
[
174,
175
],
[
174,
176
],
[
163,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
180,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
189,
191
],
[
186,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
186,
196
],
[
196,
197
],
[
197,
198
],
[
178,
199
],
[
199,
200
],
[
163,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
206,
208
],
[
203,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
212,
213
],
[
212,
214
],
[
209,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
209,
219
],
[
219,
220
],
[
220,
221
],
[
203,
222
],
[
222,
223
],
[
163,
224
],
[
224,
225
],
[
224,
226
],
[
226,
227
],
[
227,
228
],
[
228,
229
],
[
228,
230
],
[
227,
231
],
[
231,
232
],
[
232,
233
],
[
227,
234
],
[
234,
235
],
[
235,
236
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\n\nclass Main{\n\n\tpublic static void main(String[] args) throws IOException{\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tQueue queue = new Queue();\n\t\tString[] input;\n\t\tint n, q;\n\t\tint end_time = 0;\n\t\tString[] name;\n\t\tint[] time;\n\n\t\tinput = br.readLine().split(\" \");\n\t\tn = Integer.parseInt(input[0]);\n\t\tq = Integer.parseInt(input[1]);\n\t\tname = new String[n];\n\t\ttime = new int[n];\n\n\t\tfor(int i = 0; i < n; i++){\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}\n\n\t\twhile(!queue.isEmpty()){\n\n\t\t\tint index = queue.dequeue();\n\n\t\t\tif(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nclass Queue{\n\n\tprivate int head = 0;\n\tprivate int tail = 0;\n\tprivate int len = 100000;\n\tprivate int[] data = new int[len];\n\n\tpublic void enqueue(int x){\n\n\t\tdata[tail] = x;\n\n\t\tif(tail == len - 1){\n\t\t\ttail = 0;\n\t\t}else{\n\t\t\ttail++;\n\t\t}\n\n\t}\n\n\tpublic int dequeue(){\n\n\t\tint x = data[head];\n\n\t\tif(head == len - 1){\n\t\t\thead = 0;\n\t\t}else{\n\t\t\thead++;\n\t\t}\n\n\t\treturn x;\n\n\t}\n\n\tpublic boolean isEmpty(){\n\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\n\t}\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"class Main{\n\n\tpublic static void main(String[] args) throws IOException{\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tQueue queue = new Queue();\n\t\tString[] input;\n\t\tint n, q;\n\t\tint end_time = 0;\n\t\tString[] name;\n\t\tint[] time;\n\n\t\tinput = br.readLine().split(\" \");\n\t\tn = Integer.parseInt(input[0]);\n\t\tq = Integer.parseInt(input[1]);\n\t\tname = new String[n];\n\t\ttime = new int[n];\n\n\t\tfor(int i = 0; i < n; i++){\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}\n\n\t\twhile(!queue.isEmpty()){\n\n\t\t\tint index = queue.dequeue();\n\n\t\t\tif(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tQueue queue = new Queue();\n\t\tString[] input;\n\t\tint n, q;\n\t\tint end_time = 0;\n\t\tString[] name;\n\t\tint[] time;\n\n\t\tinput = br.readLine().split(\" \");\n\t\tn = Integer.parseInt(input[0]);\n\t\tq = Integer.parseInt(input[1]);\n\t\tname = new String[n];\n\t\ttime = new int[n];\n\n\t\tfor(int i = 0; i < n; i++){\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}\n\n\t\twhile(!queue.isEmpty()){\n\n\t\t\tint index = queue.dequeue();\n\n\t\t\tif(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}\n\n\t\t}\n\n\t}",
"main",
"{\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tQueue queue = new Queue();\n\t\tString[] input;\n\t\tint n, q;\n\t\tint end_time = 0;\n\t\tString[] name;\n\t\tint[] time;\n\n\t\tinput = br.readLine().split(\" \");\n\t\tn = Integer.parseInt(input[0]);\n\t\tq = Integer.parseInt(input[1]);\n\t\tname = new String[n];\n\t\ttime = new int[n];\n\n\t\tfor(int i = 0; i < n; i++){\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}\n\n\t\twhile(!queue.isEmpty()){\n\n\t\t\tint index = queue.dequeue();\n\n\t\t\tif(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}\n\n\t\t}\n\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"Queue queue = new Queue();",
"queue",
"new Queue()",
"String[] input;",
"input",
"int n",
"n",
"q;",
"q",
"int end_time = 0;",
"end_time",
"0",
"String[] name;",
"name",
"int[] time;",
"time",
"input = br.readLine().split(\" \")",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"n = Integer.parseInt(input[0])",
"n",
"Integer.parseInt(input[0])",
"Integer.parseInt",
"Integer",
"input[0]",
"input",
"0",
"q = Integer.parseInt(input[1])",
"q",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"name = new String[n]",
"name",
"new String[n]",
"n",
"time = new int[n]",
"time",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}",
"{\n\n\t\t\tinput = br.readLine().split(\" \");\n\t\t\tname[i] = input[0];\n\t\t\ttime[i] = Integer.parseInt(input[1]);\n\t\t\tqueue.enqueue(i);\n\n\t\t}",
"input = br.readLine().split(\" \")",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"name[i] = input[0]",
"name[i]",
"name",
"i",
"input[0]",
"input",
"0",
"time[i] = Integer.parseInt(input[1])",
"time[i]",
"time",
"i",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"queue.enqueue(i)",
"queue.enqueue",
"queue",
"i",
"while(!queue.isEmpty()){\n\n\t\t\tint index = queue.dequeue();\n\n\t\t\tif(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}\n\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\n\t\t\tint index = queue.dequeue();\n\n\t\t\tif(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}\n\n\t\t}",
"int index = queue.dequeue();",
"index",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if(time[index] > q){\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}else{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}",
"time[index] > q",
"time[index]",
"time",
"index",
"q",
"{\n\t\t\t\tend_time += q;\n\t\t\t\ttime[index] -= q;\n\t\t\t\tqueue.enqueue(index);\n\t\t\t}",
"end_time += q",
"end_time",
"q",
"time[index] -= q",
"time[index]",
"time",
"index",
"q",
"queue.enqueue(index)",
"queue.enqueue",
"queue",
"index",
"{\n\t\t\t\tend_time += time[index];\n\t\t\t\ttime[index] = 0;\n\t\t\t\tSystem.out.println(name[index] + \" \" + end_time);\n\t\t\t}",
"end_time += time[index]",
"end_time",
"time[index]",
"time",
"index",
"time[index] = 0",
"time[index]",
"time",
"index",
"0",
"System.out.println(name[index] + \" \" + end_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[index] + \" \" + end_time",
"name[index] + \" \" + end_time",
"name[index]",
"name",
"index",
"\" \"",
"end_time",
"String[] args",
"args",
"class Queue{\n\n\tprivate int head = 0;\n\tprivate int tail = 0;\n\tprivate int len = 100000;\n\tprivate int[] data = new int[len];\n\n\tpublic void enqueue(int x){\n\n\t\tdata[tail] = x;\n\n\t\tif(tail == len - 1){\n\t\t\ttail = 0;\n\t\t}else{\n\t\t\ttail++;\n\t\t}\n\n\t}\n\n\tpublic int dequeue(){\n\n\t\tint x = data[head];\n\n\t\tif(head == len - 1){\n\t\t\thead = 0;\n\t\t}else{\n\t\t\thead++;\n\t\t}\n\n\t\treturn x;\n\n\t}\n\n\tpublic boolean isEmpty(){\n\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\n\t}\n\n}",
"Queue",
"private int head = 0;",
"head",
"0",
"private int tail = 0;",
"tail",
"0",
"private int len = 100000;",
"len",
"100000",
"private int[] data = new int[len];",
"data",
"new int[len]",
"len",
"public void enqueue(int x){\n\n\t\tdata[tail] = x;\n\n\t\tif(tail == len - 1){\n\t\t\ttail = 0;\n\t\t}else{\n\t\t\ttail++;\n\t\t}\n\n\t}",
"enqueue",
"{\n\n\t\tdata[tail] = x;\n\n\t\tif(tail == len - 1){\n\t\t\ttail = 0;\n\t\t}else{\n\t\t\ttail++;\n\t\t}\n\n\t}",
"data[tail] = x",
"data[tail]",
"data",
"tail",
"x",
"if(tail == len - 1){\n\t\t\ttail = 0;\n\t\t}else{\n\t\t\ttail++;\n\t\t}",
"tail == len - 1",
"tail",
"len - 1",
"len",
"1",
"{\n\t\t\ttail = 0;\n\t\t}",
"tail = 0",
"tail",
"0",
"{\n\t\t\ttail++;\n\t\t}",
"tail++",
"tail",
"int x",
"x",
"public int dequeue(){\n\n\t\tint x = data[head];\n\n\t\tif(head == len - 1){\n\t\t\thead = 0;\n\t\t}else{\n\t\t\thead++;\n\t\t}\n\n\t\treturn x;\n\n\t}",
"dequeue",
"{\n\n\t\tint x = data[head];\n\n\t\tif(head == len - 1){\n\t\t\thead = 0;\n\t\t}else{\n\t\t\thead++;\n\t\t}\n\n\t\treturn x;\n\n\t}",
"int x = data[head];",
"x",
"data[head]",
"data",
"head",
"if(head == len - 1){\n\t\t\thead = 0;\n\t\t}else{\n\t\t\thead++;\n\t\t}",
"head == len - 1",
"head",
"len - 1",
"len",
"1",
"{\n\t\t\thead = 0;\n\t\t}",
"head = 0",
"head",
"0",
"{\n\t\t\thead++;\n\t\t}",
"head++",
"head",
"return x;",
"x",
"public boolean isEmpty(){\n\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\n\t}",
"isEmpty",
"{\n\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}\n\n\t}",
"if(head == tail){\n\t\t\treturn true;\n\t\t}else{\n\t\t\treturn false;\n\t\t}",
"head == tail",
"head",
"tail",
"{\n\t\t\treturn true;\n\t\t}",
"return true;",
"true",
"{\n\t\t\treturn false;\n\t\t}",
"return false;",
"false"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Queue queue = new Queue();
String[] input;
int n, q;
int end_time = 0;
String[] name;
int[] time;
input = br.readLine().split(" ");
n = Integer.parseInt(input[0]);
q = Integer.parseInt(input[1]);
name = new String[n];
time = new int[n];
for(int i = 0; i < n; i++){
input = br.readLine().split(" ");
name[i] = input[0];
time[i] = Integer.parseInt(input[1]);
queue.enqueue(i);
}
while(!queue.isEmpty()){
int index = queue.dequeue();
if(time[index] > q){
end_time += q;
time[index] -= q;
queue.enqueue(index);
}else{
end_time += time[index];
time[index] = 0;
System.out.println(name[index] + " " + end_time);
}
}
}
}
class Queue{
private int head = 0;
private int tail = 0;
private int len = 100000;
private int[] data = new int[len];
public void enqueue(int x){
data[tail] = x;
if(tail == len - 1){
tail = 0;
}else{
tail++;
}
}
public int dequeue(){
int x = data[head];
if(head == len - 1){
head = 0;
}else{
head++;
}
return x;
}
public boolean isEmpty(){
if(head == tail){
return true;
}else{
return false;
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
20,
41,
13,
20,
4,
18,
13,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
13,
17,
4,
18,
13,
13,
17,
30,
0,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
42,
40,
4,
18,
13,
30,
38,
5,
13,
30,
37,
20,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
0,
13,
20,
0,
13,
20,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
22,
23
],
[
22,
24
],
[
0,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
32,
34
],
[
29,
35
],
[
35,
36
],
[
35,
37
],
[
29,
38
],
[
38,
39
],
[
38,
40
],
[
29,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
27,
45
],
[
45,
46
],
[
25,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
51,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
62,
63
],
[
62,
64
],
[
51,
65
],
[
65,
66
],
[
65,
67
],
[
51,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
68,
76
],
[
76,
77
],
[
77,
78
],
[
68,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
85,
86
],
[
80,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
90,
91
],
[
91,
92
],
[
51,
93
],
[
93,
94
],
[
93,
95
],
[
51,
96
],
[
96,
97
],
[
96,
98
],
[
51,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
99,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
104,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
127,
133
],
[
125,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
123,
138
],
[
115,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
143,
145
],
[
139,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
139,
150
],
[
150,
151
],
[
151,
152
],
[
150,
153
],
[
51,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
49,
160
],
[
160,
161
],
[
25,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
162,
166
],
[
166,
167
],
[
162,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
171,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
177,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
170,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
162,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
196,
197
],
[
195,
198
],
[
198,
199
],
[
162,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
203,
205
],
[
202,
206
],
[
206,
207
],
[
206,
208
],
[
200,
209
],
[
209,
210
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.InputMismatchException;\nimport java.util.StringTokenizer;\n\nclass Main {\n\t\n\tstatic class Queue {\n\t\tpublic void queue (InputReader ir) {\n\t\t\t\n\t\t\t// プロセス数\n\t\t\tint n = ir.nextInt();\n\t\t\t\n\t\t\t// クオンタム\n\t\t\tint q = ir.nextInt();\n\t\t\t\n\t\t\t// プロセス情報\n\t\t\tDeque<String> process = new ArrayDeque<String>();\n\t\t\tDeque<Integer> quantum = new ArrayDeque<Integer>();\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tint time = 0;\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\n\t\t\twhile (!quantum.isEmpty()) {\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(sb);\n\t\t}\n\t}\n\t\n\tstatic class InputReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic String nextString() {\n\t\t\t\n\t\t\t while (!st.hasMoreTokens()) {\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\t\t\t\t\t\n\t\tpublic InputReader (InputStream inputStream) {\n\t\t\tbr = new BufferedReader (new InputStreamReader (inputStream));\n\t\t\tst = new StringTokenizer (\"\");\n\t\t}\n\t\t\n\t}\n\t\n\tpublic static void main (String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tInputReader ir = new InputReader (inputStream);\n\t\tQueue obj = new Queue();\n\t\tobj.queue(ir);\n\t}\n}\n",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.InputMismatchException;",
"InputMismatchException",
"java.util",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"class Main {\n\t\n\tstatic class Queue {\n\t\tpublic void queue (InputReader ir) {\n\t\t\t\n\t\t\t// プロセス数\n\t\t\tint n = ir.nextInt();\n\t\t\t\n\t\t\t// クオンタム\n\t\t\tint q = ir.nextInt();\n\t\t\t\n\t\t\t// プロセス情報\n\t\t\tDeque<String> process = new ArrayDeque<String>();\n\t\t\tDeque<Integer> quantum = new ArrayDeque<Integer>();\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tint time = 0;\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\n\t\t\twhile (!quantum.isEmpty()) {\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(sb);\n\t\t}\n\t}\n\t\n\tstatic class InputReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic String nextString() {\n\t\t\t\n\t\t\t while (!st.hasMoreTokens()) {\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\t\t\t\t\t\n\t\tpublic InputReader (InputStream inputStream) {\n\t\t\tbr = new BufferedReader (new InputStreamReader (inputStream));\n\t\t\tst = new StringTokenizer (\"\");\n\t\t}\n\t\t\n\t}\n\t\n\tpublic static void main (String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tInputReader ir = new InputReader (inputStream);\n\t\tQueue obj = new Queue();\n\t\tobj.queue(ir);\n\t}\n}",
"Main",
"public static void main (String[] args) {\n\t\tInputStream inputStream = System.in;\n\t\tInputReader ir = new InputReader (inputStream);\n\t\tQueue obj = new Queue();\n\t\tobj.queue(ir);\n\t}",
"main",
"{\n\t\tInputStream inputStream = System.in;\n\t\tInputReader ir = new InputReader (inputStream);\n\t\tQueue obj = new Queue();\n\t\tobj.queue(ir);\n\t}",
"InputStream inputStream = System.in;",
"inputStream",
"System.in",
"System",
"System.in",
"InputReader ir = new InputReader (inputStream);",
"ir",
"new InputReader (inputStream)",
"Queue obj = new Queue();",
"obj",
"new Queue()",
"obj.queue(ir)",
"obj.queue",
"obj",
"ir",
"String[] args",
"args",
"static class Queue {\n\t\tpublic void queue (InputReader ir) {\n\t\t\t\n\t\t\t// プロセス数\n\t\t\tint n = ir.nextInt();\n\t\t\t\n\t\t\t// クオンタム\n\t\t\tint q = ir.nextInt();\n\t\t\t\n\t\t\t// プロセス情報\n\t\t\tDeque<String> process = new ArrayDeque<String>();\n\t\t\tDeque<Integer> quantum = new ArrayDeque<Integer>();\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tint time = 0;\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\n\t\t\twhile (!quantum.isEmpty()) {\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(sb);\n\t\t}\n\t}",
"Queue",
"public void queue (InputReader ir) {\n\t\t\t\n\t\t\t// プロセス数\n\t\t\tint n = ir.nextInt();\n\t\t\t\n\t\t\t// クオンタム\n\t\t\tint q = ir.nextInt();\n\t\t\t\n\t\t\t// プロセス情報\n\t\t\tDeque<String> process = new ArrayDeque<String>();\n\t\t\tDeque<Integer> quantum = new ArrayDeque<Integer>();\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tint time = 0;\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\n\t\t\twhile (!quantum.isEmpty()) {\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(sb);\n\t\t}",
"queue",
"{\n\t\t\t\n\t\t\t// プロセス数\n\t\t\tint n = ir.nextInt();\n\t\t\t\n\t\t\t// クオンタム\n\t\t\tint q = ir.nextInt();\n\t\t\t\n\t\t\t// プロセス情報\n\t\t\tDeque<String> process = new ArrayDeque<String>();\n\t\t\tDeque<Integer> quantum = new ArrayDeque<Integer>();\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}\n\t\t\t\n\t\t\tint time = 0;\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\t\n\t\t\twhile (!quantum.isEmpty()) {\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(sb);\n\t\t}",
"int n = ir.nextInt();",
"n",
"ir.nextInt()",
"ir.nextInt",
"ir",
"int q = ir.nextInt();",
"q",
"ir.nextInt()",
"ir.nextInt",
"ir",
"Deque<String> process = new ArrayDeque<String>();",
"process",
"new ArrayDeque<String>()",
"Deque<Integer> quantum = new ArrayDeque<Integer>();",
"quantum",
"new ArrayDeque<Integer>()",
"for (int i = 0; i < n; i++) {\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}",
"{\n\t\t\t\tprocess.add(ir.nextString());\n\t\t\t\tquantum.add(ir.nextInt());\n\t\t\t}",
"process.add(ir.nextString())",
"process.add",
"process",
"ir.nextString()",
"ir.nextString",
"ir",
"quantum.add(ir.nextInt())",
"quantum.add",
"quantum",
"ir.nextInt()",
"ir.nextInt",
"ir",
"int time = 0;",
"time",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"while (!quantum.isEmpty()) {\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}",
"!quantum.isEmpty()",
"quantum.isEmpty()",
"quantum.isEmpty",
"quantum",
"{\n\t\t\t\tString posname = process.poll();\n\t\t\t\tint postime = quantum.poll();\n\t\t\t\t\n\t\t\t\tif ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}\n\t\t\t}",
"String posname = process.poll();",
"posname",
"process.poll()",
"process.poll",
"process",
"int postime = quantum.poll();",
"postime",
"quantum.poll()",
"quantum.poll",
"quantum",
"if ( postime <= q) {\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}",
"postime <= q",
"postime",
"q",
"{\n\t\t\t\t\ttime += postime;\n\t\t\t\t\tsb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\");\n\t\t\t\t}",
"time += postime",
"time",
"postime",
"sb.append(posname).append(\" \").append(Integer.toString(time)).append(\"\\n\")",
"sb.append(posname).append(\" \").append(Integer.toString(time)).append",
"sb.append(posname).append(\" \").append(Integer.toString(time))",
"sb.append(posname).append(\" \").append",
"sb.append(posname).append(\" \")",
"sb.append(posname).append",
"sb.append(posname)",
"sb.append",
"sb",
"posname",
"\" \"",
"Integer.toString(time)",
"Integer.toString",
"Integer",
"time",
"\"\\n\"",
"{\n\t\t\t\t\tpostime -= q;\n\t\t\t\t\ttime += q;\n\t\t\t\t\tprocess.add(posname);\n\t\t\t\t\tquantum.add(postime);\n\t\t\t\t}",
"postime -= q",
"postime",
"q",
"time += q",
"time",
"q",
"process.add(posname)",
"process.add",
"process",
"posname",
"quantum.add(postime)",
"quantum.add",
"quantum",
"postime",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"InputReader ir",
"ir",
"static class InputReader {\n\t\tBufferedReader br;\n\t\tStringTokenizer st;\n\t\t\n\t\tpublic String nextString() {\n\t\t\t\n\t\t\t while (!st.hasMoreTokens()) {\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }\n\t\t\treturn st.nextToken();\n\t\t}\n\t\t\n\t\tpublic int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}\n\t\t\t\t\t\n\t\tpublic InputReader (InputStream inputStream) {\n\t\t\tbr = new BufferedReader (new InputStreamReader (inputStream));\n\t\t\tst = new StringTokenizer (\"\");\n\t\t}\n\t\t\n\t}",
"InputReader",
"BufferedReader br;",
"br",
"StringTokenizer st;",
"st",
"public String nextString() {\n\t\t\t\n\t\t\t while (!st.hasMoreTokens()) {\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }\n\t\t\treturn st.nextToken();\n\t\t}",
"nextString",
"{\n\t\t\t\n\t\t\t while (!st.hasMoreTokens()) {\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }\n\t\t\treturn st.nextToken();\n\t\t}",
"while (!st.hasMoreTokens()) {\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }",
"!st.hasMoreTokens()",
"st.hasMoreTokens()",
"st.hasMoreTokens",
"st",
"{\n\t try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }\n\t }",
"try {\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t } catch (IOException e) {\n\t throw new InputMismatchException();\n\t }",
"catch (IOException e) {\n\t throw new InputMismatchException();\n\t }",
"IOException e",
"{\n\t throw new InputMismatchException();\n\t }",
"throw new InputMismatchException();",
"new InputMismatchException()",
"{\n\t st = new StringTokenizer(br.readLine(), \" \");\n\t }",
"st = new StringTokenizer(br.readLine(), \" \")",
"st",
"new StringTokenizer(br.readLine(), \" \")",
"return st.nextToken();",
"st.nextToken()",
"st.nextToken",
"st",
"public int nextInt() {\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}",
"nextInt",
"{\n\t\t\treturn Integer.parseInt(nextString());\n\t\t}",
"return Integer.parseInt(nextString());",
"Integer.parseInt(nextString())",
"Integer.parseInt",
"Integer",
"nextString()",
"nextString",
"public InputReader (InputStream inputStream) {\n\t\t\tbr = new BufferedReader (new InputStreamReader (inputStream));\n\t\t\tst = new StringTokenizer (\"\");\n\t\t}",
"InputReader",
"{\n\t\t\tbr = new BufferedReader (new InputStreamReader (inputStream));\n\t\t\tst = new StringTokenizer (\"\");\n\t\t}",
"br = new BufferedReader (new InputStreamReader (inputStream))",
"br",
"new BufferedReader (new InputStreamReader (inputStream))",
"st = new StringTokenizer (\"\")",
"st",
"new StringTokenizer (\"\")",
"InputStream inputStream",
"inputStream"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.StringTokenizer;
class Main {
static class Queue {
public void queue (InputReader ir) {
// プロセス数
int n = ir.nextInt();
// クオンタム
int q = ir.nextInt();
// プロセス情報
Deque<String> process = new ArrayDeque<String>();
Deque<Integer> quantum = new ArrayDeque<Integer>();
for (int i = 0; i < n; i++) {
process.add(ir.nextString());
quantum.add(ir.nextInt());
}
int time = 0;
StringBuilder sb = new StringBuilder();
while (!quantum.isEmpty()) {
String posname = process.poll();
int postime = quantum.poll();
if ( postime <= q) {
time += postime;
sb.append(posname).append(" ").append(Integer.toString(time)).append("\n");
} else {
postime -= q;
time += q;
process.add(posname);
quantum.add(postime);
}
}
System.out.print(sb);
}
}
static class InputReader {
BufferedReader br;
StringTokenizer st;
public String nextString() {
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine(), " ");
} catch (IOException e) {
throw new InputMismatchException();
}
}
return st.nextToken();
}
public int nextInt() {
return Integer.parseInt(nextString());
}
public InputReader (InputStream inputStream) {
br = new BufferedReader (new InputStreamReader (inputStream));
st = new StringTokenizer ("");
}
}
public static void main (String[] args) {
InputStream inputStream = System.in;
InputReader ir = new InputReader (inputStream);
Queue obj = new Queue();
obj.queue(ir);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
17,
13,
41,
13,
4,
18,
13,
4,
18,
13,
2,
13,
17,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
17,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
13,
17,
41,
13,
40,
17,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
11,
1,
41,
13,
17,
2,
13,
4,
18,
13,
1,
40,
13,
30,
30,
14,
2,
4,
18,
13,
17,
13,
30,
4,
18,
13,
2,
4,
18,
13,
17,
13,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
17,
0,
13,
2,
13,
13,
30,
0,
13,
2,
13,
4,
18,
13,
17,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
17,
13,
4,
18,
13,
17,
4,
18,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
193,
5
],
[
193,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
19,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
28,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
35,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
8,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
55,
56
],
[
55,
57
],
[
50,
58
],
[
58,
59
],
[
59,
60
],
[
50,
61
],
[
62,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
62,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
62,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
77,
81
],
[
62,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
91,
92
],
[
91,
93
],
[
8,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
8,
98
],
[
98,
99
],
[
98,
100
],
[
8,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
108,
118
],
[
118,
119
],
[
119,
120
],
[
108,
121
],
[
122,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
124,
129
],
[
123,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
134,
139
],
[
130,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
130,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
130,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
130,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
157,
159
],
[
123,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
160,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
175,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
175,
180
],
[
175,
181
],
[
160,
182
],
[
182,
183
],
[
183,
184
],
[
182,
185
],
[
160,
186
],
[
186,
187
],
[
187,
188
],
[
186,
189
],
[
6,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma =line.indexOf(\" \");\n int process = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }\n\n int save=-1;\n int timeCount=0;\n \n while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }\n } \n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma =line.indexOf(\" \");\n int process = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }\n\n int save=-1;\n int timeCount=0;\n \n while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }\n } \n}",
"Main",
"public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma =line.indexOf(\" \");\n int process = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }\n\n int save=-1;\n int timeCount=0;\n \n while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }\n }",
"main",
"{\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma =line.indexOf(\" \");\n int process = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }\n\n int save=-1;\n int timeCount=0;\n \n while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String line = sc.nextLine();",
"line",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int ma =line.indexOf(\" \");",
"ma",
"line.indexOf(\" \")",
"line.indexOf",
"line",
"\" \"",
"int process = Integer.parseInt(line.substring(0, ma));",
"process",
"Integer.parseInt(line.substring(0, ma))",
"Integer.parseInt",
"Integer",
"line.substring(0, ma)",
"line.substring",
"line",
"0",
"ma",
"int quantum = Integer.parseInt(line.substring(ma+1));",
"quantum",
"Integer.parseInt(line.substring(ma+1))",
"Integer.parseInt",
"Integer",
"line.substring(ma+1)",
"line.substring",
"line",
"ma+1",
"ma",
"1",
"ArrayList<String> lingerJob = new ArrayList<String>();",
"lingerJob",
"new ArrayList<String>()",
"ArrayList<Integer> lingerTime = new ArrayList<Integer>();",
"lingerTime",
"new ArrayList<Integer>()",
"for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<process",
"i",
"process",
"i++",
"i++",
"i",
"{\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }",
"{\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }",
"String line2 = sc.nextLine();",
"line2",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int ma2 =line2.indexOf(\" \");",
"ma2",
"line2.indexOf(\" \")",
"line2.indexOf",
"line2",
"\" \"",
"lingerJob.add(line2.substring(0, ma2))",
"lingerJob.add",
"lingerJob",
"line2.substring(0, ma2)",
"line2.substring",
"line2",
"0",
"ma2",
"lingerTime.add(Integer.parseInt(line2.substring(ma2+1)))",
"lingerTime.add",
"lingerTime",
"Integer.parseInt(line2.substring(ma2+1))",
"Integer.parseInt",
"Integer",
"line2.substring(ma2+1)",
"line2.substring",
"line2",
"ma2+1",
"ma2",
"1",
"int save=-1;",
"save",
"-1",
"1",
"int timeCount=0;",
"timeCount",
"0",
"while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }",
"lingerJob.size()!=0",
"lingerJob.size()",
"lingerJob.size",
"lingerJob",
"0",
"{\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }",
"for(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<lingerJob.size()",
"i",
"lingerJob.size()",
"lingerJob.size",
"lingerJob",
"i++",
"i++",
"i",
"{\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}",
"{\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}",
"if(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}",
"lingerTime.get(0)>quantum",
"lingerTime.get(0)",
"lingerTime.get",
"lingerTime",
"0",
"quantum",
"{\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}",
"lingerTime.add(lingerTime.get(0)-quantum)",
"lingerTime.add",
"lingerTime",
"lingerTime.get(0)-quantum",
"lingerTime.get(0)",
"lingerTime.get",
"lingerTime",
"0",
"quantum",
"lingerTime.remove(0)",
"lingerTime.remove",
"lingerTime",
"0",
"lingerJob.add(lingerJob.get(0))",
"lingerJob.add",
"lingerJob",
"lingerJob.get(0)",
"lingerJob.get",
"lingerJob",
"0",
"lingerJob.remove(0)",
"lingerJob.remove",
"lingerJob",
"0",
"timeCount=timeCount+quantum",
"timeCount",
"timeCount+quantum",
"timeCount",
"quantum",
"{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}",
"timeCount=timeCount+lingerTime.get(0)",
"timeCount",
"timeCount+lingerTime.get(0)",
"timeCount",
"lingerTime.get(0)",
"lingerTime.get",
"lingerTime",
"0",
"System.out.println(lingerJob.get(0)+\" \"+timeCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"lingerJob.get(0)+\" \"+timeCount",
"lingerJob.get(0)+\" \"+timeCount",
"lingerJob.get(0)",
"lingerJob.get",
"lingerJob",
"0",
"\" \"",
"timeCount",
"lingerTime.remove(0)",
"lingerTime.remove",
"lingerTime",
"0",
"lingerJob.remove(0)",
"lingerJob.remove",
"lingerJob",
"0",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma =line.indexOf(\" \");\n int process = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }\n\n int save=-1;\n int timeCount=0;\n \n while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }\n } \n}",
"public class Main {\n public static void main(String[] args) {\n \tScanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma =line.indexOf(\" \");\n int process = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<process;i++){\n String line2 = sc.nextLine();\n int ma2 =line2.indexOf(\" \");\n lingerJob.add(line2.substring(0, ma2));\n lingerTime.add(Integer.parseInt(line2.substring(ma2+1))); \t\n }\n\n int save=-1;\n int timeCount=0;\n \n while(lingerJob.size()!=0){\n \tfor(int i=0;i<lingerJob.size();i++){\n \t\tif(lingerTime.get(0)>quantum){\n \t\t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.add(lingerJob.get(0));\n \t\t\tlingerJob.remove(0);\n \t\t\ttimeCount=timeCount+quantum;\n \t\t}else{\n \t\t\ttimeCount=timeCount+lingerTime.get(0);\n \t\t\tSystem.out.println(lingerJob.get(0)+\" \"+timeCount);\n \t\t\tlingerTime.remove(0);\n \t\t\tlingerJob.remove(0);\n \t\t}\n \t}\n }\n } \n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
int ma =line.indexOf(" ");
int process = Integer.parseInt(line.substring(0, ma));
int quantum = Integer.parseInt(line.substring(ma+1));
ArrayList<String> lingerJob = new ArrayList<String>();
ArrayList<Integer> lingerTime = new ArrayList<Integer>();
for(int i=0;i<process;i++){
String line2 = sc.nextLine();
int ma2 =line2.indexOf(" ");
lingerJob.add(line2.substring(0, ma2));
lingerTime.add(Integer.parseInt(line2.substring(ma2+1)));
}
int save=-1;
int timeCount=0;
while(lingerJob.size()!=0){
for(int i=0;i<lingerJob.size();i++){
if(lingerTime.get(0)>quantum){
lingerTime.add(lingerTime.get(0)-quantum);
lingerTime.remove(0);
lingerJob.add(lingerJob.get(0));
lingerJob.remove(0);
timeCount=timeCount+quantum;
}else{
timeCount=timeCount+lingerTime.get(0);
System.out.println(lingerJob.get(0)+" "+timeCount);
lingerTime.remove(0);
lingerJob.remove(0);
}
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
41,
13,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
13,
20,
13,
0,
13,
20,
13,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
42,
2,
13,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
18,
13,
13,
17,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
0,
18,
13,
13,
40,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
18,
13,
13,
17,
40,
18,
13,
18,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
174,
5
],
[
174,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
22
],
[
22,
23
],
[
8,
24
],
[
24,
25
],
[
8,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
8,
38
],
[
38,
39
],
[
38,
40
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
8,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
55,
56
],
[
55,
57
],
[
50,
58
],
[
58,
59
],
[
59,
60
],
[
50,
61
],
[
62,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
67,
68
],
[
68,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
74,
75
],
[
75,
76
],
[
8,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
87,
88
],
[
87,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
82,
93
],
[
94,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
108,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
108,
119
],
[
119,
120
],
[
108,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
125,
126
],
[
102,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
127,
133
],
[
133,
134
],
[
133,
135
],
[
8,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
141,
142
],
[
141,
143
],
[
136,
144
],
[
144,
145
],
[
145,
146
],
[
136,
147
],
[
148,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
155,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
158,
160
],
[
155,
161
],
[
155,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
165,
167
],
[
8,
168
],
[
168,
169
],
[
169,
170
],
[
6,
171
],
[
171,
172
],
[
0,
173
],
[
173,
174
],
[
173,
175
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n, q, sum = 0, num = 0;\n\t\tint[] time, end;\n\t\tString[] name;\n\t\t\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\n\t\ttime = new int[n];\n\t\tend = new int[n];\n\t\tname = new String[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\twhile(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}\n\t\t\n\t\tscan.close();\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n, q, sum = 0, num = 0;\n\t\tint[] time, end;\n\t\tString[] name;\n\t\t\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\n\t\ttime = new int[n];\n\t\tend = new int[n];\n\t\tname = new String[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\twhile(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}\n\t\t\n\t\tscan.close();\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n, q, sum = 0, num = 0;\n\t\tint[] time, end;\n\t\tString[] name;\n\t\t\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\n\t\ttime = new int[n];\n\t\tend = new int[n];\n\t\tname = new String[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\twhile(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}\n\t\t\n\t\tscan.close();\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n, q, sum = 0, num = 0;\n\t\tint[] time, end;\n\t\tString[] name;\n\t\t\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\n\t\ttime = new int[n];\n\t\tend = new int[n];\n\t\tname = new String[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\twhile(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}\n\t\t\n\t\tscan.close();\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n",
"n",
"q",
"q",
"sum = 0",
"sum",
"0",
"num = 0;",
"num",
"0",
"int[] time",
"time",
"end;",
"end",
"String[] name;",
"name",
"n = scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"q = scan.nextInt()",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"time = new int[n]",
"time",
"new int[n]",
"n",
"end = new int[n]",
"end",
"new int[n]",
"n",
"name = new String[n]",
"name",
"new String[n]",
"n",
"for(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}",
"{\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}",
"name[i] = scan.next()",
"name[i]",
"name",
"i",
"scan.next()",
"scan.next",
"scan",
"time[i] = scan.nextInt()",
"time[i]",
"time",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"num < n",
"num",
"n",
"{\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"for(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}",
"if(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}",
"time[i] > 0",
"time[i]",
"time",
"i",
"0",
"{\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}",
"if(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}",
"time[i] <= q",
"time[i]",
"time",
"i",
"q",
"{\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t}",
"sum += time[i]",
"sum",
"time[i]",
"time",
"i",
"end[num] = i",
"end[num]",
"end",
"num",
"i",
"num++",
"num",
"time[i] = -sum",
"time[i]",
"time",
"i",
"-sum",
"sum",
"{\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}",
"time[i] -= q",
"time[i]",
"time",
"i",
"q",
"sum += q",
"sum",
"q",
"for(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}",
"{\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}",
"System.out.println(name[end[i]] + \" \" + -time[end[i]])",
"System.out.println",
"System.out",
"System",
"System.out",
"name[end[i]] + \" \" + -time[end[i]]",
"name[end[i]] + \" \" + -time[end[i]]",
"name[end[i]]",
"name",
"end[i]",
"end",
"i",
"\" \"",
"-time[end[i]]",
"time[end[i]]",
"time",
"end[i]",
"end",
"i",
"scan.close()",
"scan.close",
"scan",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n, q, sum = 0, num = 0;\n\t\tint[] time, end;\n\t\tString[] name;\n\t\t\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\n\t\ttime = new int[n];\n\t\tend = new int[n];\n\t\tname = new String[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\twhile(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}\n\t\t\n\t\tscan.close();\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\tint n, q, sum = 0, num = 0;\n\t\tint[] time, end;\n\t\tString[] name;\n\t\t\n\t\tn = scan.nextInt();\n\t\tq = scan.nextInt();\n\n\t\ttime = new int[n];\n\t\tend = new int[n];\n\t\tname = new String[n];\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = scan.next();\n\t\t\ttime[i] = scan.nextInt();\n\t\t}\n\t\t\n\t\twhile(num < n) {\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(time[i] > 0) {\n\t\t\t\t\tif(time[i] <= q) {\n\t\t\t\t\t\tsum += time[i];\n\t\t\t\t\t\tend[num] = i;\n\t\t\t\t\t\tnum++;\n\t\t\t\t\t\ttime[i] = -sum;\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttime[i] -= q;\n\t\t\t\t\t\tsum += q;\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[end[i]] + \" \" + -time[end[i]]);\n\t\t}\n\t\t\n\t\tscan.close();\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n, q, sum = 0, num = 0;
int[] time, end;
String[] name;
n = scan.nextInt();
q = scan.nextInt();
time = new int[n];
end = new int[n];
name = new String[n];
for(int i = 0; i < n; i++) {
name[i] = scan.next();
time[i] = scan.nextInt();
}
while(num < n) {
for(int i = 0; i < n; i++) {
if(time[i] > 0) {
if(time[i] <= q) {
sum += time[i];
end[num] = i;
num++;
time[i] = -sum;
} else {
time[i] -= q;
sum += q;
}
}
}
}
for(int i = 0; i < n; i++) {
System.out.println(name[end[i]] + " " + -time[end[i]]);
}
scan.close();
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
17,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
0,
18,
13,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
13,
42,
2,
13,
13,
30,
41,
13,
18,
13,
13,
40,
13,
14,
2,
13,
17,
30,
0,
13,
17,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
18,
13,
13,
13,
40,
13,
14,
2,
13,
17,
30,
0,
13,
17,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
193,
5
],
[
193,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
18,
21
],
[
21,
22
],
[
22,
23
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
26,
29
],
[
29,
30
],
[
30,
31
],
[
8,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
44,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
44,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
55,
56
],
[
56,
57
],
[
44,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
8,
63
],
[
63,
64
],
[
63,
65
],
[
8,
66
],
[
66,
67
],
[
66,
68
],
[
8,
69
],
[
69,
70
],
[
69,
71
],
[
8,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
76,
82
],
[
82,
83
],
[
76,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
76,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
93,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
98,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
104,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
109,
113
],
[
98,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
92,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
127,
131
],
[
120,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
120,
137
],
[
137,
138
],
[
120,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
6,
147
],
[
147,
148
],
[
0,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
149,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
157,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
155,
168
],
[
168,
169
],
[
155,
170
],
[
170,
171
],
[
149,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
149,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
180,
181
],
[
149,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
185,
189
],
[
182,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
]
] | [
"import java.util.Scanner;\n\npublic class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tTask2[] tasks = new Task2[100000];\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}\n\t\tint time = 0;\n\t\tint head = 0;\n\t\tint tail = n;\n\t\twhile (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nclass Task2 {\n\tString name;\n\tint second;\n\n\tpublic Task2(String name, int second) {\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getSecond() {\n\t\treturn second;\n\t}\n\n\tpublic void setSecond(int second) {\n\t\tthis.second = second;\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tTask2[] tasks = new Task2[100000];\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}\n\t\tint time = 0;\n\t\tint head = 0;\n\t\tint tail = n;\n\t\twhile (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tTask2[] tasks = new Task2[100000];\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}\n\t\tint time = 0;\n\t\tint head = 0;\n\t\tint tail = n;\n\t\twhile (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tTask2[] tasks = new Task2[100000];\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}\n\t\tint time = 0;\n\t\tint head = 0;\n\t\tint tail = n;\n\t\twhile (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Task2[] tasks = new Task2[100000];",
"tasks",
"new Task2[100000]",
"100000",
"int n = Integer.parseInt(sc.next());",
"n",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int q = Integer.parseInt(sc.next());",
"q",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int second = Integer.parseInt(sc.next());",
"second",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"tasks[i] = new Task2(name, second)",
"tasks[i]",
"tasks",
"i",
"new Task2(name, second)",
"int time = 0;",
"time",
"0",
"int head = 0;",
"head",
"0",
"int tail = n;",
"tail",
"n",
"while (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"head != tail",
"head",
"tail",
"{\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"Task2 task = tasks[head];",
"task",
"tasks[head]",
"tasks",
"head",
"head++",
"head",
"if (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}",
"head == 100000",
"head",
"100000",
"{\n\t\t\t\thead = 0;\n\t\t\t}",
"head = 0",
"head",
"0",
"if (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}",
"task.getSecond() <= q",
"task.getSecond()",
"task.getSecond",
"task",
"q",
"{\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t}",
"time += task.getSecond()",
"time",
"task.getSecond()",
"task.getSecond",
"task",
"System.out.print(task.getName() + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"task.getName() + \" \"",
"task.getName()",
"task.getName",
"task",
"\" \"",
"System.out.println(time)",
"System.out.println",
"System.out",
"System",
"System.out",
"time",
"{\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}",
"time += q",
"time",
"q",
"task.setSecond(task.getSecond() - q)",
"task.setSecond",
"task",
"task.getSecond() - q",
"task.getSecond()",
"task.getSecond",
"task",
"q",
"tasks[tail] = task",
"tasks[tail]",
"tasks",
"tail",
"task",
"tail++",
"tail",
"if (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}",
"tail == 100000",
"tail",
"100000",
"{\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}",
"tail = 0",
"tail",
"0",
"String[] args",
"args",
"class Task2 {\n\tString name;\n\tint second;\n\n\tpublic Task2(String name, int second) {\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getSecond() {\n\t\treturn second;\n\t}\n\n\tpublic void setSecond(int second) {\n\t\tthis.second = second;\n\t}\n\n}",
"Task2",
"String name;",
"name",
"int second;",
"second",
"public Task2(String name, int second) {\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}",
"Task2",
"{\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.second = second",
"this.second",
"this",
"this.second",
"second",
"String name",
"name",
"int second",
"second",
"public String getName() {\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public int getSecond() {\n\t\treturn second;\n\t}",
"getSecond",
"{\n\t\treturn second;\n\t}",
"return second;",
"second",
"public void setSecond(int second) {\n\t\tthis.second = second;\n\t}",
"setSecond",
"{\n\t\tthis.second = second;\n\t}",
"this.second = second",
"this.second",
"this",
"this.second",
"second",
"int second",
"second",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tTask2[] tasks = new Task2[100000];\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}\n\t\tint time = 0;\n\t\tint head = 0;\n\t\tint tail = n;\n\t\twhile (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tTask2[] tasks = new Task2[100000];\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\ttasks[i] = new Task2(name, second);\n\t\t}\n\t\tint time = 0;\n\t\tint head = 0;\n\t\tint tail = n;\n\t\twhile (head != tail) {\n\t\t\tTask2 task = tasks[head];\n\t\t\thead++;\n\t\t\tif (head == 100000) {\n\t\t\t\thead = 0;\n\t\t\t}\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks[tail] = task;\n\t\t\t\ttail++;\n\t\t\t\tif (tail == 100000) {\n\t\t\t\t\ttail = 0;\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Task2[] tasks = new Task2[100000];
int n = Integer.parseInt(sc.next());
int q = Integer.parseInt(sc.next());
for (int i = 0; i < n; i++) {
String name = sc.next();
int second = Integer.parseInt(sc.next());
tasks[i] = new Task2(name, second);
}
int time = 0;
int head = 0;
int tail = n;
while (head != tail) {
Task2 task = tasks[head];
head++;
if (head == 100000) {
head = 0;
}
if (task.getSecond() <= q) {
time += task.getSecond();
System.out.print(task.getName() + " ");
System.out.println(time);
} else {
time += q;
task.setSecond(task.getSecond() - q);
tasks[tail] = task;
tail++;
if (tail == 100000) {
tail = 0;
}
}
}
}
}
class Task2 {
String name;
int second;
public Task2(String name, int second) {
this.name = name;
this.second = second;
}
public String getName() {
return name;
}
public int getSecond() {
return second;
}
public void setSecond(int second) {
this.second = second;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
117,
5
],
[
117,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
37,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
8,
62
],
[
62,
63
],
[
62,
64
],
[
8,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
66,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
95,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
95,
100
],
[
77,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
107,
109
],
[
101,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
6,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Combo {\n\t\t\tString name;\n\t\t\tlong time;\n\t\t}\n\t\t\n\t\tQueue<Combo> remain = new LinkedList<Combo>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}\n\t\tscanner.close();\n\t\t\n\n\t\tlong GlobeTime = 0;\n\t\t\n\t\twhile (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n} ",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Combo {\n\t\t\tString name;\n\t\t\tlong time;\n\t\t}\n\t\t\n\t\tQueue<Combo> remain = new LinkedList<Combo>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}\n\t\tscanner.close();\n\t\t\n\n\t\tlong GlobeTime = 0;\n\t\t\n\t\twhile (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tclass Combo {\n\t\t\tString name;\n\t\t\tlong time;\n\t\t}\n\t\t\n\t\tQueue<Combo> remain = new LinkedList<Combo>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}\n\t\tscanner.close();\n\t\t\n\n\t\tlong GlobeTime = 0;\n\t\t\n\t\twhile (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tclass Combo {\n\t\t\tString name;\n\t\t\tlong time;\n\t\t}\n\t\t\n\t\tQueue<Combo> remain = new LinkedList<Combo>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}\n\t\tscanner.close();\n\t\t\n\n\t\tlong GlobeTime = 0;\n\t\t\n\t\twhile (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"Queue<Combo> remain = new LinkedList<Combo>();",
"remain",
"new LinkedList<Combo>()",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"long n = scanner.nextLong();",
"n",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"long q = scanner.nextLong();",
"q",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"for (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i ++",
"i ++",
"i",
"{\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}",
"{\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}",
"Combo process = new Combo();",
"process",
"new Combo()",
"process.name = scanner.next()",
"process.name",
"process",
"process.name",
"scanner.next()",
"scanner.next",
"scanner",
"process.time = scanner.nextLong()",
"process.time",
"process",
"process.time",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"remain.add(process)",
"remain.add",
"remain",
"process",
"scanner.close()",
"scanner.close",
"scanner",
"long GlobeTime = 0;",
"GlobeTime",
"0",
"while (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}",
"remain.size() > 0",
"remain.size()",
"remain.size",
"remain",
"0",
"{\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}",
"Combo currentProcess = remain.remove();",
"currentProcess",
"remain.remove()",
"remain.remove",
"remain",
"if (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}",
"currentProcess.time <= q",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"q",
"{\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t}",
"GlobeTime += currentProcess.time",
"GlobeTime",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"System.out.println(currentProcess.name + \" \" + GlobeTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"currentProcess.name + \" \" + GlobeTime",
"currentProcess.name + \" \" + GlobeTime",
"currentProcess.name",
"currentProcess",
"currentProcess.name",
"\" \"",
"GlobeTime",
"{\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}",
"currentProcess.time -= q",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"q",
"GlobeTime += q",
"GlobeTime",
"q",
"remain.add(currentProcess)",
"remain.add",
"remain",
"currentProcess",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Combo {\n\t\t\tString name;\n\t\t\tlong time;\n\t\t}\n\t\t\n\t\tQueue<Combo> remain = new LinkedList<Combo>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}\n\t\tscanner.close();\n\t\t\n\n\t\tlong GlobeTime = 0;\n\t\t\n\t\twhile (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Combo {\n\t\t\tString name;\n\t\t\tlong time;\n\t\t}\n\t\t\n\t\tQueue<Combo> remain = new LinkedList<Combo>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tCombo process = new Combo();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tremain.add(process);\n\t\t}\n\t\tscanner.close();\n\t\t\n\n\t\tlong GlobeTime = 0;\n\t\t\n\t\twhile (remain.size() > 0) {\n\t\t\tCombo currentProcess = remain.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tGlobeTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + GlobeTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tGlobeTime += q;\n\t\t\t\tremain.add(currentProcess);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
class Combo {
String name;
long time;
}
Queue<Combo> remain = new LinkedList<Combo>();
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long q = scanner.nextLong();
for (int i = 0; i < n; i ++) {
Combo process = new Combo();
process.name = scanner.next();
process.time = scanner.nextLong();
remain.add(process);
}
scanner.close();
long GlobeTime = 0;
while (remain.size() > 0) {
Combo currentProcess = remain.remove();
if (currentProcess.time <= q) {
GlobeTime += currentProcess.time;
System.out.println(currentProcess.name + " " + GlobeTime);
} else {
currentProcess.time -= q;
GlobeTime += q;
remain.add(currentProcess);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
18,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
43,
46
],
[
14,
47
],
[
47,
48
],
[
47,
49
],
[
14,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
51,
55
],
[
50,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
74,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
80,
85
],
[
62,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
86,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
12,
98
],
[
98,
99
],
[
10,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
100,
104
],
[
104,
105
],
[
100,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
112,
114
],
[
106,
115
],
[
115,
116
],
[
106,
117
],
[
117,
118
],
[
100,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
125,
126
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\nimport java.util.Queue;\n\nclass Main {\n\n static class Process{\n String name;\n int time;\n\n Process(String n, int t){\n name = n;\n time = t;\n }\n void updateTime(int t){\n time -= t;\n }\n }\n\n\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int quantum = sc.nextInt();\n\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++)\n queue.add(new Process(sc.next(), sc.nextInt()));\n\n int elapsed = 0;\n while (queue.size() > 0){\n Process p = queue.poll();\n if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }\n }\n }\n}\n",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"class Main {\n\n static class Process{\n String name;\n int time;\n\n Process(String n, int t){\n name = n;\n time = t;\n }\n void updateTime(int t){\n time -= t;\n }\n }\n\n\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int quantum = sc.nextInt();\n\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++)\n queue.add(new Process(sc.next(), sc.nextInt()));\n\n int elapsed = 0;\n while (queue.size() > 0){\n Process p = queue.poll();\n if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int quantum = sc.nextInt();\n\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++)\n queue.add(new Process(sc.next(), sc.nextInt()));\n\n int elapsed = 0;\n while (queue.size() > 0){\n Process p = queue.poll();\n if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int quantum = sc.nextInt();\n\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++)\n queue.add(new Process(sc.next(), sc.nextInt()));\n\n int elapsed = 0;\n while (queue.size() > 0){\n Process p = queue.poll();\n if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int quantum = sc.nextInt();",
"quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Process> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for (int i = 0; i < n; i++)\n queue.add(new Process(sc.next(), sc.nextInt()));",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"queue.add(new Process(sc.next(), sc.nextInt()));",
"queue.add(new Process(sc.next(), sc.nextInt()))",
"queue.add",
"queue",
"new Process(sc.next(), sc.nextInt())",
"int elapsed = 0;",
"elapsed",
"0",
"while (queue.size() > 0){\n Process p = queue.poll();\n if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Process p = queue.poll();\n if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }\n }",
"Process p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"if (p.time <= quantum){\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }\n else{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }",
"p.time <= quantum",
"p.time",
"p",
"p.time",
"quantum",
"{\n elapsed += p.time;\n System.out.println(p.name + \" \" + elapsed);\n }",
"elapsed += p.time",
"elapsed",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + elapsed)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + elapsed",
"p.name + \" \" + elapsed",
"p.name",
"p",
"p.name",
"\" \"",
"elapsed",
"{\n elapsed += quantum;\n p.updateTime(quantum);\n queue.offer(p);\n }",
"elapsed += quantum",
"elapsed",
"quantum",
"p.updateTime(quantum)",
"p.updateTime",
"p",
"quantum",
"queue.offer(p)",
"queue.offer",
"queue",
"p",
"String[] args",
"args",
"static class Process{\n String name;\n int time;\n\n Process(String n, int t){\n name = n;\n time = t;\n }\n void updateTime(int t){\n time -= t;\n }\n }",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String n, int t){\n name = n;\n time = t;\n }",
"Process",
"{\n name = n;\n time = t;\n }",
"name = n",
"name",
"n",
"time = t",
"time",
"t",
"String n",
"n",
"int t",
"t",
"void updateTime(int t){\n time -= t;\n }",
"updateTime",
"{\n time -= t;\n }",
"time -= t",
"time",
"t",
"int t",
"t"
] | import java.util.LinkedList;
import java.util.Scanner;
import java.util.Queue;
class Main {
static class Process{
String name;
int time;
Process(String n, int t){
name = n;
time = t;
}
void updateTime(int t){
time -= t;
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int quantum = sc.nextInt();
Queue<Process> queue = new LinkedList<>();
for (int i = 0; i < n; i++)
queue.add(new Process(sc.next(), sc.nextInt()));
int elapsed = 0;
while (queue.size() > 0){
Process p = queue.poll();
if (p.time <= quantum){
elapsed += p.time;
System.out.println(p.name + " " + elapsed);
}
else{
elapsed += quantum;
p.updateTime(quantum);
queue.offer(p);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
17,
41,
13,
17,
41,
13,
20,
41,
13,
20,
12,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
13,
41,
13,
18,
13,
17,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
13,
13,
4,
13,
18,
13,
17,
4,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
13,
41,
13,
17,
42,
2,
13,
17,
30,
41,
13,
4,
13,
14,
2,
13,
13,
30,
4,
13,
13,
4,
13,
2,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
0,
13,
4,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
14,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
17,
4,
18,
13,
17,
30,
0,
13,
17,
29,
13,
12,
13,
30,
41,
13,
14,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
17,
4,
18,
13,
17,
30,
0,
13,
40,
17,
29,
13,
12,
13,
30,
0,
18,
13,
40,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
18,
13,
40,
13,
12,
13,
30,
29,
20,
12,
13,
30,
41,
13,
4,
18,
13,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
20,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
17,
29,
2,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
13,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
13,
13,
29,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
18,
13,
13,
17,
23,
13,
23,
13,
12,
13,
30,
4,
13,
13,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
2,
4,
18,
13,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
0,
13,
17,
30,
30,
14,
2,
2,
13,
13,
17,
30,
29,
17,
29,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
470,
11
],
[
470,
12
],
[
12,
13
],
[
12,
14
],
[
470,
16
],
[
16,
17
],
[
16,
18
],
[
470,
19
],
[
19,
20
],
[
19,
21
],
[
470,
22
],
[
22,
23
],
[
22,
24
],
[
470,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
27,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
34,
36
],
[
27,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
39,
41
],
[
27,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
44,
46
],
[
27,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
47,
52
],
[
52,
53
],
[
52,
54
],
[
47,
55
],
[
55,
56
],
[
56,
57
],
[
47,
58
],
[
59,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
59,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
59,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
27,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
27,
82
],
[
82,
83
],
[
82,
84
],
[
27,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
89,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
98,
107
],
[
107,
108
],
[
107,
109
],
[
94,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
120,
120
],
[
120,
121
],
[
120,
122
],
[
120,
123
],
[
89,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
25,
128
],
[
128,
129
],
[
470,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
130,
137
],
[
137,
138
],
[
470,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
139,
146
],
[
146,
147
],
[
470,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
150,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
154,
158
],
[
153,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
159,
166
],
[
166,
167
],
[
167,
168
],
[
166,
169
],
[
153,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
150,
174
],
[
174,
175
],
[
470,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
178,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
182,
186
],
[
181,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
191,
192
],
[
190,
193
],
[
187,
194
],
[
194,
195
],
[
195,
196
],
[
194,
197
],
[
181,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
178,
203
],
[
203,
204
],
[
470,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
208,
213
],
[
205,
214
],
[
214,
215
],
[
470,
216
],
[
216,
217
],
[
216,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
221,
222
],
[
220,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
470,
227
],
[
227,
228
],
[
227,
229
],
[
229,
230
],
[
230,
231
],
[
470,
232
],
[
232,
233
],
[
232,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
238,
239
],
[
234,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
241,
244
],
[
232,
245
],
[
245,
246
],
[
470,
247
],
[
247,
248
],
[
247,
249
],
[
249,
250
],
[
250,
251
],
[
250,
252
],
[
252,
253
],
[
253,
254
],
[
249,
255
],
[
255,
256
],
[
255,
257
],
[
257,
258
],
[
258,
259
],
[
257,
260
],
[
249,
261
],
[
261,
262
],
[
247,
263
],
[
263,
264
],
[
470,
265
],
[
265,
266
],
[
265,
267
],
[
267,
268
],
[
268,
269
],
[
268,
270
],
[
270,
271
],
[
271,
272
],
[
267,
273
],
[
273,
274
],
[
273,
275
],
[
275,
276
],
[
276,
277
],
[
275,
278
],
[
267,
279
],
[
279,
280
],
[
279,
281
],
[
282,
283
],
[
282,
284
],
[
267,
285
],
[
285,
286
],
[
286,
287
],
[
287,
288
],
[
287,
289
],
[
285,
290
],
[
290,
291
],
[
290,
292
],
[
292,
293
],
[
292,
294
],
[
285,
295
],
[
295,
296
],
[
296,
297
],
[
285,
298
],
[
299,
299
],
[
299,
300
],
[
300,
301
],
[
301,
302
],
[
301,
303
],
[
300,
304
],
[
304,
305
],
[
305,
306
],
[
304,
307
],
[
307,
308
],
[
307,
309
],
[
267,
310
],
[
310,
311
],
[
265,
312
],
[
312,
313
],
[
470,
314
],
[
314,
315
],
[
314,
316
],
[
316,
317
],
[
317,
318
],
[
317,
319
],
[
319,
320
],
[
320,
321
],
[
319,
322
],
[
316,
323
],
[
323,
324
],
[
323,
325
],
[
325,
326
],
[
326,
327
],
[
325,
328
],
[
316,
329
],
[
329,
330
],
[
330,
331
],
[
330,
332
],
[
314,
333
],
[
333,
334
],
[
314,
335
],
[
335,
336
],
[
470,
337
],
[
337,
338
],
[
337,
339
],
[
339,
340
],
[
340,
341
],
[
340,
342
],
[
342,
343
],
[
342,
344
],
[
339,
345
],
[
345,
346
],
[
345,
347
],
[
339,
349
],
[
349,
350
],
[
350,
351
],
[
351,
352
],
[
351,
353
],
[
349,
354
],
[
354,
355
],
[
354,
356
],
[
349,
357
],
[
357,
358
],
[
358,
359
],
[
349,
360
],
[
361,
361
],
[
361,
362
],
[
362,
363
],
[
363,
364
],
[
363,
365
],
[
362,
366
],
[
366,
367
],
[
366,
368
],
[
339,
369
],
[
369,
370
],
[
337,
371
],
[
371,
372
],
[
470,
373
],
[
373,
374
],
[
373,
375
],
[
375,
376
],
[
376,
377
],
[
377,
378
],
[
378,
379
],
[
378,
380
],
[
376,
381
],
[
381,
382
],
[
381,
383
],
[
376,
384
],
[
384,
385
],
[
385,
386
],
[
376,
387
],
[
388,
388
],
[
388,
389
],
[
389,
390
],
[
390,
391
],
[
391,
392
],
[
391,
393
],
[
389,
394
],
[
394,
395
],
[
394,
396
],
[
388,
397
],
[
397,
398
],
[
398,
399
],
[
398,
400
],
[
400,
401
],
[
400,
402
],
[
397,
403
],
[
403,
404
],
[
404,
405
],
[
405,
406
],
[
406,
407
],
[
406,
408
],
[
404,
409
],
[
375,
410
],
[
410,
411
],
[
411,
412
],
[
412,
413
],
[
412,
414
],
[
410,
415
],
[
373,
416
],
[
416,
417
],
[
373,
418
],
[
418,
419
],
[
470,
420
],
[
420,
421
],
[
420,
422
],
[
422,
423
],
[
423,
424
],
[
423,
425
],
[
423,
426
],
[
426,
427
],
[
426,
428
],
[
420,
429
],
[
429,
430
],
[
470,
431
],
[
431,
432
],
[
431,
433
],
[
433,
434
],
[
434,
435
],
[
434,
436
],
[
436,
437
],
[
437,
438
],
[
438,
439
],
[
437,
440
],
[
436,
441
],
[
433,
442
],
[
442,
443
],
[
443,
444
],
[
444,
445
],
[
444,
446
],
[
442,
447
],
[
447,
448
],
[
447,
449
],
[
442,
450
],
[
450,
451
],
[
451,
452
],
[
451,
453
],
[
442,
454
],
[
455,
455
],
[
455,
456
],
[
456,
457
],
[
457,
458
],
[
458,
459
],
[
458,
460
],
[
457,
461
],
[
456,
462
],
[
462,
463
],
[
463,
464
],
[
433,
465
],
[
465,
466
],
[
431,
467
],
[
467,
468
],
[
0,
469
],
[
469,
470
],
[
469,
471
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\n\n\npublic class Main {\n\tstatic int[] numStack = new int[100];\n\tstatic int numOfs= 0;\n\tstatic ArrayList<String> strList = new ArrayList<String>();\n\tstatic ArrayList<Integer> intList = new ArrayList<Integer>();\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint[] elm = getIntAry(breader);\n\t\tint num = elm[0];\n\t\tint quantum = elm[1];\n\t\tfor(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}\n\t\tString ps = strDequeue();\n\t\tint elapse = 0;\n\t\twhile( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}\n\t}\n\tpublic static void strEnqueue(String str) {\n\t\tstrList.add(str);\n\t}\n\tpublic static void intEnqueue(int num) {\n\t\tintList.add(num);\n\t}\n\tpublic static String strDequeue() {\n\t\tString val;\n\t\tif ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static int intDequeue() {\n\t\tint val;\n\t\tif ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static void numPush(int n) {\n\t\tnumStack[numOfs++] = n;\n\t}\n\tpublic static int numPop() {\n\t\treturn(Integer.valueOf(numStack[--numOfs]));\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static String[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\treturn nstr;\n\t}\n\tpublic static int[] getIntAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int cardComp(String left, String right) {\n\t\tchar l = left.charAt(1);\n\t\tchar r = right.charAt(1);\n\t\treturn(l-r);\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"public class Main {\n\tstatic int[] numStack = new int[100];\n\tstatic int numOfs= 0;\n\tstatic ArrayList<String> strList = new ArrayList<String>();\n\tstatic ArrayList<Integer> intList = new ArrayList<Integer>();\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint[] elm = getIntAry(breader);\n\t\tint num = elm[0];\n\t\tint quantum = elm[1];\n\t\tfor(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}\n\t\tString ps = strDequeue();\n\t\tint elapse = 0;\n\t\twhile( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}\n\t}\n\tpublic static void strEnqueue(String str) {\n\t\tstrList.add(str);\n\t}\n\tpublic static void intEnqueue(int num) {\n\t\tintList.add(num);\n\t}\n\tpublic static String strDequeue() {\n\t\tString val;\n\t\tif ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static int intDequeue() {\n\t\tint val;\n\t\tif ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static void numPush(int n) {\n\t\tnumStack[numOfs++] = n;\n\t}\n\tpublic static int numPop() {\n\t\treturn(Integer.valueOf(numStack[--numOfs]));\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static String[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\treturn nstr;\n\t}\n\tpublic static int[] getIntAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int cardComp(String left, String right) {\n\t\tchar l = left.charAt(1);\n\t\tchar r = right.charAt(1);\n\t\treturn(l-r);\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"Main",
"static int[] numStack = new int[100];",
"numStack",
"new int[100]",
"100",
"static int numOfs= 0;",
"numOfs",
"0",
"static ArrayList<String> strList = new ArrayList<String>();",
"strList",
"new ArrayList<String>()",
"static ArrayList<Integer> intList = new ArrayList<Integer>();",
"intList",
"new ArrayList<Integer>()",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint[] elm = getIntAry(breader);\n\t\tint num = elm[0];\n\t\tint quantum = elm[1];\n\t\tfor(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}\n\t\tString ps = strDequeue();\n\t\tint elapse = 0;\n\t\twhile( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader breader = getReader();\n\t\tint[] elm = getIntAry(breader);\n\t\tint num = elm[0];\n\t\tint quantum = elm[1];\n\t\tfor(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}\n\t\tString ps = strDequeue();\n\t\tint elapse = 0;\n\t\twhile( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}\n\t}",
"BufferedReader breader = getReader();",
"breader",
"getReader()",
"getReader",
"int[] elm = getIntAry(breader);",
"elm",
"getIntAry(breader)",
"getIntAry",
"breader",
"int num = elm[0];",
"num",
"elm[0]",
"elm",
"0",
"int quantum = elm[1];",
"quantum",
"elm[1]",
"elm",
"1",
"for(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}",
"{\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}",
"String[] ps = getAry(breader);",
"ps",
"getAry(breader)",
"getAry",
"breader",
"strEnqueue(ps[0])",
"strEnqueue",
"ps[0]",
"ps",
"0",
"intEnqueue(Integer.valueOf(ps[1]))",
"intEnqueue",
"Integer.valueOf(ps[1])",
"Integer.valueOf",
"Integer",
"ps[1]",
"ps",
"1",
"String ps = strDequeue();",
"ps",
"strDequeue()",
"strDequeue",
"int elapse = 0;",
"elapse",
"0",
"while( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}",
"ps != null",
"ps",
"null",
"{\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}",
"int ms = intDequeue();",
"ms",
"intDequeue()",
"intDequeue",
"if ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}",
"ms > quantum",
"ms",
"quantum",
"{\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t}",
"strEnqueue(ps)",
"strEnqueue",
"ps",
"intEnqueue(ms-quantum)",
"intEnqueue",
"ms-quantum",
"ms",
"quantum",
"elapse += quantum",
"elapse",
"quantum",
"{\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}",
"elapse += ms",
"elapse",
"ms",
"System.out.println(ps + \" \" + elapse)",
"System.out.println",
"System.out",
"System",
"System.out",
"ps + \" \" + elapse",
"ps + \" \" + elapse",
"ps",
"\" \"",
"elapse",
"ps = strDequeue()",
"ps",
"strDequeue()",
"strDequeue",
"String[] args",
"args",
"public static void strEnqueue(String str) {\n\t\tstrList.add(str);\n\t}",
"strEnqueue",
"{\n\t\tstrList.add(str);\n\t}",
"strList.add(str)",
"strList.add",
"strList",
"str",
"String str",
"str",
"public static void intEnqueue(int num) {\n\t\tintList.add(num);\n\t}",
"intEnqueue",
"{\n\t\tintList.add(num);\n\t}",
"intList.add(num)",
"intList.add",
"intList",
"num",
"int num",
"num",
"public static String strDequeue() {\n\t\tString val;\n\t\tif ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}\n\t\treturn val;\n\t}",
"strDequeue",
"{\n\t\tString val;\n\t\tif ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}\n\t\treturn val;\n\t}",
"String val;",
"val",
"if ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}",
"strList.size() > 0",
"strList.size()",
"strList.size",
"strList",
"0",
"{\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t}",
"val = strList.get(0)",
"val",
"strList.get(0)",
"strList.get",
"strList",
"0",
"strList.remove(0)",
"strList.remove",
"strList",
"0",
"{\n\t\t\tval = null;\n\t\t}",
"val = null",
"val",
"null",
"return val;",
"val",
"public static int intDequeue() {\n\t\tint val;\n\t\tif ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}\n\t\treturn val;\n\t}",
"intDequeue",
"{\n\t\tint val;\n\t\tif ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}\n\t\treturn val;\n\t}",
"int val;",
"val",
"if ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}",
"intList.size() > 0",
"intList.size()",
"intList.size",
"intList",
"0",
"{\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t}",
"val = intList.get(0)",
"val",
"intList.get(0)",
"intList.get",
"intList",
"0",
"intList.remove(0)",
"intList.remove",
"intList",
"0",
"{\n\t\t\tval = -1;\n\t\t}",
"val = -1",
"val",
"-1",
"1",
"return val;",
"val",
"public static void numPush(int n) {\n\t\tnumStack[numOfs++] = n;\n\t}",
"numPush",
"{\n\t\tnumStack[numOfs++] = n;\n\t}",
"numStack[numOfs++] = n",
"numStack[numOfs++]",
"numStack",
"numOfs++",
"numOfs",
"n",
"int n",
"n",
"public static int numPop() {\n\t\treturn(Integer.valueOf(numStack[--numOfs]));\n\t}",
"numPop",
"{\n\t\treturn(Integer.valueOf(numStack[--numOfs]));\n\t}",
"return(Integer.valueOf(numStack[--numOfs]));",
"(Integer.valueOf(numStack[--numOfs]))",
"Integer.valueOf",
"Integer",
"numStack[--numOfs]",
"numStack",
"--numOfs",
"numOfs",
"public static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));\n\t}",
"getReader",
"{\n\t\treturn( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));\n\t}",
"return( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));",
"( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)))",
"public static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}",
"getInt",
"{\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"return Integer.valueOf(line);",
"Integer.valueOf(line)",
"Integer.valueOf",
"Integer",
"line",
"BufferedReader br",
"br",
"public static String[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\treturn nstr;\n\t}",
"getAry",
"{\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\treturn nstr;\n\t}",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"String[] nstr = line.split(\" \");",
"nstr",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"return nstr;",
"nstr",
"BufferedReader br",
"br",
"public static int[] getIntAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}",
"getIntAry",
"{\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"String[] nstr = line.split(\" \");",
"nstr",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"int[] n = new int[nstr.length];",
"n",
"new int[nstr.length]",
"nstr.length",
"nstr",
"nstr.length",
"for( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i < nstr.length",
"i",
"nstr.length",
"nstr",
"nstr.length",
"i++",
"i++",
"i",
"{\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}",
"{\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}",
"n[i] = Integer.valueOf(nstr[i])",
"n[i]",
"n",
"i",
"Integer.valueOf(nstr[i])",
"Integer.valueOf",
"Integer",
"nstr[i]",
"nstr",
"i",
"return n;",
"n",
"BufferedReader br",
"br",
"public static int cardComp(String left, String right) {\n\t\tchar l = left.charAt(1);\n\t\tchar r = right.charAt(1);\n\t\treturn(l-r);\n\t}",
"cardComp",
"{\n\t\tchar l = left.charAt(1);\n\t\tchar r = right.charAt(1);\n\t\treturn(l-r);\n\t}",
"char l = left.charAt(1);",
"l",
"left.charAt(1)",
"left.charAt",
"left",
"1",
"char r = right.charAt(1);",
"r",
"right.charAt(1)",
"right.charAt",
"right",
"1",
"return(l-r);",
"(l-r)",
"l",
"r",
"String left",
"left",
"String right",
"right",
"public static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}",
"getAryMl",
"{\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}",
"int n = getInt(br);",
"n",
"getInt(br)",
"getInt",
"br",
"int[] ary = new int[n];",
"ary",
"new int[n]",
"n",
"for( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tary[i] = getInt(br);\n\t\t}",
"{\n\t\t\tary[i] = getInt(br);\n\t\t}",
"ary[i] = getInt(br)",
"ary[i]",
"ary",
"i",
"getInt(br)",
"getInt",
"br",
"return ary;",
"ary",
"BufferedReader br",
"br",
"public static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}",
"putAry",
"{\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}",
"for( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"{\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}",
"System.out.print(ary[i])",
"System.out.print",
"System.out",
"System",
"System.out",
"ary[i]",
"ary",
"i",
"if ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"i < num-1",
"i",
"num-1",
"num",
"1",
"{\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(\"\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\"",
"int[] ary",
"ary",
"int num",
"num",
"public static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}",
"putAry",
"{\n\t\tputAry(ary, ary.length ) ;\n\t}",
"putAry(ary, ary.length )",
"putAry",
"ary",
"ary.length",
"ary",
"ary.length",
"int[] ary",
"ary",
"public static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}",
"isPrime",
"{\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}",
"int r = (int)Math.sqrt((double)n)+1;",
"r",
"(int)Math.sqrt((double)n)+1",
"(int)Math.sqrt((double)n)",
"Math.sqrt",
"Math",
"(double)n",
"1",
"for( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}",
"int j = 2 ;",
"int j = 2 ;",
"j",
"2",
"j < r",
"j",
"r",
"j += 1",
"j += 1",
"j",
"1",
"{\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}",
"{\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}",
"if ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}",
"n%j == 0",
"n%j",
"n",
"j",
"0",
"{\n\t\t\t\treturn false;\n\t\t\t}",
"return false;",
"false",
"return true;",
"true",
"int n",
"n",
"public class Main {\n\tstatic int[] numStack = new int[100];\n\tstatic int numOfs= 0;\n\tstatic ArrayList<String> strList = new ArrayList<String>();\n\tstatic ArrayList<Integer> intList = new ArrayList<Integer>();\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint[] elm = getIntAry(breader);\n\t\tint num = elm[0];\n\t\tint quantum = elm[1];\n\t\tfor(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}\n\t\tString ps = strDequeue();\n\t\tint elapse = 0;\n\t\twhile( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}\n\t}\n\tpublic static void strEnqueue(String str) {\n\t\tstrList.add(str);\n\t}\n\tpublic static void intEnqueue(int num) {\n\t\tintList.add(num);\n\t}\n\tpublic static String strDequeue() {\n\t\tString val;\n\t\tif ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static int intDequeue() {\n\t\tint val;\n\t\tif ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static void numPush(int n) {\n\t\tnumStack[numOfs++] = n;\n\t}\n\tpublic static int numPop() {\n\t\treturn(Integer.valueOf(numStack[--numOfs]));\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static String[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\treturn nstr;\n\t}\n\tpublic static int[] getIntAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int cardComp(String left, String right) {\n\t\tchar l = left.charAt(1);\n\t\tchar r = right.charAt(1);\n\t\treturn(l-r);\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"public class Main {\n\tstatic int[] numStack = new int[100];\n\tstatic int numOfs= 0;\n\tstatic ArrayList<String> strList = new ArrayList<String>();\n\tstatic ArrayList<Integer> intList = new ArrayList<Integer>();\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader breader = getReader();\n\t\tint[] elm = getIntAry(breader);\n\t\tint num = elm[0];\n\t\tint quantum = elm[1];\n\t\tfor(int i = 0 ; i < num ; i++ ) {\n\t\t\tString[] ps = getAry(breader);\n\t\t\tstrEnqueue(ps[0]);\n\t\t\tintEnqueue(Integer.valueOf(ps[1]));\n\t\t}\n\t\tString ps = strDequeue();\n\t\tint elapse = 0;\n\t\twhile( ps != null) {\n\t\t\tint ms = intDequeue();\n\t\t\tif ( ms > quantum ) {\n\t\t\t\tstrEnqueue(ps);\n\t\t\t\tintEnqueue(ms-quantum);\n\t\t\t\telapse += quantum;\n\t\t\t} else {\n\t\t\t\telapse += ms;\n\t\t\t\tSystem.out.println(ps + \" \" + elapse);\n\t\t\t}\n\t\t\tps = strDequeue();\n\t\t}\n\t}\n\tpublic static void strEnqueue(String str) {\n\t\tstrList.add(str);\n\t}\n\tpublic static void intEnqueue(int num) {\n\t\tintList.add(num);\n\t}\n\tpublic static String strDequeue() {\n\t\tString val;\n\t\tif ( strList.size() > 0 ) {\n\t\t\tval = strList.get(0);\n\t\t\tstrList.remove(0);\n\t\t} else {\n\t\t\tval = null;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static int intDequeue() {\n\t\tint val;\n\t\tif ( intList.size() > 0) {\n\t\t\tval = intList.get(0);\n\t\t\tintList.remove(0);\n\t\t} else {\n\t\t\tval = -1;\n\t\t}\n\t\treturn val;\n\t}\n\tpublic static void numPush(int n) {\n\t\tnumStack[numOfs++] = n;\n\t}\n\tpublic static int numPop() {\n\t\treturn(Integer.valueOf(numStack[--numOfs]));\n\t}\n\tpublic static BufferedReader getReader() {\n\t\treturn( new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in)));\n\t}\n\tpublic static int getInt(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\treturn Integer.valueOf(line);\n\t}\n\tpublic static String[] getAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\treturn nstr;\n\t}\n\tpublic static int[] getIntAry(BufferedReader br)throws Exception {\n\t\tString line = br.readLine();\n\t\tString[] nstr = line.split(\" \");\n\t\tint[] n = new int[nstr.length];\n\t\tfor( int i=0 ; i < nstr.length ; i++ ) {\n\t\t\tn[i] = Integer.valueOf(nstr[i]);\n\t\t}\n\t\treturn n;\n\t}\n\tpublic static int cardComp(String left, String right) {\n\t\tchar l = left.charAt(1);\n\t\tchar r = right.charAt(1);\n\t\treturn(l-r);\n\t}\n\tpublic static int[] getAryMl(BufferedReader br)throws Exception {\n\t\tint n = getInt(br);\n\t\tint[] ary = new int[n];\n\t\tfor( int i=0 ; i < n ; i++ ) {\n\t\t\tary[i] = getInt(br);\n\t\t}\n\t\treturn ary;\n\t}\n\tpublic static void putAry(int[] ary, int num) {\n\t\tfor( int i = 0; i < num ; i++ ) {\n\t\t\tSystem.out.print(ary[i]);\n\t\t\tif ( i < num-1) {\n\t\t\t\tSystem.out.print(\" \");\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(\"\");\n\t}\n\tpublic static void putAry(int[] ary) {\n\t\tputAry(ary, ary.length ) ;\n\t}\n\tpublic static boolean isPrime(int n) {\n\t\tint r = (int)Math.sqrt((double)n)+1;\n\t\tfor( int j = 2 ; j < r ; j += 1) {\n\t\t\tif ( n%j == 0 ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
static int[] numStack = new int[100];
static int numOfs= 0;
static ArrayList<String> strList = new ArrayList<String>();
static ArrayList<Integer> intList = new ArrayList<Integer>();
public static void main(String[] args) throws Exception {
BufferedReader breader = getReader();
int[] elm = getIntAry(breader);
int num = elm[0];
int quantum = elm[1];
for(int i = 0 ; i < num ; i++ ) {
String[] ps = getAry(breader);
strEnqueue(ps[0]);
intEnqueue(Integer.valueOf(ps[1]));
}
String ps = strDequeue();
int elapse = 0;
while( ps != null) {
int ms = intDequeue();
if ( ms > quantum ) {
strEnqueue(ps);
intEnqueue(ms-quantum);
elapse += quantum;
} else {
elapse += ms;
System.out.println(ps + " " + elapse);
}
ps = strDequeue();
}
}
public static void strEnqueue(String str) {
strList.add(str);
}
public static void intEnqueue(int num) {
intList.add(num);
}
public static String strDequeue() {
String val;
if ( strList.size() > 0 ) {
val = strList.get(0);
strList.remove(0);
} else {
val = null;
}
return val;
}
public static int intDequeue() {
int val;
if ( intList.size() > 0) {
val = intList.get(0);
intList.remove(0);
} else {
val = -1;
}
return val;
}
public static void numPush(int n) {
numStack[numOfs++] = n;
}
public static int numPop() {
return(Integer.valueOf(numStack[--numOfs]));
}
public static BufferedReader getReader() {
return( new BufferedReader(new InputStreamReader(
System.in)));
}
public static int getInt(BufferedReader br)throws Exception {
String line = br.readLine();
return Integer.valueOf(line);
}
public static String[] getAry(BufferedReader br)throws Exception {
String line = br.readLine();
String[] nstr = line.split(" ");
return nstr;
}
public static int[] getIntAry(BufferedReader br)throws Exception {
String line = br.readLine();
String[] nstr = line.split(" ");
int[] n = new int[nstr.length];
for( int i=0 ; i < nstr.length ; i++ ) {
n[i] = Integer.valueOf(nstr[i]);
}
return n;
}
public static int cardComp(String left, String right) {
char l = left.charAt(1);
char r = right.charAt(1);
return(l-r);
}
public static int[] getAryMl(BufferedReader br)throws Exception {
int n = getInt(br);
int[] ary = new int[n];
for( int i=0 ; i < n ; i++ ) {
ary[i] = getInt(br);
}
return ary;
}
public static void putAry(int[] ary, int num) {
for( int i = 0; i < num ; i++ ) {
System.out.print(ary[i]);
if ( i < num-1) {
System.out.print(" ");
}
}
System.out.println("");
}
public static void putAry(int[] ary) {
putAry(ary, ary.length ) ;
}
public static boolean isPrime(int n) {
int r = (int)Math.sqrt((double)n)+1;
for( int j = 2 ; j < r ; j += 1) {
if ( n%j == 0 ) {
return false;
}
}
return true;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
17,
4,
18,
13,
17,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
8,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
8,
32
],
[
32,
33
],
[
33,
34
],
[
8,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
35,
40
],
[
40,
41
],
[
40,
42
],
[
35,
43
],
[
43,
44
],
[
44,
45
],
[
35,
46
],
[
47,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
50,
55
],
[
47,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
8,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
61,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
66,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
66,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
95,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
95,
100
],
[
77,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
107,
109
],
[
101,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
6,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
116,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
128,
130
],
[
122,
131
],
[
131,
132
],
[
122,
133
],
[
133,
134
]
] | [
"import java.util.*;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n,t;\n int nowt=0;\n ArrayList<P> list = new ArrayList<P>();\n n = sc.nextInt();\n t = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }\n while(list.size()!=0){\n P p = list.get(0);\n list.remove(0);\n if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }\n }\n }\n}\n\nclass P{\n String name;\n int t;\n public P(String s,int tt){\n name = s;\n t = tt;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n,t;\n int nowt=0;\n ArrayList<P> list = new ArrayList<P>();\n n = sc.nextInt();\n t = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }\n while(list.size()!=0){\n P p = list.get(0);\n list.remove(0);\n if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }\n }\n }\n}",
"Main",
"public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int n,t;\n int nowt=0;\n ArrayList<P> list = new ArrayList<P>();\n n = sc.nextInt();\n t = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }\n while(list.size()!=0){\n P p = list.get(0);\n list.remove(0);\n if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n,t;\n int nowt=0;\n ArrayList<P> list = new ArrayList<P>();\n n = sc.nextInt();\n t = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }\n while(list.size()!=0){\n P p = list.get(0);\n list.remove(0);\n if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n",
"n",
"t;",
"t",
"int nowt=0;",
"nowt",
"0",
"ArrayList<P> list = new ArrayList<P>();",
"list",
"new ArrayList<P>()",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"t = sc.nextInt()",
"t",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.nextLine()",
"sc.nextLine",
"sc",
"for(int i=0;i<n;i++){\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }",
"{\n String str[] = sc.nextLine().split(\" \");\n list.add(new P(str[0],Integer.parseInt(str[1])));\n }",
"String str[] = sc.nextLine().split(\" \");",
"str",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"list.add(new P(str[0],Integer.parseInt(str[1])))",
"list.add",
"list",
"new P(str[0],Integer.parseInt(str[1]))",
"while(list.size()!=0){\n P p = list.get(0);\n list.remove(0);\n if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }\n }",
"list.size()!=0",
"list.size()",
"list.size",
"list",
"0",
"{\n P p = list.get(0);\n list.remove(0);\n if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }\n }",
"P p = list.get(0);",
"p",
"list.get(0)",
"list.get",
"list",
"0",
"list.remove(0)",
"list.remove",
"list",
"0",
"if(p.t<=t){\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }else{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }",
"p.t<=t",
"p.t",
"p",
"p.t",
"t",
"{\n nowt+=p.t;\n System.out.println(p.name+\" \"+nowt);\n }",
"nowt+=p.t",
"nowt",
"p.t",
"p",
"p.t",
"System.out.println(p.name+\" \"+nowt)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name+\" \"+nowt",
"p.name+\" \"+nowt",
"p.name",
"p",
"p.name",
"\" \"",
"nowt",
"{\n p.t-=t;\n nowt+=t;\n list.add(p);\n }",
"p.t-=t",
"p.t",
"p",
"p.t",
"t",
"nowt+=t",
"nowt",
"t",
"list.add(p)",
"list.add",
"list",
"p",
"String args[]",
"args",
"class P{\n String name;\n int t;\n public P(String s,int tt){\n name = s;\n t = tt;\n }\n}",
"P",
"String name;",
"name",
"int t;",
"t",
"public P(String s,int tt){\n name = s;\n t = tt;\n }",
"P",
"{\n name = s;\n t = tt;\n }",
"name = s",
"name",
"s",
"t = tt",
"t",
"tt",
"String s",
"s",
"int tt",
"tt"
] | import java.util.*;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n,t;
int nowt=0;
ArrayList<P> list = new ArrayList<P>();
n = sc.nextInt();
t = sc.nextInt();
sc.nextLine();
for(int i=0;i<n;i++){
String str[] = sc.nextLine().split(" ");
list.add(new P(str[0],Integer.parseInt(str[1])));
}
while(list.size()!=0){
P p = list.get(0);
list.remove(0);
if(p.t<=t){
nowt+=p.t;
System.out.println(p.name+" "+nowt);
}else{
p.t-=t;
nowt+=t;
list.add(p);
}
}
}
}
class P{
String name;
int t;
public P(String s,int tt){
name = s;
t = tt;
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
41,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
14,
4,
18,
13,
30,
4,
18,
13,
20,
30,
4,
18,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
4,
18,
13,
17,
18,
13,
13,
18,
13,
13,
12,
13,
30,
4,
18,
20,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
18,
36,
13,
0,
18,
36,
13,
4,
18,
13,
17,
2,
18,
36,
13,
13,
29,
2,
13,
18,
36,
13,
23,
13,
12,
13,
30,
29,
2,
18,
36,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
190,
5
],
[
190,
6
],
[
6,
7
],
[
6,
8
],
[
190,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
11,
22
],
[
22,
23
],
[
22,
24
],
[
11,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
11,
42
],
[
42,
43
],
[
42,
44
],
[
11,
45
],
[
45,
46
],
[
45,
47
],
[
11,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
48,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
53,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
61,
64
],
[
53,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
65,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
11,
79
],
[
79,
80
],
[
79,
81
],
[
79,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
89,
93
],
[
93,
94
],
[
93,
95
],
[
89,
96
],
[
96,
97
],
[
96,
98
],
[
190,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
99,
105
],
[
105,
106
],
[
190,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
107,
111
],
[
111,
112
],
[
107,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
113,
126
],
[
126,
127
],
[
113,
128
],
[
128,
129
],
[
107,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
135,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
142,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
146,
150
],
[
132,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
154,
156
],
[
130,
157
],
[
157,
158
],
[
107,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
190,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
168,
172
],
[
172,
173
],
[
168,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
176,
182
],
[
182,
183
],
[
182,
184
],
[
174,
185
],
[
185,
186
],
[
174,
187
],
[
187,
188
],
[
0,
189
],
[
189,
190
],
[
189,
191
]
] | [
"import java.util.*;\n\npublic class Main {\n\n Scanner sc = new Scanner(System.in);\n\n class Process {\n final String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int time) {\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }\n\n public boolean isFinished() {\n return this.time == 0;\n }\n }\n\n class Result {\n final String name;\n final int finishedTime;\n public Result(String name, int time) {\n this.name = name;\n finishedTime = time;\n }\n }\n\n void solve() {\n // Input\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> que = new ArrayDeque<>();\n for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }\n\n // Solve\n List<Result> results = new ArrayList<>();\n int time = 0;\n while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }\n\n // Output\n for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }\n }\n\n public static void main(String[] args) {\n new Main().solve();\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n Scanner sc = new Scanner(System.in);\n\n class Process {\n final String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int time) {\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }\n\n public boolean isFinished() {\n return this.time == 0;\n }\n }\n\n class Result {\n final String name;\n final int finishedTime;\n public Result(String name, int time) {\n this.name = name;\n finishedTime = time;\n }\n }\n\n void solve() {\n // Input\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> que = new ArrayDeque<>();\n for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }\n\n // Solve\n List<Result> results = new ArrayList<>();\n int time = 0;\n while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }\n\n // Output\n for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }\n }\n\n public static void main(String[] args) {\n new Main().solve();\n }\n}",
"Main",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"void solve() {\n // Input\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> que = new ArrayDeque<>();\n for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }\n\n // Solve\n List<Result> results = new ArrayList<>();\n int time = 0;\n while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }\n\n // Output\n for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }\n }",
"solve",
"{\n // Input\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> que = new ArrayDeque<>();\n for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }\n\n // Solve\n List<Result> results = new ArrayList<>();\n int time = 0;\n while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }\n\n // Output\n for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }\n }",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Process> que = new ArrayDeque<>();",
"que",
"new ArrayDeque<>()",
"for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }",
"int i= 0;",
"int i= 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n que.add(new Process(sc.next(), sc.nextInt()));\n }",
"{\n que.add(new Process(sc.next(), sc.nextInt()));\n }",
"que.add(new Process(sc.next(), sc.nextInt()))",
"que.add",
"que",
"new Process(sc.next(), sc.nextInt())",
"List<Result> results = new ArrayList<>();",
"results",
"new ArrayList<>()",
"int time = 0;",
"time",
"0",
"while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }",
"Process top = que.poll();",
"top",
"que.poll()",
"que.poll",
"que",
"time += top.run(q)",
"time",
"top.run(q)",
"top.run",
"top",
"q",
"if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }",
"top.isFinished()",
"top.isFinished",
"top",
"{\n results.add(new Result(top.name, time));\n }",
"results.add(new Result(top.name, time))",
"results.add",
"results",
"new Result(top.name, time)",
"{\n que.add(top);\n }",
"que.add(top)",
"que.add",
"que",
"top",
"for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }",
"Result result",
"results",
"{\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }",
"{\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }",
"System.out.println(String.format(\"%s %d\", result.name, result.finishedTime))",
"System.out.println",
"System.out",
"System",
"System.out",
"String.format(\"%s %d\", result.name, result.finishedTime)",
"String.format",
"String",
"\"%s %d\"",
"result.name",
"result",
"result.name",
"result.finishedTime",
"result",
"result.finishedTime",
"public static void main(String[] args) {\n new Main().solve();\n }",
"main",
"{\n new Main().solve();\n }",
"new Main().solve()",
"new Main().solve",
"new Main()",
"String[] args",
"args",
"class Process {\n final String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int time) {\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }\n\n public boolean isFinished() {\n return this.time == 0;\n }\n }",
"Process",
"final String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Process",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public int run(int time) {\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }",
"run",
"{\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }",
"int pre = this.time;",
"pre",
"this.time",
"this",
"this.time",
"this.time = Math.max(0, this.time - time)",
"this.time",
"this",
"this.time",
"Math.max(0, this.time - time)",
"Math.max",
"Math",
"0",
"this.time - time",
"this.time",
"this",
"this.time",
"time",
"return pre - this.time;",
"pre - this.time",
"pre",
"this.time",
"this",
"this.time",
"int time",
"time",
"public boolean isFinished() {\n return this.time == 0;\n }",
"isFinished",
"{\n return this.time == 0;\n }",
"return this.time == 0;",
"this.time == 0",
"this.time",
"this",
"this.time",
"0",
"class Result {\n final String name;\n final int finishedTime;\n public Result(String name, int time) {\n this.name = name;\n finishedTime = time;\n }\n }",
"Result",
"final String name;",
"name",
"final int finishedTime;",
"finishedTime",
"public Result(String name, int time) {\n this.name = name;\n finishedTime = time;\n }",
"Result",
"{\n this.name = name;\n finishedTime = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"finishedTime = time",
"finishedTime",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n Scanner sc = new Scanner(System.in);\n\n class Process {\n final String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int time) {\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }\n\n public boolean isFinished() {\n return this.time == 0;\n }\n }\n\n class Result {\n final String name;\n final int finishedTime;\n public Result(String name, int time) {\n this.name = name;\n finishedTime = time;\n }\n }\n\n void solve() {\n // Input\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> que = new ArrayDeque<>();\n for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }\n\n // Solve\n List<Result> results = new ArrayList<>();\n int time = 0;\n while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }\n\n // Output\n for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }\n }\n\n public static void main(String[] args) {\n new Main().solve();\n }\n}",
"public class Main {\n\n Scanner sc = new Scanner(System.in);\n\n class Process {\n final String name;\n int time;\n public Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int time) {\n int pre = this.time;\n this.time = Math.max(0, this.time - time);\n return pre - this.time;\n }\n\n public boolean isFinished() {\n return this.time == 0;\n }\n }\n\n class Result {\n final String name;\n final int finishedTime;\n public Result(String name, int time) {\n this.name = name;\n finishedTime = time;\n }\n }\n\n void solve() {\n // Input\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> que = new ArrayDeque<>();\n for(int i= 0; i<n;i++) {\n que.add(new Process(sc.next(), sc.nextInt()));\n }\n\n // Solve\n List<Result> results = new ArrayList<>();\n int time = 0;\n while (!que.isEmpty()) {\n Process top = que.poll();\n time += top.run(q);\n if(top.isFinished()) {\n results.add(new Result(top.name, time));\n } else {\n que.add(top);\n }\n }\n\n // Output\n for(Result result : results) {\n System.out.println(String.format(\"%s %d\", result.name, result.finishedTime));\n }\n }\n\n public static void main(String[] args) {\n new Main().solve();\n }\n}",
"Main"
] | import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
class Process {
final String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public int run(int time) {
int pre = this.time;
this.time = Math.max(0, this.time - time);
return pre - this.time;
}
public boolean isFinished() {
return this.time == 0;
}
}
class Result {
final String name;
final int finishedTime;
public Result(String name, int time) {
this.name = name;
finishedTime = time;
}
}
void solve() {
// Input
int n = sc.nextInt();
int q = sc.nextInt();
Queue<Process> que = new ArrayDeque<>();
for(int i= 0; i<n;i++) {
que.add(new Process(sc.next(), sc.nextInt()));
}
// Solve
List<Result> results = new ArrayList<>();
int time = 0;
while (!que.isEmpty()) {
Process top = que.poll();
time += top.run(q);
if(top.isFinished()) {
results.add(new Result(top.name, time));
} else {
que.add(top);
}
}
// Output
for(Result result : results) {
System.out.println(String.format("%s %d", result.name, result.finishedTime));
}
}
public static void main(String[] args) {
new Main().solve();
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
17,
0,
13,
17,
0,
13,
17,
12,
13,
30,
14,
2,
13,
13,
29,
17,
29,
17,
12,
13,
30,
0,
18,
13,
13,
13,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
40,
13,
29,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
8,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
44,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
49,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
55,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
64,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
73,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
73,
78
],
[
55,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
79,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
6,
92
],
[
92,
93
],
[
0,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
94,
98
],
[
98,
99
],
[
94,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
100,
113
],
[
113,
114
],
[
100,
115
],
[
115,
116
],
[
0,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
117,
121
],
[
121,
122
],
[
117,
123
],
[
123,
124
],
[
117,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
132
],
[
132,
133
],
[
132,
134
],
[
127,
135
],
[
135,
136
],
[
135,
137
],
[
117,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
141,
147
],
[
147,
148
],
[
117,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
151,
157
],
[
157,
158
],
[
149,
159
],
[
159,
160
],
[
117,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
166,
168
],
[
163,
169
],
[
169,
170
],
[
163,
171
],
[
171,
172
]
] | [
"import java.util.*;\n\nclass Main{\n public static void main(String[] args) {\n Scanner in=new Scanner(System.in);\n myQueue que=new myQueue();\n \n int n=in.nextInt(),limit=in.nextInt(),sum=0;\n for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));\n\n while(!que.isEmpty()){\n process p=que.pop();\n if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }\n }\n }\n}\n\nclass process{\n String p;\n int time;\n\n process(String p,int time){\n this.p=p;\n this.time=time;\n }\n}\n\nclass myQueue{\n process array[];\n int top,tail;\n\n myQueue(){\n array=new process[1000000];\n top=1; tail=1;\n }\n\n boolean isEmpty(){\n if(top==tail)return true;\n else return false;\n }\n\n void push(process x){\n array[tail]=x;\n tail++;\n }\n\n process pop(){\n process res=array[top];\n top++;\n return res;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class Main{\n public static void main(String[] args) {\n Scanner in=new Scanner(System.in);\n myQueue que=new myQueue();\n \n int n=in.nextInt(),limit=in.nextInt(),sum=0;\n for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));\n\n while(!que.isEmpty()){\n process p=que.pop();\n if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner in=new Scanner(System.in);\n myQueue que=new myQueue();\n \n int n=in.nextInt(),limit=in.nextInt(),sum=0;\n for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));\n\n while(!que.isEmpty()){\n process p=que.pop();\n if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }\n }\n }",
"main",
"{\n Scanner in=new Scanner(System.in);\n myQueue que=new myQueue();\n \n int n=in.nextInt(),limit=in.nextInt(),sum=0;\n for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));\n\n while(!que.isEmpty()){\n process p=que.pop();\n if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }\n }\n }",
"Scanner in=new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"myQueue que=new myQueue();",
"que",
"new myQueue()",
"int n=in.nextInt()",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"limit=in.nextInt()",
"limit",
"in.nextInt()",
"in.nextInt",
"in",
"sum=0;",
"sum",
"0",
"for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"que.push(new process(in.next(), in.nextInt()));",
"que.push(new process(in.next(), in.nextInt()))",
"que.push",
"que",
"new process(in.next(), in.nextInt())",
"while(!que.isEmpty()){\n process p=que.pop();\n if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }\n }",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n process p=que.pop();\n if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }\n }",
"process p=que.pop();",
"p",
"que.pop()",
"que.pop",
"que",
"if(p.time<=limit){\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }\n else{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }",
"p.time<=limit",
"p.time",
"p",
"p.time",
"limit",
"{\n sum+=p.time;\n System.out.println(p.p+\" \"+sum);\n }",
"sum+=p.time",
"sum",
"p.time",
"p",
"p.time",
"System.out.println(p.p+\" \"+sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.p+\" \"+sum",
"p.p+\" \"+sum",
"p.p",
"p",
"p.p",
"\" \"",
"sum",
"{\n sum+=limit;\n p.time-=limit;\n que.push(p);\n }",
"sum+=limit",
"sum",
"limit",
"p.time-=limit",
"p.time",
"p",
"p.time",
"limit",
"que.push(p)",
"que.push",
"que",
"p",
"String[] args",
"args",
"class process{\n String p;\n int time;\n\n process(String p,int time){\n this.p=p;\n this.time=time;\n }\n}",
"process",
"String p;",
"p",
"int time;",
"time",
"process(String p,int time){\n this.p=p;\n this.time=time;\n }",
"process",
"{\n this.p=p;\n this.time=time;\n }",
"this.p=p",
"this.p",
"this",
"this.p",
"p",
"this.time=time",
"this.time",
"this",
"this.time",
"time",
"String p",
"p",
"int time",
"time",
"class myQueue{\n process array[];\n int top,tail;\n\n myQueue(){\n array=new process[1000000];\n top=1; tail=1;\n }\n\n boolean isEmpty(){\n if(top==tail)return true;\n else return false;\n }\n\n void push(process x){\n array[tail]=x;\n tail++;\n }\n\n process pop(){\n process res=array[top];\n top++;\n return res;\n }\n}",
"myQueue",
"process array[];",
"array",
"int top",
"top",
"tail;",
"tail",
"myQueue(){\n array=new process[1000000];\n top=1; tail=1;\n }",
"myQueue",
"{\n array=new process[1000000];\n top=1; tail=1;\n }",
"array=new process[1000000]",
"array",
"new process[1000000]",
"1000000",
"top=1",
"top",
"1",
"tail=1",
"tail",
"1",
"boolean isEmpty(){\n if(top==tail)return true;\n else return false;\n }",
"isEmpty",
"{\n if(top==tail)return true;\n else return false;\n }",
"if(top==tail)return true;\n else return false;",
"top==tail",
"top",
"tail",
"return true;",
"true",
"return false;",
"false",
"void push(process x){\n array[tail]=x;\n tail++;\n }",
"push",
"{\n array[tail]=x;\n tail++;\n }",
"array[tail]=x",
"array[tail]",
"array",
"tail",
"x",
"tail++",
"tail",
"process x",
"x",
"process pop(){\n process res=array[top];\n top++;\n return res;\n }",
"pop",
"{\n process res=array[top];\n top++;\n return res;\n }",
"process res=array[top];",
"res",
"array[top]",
"array",
"top",
"top++",
"top",
"return res;",
"res"
] | import java.util.*;
class Main{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
myQueue que=new myQueue();
int n=in.nextInt(),limit=in.nextInt(),sum=0;
for(int i=0;i<n;i++)que.push(new process(in.next(), in.nextInt()));
while(!que.isEmpty()){
process p=que.pop();
if(p.time<=limit){
sum+=p.time;
System.out.println(p.p+" "+sum);
}
else{
sum+=limit;
p.time-=limit;
que.push(p);
}
}
}
}
class process{
String p;
int time;
process(String p,int time){
this.p=p;
this.time=time;
}
}
class myQueue{
process array[];
int top,tail;
myQueue(){
array=new process[1000000];
top=1; tail=1;
}
boolean isEmpty(){
if(top==tail)return true;
else return false;
}
void push(process x){
array[tail]=x;
tail++;
}
process pop(){
process res=array[top];
top++;
return res;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
4,
18,
13,
13,
30,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
147,
11
],
[
147,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
20,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
31,
32
],
[
31,
33
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
14,
42
],
[
42,
43
],
[
42,
44
],
[
14,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
14,
62
],
[
62,
63
],
[
62,
64
],
[
14,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
65,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
70,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
70,
90
],
[
90,
91
],
[
90,
92
],
[
70,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
106,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
106,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
93,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
12,
120
],
[
120,
121
],
[
147,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
122,
126
],
[
126,
127
],
[
122,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
130,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
141,
142
],
[
141,
143
],
[
128,
144
],
[
144,
145
],
[
0,
146
],
[
146,
147
],
[
146,
148
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String[] values = scanner.nextLine().split(\" \");\n int n = Integer.parseInt(values[0]);\n int limit = Integer.parseInt(values[1]);\n\n Queue<Process> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }\n\n int elapsedTime = 0;\n while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }\n\n }\n\n private static class Process {\n String processName;\n int reamingTime;\n\n Process(String[] data) {\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }\n\n }\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String[] values = scanner.nextLine().split(\" \");\n int n = Integer.parseInt(values[0]);\n int limit = Integer.parseInt(values[1]);\n\n Queue<Process> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }\n\n int elapsedTime = 0;\n while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }\n\n }\n\n private static class Process {\n String processName;\n int reamingTime;\n\n Process(String[] data) {\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }\n\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String[] values = scanner.nextLine().split(\" \");\n int n = Integer.parseInt(values[0]);\n int limit = Integer.parseInt(values[1]);\n\n Queue<Process> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }\n\n int elapsedTime = 0;\n while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }\n\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n\n String[] values = scanner.nextLine().split(\" \");\n int n = Integer.parseInt(values[0]);\n int limit = Integer.parseInt(values[1]);\n\n Queue<Process> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }\n\n int elapsedTime = 0;\n while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }\n\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"String[] values = scanner.nextLine().split(\" \");",
"values",
"scanner.nextLine().split(\" \")",
"scanner.nextLine().split",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"\" \"",
"int n = Integer.parseInt(values[0]);",
"n",
"Integer.parseInt(values[0])",
"Integer.parseInt",
"Integer",
"values[0]",
"values",
"0",
"int limit = Integer.parseInt(values[1]);",
"limit",
"Integer.parseInt(values[1])",
"Integer.parseInt",
"Integer",
"values[1]",
"values",
"1",
"Queue<Process> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }",
"{\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }",
"queue.add(new Process(scanner.nextLine().split(\" \")))",
"queue.add",
"queue",
"new Process(scanner.nextLine().split(\" \"))",
"int elapsedTime = 0;",
"elapsedTime",
"0",
"while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }",
"Process process = queue.poll();",
"process",
"queue.poll()",
"queue.poll",
"queue",
"int processTime = Math.min(process.reamingTime, limit);",
"processTime",
"Math.min(process.reamingTime, limit)",
"Math.min",
"Math",
"process.reamingTime",
"process",
"process.reamingTime",
"limit",
"process.reamingTime -= processTime",
"process.reamingTime",
"process",
"process.reamingTime",
"processTime",
"elapsedTime += processTime",
"elapsedTime",
"processTime",
"if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }",
"process.reamingTime == 0",
"process.reamingTime",
"process",
"process.reamingTime",
"0",
"{\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n }",
"System.out.println(process.processName + \" \" + Integer.toString(elapsedTime))",
"System.out.println",
"System.out",
"System",
"System.out",
"process.processName + \" \" + Integer.toString(elapsedTime)",
"process.processName + \" \" + Integer.toString(elapsedTime)",
"process.processName",
"process",
"process.processName",
"\" \"",
"Integer.toString(elapsedTime)",
"Integer.toString",
"Integer",
"elapsedTime",
"{\n queue.add(process);\n }",
"queue.add(process)",
"queue.add",
"queue",
"process",
"String[] args",
"args",
"private static class Process {\n String processName;\n int reamingTime;\n\n Process(String[] data) {\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }\n\n }",
"Process",
"String processName;",
"processName",
"int reamingTime;",
"reamingTime",
"Process(String[] data) {\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }",
"Process",
"{\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }",
"processName = data[0]",
"processName",
"data[0]",
"data",
"0",
"reamingTime = Integer.parseInt(data[1])",
"reamingTime",
"Integer.parseInt(data[1])",
"Integer.parseInt",
"Integer",
"data[1]",
"data",
"1",
"String[] data",
"data",
"public class Main {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String[] values = scanner.nextLine().split(\" \");\n int n = Integer.parseInt(values[0]);\n int limit = Integer.parseInt(values[1]);\n\n Queue<Process> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }\n\n int elapsedTime = 0;\n while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }\n\n }\n\n private static class Process {\n String processName;\n int reamingTime;\n\n Process(String[] data) {\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }\n\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n\n String[] values = scanner.nextLine().split(\" \");\n int n = Integer.parseInt(values[0]);\n int limit = Integer.parseInt(values[1]);\n\n Queue<Process> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(scanner.nextLine().split(\" \")));\n }\n\n int elapsedTime = 0;\n while (!queue.isEmpty()) {\n Process process = queue.poll();\n int processTime = Math.min(process.reamingTime, limit);\n process.reamingTime -= processTime;\n elapsedTime += processTime;\n if (process.reamingTime == 0) {\n System.out.println(process.processName + \" \" + Integer.toString(elapsedTime));\n } else {\n queue.add(process);\n }\n }\n\n }\n\n private static class Process {\n String processName;\n int reamingTime;\n\n Process(String[] data) {\n processName = data[0];\n reamingTime = Integer.parseInt(data[1]);\n }\n\n }\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] values = scanner.nextLine().split(" ");
int n = Integer.parseInt(values[0]);
int limit = Integer.parseInt(values[1]);
Queue<Process> queue = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
queue.add(new Process(scanner.nextLine().split(" ")));
}
int elapsedTime = 0;
while (!queue.isEmpty()) {
Process process = queue.poll();
int processTime = Math.min(process.reamingTime, limit);
process.reamingTime -= processTime;
elapsedTime += processTime;
if (process.reamingTime == 0) {
System.out.println(process.processName + " " + Integer.toString(elapsedTime));
} else {
queue.add(process);
}
}
}
private static class Process {
String processName;
int reamingTime;
Process(String[] data) {
processName = data[0];
reamingTime = Integer.parseInt(data[1]);
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
41,
13,
20,
17,
41,
13,
20,
41,
13,
20,
41,
13,
20,
0,
13,
2,
17,
4,
18,
13,
0,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
0,
13,
17,
30,
30,
0,
13,
18,
13,
13,
4,
18,
13,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
0,
13,
17,
30,
30,
0,
13,
4,
18,
13,
18,
13,
13,
4,
18,
13,
13,
0,
13,
17,
42,
17,
30,
14,
4,
18,
13,
30,
3,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
2,
13,
13,
17,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
11,
14
],
[
14,
15
],
[
11,
16
],
[
16,
17
],
[
11,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
11,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
11,
27
],
[
27,
28
],
[
27,
29
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
11,
37
],
[
37,
38
],
[
37,
39
],
[
11,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
11,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
11,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
70,
71
],
[
11,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
72,
77
],
[
77,
78
],
[
77,
79
],
[
72,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
72,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
85,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
11,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
100,
101
],
[
100,
102
],
[
95,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
95,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
114,
115
],
[
114,
116
],
[
108,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
11,
121
],
[
121,
122
],
[
121,
123
],
[
11,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
127,
131
],
[
131,
132
],
[
126,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
126,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
141,
142
],
[
126,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
143,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
153,
158
],
[
159,
159
],
[
159,
160
],
[
159,
161
],
[
159,
162
],
[
143,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
167,
168
],
[
168,
169
],
[
167,
170
],
[
170,
171
],
[
170,
172
],
[
163,
173
],
[
173,
174
],
[
174,
175
],
[
173,
176
],
[
9,
177
],
[
177,
178
]
] | [
"import java.util.*;\nimport java.io.*;\nclass Main{\n public static void main(String args[]) throws IOException {\n\t\n\tint i,j,n,q,time=0,a;\n\tString c;\n\tString array[] = new String[100000];\n\tScanner scan = new Scanner(System.in);\n\tQueue<Integer> que = new ArrayDeque<Integer>();\n\tQueue<String> ques = new ArrayDeque<String>();\n\t\n\tn = 2*scan.nextInt();\n\tq = scan.nextInt();\n\t\n\tfor(i=0;i<n;i++){\n\t array[i] = scan.next();\n\t}\n\tfor(i=0;i<n;i+=2){\n\t c = array[i];\n\t ques.add(c);\n\t}\n\tfor(i=1;i<n;i+=2){\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}\n\t\n\ti=1;\n\twhile(true){\n\t if(que.isEmpty()){break;}\n\t //if(ques.isEmpty()){break;}\n\t a = que.remove();\n\t c = ques.remove();\n\t if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }\n\t}\n\t\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"class Main{\n public static void main(String args[]) throws IOException {\n\t\n\tint i,j,n,q,time=0,a;\n\tString c;\n\tString array[] = new String[100000];\n\tScanner scan = new Scanner(System.in);\n\tQueue<Integer> que = new ArrayDeque<Integer>();\n\tQueue<String> ques = new ArrayDeque<String>();\n\t\n\tn = 2*scan.nextInt();\n\tq = scan.nextInt();\n\t\n\tfor(i=0;i<n;i++){\n\t array[i] = scan.next();\n\t}\n\tfor(i=0;i<n;i+=2){\n\t c = array[i];\n\t ques.add(c);\n\t}\n\tfor(i=1;i<n;i+=2){\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}\n\t\n\ti=1;\n\twhile(true){\n\t if(que.isEmpty()){break;}\n\t //if(ques.isEmpty()){break;}\n\t a = que.remove();\n\t c = ques.remove();\n\t if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }\n\t}\n\t\n }\n}",
"Main",
"public static void main(String args[]) throws IOException {\n\t\n\tint i,j,n,q,time=0,a;\n\tString c;\n\tString array[] = new String[100000];\n\tScanner scan = new Scanner(System.in);\n\tQueue<Integer> que = new ArrayDeque<Integer>();\n\tQueue<String> ques = new ArrayDeque<String>();\n\t\n\tn = 2*scan.nextInt();\n\tq = scan.nextInt();\n\t\n\tfor(i=0;i<n;i++){\n\t array[i] = scan.next();\n\t}\n\tfor(i=0;i<n;i+=2){\n\t c = array[i];\n\t ques.add(c);\n\t}\n\tfor(i=1;i<n;i+=2){\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}\n\t\n\ti=1;\n\twhile(true){\n\t if(que.isEmpty()){break;}\n\t //if(ques.isEmpty()){break;}\n\t a = que.remove();\n\t c = ques.remove();\n\t if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }\n\t}\n\t\n }",
"main",
"{\n\t\n\tint i,j,n,q,time=0,a;\n\tString c;\n\tString array[] = new String[100000];\n\tScanner scan = new Scanner(System.in);\n\tQueue<Integer> que = new ArrayDeque<Integer>();\n\tQueue<String> ques = new ArrayDeque<String>();\n\t\n\tn = 2*scan.nextInt();\n\tq = scan.nextInt();\n\t\n\tfor(i=0;i<n;i++){\n\t array[i] = scan.next();\n\t}\n\tfor(i=0;i<n;i+=2){\n\t c = array[i];\n\t ques.add(c);\n\t}\n\tfor(i=1;i<n;i+=2){\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}\n\t\n\ti=1;\n\twhile(true){\n\t if(que.isEmpty()){break;}\n\t //if(ques.isEmpty()){break;}\n\t a = que.remove();\n\t c = ques.remove();\n\t if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }\n\t}\n\t\n }",
"int i",
"i",
"j",
"j",
"n",
"n",
"q",
"q",
"time=0",
"time",
"0",
"a;",
"a",
"String c;",
"c",
"String array[] = new String[100000];",
"array",
"new String[100000]",
"100000",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"Queue<Integer> que = new ArrayDeque<Integer>();",
"que",
"new ArrayDeque<Integer>()",
"Queue<String> ques = new ArrayDeque<String>();",
"ques",
"new ArrayDeque<String>()",
"n = 2*scan.nextInt()",
"n",
"2*scan.nextInt()",
"2",
"scan.nextInt()",
"scan.nextInt",
"scan",
"q = scan.nextInt()",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(i=0;i<n;i++){\n\t array[i] = scan.next();\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t array[i] = scan.next();\n\t}",
"{\n\t array[i] = scan.next();\n\t}",
"array[i] = scan.next()",
"array[i]",
"array",
"i",
"scan.next()",
"scan.next",
"scan",
"for(i=0;i<n;i+=2){\n\t c = array[i];\n\t ques.add(c);\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i+=2",
"i+=2",
"i",
"2",
"{\n\t c = array[i];\n\t ques.add(c);\n\t}",
"{\n\t c = array[i];\n\t ques.add(c);\n\t}",
"c = array[i]",
"c",
"array[i]",
"array",
"i",
"ques.add(c)",
"ques.add",
"ques",
"c",
"for(i=1;i<n;i+=2){\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}",
"i=1;",
"i=1",
"i",
"1",
"i<n",
"i",
"n",
"i+=2",
"i+=2",
"i",
"2",
"{\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}",
"{\n\t a = Integer.parseInt(array[i]);\n\t que.add(a);\n\t}",
"a = Integer.parseInt(array[i])",
"a",
"Integer.parseInt(array[i])",
"Integer.parseInt",
"Integer",
"array[i]",
"array",
"i",
"que.add(a)",
"que.add",
"que",
"a",
"i=1",
"i",
"1",
"while(true){\n\t if(que.isEmpty()){break;}\n\t //if(ques.isEmpty()){break;}\n\t a = que.remove();\n\t c = ques.remove();\n\t if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }\n\t}",
"true",
"{\n\t if(que.isEmpty()){break;}\n\t //if(ques.isEmpty()){break;}\n\t a = que.remove();\n\t c = ques.remove();\n\t if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }\n\t}",
"if(que.isEmpty()){break;}",
"que.isEmpty()",
"que.isEmpty",
"que",
"{break;}",
"break;",
"a = que.remove()",
"a",
"que.remove()",
"que.remove",
"que",
"c = ques.remove()",
"c",
"ques.remove()",
"ques.remove",
"ques",
"if(a-q<=0){\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }\n\t else {\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }",
"a-q<=0",
"a-q",
"a",
"q",
"0",
"{\n\t\ttime += a;\n\t\tSystem.out.println(c+\" \"+time);\n\t }",
"time += a",
"time",
"a",
"System.out.println(c+\" \"+time)",
"System.out.println",
"System.out",
"System",
"System.out",
"c+\" \"+time",
"c+\" \"+time",
"c",
"\" \"",
"time",
"{\n\t\ttime += q;\n\t\tque.add(a-q);\n\t\tques.add(c);\n\t }",
"time += q",
"time",
"q",
"que.add(a-q)",
"que.add",
"que",
"a-q",
"a",
"q",
"ques.add(c)",
"ques.add",
"ques",
"c",
"String args[]",
"args"
] | import java.util.*;
import java.io.*;
class Main{
public static void main(String args[]) throws IOException {
int i,j,n,q,time=0,a;
String c;
String array[] = new String[100000];
Scanner scan = new Scanner(System.in);
Queue<Integer> que = new ArrayDeque<Integer>();
Queue<String> ques = new ArrayDeque<String>();
n = 2*scan.nextInt();
q = scan.nextInt();
for(i=0;i<n;i++){
array[i] = scan.next();
}
for(i=0;i<n;i+=2){
c = array[i];
ques.add(c);
}
for(i=1;i<n;i+=2){
a = Integer.parseInt(array[i]);
que.add(a);
}
i=1;
while(true){
if(que.isEmpty()){break;}
//if(ques.isEmpty()){break;}
a = que.remove();
c = ques.remove();
if(a-q<=0){
time += a;
System.out.println(c+" "+time);
}
else {
time += q;
que.add(a-q);
ques.add(c);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
17,
13,
41,
13,
4,
18,
13,
4,
18,
13,
2,
13,
17,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
17,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
13,
17,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
14,
2,
4,
18,
13,
17,
13,
30,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
2,
4,
18,
13,
17,
13,
4,
18,
13,
17,
0,
13,
13,
30,
0,
13,
4,
18,
13,
17,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
17,
13,
4,
18,
13,
17,
4,
18,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
170,
5
],
[
170,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
19,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
28,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
35,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
41,
42
],
[
41,
43
],
[
8,
44
],
[
44,
45
],
[
44,
46
],
[
8,
47
],
[
47,
48
],
[
47,
49
],
[
8,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
55,
56
],
[
55,
57
],
[
50,
58
],
[
58,
59
],
[
59,
60
],
[
50,
61
],
[
62,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
62,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
62,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
77,
81
],
[
62,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
91,
92
],
[
91,
93
],
[
8,
94
],
[
94,
95
],
[
94,
96
],
[
8,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
98,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
105,
110
],
[
104,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
111,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
126,
131
],
[
111,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
111,
136
],
[
136,
137
],
[
136,
138
],
[
104,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
139,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
152,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
153,
156
],
[
152,
157
],
[
152,
158
],
[
139,
159
],
[
159,
160
],
[
160,
161
],
[
159,
162
],
[
139,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
6,
167
],
[
167,
168
],
[
0,
169
],
[
169,
170
],
[
169,
171
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma = line.indexOf(\" \");\n int jobAmount = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }\n \n \n \n int nowTime=0;\n \n while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma = line.indexOf(\" \");\n int jobAmount = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }\n \n \n \n int nowTime=0;\n \n while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma = line.indexOf(\" \");\n int jobAmount = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }\n \n \n \n int nowTime=0;\n \n while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma = line.indexOf(\" \");\n int jobAmount = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }\n \n \n \n int nowTime=0;\n \n while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String line = sc.nextLine();",
"line",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int ma = line.indexOf(\" \");",
"ma",
"line.indexOf(\" \")",
"line.indexOf",
"line",
"\" \"",
"int jobAmount = Integer.parseInt(line.substring(0, ma));",
"jobAmount",
"Integer.parseInt(line.substring(0, ma))",
"Integer.parseInt",
"Integer",
"line.substring(0, ma)",
"line.substring",
"line",
"0",
"ma",
"int quantum = Integer.parseInt(line.substring(ma+1));",
"quantum",
"Integer.parseInt(line.substring(ma+1))",
"Integer.parseInt",
"Integer",
"line.substring(ma+1)",
"line.substring",
"line",
"ma+1",
"ma",
"1",
"ArrayList<String> lingerJob = new ArrayList<String>();",
"lingerJob",
"new ArrayList<String>()",
"ArrayList<Integer> lingerTime = new ArrayList<Integer>();",
"lingerTime",
"new ArrayList<Integer>()",
"for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<jobAmount",
"i",
"jobAmount",
"i++",
"i++",
"i",
"{\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }",
"{\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }",
"String line2 = sc.nextLine();",
"line2",
"sc.nextLine()",
"sc.nextLine",
"sc",
"int ma2 = line2.indexOf(\" \");",
"ma2",
"line2.indexOf(\" \")",
"line2.indexOf",
"line2",
"\" \"",
"lingerJob.add(line2.substring(0, ma2))",
"lingerJob.add",
"lingerJob",
"line2.substring(0, ma2)",
"line2.substring",
"line2",
"0",
"ma2",
"lingerTime.add(Integer.parseInt(line2.substring(ma2+1)))",
"lingerTime.add",
"lingerTime",
"Integer.parseInt(line2.substring(ma2+1))",
"Integer.parseInt",
"Integer",
"line2.substring(ma2+1)",
"line2.substring",
"line2",
"ma2+1",
"ma2",
"1",
"int nowTime=0;",
"nowTime",
"0",
"while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }",
"lingerJob.size()!=0",
"lingerJob.size()",
"lingerJob.size",
"lingerJob",
"0",
"{\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }",
"if(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}",
"lingerTime.get(0)>quantum",
"lingerTime.get(0)",
"lingerTime.get",
"lingerTime",
"0",
"quantum",
"{\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}",
"lingerJob.add(lingerJob.get(0))",
"lingerJob.add",
"lingerJob",
"lingerJob.get(0)",
"lingerJob.get",
"lingerJob",
"0",
"lingerJob.remove(0)",
"lingerJob.remove",
"lingerJob",
"0",
"lingerTime.add(lingerTime.get(0)-quantum)",
"lingerTime.add",
"lingerTime",
"lingerTime.get(0)-quantum",
"lingerTime.get(0)",
"lingerTime.get",
"lingerTime",
"0",
"quantum",
"lingerTime.remove(0)",
"lingerTime.remove",
"lingerTime",
"0",
"nowTime+=quantum",
"nowTime",
"quantum",
"{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}",
"nowTime+=lingerTime.get(0)",
"nowTime",
"lingerTime.get(0)",
"lingerTime.get",
"lingerTime",
"0",
"System.out.println(lingerJob.get(0)+\" \"+nowTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"lingerJob.get(0)+\" \"+nowTime",
"lingerJob.get(0)+\" \"+nowTime",
"lingerJob.get(0)",
"lingerJob.get",
"lingerJob",
"0",
"\" \"",
"nowTime",
"lingerJob.remove(0)",
"lingerJob.remove",
"lingerJob",
"0",
"lingerTime.remove(0)",
"lingerTime.remove",
"lingerTime",
"0",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma = line.indexOf(\" \");\n int jobAmount = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }\n \n \n \n int nowTime=0;\n \n while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n String line = sc.nextLine();\n int ma = line.indexOf(\" \");\n int jobAmount = Integer.parseInt(line.substring(0, ma));\n int quantum = Integer.parseInt(line.substring(ma+1));\n \n ArrayList<String> lingerJob = new ArrayList<String>();\n ArrayList<Integer> lingerTime = new ArrayList<Integer>();\n \n for(int i=0;i<jobAmount;i++){\n \tString line2 = sc.nextLine();\n \tint ma2 = line2.indexOf(\" \");\n \t\n \tlingerJob.add(line2.substring(0, ma2));\n \tlingerTime.add(Integer.parseInt(line2.substring(ma2+1)));\n }\n \n \n \n int nowTime=0;\n \n while(lingerJob.size()!=0){\n \t\n \tif(lingerTime.get(0)>quantum){\n \t\tlingerJob.add(lingerJob.get(0));\n \t\tlingerJob.remove(0);\n \t\tlingerTime.add(lingerTime.get(0)-quantum);\n \t\tlingerTime.remove(0);\n \t\tnowTime+=quantum; \t\t\n \t}else{\n \t\tnowTime+=lingerTime.get(0);\n \t\tSystem.out.println(lingerJob.get(0)+\" \"+nowTime);\n \t\tlingerJob.remove(0);\n \t\tlingerTime.remove(0); \t\t\n \t}\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = sc.nextLine();
int ma = line.indexOf(" ");
int jobAmount = Integer.parseInt(line.substring(0, ma));
int quantum = Integer.parseInt(line.substring(ma+1));
ArrayList<String> lingerJob = new ArrayList<String>();
ArrayList<Integer> lingerTime = new ArrayList<Integer>();
for(int i=0;i<jobAmount;i++){
String line2 = sc.nextLine();
int ma2 = line2.indexOf(" ");
lingerJob.add(line2.substring(0, ma2));
lingerTime.add(Integer.parseInt(line2.substring(ma2+1)));
}
int nowTime=0;
while(lingerJob.size()!=0){
if(lingerTime.get(0)>quantum){
lingerJob.add(lingerJob.get(0));
lingerJob.remove(0);
lingerTime.add(lingerTime.get(0)-quantum);
lingerTime.remove(0);
nowTime+=quantum;
}else{
nowTime+=lingerTime.get(0);
System.out.println(lingerJob.get(0)+" "+nowTime);
lingerJob.remove(0);
lingerTime.remove(0);
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
0,
18,
13,
13,
20,
0,
18,
18,
13,
13,
13,
18,
13,
17,
0,
18,
18,
13,
13,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
0,
10
],
[
145,
11
],
[
145,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
14,
35
],
[
35,
36
],
[
36,
37
],
[
14,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
53,
58
],
[
50,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
50,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
50,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
82,
83
],
[
82,
84
],
[
50,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
88,
89
],
[
88,
90
],
[
14,
91
],
[
91,
92
],
[
91,
93
],
[
14,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
94,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
99,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
105,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
111,
121
],
[
121,
122
],
[
121,
123
],
[
105,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
124,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
136,
141
],
[
12,
142
],
[
142,
143
],
[
0,
144
],
[
144,
145
],
[
144,
146
]
] | [
"import java.util.*;\n\nclass CPU{\n int time;\n String name;\n}\n\npublic class Main {\n public static void main(String[] Args){\n Scanner sc = new Scanner(System.in);\n Queue<CPU> que = new LinkedList<>();\n int n = sc.nextInt();\n CPU[] cc = new CPU[n];\n int q = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }\n int tot=0;\n while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }\n }\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"class CPU{\n int time;\n String name;\n}",
"CPU",
"int time;",
"time",
"String name;",
"name",
"public class Main {\n public static void main(String[] Args){\n Scanner sc = new Scanner(System.in);\n Queue<CPU> que = new LinkedList<>();\n int n = sc.nextInt();\n CPU[] cc = new CPU[n];\n int q = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }\n int tot=0;\n while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }\n }\n\n}",
"Main",
"public static void main(String[] Args){\n Scanner sc = new Scanner(System.in);\n Queue<CPU> que = new LinkedList<>();\n int n = sc.nextInt();\n CPU[] cc = new CPU[n];\n int q = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }\n int tot=0;\n while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n Queue<CPU> que = new LinkedList<>();\n int n = sc.nextInt();\n CPU[] cc = new CPU[n];\n int q = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }\n int tot=0;\n while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<CPU> que = new LinkedList<>();",
"que",
"new LinkedList<>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"CPU[] cc = new CPU[n];",
"cc",
"new CPU[n]",
"n",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.nextLine()",
"sc.nextLine",
"sc",
"for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }",
"{\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }",
"String[] tt = sc.nextLine().split(\" \");",
"tt",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"cc[i] = new CPU()",
"cc[i]",
"cc",
"i",
"new CPU()",
"cc[i].name = tt[0]",
"cc[i].name",
"cc[i]",
"cc",
"i",
"cc[i].name",
"tt[0]",
"tt",
"0",
"cc[i].time = Integer.parseInt(tt[1])",
"cc[i].time",
"cc[i]",
"cc",
"i",
"cc[i].time",
"Integer.parseInt(tt[1])",
"Integer.parseInt",
"Integer",
"tt[1]",
"tt",
"1",
"que.add(cc[i])",
"que.add",
"que",
"cc[i]",
"cc",
"i",
"int tot=0;",
"tot",
"0",
"while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }",
"CPU now = que.poll();",
"now",
"que.poll()",
"que.poll",
"que",
"if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }",
"now.time > q",
"now.time",
"now",
"now.time",
"q",
"{\n now.time -= q;\n que.add(now);\n tot += q;\n }",
"now.time -= q",
"now.time",
"now",
"now.time",
"q",
"que.add(now)",
"que.add",
"que",
"now",
"tot += q",
"tot",
"q",
"{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }",
"tot += now.time",
"tot",
"now.time",
"now",
"now.time",
"System.out.println(now.name + \" \" + tot)",
"System.out.println",
"System.out",
"System",
"System.out",
"now.name + \" \" + tot",
"now.name + \" \" + tot",
"now.name",
"now",
"now.name",
"\" \"",
"tot",
"String[] Args",
"Args",
"public class Main {\n public static void main(String[] Args){\n Scanner sc = new Scanner(System.in);\n Queue<CPU> que = new LinkedList<>();\n int n = sc.nextInt();\n CPU[] cc = new CPU[n];\n int q = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }\n int tot=0;\n while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }\n }\n\n}",
"public class Main {\n public static void main(String[] Args){\n Scanner sc = new Scanner(System.in);\n Queue<CPU> que = new LinkedList<>();\n int n = sc.nextInt();\n CPU[] cc = new CPU[n];\n int q = sc.nextInt();\n sc.nextLine();\n for(int i=0;i<n;i++){\n String[] tt = sc.nextLine().split(\" \");\n cc[i] = new CPU();\n cc[i].name = tt[0];\n cc[i].time = Integer.parseInt(tt[1]);\n que.add(cc[i]);\n }\n int tot=0;\n while(!que.isEmpty()){\n CPU now = que.poll();//返回第一个元素,并删除\n if(now.time > q){\n now.time -= q;\n que.add(now);\n tot += q;\n }\n else{\n tot += now.time;\n System.out.println(now.name + \" \" + tot);\n }\n }\n }\n\n}",
"Main"
] | import java.util.*;
class CPU{
int time;
String name;
}
public class Main {
public static void main(String[] Args){
Scanner sc = new Scanner(System.in);
Queue<CPU> que = new LinkedList<>();
int n = sc.nextInt();
CPU[] cc = new CPU[n];
int q = sc.nextInt();
sc.nextLine();
for(int i=0;i<n;i++){
String[] tt = sc.nextLine().split(" ");
cc[i] = new CPU();
cc[i].name = tt[0];
cc[i].time = Integer.parseInt(tt[1]);
que.add(cc[i]);
}
int tot=0;
while(!que.isEmpty()){
CPU now = que.poll();//返回第一个元素,并删除
if(now.time > q){
now.time -= q;
que.add(now);
tot += q;
}
else{
tot += now.time;
System.out.println(now.name + " " + tot);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
20,
2,
4,
18,
13,
18,
13,
17,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
4,
18,
13,
18,
13,
17,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
13,
4,
18,
18,
13,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
42,
40,
4,
18,
13,
30,
14,
2,
2,
13,
4,
18,
13,
17,
30,
4,
18,
13,
2,
40,
17,
2,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
170,
11
],
[
170,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
14,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
14,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
14,
38
],
[
38,
39
],
[
38,
40
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
41,
48
],
[
14,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
54,
55
],
[
54,
56
],
[
14,
57
],
[
57,
58
],
[
57,
59
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
63,
65
],
[
14,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
76,
77
],
[
76,
78
],
[
66,
79
],
[
79,
80
],
[
80,
81
],
[
66,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
89,
90
],
[
83,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
93,
98
],
[
83,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
102,
103
],
[
102,
104
],
[
83,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
108,
111
],
[
111,
112
],
[
111,
113
],
[
14,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
114,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
121,
127
],
[
120,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
128,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
143,
144
],
[
144,
145
],
[
128,
146
],
[
146,
147
],
[
146,
148
],
[
120,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
161,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
161,
165
],
[
161,
166
],
[
12,
167
],
[
167,
168
],
[
0,
169
],
[
169,
170
],
[
169,
171
]
] | [
"import java.util.Scanner;\nimport java.util.LinkedList; \nimport java.util.Queue; \n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint ts = 0;\n\t\t\n\t\tQueue<Integer> qN = new LinkedList<>(); \n\t\tQueue<String> qP = new LinkedList<>(); \n\t\t\n\t\tString line = sc.nextLine();\n\t\t\n\t\tString[] lineList = line.split(\" \");\n\t\tString[] itemsList = new String[Integer.parseInt(lineList[0])*2];\n\t\t\n\t\tint q = Integer.parseInt(lineList[1]);\n\t\t\n\t\tString[] items = new String[Integer.parseInt(lineList[0])];\n\t\t\n\t\t//add everything into queues\n\t\tfor(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}\n\t\t\n\t\twhile(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint ts = 0;\n\t\t\n\t\tQueue<Integer> qN = new LinkedList<>(); \n\t\tQueue<String> qP = new LinkedList<>(); \n\t\t\n\t\tString line = sc.nextLine();\n\t\t\n\t\tString[] lineList = line.split(\" \");\n\t\tString[] itemsList = new String[Integer.parseInt(lineList[0])*2];\n\t\t\n\t\tint q = Integer.parseInt(lineList[1]);\n\t\t\n\t\tString[] items = new String[Integer.parseInt(lineList[0])];\n\t\t\n\t\t//add everything into queues\n\t\tfor(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}\n\t\t\n\t\twhile(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint ts = 0;\n\t\t\n\t\tQueue<Integer> qN = new LinkedList<>(); \n\t\tQueue<String> qP = new LinkedList<>(); \n\t\t\n\t\tString line = sc.nextLine();\n\t\t\n\t\tString[] lineList = line.split(\" \");\n\t\tString[] itemsList = new String[Integer.parseInt(lineList[0])*2];\n\t\t\n\t\tint q = Integer.parseInt(lineList[1]);\n\t\t\n\t\tString[] items = new String[Integer.parseInt(lineList[0])];\n\t\t\n\t\t//add everything into queues\n\t\tfor(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}\n\t\t\n\t\twhile(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint ts = 0;\n\t\t\n\t\tQueue<Integer> qN = new LinkedList<>(); \n\t\tQueue<String> qP = new LinkedList<>(); \n\t\t\n\t\tString line = sc.nextLine();\n\t\t\n\t\tString[] lineList = line.split(\" \");\n\t\tString[] itemsList = new String[Integer.parseInt(lineList[0])*2];\n\t\t\n\t\tint q = Integer.parseInt(lineList[1]);\n\t\t\n\t\tString[] items = new String[Integer.parseInt(lineList[0])];\n\t\t\n\t\t//add everything into queues\n\t\tfor(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}\n\t\t\n\t\twhile(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int ts = 0;",
"ts",
"0",
"Queue<Integer> qN = new LinkedList<>();",
"qN",
"new LinkedList<>()",
"Queue<String> qP = new LinkedList<>();",
"qP",
"new LinkedList<>()",
"String line = sc.nextLine();",
"line",
"sc.nextLine()",
"sc.nextLine",
"sc",
"String[] lineList = line.split(\" \");",
"lineList",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"String[] itemsList = new String[Integer.parseInt(lineList[0])*2];",
"itemsList",
"new String[Integer.parseInt(lineList[0])*2]",
"Integer.parseInt(lineList[0])*2",
"Integer.parseInt(lineList[0])",
"Integer.parseInt",
"Integer",
"lineList[0]",
"lineList",
"0",
"2",
"int q = Integer.parseInt(lineList[1]);",
"q",
"Integer.parseInt(lineList[1])",
"Integer.parseInt",
"Integer",
"lineList[1]",
"lineList",
"1",
"String[] items = new String[Integer.parseInt(lineList[0])];",
"items",
"new String[Integer.parseInt(lineList[0])]",
"Integer.parseInt(lineList[0])",
"Integer.parseInt",
"Integer",
"lineList[0]",
"lineList",
"0",
"for(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < Integer.parseInt(lineList[0])",
"i",
"Integer.parseInt(lineList[0])",
"Integer.parseInt",
"Integer",
"lineList[0]",
"lineList",
"0",
"i++",
"i++",
"i",
"{\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}",
"{\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}",
"items[i] = sc.nextLine()",
"items[i]",
"items",
"i",
"sc.nextLine()",
"sc.nextLine",
"sc",
"itemsList = items[i].split(\" \")",
"itemsList",
"items[i].split(\" \")",
"items[i].split",
"items[i]",
"items",
"i",
"\" \"",
"qP.add(itemsList[0])",
"qP.add",
"qP",
"itemsList[0]",
"itemsList",
"0",
"qN.add(Integer.parseInt(itemsList[1]))",
"qN.add",
"qN",
"Integer.parseInt(itemsList[1])",
"Integer.parseInt",
"Integer",
"itemsList[1]",
"itemsList",
"1",
"while(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}",
"!qP.isEmpty()",
"qP.isEmpty()",
"qP.isEmpty",
"qP",
"{\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}",
"if(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}",
"q - qN.peek() < 0",
"q - qN.peek()",
"q",
"qN.peek()",
"qN.peek",
"qN",
"0",
"{\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}",
"qN.add(-1*(q-qN.remove()))",
"qN.add",
"qN",
"-1*(q-qN.remove())",
"-1",
"1",
"(q-qN.remove())",
"q",
"qN.remove()",
"qN.remove",
"qN",
"qP.add(qP.remove())",
"qP.add",
"qP",
"qP.remove()",
"qP.remove",
"qP",
"ts += q",
"ts",
"q",
"{\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}",
"ts += qN.remove()",
"ts",
"qN.remove()",
"qN.remove",
"qN",
"System.out.println(qP.remove() + \" \" + ts)",
"System.out.println",
"System.out",
"System",
"System.out",
"qP.remove() + \" \" + ts",
"qP.remove() + \" \" + ts",
"qP.remove()",
"qP.remove",
"qP",
"\" \"",
"ts",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint ts = 0;\n\t\t\n\t\tQueue<Integer> qN = new LinkedList<>(); \n\t\tQueue<String> qP = new LinkedList<>(); \n\t\t\n\t\tString line = sc.nextLine();\n\t\t\n\t\tString[] lineList = line.split(\" \");\n\t\tString[] itemsList = new String[Integer.parseInt(lineList[0])*2];\n\t\t\n\t\tint q = Integer.parseInt(lineList[1]);\n\t\t\n\t\tString[] items = new String[Integer.parseInt(lineList[0])];\n\t\t\n\t\t//add everything into queues\n\t\tfor(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}\n\t\t\n\t\twhile(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint ts = 0;\n\t\t\n\t\tQueue<Integer> qN = new LinkedList<>(); \n\t\tQueue<String> qP = new LinkedList<>(); \n\t\t\n\t\tString line = sc.nextLine();\n\t\t\n\t\tString[] lineList = line.split(\" \");\n\t\tString[] itemsList = new String[Integer.parseInt(lineList[0])*2];\n\t\t\n\t\tint q = Integer.parseInt(lineList[1]);\n\t\t\n\t\tString[] items = new String[Integer.parseInt(lineList[0])];\n\t\t\n\t\t//add everything into queues\n\t\tfor(int i = 0; i < Integer.parseInt(lineList[0]); i++) {\n\t\t\titems[i] = sc.nextLine();\n\t\t\titemsList = items[i].split(\" \");\n\t\t\tqP.add(itemsList[0]);\n\t\t\tqN.add(Integer.parseInt(itemsList[1]));\n\t\t}\n\t\t\n\t\twhile(!qP.isEmpty()){\n\t\t\tif(q - qN.peek() < 0) {\n\t\t\t\tqN.add(-1*(q-qN.remove()));\n\t\t\t\tqP.add(qP.remove());\n\t\t\t\tts += q;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tts += qN.remove();\n\t\t\t\tSystem.out.println(qP.remove() + \" \" + ts);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main"
] | import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int ts = 0;
Queue<Integer> qN = new LinkedList<>();
Queue<String> qP = new LinkedList<>();
String line = sc.nextLine();
String[] lineList = line.split(" ");
String[] itemsList = new String[Integer.parseInt(lineList[0])*2];
int q = Integer.parseInt(lineList[1]);
String[] items = new String[Integer.parseInt(lineList[0])];
//add everything into queues
for(int i = 0; i < Integer.parseInt(lineList[0]); i++) {
items[i] = sc.nextLine();
itemsList = items[i].split(" ");
qP.add(itemsList[0]);
qN.add(Integer.parseInt(itemsList[1]));
}
while(!qP.isEmpty()){
if(q - qN.peek() < 0) {
qN.add(-1*(q-qN.remove()));
qP.add(qP.remove());
ts += q;
}
else {
ts += qN.remove();
System.out.println(qP.remove() + " " + ts);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
2,
13,
17,
41,
13,
20,
2,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
41,
13,
2,
13,
17,
0,
18,
13,
13,
17,
42,
17,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
14,
2,
13,
13,
3,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
17,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
17,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
31,
32
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
37,
38
],
[
37,
39
],
[
11,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
40,
45
],
[
45,
46
],
[
45,
47
],
[
40,
48
],
[
48,
49
],
[
49,
50
],
[
40,
51
],
[
52,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
57,
58
],
[
58,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
11,
67
],
[
67,
68
],
[
67,
69
],
[
11,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
11,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
11,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
89,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
103,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
103,
108
],
[
89,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
89,
114
],
[
114,
115
],
[
114,
116
],
[
89,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
83,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
125,
131
],
[
131,
132
],
[
131,
133
],
[
125,
134
],
[
134,
135
],
[
134,
136
],
[
125,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
125,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
149,
150
],
[
149,
151
],
[
125,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
156,
157
],
[
156,
158
],
[
125,
159
],
[
159,
160
],
[
159,
161
],
[
125,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
9,
170
],
[
170,
171
]
] | [
"import java.io.IOException;\nimport java.util.Scanner;\nclass Main{\n\tpublic static void main(String[] args)throws NumberFormatException, IOException{\n//\t\tSystem.out.println(\" \");\n\t\tScanner scan = new Scanner(System.in);\n\t\tint queueAmount = scan.nextInt();\n\t\tint qTime = scan.nextInt();\n\t\tint totalTime = 0;\n\t\tint[] proNum = new int[queueAmount+1];\t//?????°?????????????????????1????????¨??????\n\t\tString[] proID = new String[queueAmount+1];\n\n\t\tfor(int i=0; i<queueAmount; i++){\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}\n\t\tint dataTop = 0;\n\t\tint dataBottom = queueAmount-1;\n\t\tproNum[queueAmount] = 0;\n\t\t\n\t\twhile(true){\n\t\t\t//?????????????????????????????????????????????\n\t\t\tif(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tSystem.out.println(\"totaltime is \"+totalTime);\n\t\t}\n\t}\n}",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n\tpublic static void main(String[] args)throws NumberFormatException, IOException{\n//\t\tSystem.out.println(\" \");\n\t\tScanner scan = new Scanner(System.in);\n\t\tint queueAmount = scan.nextInt();\n\t\tint qTime = scan.nextInt();\n\t\tint totalTime = 0;\n\t\tint[] proNum = new int[queueAmount+1];\t//?????°?????????????????????1????????¨??????\n\t\tString[] proID = new String[queueAmount+1];\n\n\t\tfor(int i=0; i<queueAmount; i++){\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}\n\t\tint dataTop = 0;\n\t\tint dataBottom = queueAmount-1;\n\t\tproNum[queueAmount] = 0;\n\t\t\n\t\twhile(true){\n\t\t\t//?????????????????????????????????????????????\n\t\t\tif(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tSystem.out.println(\"totaltime is \"+totalTime);\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args)throws NumberFormatException, IOException{\n//\t\tSystem.out.println(\" \");\n\t\tScanner scan = new Scanner(System.in);\n\t\tint queueAmount = scan.nextInt();\n\t\tint qTime = scan.nextInt();\n\t\tint totalTime = 0;\n\t\tint[] proNum = new int[queueAmount+1];\t//?????°?????????????????????1????????¨??????\n\t\tString[] proID = new String[queueAmount+1];\n\n\t\tfor(int i=0; i<queueAmount; i++){\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}\n\t\tint dataTop = 0;\n\t\tint dataBottom = queueAmount-1;\n\t\tproNum[queueAmount] = 0;\n\t\t\n\t\twhile(true){\n\t\t\t//?????????????????????????????????????????????\n\t\t\tif(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tSystem.out.println(\"totaltime is \"+totalTime);\n\t\t}\n\t}",
"main",
"{\n//\t\tSystem.out.println(\" \");\n\t\tScanner scan = new Scanner(System.in);\n\t\tint queueAmount = scan.nextInt();\n\t\tint qTime = scan.nextInt();\n\t\tint totalTime = 0;\n\t\tint[] proNum = new int[queueAmount+1];\t//?????°?????????????????????1????????¨??????\n\t\tString[] proID = new String[queueAmount+1];\n\n\t\tfor(int i=0; i<queueAmount; i++){\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}\n\t\tint dataTop = 0;\n\t\tint dataBottom = queueAmount-1;\n\t\tproNum[queueAmount] = 0;\n\t\t\n\t\twhile(true){\n\t\t\t//?????????????????????????????????????????????\n\t\t\tif(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tSystem.out.println(\"totaltime is \"+totalTime);\n\t\t}\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int queueAmount = scan.nextInt();",
"queueAmount",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int qTime = scan.nextInt();",
"qTime",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int totalTime = 0;",
"totalTime",
"0",
"int[] proNum = new int[queueAmount+1];",
"proNum",
"new int[queueAmount+1]",
"queueAmount+1",
"queueAmount",
"1",
"String[] proID = new String[queueAmount+1];",
"proID",
"new String[queueAmount+1]",
"queueAmount+1",
"queueAmount",
"1",
"for(int i=0; i<queueAmount; i++){\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<queueAmount",
"i",
"queueAmount",
"i++",
"i++",
"i",
"{\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}",
"{\n\t\t\tproID[i] = scan.next();\n\t\t\tproNum[i] = scan.nextInt();\n\t\t}",
"proID[i] = scan.next()",
"proID[i]",
"proID",
"i",
"scan.next()",
"scan.next",
"scan",
"proNum[i] = scan.nextInt()",
"proNum[i]",
"proNum",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int dataTop = 0;",
"dataTop",
"0",
"int dataBottom = queueAmount-1;",
"dataBottom",
"queueAmount-1",
"queueAmount",
"1",
"proNum[queueAmount] = 0",
"proNum[queueAmount]",
"proNum",
"queueAmount",
"0",
"while(true){\n\t\t\t//?????????????????????????????????????????????\n\t\t\tif(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tSystem.out.println(\"totaltime is \"+totalTime);\n\t\t}",
"true",
"{\n\t\t\t//?????????????????????????????????????????????\n\t\t\tif(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n//\t\t\tSystem.out.println(\"totaltime is \"+totalTime);\n\t\t}",
"if(proNum[dataTop] <= qTime){\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}",
"proNum[dataTop] <= qTime",
"proNum[dataTop]",
"proNum",
"dataTop",
"qTime",
"{\t\t\t\n\t\t\t\ttotalTime = totalTime + proNum[dataTop];\n\t\t\t\tSystem.out.println(proID[dataTop]+\" \"+(totalTime) );\n\t\t\t\t//???????????§?????£??????break\n\t\t\t\tif(dataTop == dataBottom) break;\n\t\t\t\t\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}",
"totalTime = totalTime + proNum[dataTop]",
"totalTime",
"totalTime + proNum[dataTop]",
"totalTime",
"proNum[dataTop]",
"proNum",
"dataTop",
"System.out.println(proID[dataTop]+\" \"+(totalTime) )",
"System.out.println",
"System.out",
"System",
"System.out",
"proID[dataTop]+\" \"+(totalTime)",
"proID[dataTop]+\" \"+(totalTime)",
"proID[dataTop]",
"proID",
"dataTop",
"\" \"",
"(totalTime)",
"if(dataTop == dataBottom) break;",
"dataTop == dataBottom",
"dataTop",
"dataBottom",
"break;",
"dataTop += 1",
"dataTop",
"1",
"if(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}",
"dataTop > queueAmount",
"dataTop",
"queueAmount",
"{\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}",
"dataTop = 0",
"dataTop",
"0",
"{\n\t\t\t\tproNum[dataTop] -= qTime;\n\t\t\t\ttotalTime += qTime;\n\t\t\t\t//????????????????°????1???????????????????????§????????£??????0?????????\n//\t\t\t\tSystem.out.println(\"?????? \"+proID[dataTop]+\" \"+proNum[dataTop]);\n\t\t\t\tdataBottom += 1;\n\t\t\t\tif(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}\n\t\t\t\t//???????°???????????????????????????£??\\\n\t\t\t\tproNum[dataBottom] = proNum[dataTop];\n\t\t\t\tproID[dataBottom] = proID[dataTop];\n\t\t\t\tdataTop += 1;\n\t\t\t\tif(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}\n\t\t\t}",
"proNum[dataTop] -= qTime",
"proNum[dataTop]",
"proNum",
"dataTop",
"qTime",
"totalTime += qTime",
"totalTime",
"qTime",
"dataBottom += 1",
"dataBottom",
"1",
"if(dataBottom > queueAmount){\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}",
"dataBottom > queueAmount",
"dataBottom",
"queueAmount",
"{\n\t\t\t\t\tdataBottom = 0;\n\t\t\t\t}",
"dataBottom = 0",
"dataBottom",
"0",
"proNum[dataBottom] = proNum[dataTop]",
"proNum[dataBottom]",
"proNum",
"dataBottom",
"proNum[dataTop]",
"proNum",
"dataTop",
"proID[dataBottom] = proID[dataTop]",
"proID[dataBottom]",
"proID",
"dataBottom",
"proID[dataTop]",
"proID",
"dataTop",
"dataTop += 1",
"dataTop",
"1",
"if(dataTop > queueAmount){\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}",
"dataTop > queueAmount",
"dataTop",
"queueAmount",
"{\n\t\t\t\t\tdataTop = 0;\n\t\t\t\t}",
"dataTop = 0",
"dataTop",
"0",
"String[] args",
"args"
] | import java.io.IOException;
import java.util.Scanner;
class Main{
public static void main(String[] args)throws NumberFormatException, IOException{
// System.out.println(" ");
Scanner scan = new Scanner(System.in);
int queueAmount = scan.nextInt();
int qTime = scan.nextInt();
int totalTime = 0;
int[] proNum = new int[queueAmount+1]; //?????°?????????????????????1????????¨??????
String[] proID = new String[queueAmount+1];
for(int i=0; i<queueAmount; i++){
proID[i] = scan.next();
proNum[i] = scan.nextInt();
}
int dataTop = 0;
int dataBottom = queueAmount-1;
proNum[queueAmount] = 0;
while(true){
//?????????????????????????????????????????????
if(proNum[dataTop] <= qTime){
totalTime = totalTime + proNum[dataTop];
System.out.println(proID[dataTop]+" "+(totalTime) );
//???????????§?????£??????break
if(dataTop == dataBottom) break;
dataTop += 1;
if(dataTop > queueAmount){
dataTop = 0;
}
}
else{
proNum[dataTop] -= qTime;
totalTime += qTime;
//????????????????°????1???????????????????????§????????£??????0?????????
// System.out.println("?????? "+proID[dataTop]+" "+proNum[dataTop]);
dataBottom += 1;
if(dataBottom > queueAmount){
dataBottom = 0;
}
//???????°???????????????????????????£??\
proNum[dataBottom] = proNum[dataTop];
proID[dataBottom] = proID[dataTop];
dataTop += 1;
if(dataTop > queueAmount){
dataTop = 0;
}
}
// System.out.println("totaltime is "+totalTime);
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
2,
13,
13,
17,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
13,
17,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
156,
17
],
[
156,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
40,
42
],
[
20,
43
],
[
43,
44
],
[
43,
45
],
[
20,
46
],
[
46,
47
],
[
46,
48
],
[
20,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
65,
66
],
[
66,
67
],
[
61,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
72,
73
],
[
20,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
74,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
79,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
79,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
96,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
96,
107
],
[
107,
108
],
[
107,
109
],
[
90,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
114,
115
],
[
114,
116
],
[
110,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
110,
121
],
[
121,
122
],
[
121,
123
],
[
20,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
129,
130
],
[
129,
131
],
[
124,
132
],
[
132,
133
],
[
133,
134
],
[
124,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
143,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
143,
148
],
[
143,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
18,
153
],
[
153,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
]
] | [
"import java.util.ArrayList;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\nimport java.util.Stack;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint timePassed= 0;\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue<Integer> process = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\tArrayList<String> nameRt = new ArrayList<String>();\n\t\tArrayList<Integer> processRt = new ArrayList<Integer>();\n\t\tfor(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}\n\t\twhile(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}\n\t\t//System.out.println(process.toString());\n\t\t//System.out.println(name.toString());\n\t\t\n\t\t/**\n\t\tint result = 0;\n\t\tStack<Integer> stack = new Stack<Integer>(); \n\t\tScanner in = new Scanner(System.in);\n\t\tString stringIn = in.nextLine();\n\t\tString[] lineString = stringIn.split(\" \");\n\t\tfor(int i = 0; i<lineString.length;i++) {\n\t\t\tif(lineString[i].equals(\"*\")) {\n\t\t\t\tint n = stack.pop()*stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"+\")) {\n\t\t\t\tint n = stack.pop()+stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"-\")) {\n\t\t\t\tint n1 = stack.pop();\n\t\t\t\tint n2 = stack.pop();\n\t\t\t\tint n = n2-n1;\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse {\n\t\t\tstack.push(Integer.parseInt(lineString[i]));\t\n\t\t\t} \n\t\t\t//System.out.println(stack.toString());\n\t\t\t\n\t\t}\n\t\tresult = stack.pop();\n\t\tSystem.out.println(result);\n\t\t*/\n\t}\n\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Stack;",
"Stack",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint timePassed= 0;\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue<Integer> process = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\tArrayList<String> nameRt = new ArrayList<String>();\n\t\tArrayList<Integer> processRt = new ArrayList<Integer>();\n\t\tfor(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}\n\t\twhile(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}\n\t\t//System.out.println(process.toString());\n\t\t//System.out.println(name.toString());\n\t\t\n\t\t/**\n\t\tint result = 0;\n\t\tStack<Integer> stack = new Stack<Integer>(); \n\t\tScanner in = new Scanner(System.in);\n\t\tString stringIn = in.nextLine();\n\t\tString[] lineString = stringIn.split(\" \");\n\t\tfor(int i = 0; i<lineString.length;i++) {\n\t\t\tif(lineString[i].equals(\"*\")) {\n\t\t\t\tint n = stack.pop()*stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"+\")) {\n\t\t\t\tint n = stack.pop()+stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"-\")) {\n\t\t\t\tint n1 = stack.pop();\n\t\t\t\tint n2 = stack.pop();\n\t\t\t\tint n = n2-n1;\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse {\n\t\t\tstack.push(Integer.parseInt(lineString[i]));\t\n\t\t\t} \n\t\t\t//System.out.println(stack.toString());\n\t\t\t\n\t\t}\n\t\tresult = stack.pop();\n\t\tSystem.out.println(result);\n\t\t*/\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint timePassed= 0;\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue<Integer> process = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\tArrayList<String> nameRt = new ArrayList<String>();\n\t\tArrayList<Integer> processRt = new ArrayList<Integer>();\n\t\tfor(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}\n\t\twhile(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}\n\t\t//System.out.println(process.toString());\n\t\t//System.out.println(name.toString());\n\t\t\n\t\t/**\n\t\tint result = 0;\n\t\tStack<Integer> stack = new Stack<Integer>(); \n\t\tScanner in = new Scanner(System.in);\n\t\tString stringIn = in.nextLine();\n\t\tString[] lineString = stringIn.split(\" \");\n\t\tfor(int i = 0; i<lineString.length;i++) {\n\t\t\tif(lineString[i].equals(\"*\")) {\n\t\t\t\tint n = stack.pop()*stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"+\")) {\n\t\t\t\tint n = stack.pop()+stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"-\")) {\n\t\t\t\tint n1 = stack.pop();\n\t\t\t\tint n2 = stack.pop();\n\t\t\t\tint n = n2-n1;\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse {\n\t\t\tstack.push(Integer.parseInt(lineString[i]));\t\n\t\t\t} \n\t\t\t//System.out.println(stack.toString());\n\t\t\t\n\t\t}\n\t\tresult = stack.pop();\n\t\tSystem.out.println(result);\n\t\t*/\n\t}",
"main",
"{\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint timePassed= 0;\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue<Integer> process = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\tArrayList<String> nameRt = new ArrayList<String>();\n\t\tArrayList<Integer> processRt = new ArrayList<Integer>();\n\t\tfor(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}\n\t\twhile(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}\n\t\t//System.out.println(process.toString());\n\t\t//System.out.println(name.toString());\n\t\t\n\t\t/**\n\t\tint result = 0;\n\t\tStack<Integer> stack = new Stack<Integer>(); \n\t\tScanner in = new Scanner(System.in);\n\t\tString stringIn = in.nextLine();\n\t\tString[] lineString = stringIn.split(\" \");\n\t\tfor(int i = 0; i<lineString.length;i++) {\n\t\t\tif(lineString[i].equals(\"*\")) {\n\t\t\t\tint n = stack.pop()*stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"+\")) {\n\t\t\t\tint n = stack.pop()+stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"-\")) {\n\t\t\t\tint n1 = stack.pop();\n\t\t\t\tint n2 = stack.pop();\n\t\t\t\tint n = n2-n1;\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse {\n\t\t\tstack.push(Integer.parseInt(lineString[i]));\t\n\t\t\t} \n\t\t\t//System.out.println(stack.toString());\n\t\t\t\n\t\t}\n\t\tresult = stack.pop();\n\t\tSystem.out.println(result);\n\t\t*/\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int timePassed= 0;",
"timePassed",
"0",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int q = in.nextInt();",
"q",
"in.nextInt()",
"in.nextInt",
"in",
"Queue<Integer> process = new LinkedList<Integer>();",
"process",
"new LinkedList<Integer>()",
"Queue<String> name = new LinkedList<String>();",
"name",
"new LinkedList<String>()",
"ArrayList<String> nameRt = new ArrayList<String>();",
"nameRt",
"new ArrayList<String>()",
"ArrayList<Integer> processRt = new ArrayList<Integer>();",
"processRt",
"new ArrayList<Integer>()",
"for(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}",
"{\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}",
"name.add(in.next())",
"name.add",
"name",
"in.next()",
"in.next",
"in",
"process.add(in.nextInt())",
"process.add",
"process",
"in.nextInt()",
"in.nextInt",
"in",
"while(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}",
"!process.isEmpty()",
"process.isEmpty()",
"process.isEmpty",
"process",
"{\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}",
"int number = process.remove();",
"number",
"process.remove()",
"process.remove",
"process",
"String nme = name.remove();",
"nme",
"name.remove()",
"name.remove",
"name",
"if(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}",
"number-q<=0",
"number-q",
"number",
"q",
"0",
"{\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}",
"processRt.add(number+timePassed)",
"processRt.add",
"processRt",
"number+timePassed",
"number",
"timePassed",
"nameRt.add(nme)",
"nameRt.add",
"nameRt",
"nme",
"timePassed+=number",
"timePassed",
"number",
"{\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}",
"process.add(number-q)",
"process.add",
"process",
"number-q",
"number",
"q",
"name.add(nme)",
"name.add",
"name",
"nme",
"timePassed+=q",
"timePassed",
"q",
"for(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}",
"int i =0;",
"int i =0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}",
"{\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}",
"System.out.println(nameRt.get(i)+\" \"+processRt.get(i))",
"System.out.println",
"System.out",
"System",
"System.out",
"nameRt.get(i)+\" \"+processRt.get(i)",
"nameRt.get(i)+\" \"+processRt.get(i)",
"nameRt.get(i)",
"nameRt.get",
"nameRt",
"i",
"\" \"",
"processRt.get(i)",
"processRt.get",
"processRt",
"i",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint timePassed= 0;\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue<Integer> process = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\tArrayList<String> nameRt = new ArrayList<String>();\n\t\tArrayList<Integer> processRt = new ArrayList<Integer>();\n\t\tfor(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}\n\t\twhile(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}\n\t\t//System.out.println(process.toString());\n\t\t//System.out.println(name.toString());\n\t\t\n\t\t/**\n\t\tint result = 0;\n\t\tStack<Integer> stack = new Stack<Integer>(); \n\t\tScanner in = new Scanner(System.in);\n\t\tString stringIn = in.nextLine();\n\t\tString[] lineString = stringIn.split(\" \");\n\t\tfor(int i = 0; i<lineString.length;i++) {\n\t\t\tif(lineString[i].equals(\"*\")) {\n\t\t\t\tint n = stack.pop()*stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"+\")) {\n\t\t\t\tint n = stack.pop()+stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"-\")) {\n\t\t\t\tint n1 = stack.pop();\n\t\t\t\tint n2 = stack.pop();\n\t\t\t\tint n = n2-n1;\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse {\n\t\t\tstack.push(Integer.parseInt(lineString[i]));\t\n\t\t\t} \n\t\t\t//System.out.println(stack.toString());\n\t\t\t\n\t\t}\n\t\tresult = stack.pop();\n\t\tSystem.out.println(result);\n\t\t*/\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint timePassed= 0;\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue<Integer> process = new LinkedList<Integer>();\n\t\tQueue<String> name = new LinkedList<String>();\n\t\tArrayList<String> nameRt = new ArrayList<String>();\n\t\tArrayList<Integer> processRt = new ArrayList<Integer>();\n\t\tfor(int i = 0;i<n;i++) {\n\t\t\tname.add(in.next());\n\t\t\tprocess.add(in.nextInt());\n\t\t}\n\t\twhile(!process.isEmpty()) {\n\t\t\tint number = process.remove();\n\t\t\tString nme = name.remove();\n\t\t\tif(number-q<=0) {\n\t\t\t\tprocessRt.add(number+timePassed);\n\t\t\t\tnameRt.add(nme);\n\t\t\t\ttimePassed+=number;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tprocess.add(number-q);\n\t\t\t\tname.add(nme);\n\t\t\t\ttimePassed+=q;\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int i =0; i<n;i++) {\n\t\t\tSystem.out.println(nameRt.get(i)+\" \"+processRt.get(i));\n\t\t}\n\t\t//System.out.println(process.toString());\n\t\t//System.out.println(name.toString());\n\t\t\n\t\t/**\n\t\tint result = 0;\n\t\tStack<Integer> stack = new Stack<Integer>(); \n\t\tScanner in = new Scanner(System.in);\n\t\tString stringIn = in.nextLine();\n\t\tString[] lineString = stringIn.split(\" \");\n\t\tfor(int i = 0; i<lineString.length;i++) {\n\t\t\tif(lineString[i].equals(\"*\")) {\n\t\t\t\tint n = stack.pop()*stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"+\")) {\n\t\t\t\tint n = stack.pop()+stack.pop();\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse if(lineString[i].equals(\"-\")) {\n\t\t\t\tint n1 = stack.pop();\n\t\t\t\tint n2 = stack.pop();\n\t\t\t\tint n = n2-n1;\n\t\t\t\tstack.push(n);\n\t\t\t}\n\t\t\telse {\n\t\t\tstack.push(Integer.parseInt(lineString[i]));\t\n\t\t\t} \n\t\t\t//System.out.println(stack.toString());\n\t\t\t\n\t\t}\n\t\tresult = stack.pop();\n\t\tSystem.out.println(result);\n\t\t*/\n\t}\n\n}",
"Main"
] | import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int timePassed= 0;
int n = in.nextInt();
int q = in.nextInt();
Queue<Integer> process = new LinkedList<Integer>();
Queue<String> name = new LinkedList<String>();
ArrayList<String> nameRt = new ArrayList<String>();
ArrayList<Integer> processRt = new ArrayList<Integer>();
for(int i = 0;i<n;i++) {
name.add(in.next());
process.add(in.nextInt());
}
while(!process.isEmpty()) {
int number = process.remove();
String nme = name.remove();
if(number-q<=0) {
processRt.add(number+timePassed);
nameRt.add(nme);
timePassed+=number;
}
else {
process.add(number-q);
name.add(nme);
timePassed+=q;
}
}
for(int i =0; i<n;i++) {
System.out.println(nameRt.get(i)+" "+processRt.get(i));
}
//System.out.println(process.toString());
//System.out.println(name.toString());
/**
int result = 0;
Stack<Integer> stack = new Stack<Integer>();
Scanner in = new Scanner(System.in);
String stringIn = in.nextLine();
String[] lineString = stringIn.split(" ");
for(int i = 0; i<lineString.length;i++) {
if(lineString[i].equals("*")) {
int n = stack.pop()*stack.pop();
stack.push(n);
}
else if(lineString[i].equals("+")) {
int n = stack.pop()+stack.pop();
stack.push(n);
}
else if(lineString[i].equals("-")) {
int n1 = stack.pop();
int n2 = stack.pop();
int n = n2-n1;
stack.push(n);
}
else {
stack.push(Integer.parseInt(lineString[i]));
}
//System.out.println(stack.toString());
}
result = stack.pop();
System.out.println(result);
*/
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
17,
41,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
20,
2,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
0,
18,
13,
13,
13,
4,
18,
13,
0,
13,
2,
13,
17,
41,
13,
17,
41,
13,
20,
13,
41,
13,
17,
42,
2,
18,
13,
13,
17,
30,
41,
13,
4,
13,
41,
13,
18,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
40,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
2,
18,
13,
13,
17,
30,
0,
13,
17,
30,
40,
13,
0,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
17,
14,
2,
13,
2,
18,
13,
13,
17,
30,
0,
13,
17,
30,
40,
13,
29,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
222,
5
],
[
222,
6
],
[
6,
7
],
[
222,
8
],
[
8,
9
],
[
8,
10
],
[
222,
11
],
[
11,
12
],
[
222,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
15,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
15,
29
],
[
29,
30
],
[
29,
31
],
[
32,
33
],
[
32,
34
],
[
15,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
35,
40
],
[
40,
41
],
[
40,
42
],
[
35,
43
],
[
43,
44
],
[
44,
45
],
[
35,
46
],
[
47,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
15,
56
],
[
56,
57
],
[
57,
58
],
[
15,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
15,
64
],
[
64,
65
],
[
64,
66
],
[
15,
67
],
[
67,
68
],
[
67,
69
],
[
15,
71
],
[
71,
72
],
[
71,
73
],
[
15,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
74,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
80,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
80,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
94,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
94,
108
],
[
108,
109
],
[
90,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
110,
119
],
[
119,
120
],
[
119,
121
],
[
15,
122
],
[
122,
123
],
[
122,
124
],
[
122,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
127,
132
],
[
133,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
133,
138
],
[
138,
139
],
[
138,
140
],
[
13,
141
],
[
141,
142
],
[
222,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
146,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
146,
158
],
[
158,
159
],
[
159,
160
],
[
145,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
143,
166
],
[
166,
167
],
[
222,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
173,
175
],
[
170,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
170,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
181,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
181,
193
],
[
193,
194
],
[
194,
195
],
[
170,
196
],
[
196,
197
],
[
0,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
198,
202
],
[
202,
203
],
[
198,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
211
],
[
206,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
204,
217
],
[
217,
218
],
[
204,
219
],
[
219,
220
],
[
0,
221
],
[
221,
222
],
[
221,
223
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tstatic Process[] stack;\n\tstatic int firstPointer = 0;\n\tstatic int lastPointer;\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint processNum = sc.nextInt();\n\t\tint quanTime = sc.nextInt();\n\t\tstack = new Process[processNum + 1];\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}\n\t\tsc.close();\n\t\tlastPointer = processNum - 1;\n\t\tint time = 0;\n\t\tProcess[] answerProcesses = new Process[processNum];\n\t\tint answerProcessesIndex = 0;\n\t\twhile(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}\n\t\tfor(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}\n\t}\n\tpublic static void enquene(Process process) {\n\t\tif(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}\n\t\tstack[lastPointer] = process;\n\t}\n\tpublic static Process dequene() {\n\t\tProcess process = stack[firstPointer];\n\t\tstack[firstPointer] = null;\n\t\tif(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}\n\t\treturn process;\n\t}\n}\nclass Process {\n\tString name;\n\tint time;\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tstatic Process[] stack;\n\tstatic int firstPointer = 0;\n\tstatic int lastPointer;\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint processNum = sc.nextInt();\n\t\tint quanTime = sc.nextInt();\n\t\tstack = new Process[processNum + 1];\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}\n\t\tsc.close();\n\t\tlastPointer = processNum - 1;\n\t\tint time = 0;\n\t\tProcess[] answerProcesses = new Process[processNum];\n\t\tint answerProcessesIndex = 0;\n\t\twhile(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}\n\t\tfor(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}\n\t}\n\tpublic static void enquene(Process process) {\n\t\tif(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}\n\t\tstack[lastPointer] = process;\n\t}\n\tpublic static Process dequene() {\n\t\tProcess process = stack[firstPointer];\n\t\tstack[firstPointer] = null;\n\t\tif(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}\n\t\treturn process;\n\t}\n}",
"Main",
"static Process[] stack;",
"stack",
"static int firstPointer = 0;",
"firstPointer",
"0",
"static int lastPointer;",
"lastPointer",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint processNum = sc.nextInt();\n\t\tint quanTime = sc.nextInt();\n\t\tstack = new Process[processNum + 1];\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}\n\t\tsc.close();\n\t\tlastPointer = processNum - 1;\n\t\tint time = 0;\n\t\tProcess[] answerProcesses = new Process[processNum];\n\t\tint answerProcessesIndex = 0;\n\t\twhile(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}\n\t\tfor(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint processNum = sc.nextInt();\n\t\tint quanTime = sc.nextInt();\n\t\tstack = new Process[processNum + 1];\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}\n\t\tsc.close();\n\t\tlastPointer = processNum - 1;\n\t\tint time = 0;\n\t\tProcess[] answerProcesses = new Process[processNum];\n\t\tint answerProcessesIndex = 0;\n\t\twhile(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}\n\t\tfor(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int processNum = sc.nextInt();",
"processNum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int quanTime = sc.nextInt();",
"quanTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"stack = new Process[processNum + 1]",
"stack",
"new Process[processNum + 1]",
"processNum + 1",
"processNum",
"1",
"for(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < processNum",
"i",
"processNum",
"i++",
"i++",
"i",
"{\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}",
"{\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}",
"Process process = new Process(sc.next(), sc.nextInt());",
"process",
"new Process(sc.next(), sc.nextInt())",
"stack[i] = process",
"stack[i]",
"stack",
"i",
"process",
"sc.close()",
"sc.close",
"sc",
"lastPointer = processNum - 1",
"lastPointer",
"processNum - 1",
"processNum",
"1",
"int time = 0;",
"time",
"0",
"Process[] answerProcesses = new Process[processNum];",
"answerProcesses",
"new Process[processNum]",
"processNum",
"int answerProcessesIndex = 0;",
"answerProcessesIndex",
"0",
"while(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}",
"stack[firstPointer] != null",
"stack[firstPointer]",
"stack",
"firstPointer",
"null",
"{\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}",
"Process process = dequene();",
"process",
"dequene()",
"dequene",
"int processTime = process.time;",
"processTime",
"process.time",
"process",
"process.time",
"if(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}",
"processTime <= quanTime",
"processTime",
"quanTime",
"{\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t}",
"time += processTime",
"time",
"processTime",
"process.time = time",
"process.time",
"process",
"process.time",
"time",
"answerProcesses[answerProcessesIndex] = process",
"answerProcesses[answerProcessesIndex]",
"answerProcesses",
"answerProcessesIndex",
"process",
"answerProcessesIndex++",
"answerProcessesIndex",
"{\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}",
"time += quanTime",
"time",
"quanTime",
"process.time -= quanTime",
"process.time",
"process",
"process.time",
"quanTime",
"enquene(process)",
"enquene",
"process",
"for(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}",
"Process process",
"answerProcesses",
"{\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}",
"{\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}",
"System.out.println(process.name + \" \" + process.time)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + process.time",
"process.name + \" \" + process.time",
"process.name",
"process",
"process.name",
"\" \"",
"process.time",
"process",
"process.time",
"String[] args",
"args",
"public static void enquene(Process process) {\n\t\tif(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}\n\t\tstack[lastPointer] = process;\n\t}",
"enquene",
"{\n\t\tif(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}\n\t\tstack[lastPointer] = process;\n\t}",
"if(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}",
"lastPointer == stack.length - 1",
"lastPointer",
"stack.length - 1",
"stack.length",
"stack",
"stack.length",
"1",
"{\n\t\t\tlastPointer = 0;\n\t\t}",
"lastPointer = 0",
"lastPointer",
"0",
"{\n\t\t\tlastPointer++;\n\t\t}",
"lastPointer++",
"lastPointer",
"stack[lastPointer] = process",
"stack[lastPointer]",
"stack",
"lastPointer",
"process",
"Process process",
"process",
"public static Process dequene() {\n\t\tProcess process = stack[firstPointer];\n\t\tstack[firstPointer] = null;\n\t\tif(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}\n\t\treturn process;\n\t}",
"dequene",
"{\n\t\tProcess process = stack[firstPointer];\n\t\tstack[firstPointer] = null;\n\t\tif(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}\n\t\treturn process;\n\t}",
"Process process = stack[firstPointer];",
"process",
"stack[firstPointer]",
"stack",
"firstPointer",
"stack[firstPointer] = null",
"stack[firstPointer]",
"stack",
"firstPointer",
"null",
"if(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}",
"firstPointer == stack.length - 1",
"firstPointer",
"stack.length - 1",
"stack.length",
"stack",
"stack.length",
"1",
"{\n\t\t\tfirstPointer = 0;\n\t\t}",
"firstPointer = 0",
"firstPointer",
"0",
"{\n\t\t\tfirstPointer++;\n\t\t}",
"firstPointer++",
"firstPointer",
"return process;",
"process",
"class Process {\n\tString name;\n\tint time;\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\tstatic Process[] stack;\n\tstatic int firstPointer = 0;\n\tstatic int lastPointer;\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint processNum = sc.nextInt();\n\t\tint quanTime = sc.nextInt();\n\t\tstack = new Process[processNum + 1];\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}\n\t\tsc.close();\n\t\tlastPointer = processNum - 1;\n\t\tint time = 0;\n\t\tProcess[] answerProcesses = new Process[processNum];\n\t\tint answerProcessesIndex = 0;\n\t\twhile(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}\n\t\tfor(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}\n\t}\n\tpublic static void enquene(Process process) {\n\t\tif(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}\n\t\tstack[lastPointer] = process;\n\t}\n\tpublic static Process dequene() {\n\t\tProcess process = stack[firstPointer];\n\t\tstack[firstPointer] = null;\n\t\tif(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}\n\t\treturn process;\n\t}\n}",
"public class Main {\n\tstatic Process[] stack;\n\tstatic int firstPointer = 0;\n\tstatic int lastPointer;\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint processNum = sc.nextInt();\n\t\tint quanTime = sc.nextInt();\n\t\tstack = new Process[processNum + 1];\n\t\tfor(int i = 0; i < processNum; i++) {\n\t\t\tProcess process = new Process(sc.next(), sc.nextInt());\n\t\t\tstack[i] = process;\n\t\t}\n\t\tsc.close();\n\t\tlastPointer = processNum - 1;\n\t\tint time = 0;\n\t\tProcess[] answerProcesses = new Process[processNum];\n\t\tint answerProcessesIndex = 0;\n\t\twhile(stack[firstPointer] != null) {\n\t\t\tProcess process = dequene();\n\t\t\tint processTime = process.time;\n\t\t\tif(processTime <= quanTime) {\n\t\t\t\ttime += processTime;\n\t\t\t\tprocess.time = time;\n\t\t\t\tanswerProcesses[answerProcessesIndex] = process;\n\t\t\t\tanswerProcessesIndex++;\n\t\t\t} else {\n\t\t\t\ttime += quanTime;\n\t\t\t\tprocess.time -= quanTime;\n\t\t\t\tenquene(process);\n\t\t\t}\n\t\t}\n\t\tfor(Process process: answerProcesses) {\n\t\t\tSystem.out.println(process.name + \" \" + process.time);\n\t\t}\n\t}\n\tpublic static void enquene(Process process) {\n\t\tif(lastPointer == stack.length - 1) {\n\t\t\tlastPointer = 0;\n\t\t} else {\n\t\t\tlastPointer++;\n\t\t}\n\t\tstack[lastPointer] = process;\n\t}\n\tpublic static Process dequene() {\n\t\tProcess process = stack[firstPointer];\n\t\tstack[firstPointer] = null;\n\t\tif(firstPointer == stack.length - 1) {\n\t\t\tfirstPointer = 0;\n\t\t} else {\n\t\t\tfirstPointer++;\n\t\t}\n\t\treturn process;\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static Process[] stack;
static int firstPointer = 0;
static int lastPointer;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int processNum = sc.nextInt();
int quanTime = sc.nextInt();
stack = new Process[processNum + 1];
for(int i = 0; i < processNum; i++) {
Process process = new Process(sc.next(), sc.nextInt());
stack[i] = process;
}
sc.close();
lastPointer = processNum - 1;
int time = 0;
Process[] answerProcesses = new Process[processNum];
int answerProcessesIndex = 0;
while(stack[firstPointer] != null) {
Process process = dequene();
int processTime = process.time;
if(processTime <= quanTime) {
time += processTime;
process.time = time;
answerProcesses[answerProcessesIndex] = process;
answerProcessesIndex++;
} else {
time += quanTime;
process.time -= quanTime;
enquene(process);
}
}
for(Process process: answerProcesses) {
System.out.println(process.name + " " + process.time);
}
}
public static void enquene(Process process) {
if(lastPointer == stack.length - 1) {
lastPointer = 0;
} else {
lastPointer++;
}
stack[lastPointer] = process;
}
public static Process dequene() {
Process process = stack[firstPointer];
stack[firstPointer] = null;
if(firstPointer == stack.length - 1) {
firstPointer = 0;
} else {
firstPointer++;
}
return process;
}
}
class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
17,
41,
13,
41,
13,
17,
42,
2,
0,
13,
4,
18,
13,
17,
30,
14,
2,
13,
18,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
13,
17,
13,
13,
29,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
29,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
193,
14
],
[
193,
15
],
[
15,
16
],
[
193,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
19,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
26,
28
],
[
19,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
29,
34
],
[
17,
35
],
[
35,
36
],
[
193,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
39,
49
],
[
49,
50
],
[
39,
51
],
[
51,
52
],
[
51,
53
],
[
39,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
55,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
66,
68
],
[
63,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
69,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
63,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
97,
98
],
[
97,
99
],
[
92,
100
],
[
90,
101
],
[
88,
102
],
[
39,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
37,
107
],
[
107,
108
],
[
193,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
117,
122
],
[
111,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
128,
129
],
[
128,
130
],
[
111,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
136,
137
],
[
136,
138
],
[
111,
139
],
[
139,
140
],
[
139,
141
],
[
111,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
147,
148
],
[
147,
149
],
[
142,
150
],
[
150,
151
],
[
151,
152
],
[
142,
153
],
[
154,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
157,
162
],
[
154,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
111,
167
],
[
167,
168
],
[
0,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
169,
173
],
[
173,
174
],
[
169,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
177,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
175,
188
],
[
188,
189
],
[
175,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.LinkedList;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tfinal LinkedList<Process> processes = getProcesses();\n\t\tfinal String result = runProcessing(processes);\n\t\t\n\t\tSystem.out.print(result);\n\t}\n\t\n\tprivate static int quantum;\n\tpublic static String runProcessing(final LinkedList<Process> processes) {\n\t\tfinal StringBuilder result = new StringBuilder();\n\t\tfinal String lb = System.getProperty(\"line.separator\");\n\t\t\n\t\tProcess process;\n\t\tint elapsed = 0;\n\t\twhile ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn result.toString();\n\t}\n\t\n\tpublic static LinkedList<Process> getProcesses() throws IOException {\n\t\tfinal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal String[] requirement = reader.readLine().split(\" \");\n\n\t\tfinal int numberOfPprocess = Integer.parseInt(requirement[0]);\n\t\tquantum = Integer.parseInt(requirement[1]);\n\t\t\n\t\tfinal LinkedList<Process> processes = new LinkedList<Process>();\n\t\tfor (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\n\t\treturn processes;\n\t}\n}\n\nclass Process {\n\tString name;\n\tint processingTime;\n\n\tpublic Process(String name, int processingTime) {\n\t\tthis.name = name;\n\t\tthis.processingTime = processingTime;\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tfinal LinkedList<Process> processes = getProcesses();\n\t\tfinal String result = runProcessing(processes);\n\t\t\n\t\tSystem.out.print(result);\n\t}\n\t\n\tprivate static int quantum;\n\tpublic static String runProcessing(final LinkedList<Process> processes) {\n\t\tfinal StringBuilder result = new StringBuilder();\n\t\tfinal String lb = System.getProperty(\"line.separator\");\n\t\t\n\t\tProcess process;\n\t\tint elapsed = 0;\n\t\twhile ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn result.toString();\n\t}\n\t\n\tpublic static LinkedList<Process> getProcesses() throws IOException {\n\t\tfinal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal String[] requirement = reader.readLine().split(\" \");\n\n\t\tfinal int numberOfPprocess = Integer.parseInt(requirement[0]);\n\t\tquantum = Integer.parseInt(requirement[1]);\n\t\t\n\t\tfinal LinkedList<Process> processes = new LinkedList<Process>();\n\t\tfor (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\n\t\treturn processes;\n\t}\n}",
"Main",
"private static int quantum;",
"quantum",
"public static void main(String[] args) throws IOException {\n\t\tfinal LinkedList<Process> processes = getProcesses();\n\t\tfinal String result = runProcessing(processes);\n\t\t\n\t\tSystem.out.print(result);\n\t}",
"main",
"{\n\t\tfinal LinkedList<Process> processes = getProcesses();\n\t\tfinal String result = runProcessing(processes);\n\t\t\n\t\tSystem.out.print(result);\n\t}",
"final LinkedList<Process> processes = getProcesses();",
"processes",
"getProcesses()",
"getProcesses",
"final String result = runProcessing(processes);",
"result",
"runProcessing(processes)",
"runProcessing",
"processes",
"System.out.print(result)",
"System.out.print",
"System.out",
"System",
"System.out",
"result",
"String[] args",
"args",
"public static String runProcessing(final LinkedList<Process> processes) {\n\t\tfinal StringBuilder result = new StringBuilder();\n\t\tfinal String lb = System.getProperty(\"line.separator\");\n\t\t\n\t\tProcess process;\n\t\tint elapsed = 0;\n\t\twhile ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn result.toString();\n\t}",
"runProcessing",
"{\n\t\tfinal StringBuilder result = new StringBuilder();\n\t\tfinal String lb = System.getProperty(\"line.separator\");\n\t\t\n\t\tProcess process;\n\t\tint elapsed = 0;\n\t\twhile ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn result.toString();\n\t}",
"final StringBuilder result = new StringBuilder();",
"result",
"new StringBuilder()",
"final String lb = System.getProperty(\"line.separator\");",
"lb",
"System.getProperty(\"line.separator\")",
"System.getProperty",
"System",
"\"line.separator\"",
"Process process;",
"process",
"int elapsed = 0;",
"elapsed",
"0",
"while ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}",
"(process = processes.poll()) != null",
"(process = processes.poll())",
"process",
"processes.poll()",
"processes.poll",
"processes",
"null",
"{\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}",
"if (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}",
"quantum < process.processingTime",
"quantum",
"process.processingTime",
"process",
"process.processingTime",
"{\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t}",
"elapsed += quantum",
"elapsed",
"quantum",
"process.processingTime -= quantum",
"process.processingTime",
"process",
"process.processingTime",
"quantum",
"processes.add(process)",
"processes.add",
"processes",
"process",
"{\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}",
"elapsed += process.processingTime",
"elapsed",
"process.processingTime",
"process",
"process.processingTime",
"result.append(process.name).append(\" \").append(elapsed).append(lb)",
"result.append(process.name).append(\" \").append(elapsed).append",
"result.append(process.name).append(\" \").append(elapsed)",
"result.append(process.name).append(\" \").append",
"result.append(process.name).append(\" \")",
"result.append(process.name).append",
"result.append(process.name)",
"result.append",
"result",
"process.name",
"process",
"process.name",
"\" \"",
"elapsed",
"lb",
"return result.toString();",
"result.toString()",
"result.toString",
"result",
"final LinkedList<Process> processes",
"processes",
"public static LinkedList<Process> getProcesses() throws IOException {\n\t\tfinal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal String[] requirement = reader.readLine().split(\" \");\n\n\t\tfinal int numberOfPprocess = Integer.parseInt(requirement[0]);\n\t\tquantum = Integer.parseInt(requirement[1]);\n\t\t\n\t\tfinal LinkedList<Process> processes = new LinkedList<Process>();\n\t\tfor (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\n\t\treturn processes;\n\t}",
"getProcesses",
"{\n\t\tfinal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal String[] requirement = reader.readLine().split(\" \");\n\n\t\tfinal int numberOfPprocess = Integer.parseInt(requirement[0]);\n\t\tquantum = Integer.parseInt(requirement[1]);\n\t\t\n\t\tfinal LinkedList<Process> processes = new LinkedList<Process>();\n\t\tfor (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\n\t\treturn processes;\n\t}",
"final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));",
"reader",
"new BufferedReader(new InputStreamReader(System.in))",
"final String[] requirement = reader.readLine().split(\" \");",
"requirement",
"reader.readLine().split(\" \")",
"reader.readLine().split",
"reader.readLine()",
"reader.readLine",
"reader",
"\" \"",
"final int numberOfPprocess = Integer.parseInt(requirement[0]);",
"numberOfPprocess",
"Integer.parseInt(requirement[0])",
"Integer.parseInt",
"Integer",
"requirement[0]",
"requirement",
"0",
"quantum = Integer.parseInt(requirement[1])",
"quantum",
"Integer.parseInt(requirement[1])",
"Integer.parseInt",
"Integer",
"requirement[1]",
"requirement",
"1",
"final LinkedList<Process> processes = new LinkedList<Process>();",
"processes",
"new LinkedList<Process>()",
"for (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numberOfPprocess",
"i",
"numberOfPprocess",
"i++",
"i++",
"i",
"{\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}",
"{\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}",
"final String[] line = reader.readLine().split(\" \");",
"line",
"reader.readLine().split(\" \")",
"reader.readLine().split",
"reader.readLine()",
"reader.readLine",
"reader",
"\" \"",
"processes.add(new Process(line[0], Integer.parseInt(line[1])))",
"processes.add",
"processes",
"new Process(line[0], Integer.parseInt(line[1]))",
"return processes;",
"processes",
"class Process {\n\tString name;\n\tint processingTime;\n\n\tpublic Process(String name, int processingTime) {\n\t\tthis.name = name;\n\t\tthis.processingTime = processingTime;\n\t}\n}",
"Process",
"String name;",
"name",
"int processingTime;",
"processingTime",
"public Process(String name, int processingTime) {\n\t\tthis.name = name;\n\t\tthis.processingTime = processingTime;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.processingTime = processingTime;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.processingTime = processingTime",
"this.processingTime",
"this",
"this.processingTime",
"processingTime",
"String name",
"name",
"int processingTime",
"processingTime",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tfinal LinkedList<Process> processes = getProcesses();\n\t\tfinal String result = runProcessing(processes);\n\t\t\n\t\tSystem.out.print(result);\n\t}\n\t\n\tprivate static int quantum;\n\tpublic static String runProcessing(final LinkedList<Process> processes) {\n\t\tfinal StringBuilder result = new StringBuilder();\n\t\tfinal String lb = System.getProperty(\"line.separator\");\n\t\t\n\t\tProcess process;\n\t\tint elapsed = 0;\n\t\twhile ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn result.toString();\n\t}\n\t\n\tpublic static LinkedList<Process> getProcesses() throws IOException {\n\t\tfinal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal String[] requirement = reader.readLine().split(\" \");\n\n\t\tfinal int numberOfPprocess = Integer.parseInt(requirement[0]);\n\t\tquantum = Integer.parseInt(requirement[1]);\n\t\t\n\t\tfinal LinkedList<Process> processes = new LinkedList<Process>();\n\t\tfor (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\n\t\treturn processes;\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tfinal LinkedList<Process> processes = getProcesses();\n\t\tfinal String result = runProcessing(processes);\n\t\t\n\t\tSystem.out.print(result);\n\t}\n\t\n\tprivate static int quantum;\n\tpublic static String runProcessing(final LinkedList<Process> processes) {\n\t\tfinal StringBuilder result = new StringBuilder();\n\t\tfinal String lb = System.getProperty(\"line.separator\");\n\t\t\n\t\tProcess process;\n\t\tint elapsed = 0;\n\t\twhile ((process = processes.poll()) != null) {\n\t\t\tif (quantum < process.processingTime) {\n\t\t\t\telapsed += quantum;\n\t\t\t\tprocess.processingTime -= quantum;\n\t\t\t\tprocesses.add(process);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\telapsed += process.processingTime;\n\t\t\t\tresult.append(process.name).append(\" \").append(elapsed).append(lb);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn result.toString();\n\t}\n\t\n\tpublic static LinkedList<Process> getProcesses() throws IOException {\n\t\tfinal BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal String[] requirement = reader.readLine().split(\" \");\n\n\t\tfinal int numberOfPprocess = Integer.parseInt(requirement[0]);\n\t\tquantum = Integer.parseInt(requirement[1]);\n\t\t\n\t\tfinal LinkedList<Process> processes = new LinkedList<Process>();\n\t\tfor (int i = 0; i < numberOfPprocess; i++) {\n\t\t\tfinal String[] line = reader.readLine().split(\" \");\n\t\t\tprocesses.add(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\n\t\treturn processes;\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) throws IOException {
final LinkedList<Process> processes = getProcesses();
final String result = runProcessing(processes);
System.out.print(result);
}
private static int quantum;
public static String runProcessing(final LinkedList<Process> processes) {
final StringBuilder result = new StringBuilder();
final String lb = System.getProperty("line.separator");
Process process;
int elapsed = 0;
while ((process = processes.poll()) != null) {
if (quantum < process.processingTime) {
elapsed += quantum;
process.processingTime -= quantum;
processes.add(process);
} else {
elapsed += process.processingTime;
result.append(process.name).append(" ").append(elapsed).append(lb);
}
}
return result.toString();
}
public static LinkedList<Process> getProcesses() throws IOException {
final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
final String[] requirement = reader.readLine().split(" ");
final int numberOfPprocess = Integer.parseInt(requirement[0]);
quantum = Integer.parseInt(requirement[1]);
final LinkedList<Process> processes = new LinkedList<Process>();
for (int i = 0; i < numberOfPprocess; i++) {
final String[] line = reader.readLine().split(" ");
processes.add(new Process(line[0], Integer.parseInt(line[1])));
}
return processes;
}
}
class Process {
String name;
int processingTime;
public Process(String name, int processingTime) {
this.name = name;
this.processingTime = processingTime;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
14,
2,
2,
4,
18,
13,
13,
17,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
48,
49
],
[
43,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
8,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
64,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
76,
77
],
[
71,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
81,
85
],
[
71,
86
],
[
86,
87
],
[
86,
88
],
[
63,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
101,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
101,
105
],
[
101,
106
],
[
6,
107
],
[
107,
108
]
] | [
"import java.util.*;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\n\t\tQueue<String> queP = new LinkedList<String>();\n\t\tQueue<Integer> queT = new LinkedList<Integer>();\n\n\t\tint timeCount = 0;\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}\n\n\t\twhile (queP.size() != 0) {\n\t\t\tif (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\n\t\tQueue<String> queP = new LinkedList<String>();\n\t\tQueue<Integer> queT = new LinkedList<Integer>();\n\n\t\tint timeCount = 0;\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}\n\n\t\twhile (queP.size() != 0) {\n\t\t\tif (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\n\t\tQueue<String> queP = new LinkedList<String>();\n\t\tQueue<Integer> queT = new LinkedList<Integer>();\n\n\t\tint timeCount = 0;\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}\n\n\t\twhile (queP.size() != 0) {\n\t\t\tif (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner stdIn = new Scanner(System.in);\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\n\t\tQueue<String> queP = new LinkedList<String>();\n\t\tQueue<Integer> queT = new LinkedList<Integer>();\n\n\t\tint timeCount = 0;\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}\n\n\t\twhile (queP.size() != 0) {\n\t\t\tif (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}\n\t\t}\n\t}",
"Scanner stdIn = new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"int n = stdIn.nextInt();",
"n",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int q = stdIn.nextInt();",
"q",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"Queue<String> queP = new LinkedList<String>();",
"queP",
"new LinkedList<String>()",
"Queue<Integer> queT = new LinkedList<Integer>();",
"queT",
"new LinkedList<Integer>()",
"int timeCount = 0;",
"timeCount",
"0",
"for (int i=0; i<n; i++) {\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}",
"{\n\t\t\tqueP.add(stdIn.next());\n\t\t\tqueT.add(stdIn.nextInt());\n\t\t}",
"queP.add(stdIn.next())",
"queP.add",
"queP",
"stdIn.next()",
"stdIn.next",
"stdIn",
"queT.add(stdIn.nextInt())",
"queT.add",
"queT",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"while (queP.size() != 0) {\n\t\t\tif (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}\n\t\t}",
"queP.size() != 0",
"queP.size()",
"queP.size",
"queP",
"0",
"{\n\t\t\tif (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}\n\t\t}",
"if (queT.peek() - q >0) {\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}else {\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}",
"queT.peek() - q >0",
"queT.peek() - q",
"queT.peek()",
"queT.peek",
"queT",
"q",
"0",
"{\n\t\t\t\tqueP.add(queP.poll());\n\t\t\t\tqueT.add(queT.poll()-q);\n\t\t\t\ttimeCount += q;\n\t\t\t}",
"queP.add(queP.poll())",
"queP.add",
"queP",
"queP.poll()",
"queP.poll",
"queP",
"queT.add(queT.poll()-q)",
"queT.add",
"queT",
"queT.poll()-q",
"queT.poll()",
"queT.poll",
"queT",
"q",
"timeCount += q",
"timeCount",
"q",
"{\n\t\t\t\ttimeCount += queT.poll();\n\t\t\t\tSystem.out.println(queP.poll()+\" \"+timeCount);\n\t\t\t}",
"timeCount += queT.poll()",
"timeCount",
"queT.poll()",
"queT.poll",
"queT",
"System.out.println(queP.poll()+\" \"+timeCount)",
"System.out.println",
"System.out",
"System",
"System.out",
"queP.poll()+\" \"+timeCount",
"queP.poll()+\" \"+timeCount",
"queP.poll()",
"queP.poll",
"queP",
"\" \"",
"timeCount",
"String[] args",
"args"
] | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int n = stdIn.nextInt();
int q = stdIn.nextInt();
Queue<String> queP = new LinkedList<String>();
Queue<Integer> queT = new LinkedList<Integer>();
int timeCount = 0;
for (int i=0; i<n; i++) {
queP.add(stdIn.next());
queT.add(stdIn.nextInt());
}
while (queP.size() != 0) {
if (queT.peek() - q >0) {
queP.add(queP.poll());
queT.add(queT.poll()-q);
timeCount += q;
}else {
timeCount += queT.poll();
System.out.println(queP.poll()+" "+timeCount);
}
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
41,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
41,
13,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
13,
4,
18,
4,
18,
13,
0,
18,
4,
18,
13,
13,
13,
0,
13,
13,
14,
2,
4,
18,
4,
18,
13,
17,
30,
4,
18,
13,
4,
18,
13,
30,
4,
18,
13,
2,
2,
4,
18,
4,
18,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
29,
18,
36,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
160,
8
],
[
160,
9
],
[
9,
10
],
[
9,
11
],
[
160,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
14,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
14,
25
],
[
25,
26
],
[
25,
27
],
[
14,
28
],
[
28,
29
],
[
14,
30
],
[
30,
31
],
[
14,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
44,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
44,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
14,
59
],
[
59,
60
],
[
59,
61
],
[
14,
62
],
[
62,
63
],
[
14,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
70,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
83,
87
],
[
82,
88
],
[
70,
89
],
[
89,
90
],
[
89,
91
],
[
70,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
93,
99
],
[
92,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
104,
105
],
[
105,
106
],
[
92,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
108,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
112,
118
],
[
112,
119
],
[
12,
120
],
[
120,
121
],
[
0,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
122,
126
],
[
126,
127
],
[
122,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
128,
141
],
[
141,
142
],
[
128,
143
],
[
143,
144
],
[
122,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
122,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
0,
159
],
[
159,
160
],
[
159,
161
]
] | [
"import java.util.*;\nimport static java.lang.System.*;\n\npublic class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tDeque<Process> deque = new ArrayDeque<>();\n\t\tString s;\n\t\tint a;\n\t\tfor (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}\n\t\tint time = 0;\n\t\tint temp;\n\t\twhile (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}\n\t}\n}\n\nclass Process {\n\tString name;\n\tint time;\n\tpublic Process (String n, int t) {\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}\n\tpublic String getName () {\n\t\treturn this.name;\n\t}\n\tpublic int getTime () {\n\t\treturn this.time;\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"import static java.lang.System.*;",
"import static java.lang.System.*;",
"import static java.lang.System.*;",
"public class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tDeque<Process> deque = new ArrayDeque<>();\n\t\tString s;\n\t\tint a;\n\t\tfor (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}\n\t\tint time = 0;\n\t\tint temp;\n\t\twhile (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}\n\t}\n}",
"Main",
"static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tDeque<Process> deque = new ArrayDeque<>();\n\t\tString s;\n\t\tint a;\n\t\tfor (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}\n\t\tint time = 0;\n\t\tint temp;\n\t\twhile (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}\n\t}",
"main",
"{\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tDeque<Process> deque = new ArrayDeque<>();\n\t\tString s;\n\t\tint a;\n\t\tfor (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}\n\t\tint time = 0;\n\t\tint temp;\n\t\twhile (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}\n\t}",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Deque<Process> deque = new ArrayDeque<>();",
"deque",
"new ArrayDeque<>()",
"String s;",
"s",
"int a;",
"a",
"for (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}",
"{\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}",
"s = sc.next()",
"s",
"sc.next()",
"sc.next",
"sc",
"a = sc.nextInt()",
"a",
"sc.nextInt()",
"sc.nextInt",
"sc",
"deque.addLast(new Process(s,a))",
"deque.addLast",
"deque",
"new Process(s,a)",
"int time = 0;",
"time",
"0",
"int temp;",
"temp",
"while (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}",
"deque.size()!=0",
"deque.size()",
"deque.size",
"deque",
"0",
"{\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}",
"temp = Math.min(q,deque.getFirst().getTime())",
"temp",
"Math.min(q,deque.getFirst().getTime())",
"Math.min",
"Math",
"q",
"deque.getFirst().getTime()",
"deque.getFirst().getTime",
"deque.getFirst()",
"deque.getFirst",
"deque",
"deque.getFirst().time -= temp",
"deque.getFirst().time",
"deque.getFirst()",
"deque.getFirst",
"deque",
"deque.getFirst().time",
"temp",
"time += temp",
"time",
"temp",
"if (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}",
"deque.getFirst().getTime() > 0",
"deque.getFirst().getTime()",
"deque.getFirst().getTime",
"deque.getFirst()",
"deque.getFirst",
"deque",
"0",
"{\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}",
"deque.addLast(deque.removeFirst())",
"deque.addLast",
"deque",
"deque.removeFirst()",
"deque.removeFirst",
"deque",
"{out.println(deque.removeFirst().getName()+\" \"+time);}",
"out.println(deque.removeFirst().getName()+\" \"+time)",
"out.println",
"out",
"deque.removeFirst().getName()+\" \"+time",
"deque.removeFirst().getName()+\" \"+time",
"deque.removeFirst().getName()",
"deque.removeFirst().getName",
"deque.removeFirst()",
"deque.removeFirst",
"deque",
"\" \"",
"time",
"String[] args",
"args",
"class Process {\n\tString name;\n\tint time;\n\tpublic Process (String n, int t) {\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}\n\tpublic String getName () {\n\t\treturn this.name;\n\t}\n\tpublic int getTime () {\n\t\treturn this.time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process (String n, int t) {\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}",
"Process",
"{\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}",
"this.name = n",
"this.name",
"this",
"this.name",
"n",
"this.time = t",
"this.time",
"this",
"this.time",
"t",
"String n",
"n",
"int t",
"t",
"public String getName () {\n\t\treturn this.name;\n\t}",
"getName",
"{\n\t\treturn this.name;\n\t}",
"return this.name;",
"this.name",
"this",
"this.name",
"public int getTime () {\n\t\treturn this.time;\n\t}",
"getTime",
"{\n\t\treturn this.time;\n\t}",
"return this.time;",
"this.time",
"this",
"this.time",
"public class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tDeque<Process> deque = new ArrayDeque<>();\n\t\tString s;\n\t\tint a;\n\t\tfor (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}\n\t\tint time = 0;\n\t\tint temp;\n\t\twhile (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}\n\t}\n}",
"public class Main {\n\tstatic Scanner sc = new Scanner(System.in);\n\tpublic static void main(String[] args) {\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tDeque<Process> deque = new ArrayDeque<>();\n\t\tString s;\n\t\tint a;\n\t\tfor (int i=0; i<n; i++) {\n\t\t\ts = sc.next();\n\t\t\ta = sc.nextInt();\n\t\t\tdeque.addLast(new Process(s,a));\n\t\t}\n\t\tint time = 0;\n\t\tint temp;\n\t\twhile (deque.size()!=0) {\n\t\t\ttemp = Math.min(q,deque.getFirst().getTime());\n\t\t\tdeque.getFirst().time -= temp;\n\t\t\ttime += temp;\n\t\t\tif (deque.getFirst().getTime() > 0) {\n\t\t\t\tdeque.addLast(deque.removeFirst());\n\t\t\t}\n\t\t\telse {out.println(deque.removeFirst().getName()+\" \"+time);}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
import static java.lang.System.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int n = sc.nextInt();
int q = sc.nextInt();
Deque<Process> deque = new ArrayDeque<>();
String s;
int a;
for (int i=0; i<n; i++) {
s = sc.next();
a = sc.nextInt();
deque.addLast(new Process(s,a));
}
int time = 0;
int temp;
while (deque.size()!=0) {
temp = Math.min(q,deque.getFirst().getTime());
deque.getFirst().time -= temp;
time += temp;
if (deque.getFirst().getTime() > 0) {
deque.addLast(deque.removeFirst());
}
else {out.println(deque.removeFirst().getName()+" "+time);}
}
}
}
class Process {
String name;
int time;
public Process (String n, int t) {
this.name = n;
this.time = t;
}
public String getName () {
return this.name;
}
public int getTime () {
return this.time;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
41,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
17,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
16,
20
],
[
20,
21
],
[
16,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
25,
29
],
[
24,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
22,
35
],
[
35,
36
],
[
22,
37
],
[
37,
38
],
[
0,
39
],
[
170,
40
],
[
170,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
49,
54
],
[
43,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
60,
62
],
[
43,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
65,
68
],
[
68,
69
],
[
68,
70
],
[
43,
71
],
[
71,
72
],
[
71,
73
],
[
43,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
74,
79
],
[
79,
80
],
[
79,
81
],
[
74,
82
],
[
82,
83
],
[
83,
84
],
[
74,
85
],
[
86,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
89,
94
],
[
86,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
43,
99
],
[
99,
100
],
[
99,
101
],
[
43,
102
],
[
102,
103
],
[
102,
104
],
[
43,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
105,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
114,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
122,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
131,
132
],
[
131,
133
],
[
122,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
122,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
122,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
116,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
146,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
146,
155
],
[
155,
156
],
[
156,
157
],
[
155,
158
],
[
43,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
164,
165
],
[
165,
166
],
[
41,
167
],
[
167,
168
],
[
0,
169
],
[
169,
170
],
[
169,
171
]
] | [
"import java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\nclass Process {\n\tString name;\n\tint time;\n\t\n\tProcess(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// BufferedReader br = new BufferedReader(new FileReader(\"in1.txt\"));\n\t\tString[] line1 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);\n\t\tDeque<Process> que = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint timeStamp = 0;\n\t\twhile (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.FileReader;",
"FileReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"class Process {\n\tString name;\n\tint time;\n\t\n\tProcess(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// BufferedReader br = new BufferedReader(new FileReader(\"in1.txt\"));\n\t\tString[] line1 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);\n\t\tDeque<Process> que = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint timeStamp = 0;\n\t\twhile (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// BufferedReader br = new BufferedReader(new FileReader(\"in1.txt\"));\n\t\tString[] line1 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);\n\t\tDeque<Process> que = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint timeStamp = 0;\n\t\twhile (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(sb.toString());\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// BufferedReader br = new BufferedReader(new FileReader(\"in1.txt\"));\n\t\tString[] line1 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);\n\t\tDeque<Process> que = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint timeStamp = 0;\n\t\twhile (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(sb.toString());\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] line1 = br.readLine().split(\" \");",
"line1",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(line1[0])",
"n",
"Integer.parseInt(line1[0])",
"Integer.parseInt",
"Integer",
"line1[0]",
"line1",
"0",
"q = Integer.parseInt(line1[1]);",
"q",
"Integer.parseInt(line1[1])",
"Integer.parseInt",
"Integer",
"line1[1]",
"line1",
"1",
"Deque<Process> que = new ArrayDeque<Process>();",
"que",
"new ArrayDeque<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}",
"{\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}",
"String[] line = br.readLine().split(\" \");",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"que.addLast(new Process(line[0], Integer.parseInt(line[1])))",
"que.addLast",
"que",
"new Process(line[0], Integer.parseInt(line[1]))",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int timeStamp = 0;",
"timeStamp",
"0",
"while (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}",
"Process p = que.removeFirst();",
"p",
"que.removeFirst()",
"que.removeFirst",
"que",
"if (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}",
"p.time <= q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t}",
"timeStamp += p.time",
"timeStamp",
"p.time",
"p",
"p.time",
"sb.append(p.name)",
"sb.append",
"sb",
"p.name",
"p",
"p.name",
"sb.append(' ')",
"sb.append",
"sb",
"' '",
"sb.append(timeStamp)",
"sb.append",
"sb",
"timeStamp",
"sb.append('\\n')",
"sb.append",
"sb",
"'\\n'",
"{\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}",
"timeStamp += q",
"timeStamp",
"q",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"que.addLast(p)",
"que.addLast",
"que",
"p",
"System.out.print(sb.toString())",
"System.out.print",
"System.out",
"System",
"System.out",
"sb.toString()",
"sb.toString",
"sb",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// BufferedReader br = new BufferedReader(new FileReader(\"in1.txt\"));\n\t\tString[] line1 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);\n\t\tDeque<Process> que = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint timeStamp = 0;\n\t\twhile (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t// BufferedReader br = new BufferedReader(new FileReader(\"in1.txt\"));\n\t\tString[] line1 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);\n\t\tDeque<Process> que = new ArrayDeque<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] line = br.readLine().split(\" \");\n\t\t\tque.addLast(new Process(line[0], Integer.parseInt(line[1])));\n\t\t}\n\t\t\n\t\tStringBuilder sb = new StringBuilder();\n\t\tint timeStamp = 0;\n\t\twhile (!que.isEmpty()) {\n\t\t\tProcess p = que.removeFirst();\n\t\t\tif (p.time <= q) {\n\t\t\t\ttimeStamp += p.time;\n\t\t\t\tsb.append(p.name);\n\t\t\t\tsb.append(' ');\n\t\t\t\tsb.append(timeStamp);\n\t\t\t\tsb.append('\\n');\n\t\t\t} else {\n\t\t\t\ttimeStamp += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tque.addLast(p);\n\t\t\t}\n\t\t}\n\t\t\n\t\tSystem.out.print(sb.toString());\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
class Process {
String name;
int time;
Process(String name, int time) {
this.name = name;
this.time = time;
}
}
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
String[] line1 = br.readLine().split(" ");
int n = Integer.parseInt(line1[0]), q = Integer.parseInt(line1[1]);
Deque<Process> que = new ArrayDeque<Process>();
for (int i = 0; i < n; i++) {
String[] line = br.readLine().split(" ");
que.addLast(new Process(line[0], Integer.parseInt(line[1])));
}
StringBuilder sb = new StringBuilder();
int timeStamp = 0;
while (!que.isEmpty()) {
Process p = que.removeFirst();
if (p.time <= q) {
timeStamp += p.time;
sb.append(p.name);
sb.append(' ');
sb.append(timeStamp);
sb.append('\n');
} else {
timeStamp += q;
p.time -= q;
que.addLast(p);
}
}
System.out.print(sb.toString());
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
40,
4,
13,
30,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
23,
13,
12,
13,
30,
14,
40,
4,
13,
30,
0,
18,
13,
13,
13,
23,
13,
12,
13,
30,
14,
40,
4,
13,
30,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
29,
13,
30,
29,
40,
17,
12,
13,
30,
14,
40,
4,
13,
30,
41,
13,
18,
13,
13,
29,
13,
30,
29,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
0,
13,
2,
13,
17,
0,
13,
20,
13,
0,
13,
20,
13,
41,
13,
4,
18,
13,
4,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
13,
4,
18,
13,
4,
13,
4,
18,
13,
41,
13,
17,
42,
40,
4,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
13,
13,
4,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
240,
5
],
[
240,
6
],
[
6,
7
],
[
240,
8
],
[
8,
9
],
[
240,
10
],
[
10,
11
],
[
240,
12
],
[
12,
13
],
[
240,
14
],
[
14,
15
],
[
240,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
22,
23
],
[
22,
24
],
[
240,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
240,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
240,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
46,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
50,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
56,
66
],
[
66,
67
],
[
67,
68
],
[
43,
69
],
[
69,
70
],
[
240,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
74,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
71,
84
],
[
84,
85
],
[
240,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
89,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
99,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
99,
109
],
[
109,
110
],
[
110,
111
],
[
93,
112
],
[
112,
113
],
[
89,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
240,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
121,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
128,
130
],
[
125,
131
],
[
131,
132
],
[
121,
133
],
[
133,
134
],
[
134,
135
],
[
240,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
138,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
138,
152
],
[
152,
153
],
[
152,
154
],
[
138,
156
],
[
156,
157
],
[
156,
158
],
[
138,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
138,
165
],
[
165,
166
],
[
138,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
167,
172
],
[
172,
173
],
[
172,
174
],
[
167,
175
],
[
175,
176
],
[
176,
177
],
[
167,
178
],
[
179,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
179,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
138,
190
],
[
190,
191
],
[
190,
192
],
[
138,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
193,
197
],
[
197,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
197,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
197,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
206,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
210,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
214,
219
],
[
220,
220
],
[
220,
221
],
[
220,
222
],
[
220,
223
],
[
206,
224
],
[
224,
225
],
[
225,
226
],
[
225,
227
],
[
224,
228
],
[
228,
229
],
[
228,
230
],
[
224,
231
],
[
231,
232
],
[
231,
233
],
[
224,
234
],
[
234,
235
],
[
234,
236
],
[
136,
237
],
[
237,
238
],
[
0,
239
],
[
239,
240
],
[
239,
241
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tstatic int max;\n\tstatic int Q[];\n\tstatic String P[];\n\tstatic int head;\n\tstatic int tail;\n\n\tstatic void initialize() {\n\t\thead = 0;\n\t\ttail = 0;\n\t}\n\n\tstatic boolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\n\tstatic boolean isFull() {\n\t\treturn head == (tail+1)%max;\n\t}\n\n\tstatic void enqueue1(int x) {\n\t\tif(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic void enqueue2(String s) {\n\t\tif(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}\n\t}\n\n\tstatic int dequeue1() {\n\t\tif(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tstatic String dequeue2() {\n\t\tif(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tmax = n + 1;\n\t\tP = new String[max];\n\t\tQ = new int[max];\n\t\tint q = sc.nextInt();\n\t\tinitialize();\n\t\t\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}\n\t\tint time = 0;\n\t\twhile(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\n\t }\n}\n\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tstatic int max;\n\tstatic int Q[];\n\tstatic String P[];\n\tstatic int head;\n\tstatic int tail;\n\n\tstatic void initialize() {\n\t\thead = 0;\n\t\ttail = 0;\n\t}\n\n\tstatic boolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\n\tstatic boolean isFull() {\n\t\treturn head == (tail+1)%max;\n\t}\n\n\tstatic void enqueue1(int x) {\n\t\tif(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic void enqueue2(String s) {\n\t\tif(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}\n\t}\n\n\tstatic int dequeue1() {\n\t\tif(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tstatic String dequeue2() {\n\t\tif(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tmax = n + 1;\n\t\tP = new String[max];\n\t\tQ = new int[max];\n\t\tint q = sc.nextInt();\n\t\tinitialize();\n\t\t\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}\n\t\tint time = 0;\n\t\twhile(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\n\t }\n}",
"Main",
"static int max;",
"max",
"static int Q[];",
"Q",
"static String P[];",
"P",
"static int head;",
"head",
"static int tail;",
"tail",
"static void initialize() {\n\t\thead = 0;\n\t\ttail = 0;\n\t}",
"initialize",
"{\n\t\thead = 0;\n\t\ttail = 0;\n\t}",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"static boolean isEmpty() {\n\t\treturn head == tail;\n\t}",
"isEmpty",
"{\n\t\treturn head == tail;\n\t}",
"return head == tail;",
"head == tail",
"head",
"tail",
"static boolean isFull() {\n\t\treturn head == (tail+1)%max;\n\t}",
"isFull",
"{\n\t\treturn head == (tail+1)%max;\n\t}",
"return head == (tail+1)%max;",
"head == (tail+1)%max",
"head",
"(tail+1)%max",
"(tail+1)",
"tail",
"1",
"max",
"static void enqueue1(int x) {\n\t\tif(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}\n\t}",
"enqueue1",
"{\n\t\tif(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}\n\t}",
"if(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}",
"!isFull()",
"isFull()",
"isFull",
"{\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}",
"Q[tail] = x",
"Q[tail]",
"Q",
"tail",
"x",
"if(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}",
"tail+1 ==max",
"tail+1",
"tail",
"1",
"max",
"{\n\t\t\t\ttail = 0;\n\t\t\t}",
"tail = 0",
"tail",
"0",
"{\n\t\t\t\ttail++;\n\t\t\t}",
"tail++",
"tail",
"int x",
"x",
"static void enqueue2(String s) {\n\t\tif(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}\n\t}",
"enqueue2",
"{\n\t\tif(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}\n\t}",
"if(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}",
"!isFull()",
"isFull()",
"isFull",
"{\n\t\t\tP[tail] = s;\n\t\t}",
"P[tail] = s",
"P[tail]",
"P",
"tail",
"s",
"String s",
"s",
"static int dequeue1() {\n\t\tif(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}\n\t}",
"dequeue1",
"{\n\t\tif(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}\n\t}",
"if(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}",
"int x = Q[head];",
"x",
"Q[head]",
"Q",
"head",
"if(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}",
"head+1 == max",
"head+1",
"head",
"1",
"max",
"{\n\t\t\t\thead = 0;\n\t\t\t}",
"head = 0",
"head",
"0",
"{\n\t\t\t\thead++;\n\t\t\t}",
"head++",
"head",
"return x;",
"x",
"{\n\t\t\treturn -1;\n\t\t}",
"return -1;",
"-1",
"1",
"static String dequeue2() {\n\t\tif(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}\n\t}",
"dequeue2",
"{\n\t\tif(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}\n\t}",
"if(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}",
"String s = P[head];",
"s",
"P[head]",
"P",
"head",
"return s;",
"s",
"{\n\t\t\treturn \"\";\n\t\t}",
"return \"\";",
"\"\"",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tmax = n + 1;\n\t\tP = new String[max];\n\t\tQ = new int[max];\n\t\tint q = sc.nextInt();\n\t\tinitialize();\n\t\t\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}\n\t\tint time = 0;\n\t\twhile(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\n\t }",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tmax = n + 1;\n\t\tP = new String[max];\n\t\tQ = new int[max];\n\t\tint q = sc.nextInt();\n\t\tinitialize();\n\t\t\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}\n\t\tint time = 0;\n\t\twhile(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\n\t }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"max = n + 1",
"max",
"n + 1",
"n",
"1",
"P = new String[max]",
"P",
"new String[max]",
"max",
"Q = new int[max]",
"Q",
"new int[max]",
"max",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"initialize()",
"initialize",
"for(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}",
"{\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}",
"enqueue2(sc.next())",
"enqueue2",
"sc.next()",
"sc.next",
"sc",
"enqueue1(sc.nextInt())",
"enqueue1",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int time = 0;",
"time",
"0",
"while(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"String s = dequeue2();",
"s",
"dequeue2()",
"dequeue2",
"int x = dequeue1();",
"x",
"dequeue1()",
"dequeue1",
"if(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}",
"x <= q",
"x",
"q",
"{\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}",
"time += x",
"time",
"x",
"System.out.println(s + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"s + \" \" + time",
"s + \" \" + time",
"s",
"\" \"",
"time",
"{\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}",
"x -= q",
"x",
"q",
"enqueue2(s)",
"enqueue2",
"s",
"enqueue1(x)",
"enqueue1",
"x",
"time += q",
"time",
"q",
"String[] args",
"args",
"public class Main {\n\n\tstatic int max;\n\tstatic int Q[];\n\tstatic String P[];\n\tstatic int head;\n\tstatic int tail;\n\n\tstatic void initialize() {\n\t\thead = 0;\n\t\ttail = 0;\n\t}\n\n\tstatic boolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\n\tstatic boolean isFull() {\n\t\treturn head == (tail+1)%max;\n\t}\n\n\tstatic void enqueue1(int x) {\n\t\tif(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic void enqueue2(String s) {\n\t\tif(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}\n\t}\n\n\tstatic int dequeue1() {\n\t\tif(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tstatic String dequeue2() {\n\t\tif(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tmax = n + 1;\n\t\tP = new String[max];\n\t\tQ = new int[max];\n\t\tint q = sc.nextInt();\n\t\tinitialize();\n\t\t\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}\n\t\tint time = 0;\n\t\twhile(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\n\t }\n}",
"public class Main {\n\n\tstatic int max;\n\tstatic int Q[];\n\tstatic String P[];\n\tstatic int head;\n\tstatic int tail;\n\n\tstatic void initialize() {\n\t\thead = 0;\n\t\ttail = 0;\n\t}\n\n\tstatic boolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\n\tstatic boolean isFull() {\n\t\treturn head == (tail+1)%max;\n\t}\n\n\tstatic void enqueue1(int x) {\n\t\tif(!isFull()) {\n\t\t\tQ[tail] = x;\n\t\t\tif(tail+1 ==max) {\n\t\t\t\ttail = 0;\n\t\t\t}else {\n\t\t\t\ttail++;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic void enqueue2(String s) {\n\t\tif(!isFull()) {\n\t\t\tP[tail] = s;\n\t\t}\n\t}\n\n\tstatic int dequeue1() {\n\t\tif(!isEmpty()) {\n\t\t\tint x = Q[head];\n\t\t\tif(head+1 == max) {\n\t\t\t\thead = 0;\n\t\t\t}else {\n\t\t\t\thead++;\n\t\t\t}\n\t\t\treturn x;\n\t\t}else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tstatic String dequeue2() {\n\t\tif(!isEmpty()) {\n\t\t\tString s = P[head];\n\t\t\treturn s;\n\t\t}else {\n\t\t\treturn \"\";\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tmax = n + 1;\n\t\tP = new String[max];\n\t\tQ = new int[max];\n\t\tint q = sc.nextInt();\n\t\tinitialize();\n\t\t\n\t\tfor(int i=0;i<n;i++) {\n\t\t\tenqueue2(sc.next());\n\t\t\tenqueue1(sc.nextInt());\n\t\t}\n\t\tint time = 0;\n\t\twhile(!isEmpty()) {\n\t\t\tString s = dequeue2();\n\t\t\tint x = dequeue1();\n\t\t\tif(x <= q) {\n\t\t\t\ttime += x;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\tx -= q;\n\t\t\t\tenqueue2(s);\n\t\t\t\tenqueue1(x);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\n\t }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static int max;
static int Q[];
static String P[];
static int head;
static int tail;
static void initialize() {
head = 0;
tail = 0;
}
static boolean isEmpty() {
return head == tail;
}
static boolean isFull() {
return head == (tail+1)%max;
}
static void enqueue1(int x) {
if(!isFull()) {
Q[tail] = x;
if(tail+1 ==max) {
tail = 0;
}else {
tail++;
}
}
}
static void enqueue2(String s) {
if(!isFull()) {
P[tail] = s;
}
}
static int dequeue1() {
if(!isEmpty()) {
int x = Q[head];
if(head+1 == max) {
head = 0;
}else {
head++;
}
return x;
}else {
return -1;
}
}
static String dequeue2() {
if(!isEmpty()) {
String s = P[head];
return s;
}else {
return "";
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
max = n + 1;
P = new String[max];
Q = new int[max];
int q = sc.nextInt();
initialize();
for(int i=0;i<n;i++) {
enqueue2(sc.next());
enqueue1(sc.nextInt());
}
int time = 0;
while(!isEmpty()) {
String s = dequeue2();
int x = dequeue1();
if(x <= q) {
time += x;
System.out.println(s + " " + time);
}else {
x -= q;
enqueue2(s);
enqueue1(x);
time += q;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
38,
5,
13,
30,
4,
18,
18,
13,
13,
13,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
41,
13,
41,
13,
0,
13,
17,
42,
2,
17,
0,
13,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
2,
13,
13,
4,
18,
13,
17,
0,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
19,
24
],
[
15,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
28,
33
],
[
25,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
25,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
47,
49
],
[
25,
50
],
[
50,
51
],
[
50,
52
],
[
25,
53
],
[
53,
54
],
[
53,
55
],
[
25,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
56,
61
],
[
61,
62
],
[
61,
63
],
[
56,
64
],
[
64,
65
],
[
65,
66
],
[
56,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
71,
76
],
[
68,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
80,
82
],
[
68,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
25,
92
],
[
92,
93
],
[
92,
94
],
[
25,
95
],
[
95,
96
],
[
25,
97
],
[
97,
98
],
[
25,
99
],
[
99,
100
],
[
25,
101
],
[
101,
102
],
[
101,
103
],
[
25,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
104,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
112,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
119,
123
],
[
118,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
124,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
124,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
136,
137
],
[
136,
138
],
[
124,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
124,
143
],
[
143,
144
],
[
143,
145
],
[
118,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
146,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
154,
155
],
[
154,
156
],
[
146,
157
],
[
157,
158
],
[
157,
159
],
[
112,
160
],
[
160,
161
],
[
161,
162
],
[
112,
163
],
[
163,
164
],
[
164,
165
],
[
25,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
166,
171
],
[
9,
172
],
[
172,
173
]
] | [
"import java.io.*;\nimport java.util.*;\n \nclass Main {\n public static void main(String[] args) {\n BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );\n try {\n \n String[] str = kb.readLine().split( \" \" );\n int n = Integer.parseInt( str[0] );\n int q = Integer.parseInt( str[1] );\n\t\t\t\n\t\t\tLinkedList<String> ps = new LinkedList<String>();\n\t\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\t \n String job;\n int time, t;\n t = 0;\n while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }\n System.out.print( output );\n \n } catch( IOException e ) {\n System.err.println( e );\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"class Main {\n public static void main(String[] args) {\n BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );\n try {\n \n String[] str = kb.readLine().split( \" \" );\n int n = Integer.parseInt( str[0] );\n int q = Integer.parseInt( str[1] );\n\t\t\t\n\t\t\tLinkedList<String> ps = new LinkedList<String>();\n\t\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\t \n String job;\n int time, t;\n t = 0;\n while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }\n System.out.print( output );\n \n } catch( IOException e ) {\n System.err.println( e );\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );\n try {\n \n String[] str = kb.readLine().split( \" \" );\n int n = Integer.parseInt( str[0] );\n int q = Integer.parseInt( str[1] );\n\t\t\t\n\t\t\tLinkedList<String> ps = new LinkedList<String>();\n\t\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\t \n String job;\n int time, t;\n t = 0;\n while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }\n System.out.print( output );\n \n } catch( IOException e ) {\n System.err.println( e );\n }\n }",
"main",
"{\n BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );\n try {\n \n String[] str = kb.readLine().split( \" \" );\n int n = Integer.parseInt( str[0] );\n int q = Integer.parseInt( str[1] );\n\t\t\t\n\t\t\tLinkedList<String> ps = new LinkedList<String>();\n\t\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\t \n String job;\n int time, t;\n t = 0;\n while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }\n System.out.print( output );\n \n } catch( IOException e ) {\n System.err.println( e );\n }\n }",
"BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );",
"kb",
"new BufferedReader( new InputStreamReader( System.in ) )",
"try {\n \n String[] str = kb.readLine().split( \" \" );\n int n = Integer.parseInt( str[0] );\n int q = Integer.parseInt( str[1] );\n\t\t\t\n\t\t\tLinkedList<String> ps = new LinkedList<String>();\n\t\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\t \n String job;\n int time, t;\n t = 0;\n while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }\n System.out.print( output );\n \n } catch( IOException e ) {\n System.err.println( e );\n }",
"catch( IOException e ) {\n System.err.println( e );\n }",
"IOException e",
"{\n System.err.println( e );\n }",
"System.err.println( e )",
"System.err.println",
"System.err",
"System",
"System.err",
"e",
"{\n \n String[] str = kb.readLine().split( \" \" );\n int n = Integer.parseInt( str[0] );\n int q = Integer.parseInt( str[1] );\n\t\t\t\n\t\t\tLinkedList<String> ps = new LinkedList<String>();\n\t\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\t \n String job;\n int time, t;\n t = 0;\n while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }\n System.out.print( output );\n \n }",
"String[] str = kb.readLine().split( \" \" );",
"str",
"kb.readLine().split( \" \" )",
"kb.readLine().split",
"kb.readLine()",
"kb.readLine",
"kb",
"\" \"",
"int n = Integer.parseInt( str[0] );",
"n",
"Integer.parseInt( str[0] )",
"Integer.parseInt",
"Integer",
"str[0]",
"str",
"0",
"int q = Integer.parseInt( str[1] );",
"q",
"Integer.parseInt( str[1] )",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"LinkedList<String> ps = new LinkedList<String>();",
"ps",
"new LinkedList<String>()",
"LinkedList<Integer> times = new LinkedList<Integer>();",
"times",
"new LinkedList<Integer>()",
"for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }",
"{\n str = kb.readLine().split( \" \" );\n ps.offer( str[0] );\n times.offer( Integer.parseInt( str[1] ) );\n }",
"str = kb.readLine().split( \" \" )",
"str",
"kb.readLine().split( \" \" )",
"kb.readLine().split",
"kb.readLine()",
"kb.readLine",
"kb",
"\" \"",
"ps.offer( str[0] )",
"ps.offer",
"ps",
"str[0]",
"str",
"0",
"times.offer( Integer.parseInt( str[1] ) )",
"times.offer",
"times",
"Integer.parseInt( str[1] )",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"StringBuilder output = new\tStringBuilder( );",
"output",
"new\tStringBuilder( )",
"String job;",
"job",
"int time",
"time",
"t;",
"t",
"t = 0",
"t",
"0",
"while( null != ( job = ps.peek() )) {\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }",
"null != ( job = ps.peek() )",
"null",
"( job = ps.peek() )",
"job",
"ps.peek()",
"ps.peek",
"ps",
"{\n \ttime = times.peek();\n \tif( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}\n \tps.poll();\n \ttimes.poll();\n }",
"time = times.peek()",
"time",
"times.peek()",
"times.peek",
"times",
"if( times.peek() <= q ) {\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t} else {\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}",
"times.peek() <= q",
"times.peek()",
"times.peek",
"times",
"q",
"{\n \t\toutput.append( job );\n \t\toutput.append( \" \" );\n \t\toutput.append( t + time );\n \t\toutput.append( \"\\n\" );\n \t\tt += time; \t\t\n \t}",
"output.append( job )",
"output.append",
"output",
"job",
"output.append( \" \" )",
"output.append",
"output",
"\" \"",
"output.append( t + time )",
"output.append",
"output",
"t + time",
"t",
"time",
"output.append( \"\\n\" )",
"output.append",
"output",
"\"\\n\"",
"t += time",
"t",
"time",
"{\n \t\tps.offer( job );\n\t times.offer( time - q );\n\t t += q; \n \t}",
"ps.offer( job )",
"ps.offer",
"ps",
"job",
"times.offer( time - q )",
"times.offer",
"times",
"time - q",
"time",
"q",
"t += q",
"t",
"q",
"ps.poll()",
"ps.poll",
"ps",
"times.poll()",
"times.poll",
"times",
"System.out.print( output )",
"System.out.print",
"System.out",
"System",
"System.out",
"output",
"String[] args",
"args"
] | import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) {
BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
try {
String[] str = kb.readLine().split( " " );
int n = Integer.parseInt( str[0] );
int q = Integer.parseInt( str[1] );
LinkedList<String> ps = new LinkedList<String>();
LinkedList<Integer> times = new LinkedList<Integer>();
for( int i=0; i<n; i++ ) {
str = kb.readLine().split( " " );
ps.offer( str[0] );
times.offer( Integer.parseInt( str[1] ) );
}
StringBuilder output = new StringBuilder( );
String job;
int time, t;
t = 0;
while( null != ( job = ps.peek() )) {
time = times.peek();
if( times.peek() <= q ) {
output.append( job );
output.append( " " );
output.append( t + time );
output.append( "\n" );
t += time;
} else {
ps.offer( job );
times.offer( time - q );
t += q;
}
ps.poll();
times.poll();
}
System.out.print( output );
} catch( IOException e ) {
System.err.println( e );
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
22,
23
],
[
22,
24
],
[
0,
25
],
[
128,
26
],
[
128,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
29,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
29,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
29,
43
],
[
43,
44
],
[
43,
45
],
[
29,
46
],
[
46,
47
],
[
46,
48
],
[
29,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
65,
66
],
[
66,
67
],
[
61,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
72,
73
],
[
29,
74
],
[
74,
75
],
[
74,
76
],
[
29,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
77,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
82,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
82,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
97,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
108,
110
],
[
93,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
121,
121
],
[
121,
122
],
[
121,
123
],
[
121,
124
],
[
27,
125
],
[
125,
126
],
[
0,
127
],
[
127,
128
],
[
127,
129
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int n = sc.nextInt();\n\t\tfinal int q = sc.nextInt();\n\t\t\n\t\tLinkedList<String> name_queue = new LinkedList<String>();\n\t\tLinkedList<Integer> time_queue = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tint total_time = 0;\n\t\twhile(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Map;",
"Map",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int n = sc.nextInt();\n\t\tfinal int q = sc.nextInt();\n\t\t\n\t\tLinkedList<String> name_queue = new LinkedList<String>();\n\t\tLinkedList<Integer> time_queue = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tint total_time = 0;\n\t\twhile(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int n = sc.nextInt();\n\t\tfinal int q = sc.nextInt();\n\t\t\n\t\tLinkedList<String> name_queue = new LinkedList<String>();\n\t\tLinkedList<Integer> time_queue = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tint total_time = 0;\n\t\twhile(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int n = sc.nextInt();\n\t\tfinal int q = sc.nextInt();\n\t\t\n\t\tLinkedList<String> name_queue = new LinkedList<String>();\n\t\tLinkedList<Integer> time_queue = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tint total_time = 0;\n\t\twhile(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"final int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"final int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"LinkedList<String> name_queue = new LinkedList<String>();",
"name_queue",
"new LinkedList<String>()",
"LinkedList<Integer> time_queue = new LinkedList<Integer>();",
"time_queue",
"new LinkedList<Integer>()",
"for(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}",
"name_queue.add(sc.next())",
"name_queue.add",
"name_queue",
"sc.next()",
"sc.next",
"sc",
"time_queue.add(sc.nextInt())",
"time_queue.add",
"time_queue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int total_time = 0;",
"total_time",
"0",
"while(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}",
"!time_queue.isEmpty()",
"time_queue.isEmpty()",
"time_queue.isEmpty",
"time_queue",
"{\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}",
"final String name = name_queue.poll();",
"name",
"name_queue.poll()",
"name_queue.poll",
"name_queue",
"final int time = time_queue.poll();",
"time",
"time_queue.poll()",
"time_queue.poll",
"time_queue",
"if(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}",
"time > q",
"time",
"q",
"{\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}",
"total_time += q",
"total_time",
"q",
"name_queue.add(name)",
"name_queue.add",
"name_queue",
"name",
"time_queue.add(time - q)",
"time_queue.add",
"time_queue",
"time - q",
"time",
"q",
"{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}",
"total_time += time",
"total_time",
"time",
"System.out.println(name + \" \" + total_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + total_time",
"name + \" \" + total_time",
"name",
"\" \"",
"total_time",
"String args[]",
"args",
"public class Main {\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int n = sc.nextInt();\n\t\tfinal int q = sc.nextInt();\n\t\t\n\t\tLinkedList<String> name_queue = new LinkedList<String>();\n\t\tLinkedList<Integer> time_queue = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tint total_time = 0;\n\t\twhile(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n}",
"public class Main {\n\t\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tfinal int n = sc.nextInt();\n\t\tfinal int q = sc.nextInt();\n\t\t\n\t\tLinkedList<String> name_queue = new LinkedList<String>();\n\t\tLinkedList<Integer> time_queue = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tname_queue.add(sc.next());\n\t\t\ttime_queue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\tint total_time = 0;\n\t\twhile(!time_queue.isEmpty()){\n\t\t\tfinal String name = name_queue.poll();\n\t\t\tfinal int time = time_queue.poll();\n\t\t\t\n\t\t\tif(time > q){\n\t\t\t\ttotal_time += q;\n\t\t\t\tname_queue.add(name);\n\t\t\t\ttime_queue.add(time - q);\n\t\t\t}else{\n\t\t\t\ttotal_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + total_time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\t\t\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
final int n = sc.nextInt();
final int q = sc.nextInt();
LinkedList<String> name_queue = new LinkedList<String>();
LinkedList<Integer> time_queue = new LinkedList<Integer>();
for(int i = 0; i < n; i++){
name_queue.add(sc.next());
time_queue.add(sc.nextInt());
}
int total_time = 0;
while(!time_queue.isEmpty()){
final String name = name_queue.poll();
final int time = time_queue.poll();
if(time > q){
total_time += q;
name_queue.add(name);
time_queue.add(time - q);
}else{
total_time += time;
System.out.println(name + " " + total_time);
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
0,
13,
4,
18,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
0,
13,
0,
13,
17,
12,
13,
30,
41,
13,
20,
4,
18,
13,
13,
40,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
13,
40,
13,
29,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
17,
30,
29,
17,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
20,
42,
40,
4,
13,
30,
41,
13,
4,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
40,
13,
30,
0,
13,
13,
4,
13,
18,
13,
13,
2,
18,
13,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
18,
4,
18,
13,
13,
13,
17,
18,
4,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
247,
5
],
[
247,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
8,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
8,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
33,
38
],
[
38,
39
],
[
38,
40
],
[
33,
41
],
[
41,
42
],
[
42,
43
],
[
33,
44
],
[
45,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
45,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
54,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
6,
63
],
[
63,
64
],
[
0,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
65,
69
],
[
69,
70
],
[
65,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
71,
84
],
[
84,
85
],
[
71,
86
],
[
86,
87
],
[
0,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
88,
92
],
[
92,
93
],
[
88,
94
],
[
94,
95
],
[
88,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
88,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
109,
117
],
[
117,
118
],
[
107,
119
],
[
119,
120
],
[
107,
121
],
[
121,
122
],
[
88,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
125,
132
],
[
132,
133
],
[
125,
134
],
[
134,
135
],
[
88,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
139,
146
],
[
146,
147
],
[
147,
148
],
[
88,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
155,
157
],
[
151,
158
],
[
158,
159
],
[
151,
160
],
[
160,
161
],
[
160,
162
],
[
151,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
163,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
167,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
172,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
181,
183
],
[
178,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
178,
189
],
[
189,
190
],
[
190,
191
],
[
189,
192
],
[
178,
193
],
[
193,
194
],
[
172,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
201,
203
],
[
199,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
204,
208
],
[
151,
209
],
[
209,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
209,
214
],
[
214,
215
],
[
214,
216
],
[
209,
217
],
[
217,
218
],
[
218,
219
],
[
209,
220
],
[
221,
221
],
[
221,
222
],
[
222,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
222,
227
],
[
228,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
233,
234
],
[
232,
235
],
[
231,
236
],
[
228,
237
],
[
228,
238
],
[
238,
239
],
[
239,
240
],
[
240,
241
],
[
239,
242
],
[
238,
243
],
[
149,
244
],
[
244,
245
],
[
0,
246
],
[
246,
247
],
[
246,
248
]
] | [
"import java.util.*;\n\npublic class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, time, i;\n\t\tqueue que = new queue();\n\t\t\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}\n\t\t\n\t\tque.simulate(q);\n\t}\n}\n\nclass data{\n\tString name;\n\tint time;\n\t\n\tdata(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}\n\nclass queue{\n\tArrayList<data> Q;\n\tint head, tail;\n\t\n\tqueue(){\n\t\tQ = new ArrayList<data>();\n\t\thead = tail = 0;\n\t}\n\t\n\tvoid enqueue(String name, int time){\n\t\tdata process = new data(name, time);\n\t\t\n\t\tQ.add(process);\n\t\ttail ++;\n\t}\n\t\n\tdata dequeue(){\n\t\tdata process = Q.get(head);\n\t\t\n\t\thead ++;\n\t\t\n\t\treturn process;\n\t}\n\t\n\tboolean isEmpty(){\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}\n\t\telse{\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tvoid simulate(int q){\n\t\tint sum = 0, cnt = 0, t;\n\t\tArrayList<data> finish = new ArrayList<data>();\n\t\t\n\t\twhile(!isEmpty()){\n\t\t\tdata temp = dequeue();\n\t\t\tif(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < cnt; i++){\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, time, i;\n\t\tqueue que = new queue();\n\t\t\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}\n\t\t\n\t\tque.simulate(q);\n\t}\n}",
"Main",
"public static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, time, i;\n\t\tqueue que = new queue();\n\t\t\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}\n\t\t\n\t\tque.simulate(q);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, time, i;\n\t\tqueue que = new queue();\n\t\t\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}\n\t\t\n\t\tque.simulate(q);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n",
"n",
"q",
"q",
"time",
"time",
"i;",
"i",
"queue que = new queue();",
"que",
"new queue()",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = sc.nextInt()",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}",
"{\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}",
"String name = new String(sc.next());",
"name",
"new String(sc.next())",
"time = sc.nextInt()",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"que.enqueue(name, time)",
"que.enqueue",
"que",
"name",
"time",
"que.simulate(q)",
"que.simulate",
"que",
"q",
"String args[]",
"args",
"class data{\n\tString name;\n\tint time;\n\t\n\tdata(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"data",
"String name;",
"name",
"int time;",
"time",
"data(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"data",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"class queue{\n\tArrayList<data> Q;\n\tint head, tail;\n\t\n\tqueue(){\n\t\tQ = new ArrayList<data>();\n\t\thead = tail = 0;\n\t}\n\t\n\tvoid enqueue(String name, int time){\n\t\tdata process = new data(name, time);\n\t\t\n\t\tQ.add(process);\n\t\ttail ++;\n\t}\n\t\n\tdata dequeue(){\n\t\tdata process = Q.get(head);\n\t\t\n\t\thead ++;\n\t\t\n\t\treturn process;\n\t}\n\t\n\tboolean isEmpty(){\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}\n\t\telse{\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\tvoid simulate(int q){\n\t\tint sum = 0, cnt = 0, t;\n\t\tArrayList<data> finish = new ArrayList<data>();\n\t\t\n\t\twhile(!isEmpty()){\n\t\t\tdata temp = dequeue();\n\t\t\tif(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < cnt; i++){\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}\n\t}\n}",
"queue",
"ArrayList<data> Q;",
"Q",
"int head",
"head",
"tail;",
"tail",
"queue(){\n\t\tQ = new ArrayList<data>();\n\t\thead = tail = 0;\n\t}",
"queue",
"{\n\t\tQ = new ArrayList<data>();\n\t\thead = tail = 0;\n\t}",
"Q = new ArrayList<data>()",
"Q",
"new ArrayList<data>()",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"void enqueue(String name, int time){\n\t\tdata process = new data(name, time);\n\t\t\n\t\tQ.add(process);\n\t\ttail ++;\n\t}",
"enqueue",
"{\n\t\tdata process = new data(name, time);\n\t\t\n\t\tQ.add(process);\n\t\ttail ++;\n\t}",
"data process = new data(name, time);",
"process",
"new data(name, time)",
"Q.add(process)",
"Q.add",
"Q",
"process",
"tail ++",
"tail",
"String name",
"name",
"int time",
"time",
"data dequeue(){\n\t\tdata process = Q.get(head);\n\t\t\n\t\thead ++;\n\t\t\n\t\treturn process;\n\t}",
"dequeue",
"{\n\t\tdata process = Q.get(head);\n\t\t\n\t\thead ++;\n\t\t\n\t\treturn process;\n\t}",
"data process = Q.get(head);",
"process",
"Q.get(head)",
"Q.get",
"Q",
"head",
"head ++",
"head",
"return process;",
"process",
"boolean isEmpty(){\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}\n\t\telse{\n\t\t\treturn false;\n\t\t}\n\t}",
"isEmpty",
"{\n\t\tif(head == tail){\n\t\t\treturn true;\n\t\t}\n\t\telse{\n\t\t\treturn false;\n\t\t}\n\t}",
"if(head == tail){\n\t\t\treturn true;\n\t\t}\n\t\telse{\n\t\t\treturn false;\n\t\t}",
"head == tail",
"head",
"tail",
"{\n\t\t\treturn true;\n\t\t}",
"return true;",
"true",
"{\n\t\t\treturn false;\n\t\t}",
"return false;",
"false",
"void simulate(int q){\n\t\tint sum = 0, cnt = 0, t;\n\t\tArrayList<data> finish = new ArrayList<data>();\n\t\t\n\t\twhile(!isEmpty()){\n\t\t\tdata temp = dequeue();\n\t\t\tif(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < cnt; i++){\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}\n\t}",
"simulate",
"{\n\t\tint sum = 0, cnt = 0, t;\n\t\tArrayList<data> finish = new ArrayList<data>();\n\t\t\n\t\twhile(!isEmpty()){\n\t\t\tdata temp = dequeue();\n\t\t\tif(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < cnt; i++){\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}\n\t}",
"int sum = 0",
"sum",
"0",
"cnt = 0",
"cnt",
"0",
"t;",
"t",
"ArrayList<data> finish = new ArrayList<data>();",
"finish",
"new ArrayList<data>()",
"while(!isEmpty()){\n\t\t\tdata temp = dequeue();\n\t\t\tif(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}\n\t\t}",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n\t\t\tdata temp = dequeue();\n\t\t\tif(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}\n\t\t}",
"data temp = dequeue();",
"temp",
"dequeue()",
"dequeue",
"if(temp.time <= q){\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}",
"temp.time <= q",
"temp.time",
"temp",
"temp.time",
"q",
"{\n\t\t\t\tsum += temp.time;\n\t\t\t\ttemp.time = sum;\n\t\t\t\tfinish.add(temp);\n\t\t\t\t\n\t\t\t\tcnt ++;\n\t\t\t}",
"sum += temp.time",
"sum",
"temp.time",
"temp",
"temp.time",
"temp.time = sum",
"temp.time",
"temp",
"temp.time",
"sum",
"finish.add(temp)",
"finish.add",
"finish",
"temp",
"cnt ++",
"cnt",
"{\n\t\t\t\tsum += q;\n\t\t\t\tenqueue(temp.name, temp.time - q);\n\t\t\t}",
"sum += q",
"sum",
"q",
"enqueue(temp.name, temp.time - q)",
"enqueue",
"temp.name",
"temp",
"temp.name",
"temp.time - q",
"temp.time",
"temp",
"temp.time",
"q",
"for(int i = 0; i < cnt; i++){\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < cnt",
"i",
"cnt",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}",
"{\n\t\t\tSystem.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time);\n\t\t}",
"System.out.println(finish.get(i).name.toString() + \" \" + finish.get(i).time)",
"System.out.println",
"System.out",
"System",
"System.out",
"finish.get(i).name.toString() + \" \" + finish.get(i).time",
"finish.get(i).name.toString() + \" \" + finish.get(i).time",
"finish.get(i).name.toString()",
"finish.get(i).name.toString",
"finish.get(i).name",
"finish.get(i)",
"finish.get",
"finish",
"i",
"finish.get(i).name",
"\" \"",
"finish.get(i).time",
"finish.get(i)",
"finish.get",
"finish",
"i",
"finish.get(i).time",
"int q",
"q",
"public class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, time, i;\n\t\tqueue que = new queue();\n\t\t\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}\n\t\t\n\t\tque.simulate(q);\n\t}\n}",
"public class Main{\n\tpublic static void main(String args[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n, q, time, i;\n\t\tqueue que = new queue();\n\t\t\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\t\t\n\t\tfor(i = 0; i < n; i++){\n\t\t\tString name = new String(sc.next());\n\t\t\ttime = sc.nextInt();\n\t\t\t\n\t\t\tque.enqueue(name, time);\n\t\t}\n\t\t\n\t\tque.simulate(q);\n\t}\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n, q, time, i;
queue que = new queue();
n = sc.nextInt();
q = sc.nextInt();
for(i = 0; i < n; i++){
String name = new String(sc.next());
time = sc.nextInt();
que.enqueue(name, time);
}
que.simulate(q);
}
}
class data{
String name;
int time;
data(String name, int time){
this.name = name;
this.time = time;
}
}
class queue{
ArrayList<data> Q;
int head, tail;
queue(){
Q = new ArrayList<data>();
head = tail = 0;
}
void enqueue(String name, int time){
data process = new data(name, time);
Q.add(process);
tail ++;
}
data dequeue(){
data process = Q.get(head);
head ++;
return process;
}
boolean isEmpty(){
if(head == tail){
return true;
}
else{
return false;
}
}
void simulate(int q){
int sum = 0, cnt = 0, t;
ArrayList<data> finish = new ArrayList<data>();
while(!isEmpty()){
data temp = dequeue();
if(temp.time <= q){
sum += temp.time;
temp.time = sum;
finish.add(temp);
cnt ++;
}
else{
sum += q;
enqueue(temp.name, temp.time - q);
}
}
for(int i = 0; i < cnt; i++){
System.out.println(finish.get(i).name.toString() + " " + finish.get(i).time);
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
20,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
18,
13,
13,
41,
13,
18,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
20,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
153,
8
],
[
153,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
54,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
66,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
70,
75
],
[
76,
76
],
[
76,
77
],
[
76,
78
],
[
76,
79
],
[
11,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
80,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
85,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
85,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
85,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
101,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
123,
123
],
[
123,
124
],
[
123,
125
],
[
123,
126
],
[
9,
127
],
[
127,
128
],
[
153,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
129,
133
],
[
133,
134
],
[
129,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
137,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
135,
148
],
[
148,
149
],
[
135,
150
],
[
150,
151
],
[
0,
152
],
[
152,
153
],
[
152,
154
]
] | [
"\nimport java.util.LinkedList;\nimport java.util.Scanner;\n\n/**\n * Created by sd on 2016/11/22.\n */\npublic class Main {\n static class Pair{\n String name;\n int left;\n Pair(String name, int left){\n this.name = name;\n this.left = left;\n }\n }\n\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n LinkedList<Pair> queue = new LinkedList<>();\n int n = sc.nextInt(), q = sc.nextInt();\n int time_w = 0;\n for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n\n }\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n static class Pair{\n String name;\n int left;\n Pair(String name, int left){\n this.name = name;\n this.left = left;\n }\n }\n\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n LinkedList<Pair> queue = new LinkedList<>();\n int n = sc.nextInt(), q = sc.nextInt();\n int time_w = 0;\n for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n LinkedList<Pair> queue = new LinkedList<>();\n int n = sc.nextInt(), q = sc.nextInt();\n int time_w = 0;\n for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n LinkedList<Pair> queue = new LinkedList<>();\n int n = sc.nextInt(), q = sc.nextInt();\n int time_w = 0;\n for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"LinkedList<Pair> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"int n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int time_w = 0;",
"time_w",
"0",
"for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }",
"{\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }",
"String str = sc.next();",
"str",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }",
"time > q",
"time",
"q",
"{\n time_w += q;\n queue.add(new Pair(str, time-q));\n }",
"time_w += q",
"time_w",
"q",
"queue.add(new Pair(str, time-q))",
"queue.add",
"queue",
"new Pair(str, time-q)",
"{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }",
"time_w += time",
"time_w",
"time",
"System.out.println(str+\" \"+time_w)",
"System.out.println",
"System.out",
"System",
"System.out",
"str+\" \"+time_w",
"str+\" \"+time_w",
"str",
"\" \"",
"time_w",
"while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }",
"Pair p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"String str = p.name;",
"str",
"p.name",
"p",
"p.name",
"int time = p.left;",
"time",
"p.left",
"p",
"p.left",
"if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }",
"time > q",
"time",
"q",
"{\n time_w += q;\n queue.add(new Pair(str, time-q));\n }",
"time_w += q",
"time_w",
"q",
"queue.add(new Pair(str, time-q))",
"queue.add",
"queue",
"new Pair(str, time-q)",
"{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }",
"time_w += time",
"time_w",
"time",
"System.out.println(str+\" \"+time_w)",
"System.out.println",
"System.out",
"System",
"System.out",
"str+\" \"+time_w",
"str+\" \"+time_w",
"str",
"\" \"",
"time_w",
"String[] args",
"args",
"static class Pair{\n String name;\n int left;\n Pair(String name, int left){\n this.name = name;\n this.left = left;\n }\n }",
"Pair",
"String name;",
"name",
"int left;",
"left",
"Pair(String name, int left){\n this.name = name;\n this.left = left;\n }",
"Pair",
"{\n this.name = name;\n this.left = left;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.left = left",
"this.left",
"this",
"this.left",
"left",
"String name",
"name",
"int left",
"left",
"public class Main {\n static class Pair{\n String name;\n int left;\n Pair(String name, int left){\n this.name = name;\n this.left = left;\n }\n }\n\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n LinkedList<Pair> queue = new LinkedList<>();\n int n = sc.nextInt(), q = sc.nextInt();\n int time_w = 0;\n for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n\n }\n}",
"public class Main {\n static class Pair{\n String name;\n int left;\n Pair(String name, int left){\n this.name = name;\n this.left = left;\n }\n }\n\n public static void main(String[] args){\n Scanner sc = new Scanner(System.in);\n LinkedList<Pair> queue = new LinkedList<>();\n int n = sc.nextInt(), q = sc.nextInt();\n int time_w = 0;\n for(int i=0; i<n; i++){\n String str = sc.next();\n int time = sc.nextInt();\n\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n while(!queue.isEmpty()){\n Pair p = queue.poll();\n String str = p.name;\n int time = p.left;\n if(time > q){\n time_w += q;\n queue.add(new Pair(str, time-q));\n }else{\n time_w += time;\n System.out.println(str+\" \"+time_w);\n }\n }\n\n }\n}",
"Main"
] |
import java.util.LinkedList;
import java.util.Scanner;
/**
* Created by sd on 2016/11/22.
*/
public class Main {
static class Pair{
String name;
int left;
Pair(String name, int left){
this.name = name;
this.left = left;
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
LinkedList<Pair> queue = new LinkedList<>();
int n = sc.nextInt(), q = sc.nextInt();
int time_w = 0;
for(int i=0; i<n; i++){
String str = sc.next();
int time = sc.nextInt();
if(time > q){
time_w += q;
queue.add(new Pair(str, time-q));
}else{
time_w += time;
System.out.println(str+" "+time_w);
}
}
while(!queue.isEmpty()){
Pair p = queue.poll();
String str = p.name;
int time = p.left;
if(time > q){
time_w += q;
queue.add(new Pair(str, time-q));
}else{
time_w += time;
System.out.println(str+" "+time_w);
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
42,
2,
40,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
12,
13,
30,
41,
13,
20,
28,
13,
13,
30,
4,
18,
4,
18,
13,
4,
18,
13,
17,
4,
18,
18,
13,
13,
4,
18,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
13,
13,
29,
13,
23,
13,
12,
13,
30,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
182,
5
],
[
182,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
13,
14
],
[
6,
15
],
[
15,
16
],
[
182,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
19,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
19,
33
],
[
33,
34
],
[
33,
35
],
[
19,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
37,
40
],
[
36,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
41,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
41,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
19,
56
],
[
56,
57
],
[
56,
58
],
[
19,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
60,
64
],
[
59,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
72,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
89,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
89,
93
],
[
89,
94
],
[
71,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
95,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
182,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
113,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
122,
123
],
[
123,
124
],
[
117,
125
],
[
109,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
107,
136
],
[
136,
137
],
[
182,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
138,
142
],
[
142,
143
],
[
138,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
146,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
144,
157
],
[
157,
158
],
[
144,
159
],
[
159,
160
],
[
138,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
138,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
172,
173
],
[
166,
174
],
[
174,
175
],
[
138,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
0,
181
],
[
181,
182
],
[
181,
183
]
] | [
"import java.util.*;\n\npublic class Main {\n \n public static void main(String[] args) {\n Main main = new Main();\n main.solv();\n }\n \n private void solv() {\n Scanner input = new Scanner(System.in);\n int n = input.nextInt();\n int q = input.nextInt();\n Deque<Proc> st = new ArrayDeque<Proc>(n);\n while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }\n \n int t = 0;\n while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }\n }\n \n private void print(Object[] xs) {\n StringBuilder sb = new StringBuilder();\n for (Object x : xs) sb.append(x.toString()).append(' ');\n System.out.println(sb.toString().trim());\n }\n \n private static class Proc {\n String name;\n int time;\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n public int getTime() {return time;}\n public int subTime(int t) {time -= t; return time;}\n public String getName() {return name;}\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n \n public static void main(String[] args) {\n Main main = new Main();\n main.solv();\n }\n \n private void solv() {\n Scanner input = new Scanner(System.in);\n int n = input.nextInt();\n int q = input.nextInt();\n Deque<Proc> st = new ArrayDeque<Proc>(n);\n while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }\n \n int t = 0;\n while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }\n }\n \n private void print(Object[] xs) {\n StringBuilder sb = new StringBuilder();\n for (Object x : xs) sb.append(x.toString()).append(' ');\n System.out.println(sb.toString().trim());\n }\n \n private static class Proc {\n String name;\n int time;\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n public int getTime() {return time;}\n public int subTime(int t) {time -= t; return time;}\n public String getName() {return name;}\n }\n}",
"Main",
"public static void main(String[] args) {\n Main main = new Main();\n main.solv();\n }",
"main",
"{\n Main main = new Main();\n main.solv();\n }",
"Main main = new Main();",
"main",
"new Main()",
"main.solv()",
"main.solv",
"main",
"String[] args",
"args",
"private void solv() {\n Scanner input = new Scanner(System.in);\n int n = input.nextInt();\n int q = input.nextInt();\n Deque<Proc> st = new ArrayDeque<Proc>(n);\n while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }\n \n int t = 0;\n while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }\n }",
"solv",
"{\n Scanner input = new Scanner(System.in);\n int n = input.nextInt();\n int q = input.nextInt();\n Deque<Proc> st = new ArrayDeque<Proc>(n);\n while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }\n \n int t = 0;\n while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }\n }",
"Scanner input = new Scanner(System.in);",
"input",
"new Scanner(System.in)",
"int n = input.nextInt();",
"n",
"input.nextInt()",
"input.nextInt",
"input",
"int q = input.nextInt();",
"q",
"input.nextInt()",
"input.nextInt",
"input",
"Deque<Proc> st = new ArrayDeque<Proc>(n);",
"st",
"new ArrayDeque<Proc>(n)",
"while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }",
"n-- > 0",
"n--",
"n",
"0",
"{\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }",
"String name = input.next();",
"name",
"input.next()",
"input.next",
"input",
"int time = input.nextInt();",
"time",
"input.nextInt()",
"input.nextInt",
"input",
"st.add(new Proc(name, time))",
"st.add",
"st",
"new Proc(name, time)",
"int t = 0;",
"t",
"0",
"while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }",
"st.isEmpty() == false",
"st.isEmpty()",
"st.isEmpty",
"st",
"false",
"{\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }",
"Proc p = st.poll();",
"p",
"st.poll()",
"st.poll",
"st",
"if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }",
"p.getTime() <= q",
"p.getTime()",
"p.getTime",
"p",
"q",
"{\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n }",
"t += p.getTime()",
"t",
"p.getTime()",
"p.getTime",
"p",
"System.out.println(p.getName() + \" \" + t)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getName() + \" \" + t",
"p.getName() + \" \" + t",
"p.getName()",
"p.getName",
"p",
"\" \"",
"t",
"{\n t += q;\n p.subTime(q);\n st.add(p);\n }",
"t += q",
"t",
"q",
"p.subTime(q)",
"p.subTime",
"p",
"q",
"st.add(p)",
"st.add",
"st",
"p",
"private void print(Object[] xs) {\n StringBuilder sb = new StringBuilder();\n for (Object x : xs) sb.append(x.toString()).append(' ');\n System.out.println(sb.toString().trim());\n }",
"print",
"{\n StringBuilder sb = new StringBuilder();\n for (Object x : xs) sb.append(x.toString()).append(' ');\n System.out.println(sb.toString().trim());\n }",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"for (Object x : xs) sb.append(x.toString()).append(' ');",
"Object x",
"xs",
"sb.append(x.toString()).append(' ');",
"sb.append(x.toString()).append(' ')",
"sb.append(x.toString()).append",
"sb.append(x.toString())",
"sb.append",
"sb",
"x.toString()",
"x.toString",
"x",
"' '",
"System.out.println(sb.toString().trim())",
"System.out.println",
"System.out",
"System",
"System.out",
"sb.toString().trim()",
"sb.toString().trim",
"sb.toString()",
"sb.toString",
"sb",
"Object[] xs",
"xs",
"private static class Proc {\n String name;\n int time;\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n public int getTime() {return time;}\n public int subTime(int t) {time -= t; return time;}\n public String getName() {return name;}\n }",
"Proc",
"String name;",
"name",
"int time;",
"time",
"public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Proc",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public int getTime() {return time;}",
"getTime",
"{return time;}",
"return time;",
"time",
"public int subTime(int t) {time -= t; return time;}",
"subTime",
"{time -= t; return time;}",
"time -= t",
"time",
"t",
"return time;",
"time",
"int t",
"t",
"public String getName() {return name;}",
"getName",
"{return name;}",
"return name;",
"name",
"public class Main {\n \n public static void main(String[] args) {\n Main main = new Main();\n main.solv();\n }\n \n private void solv() {\n Scanner input = new Scanner(System.in);\n int n = input.nextInt();\n int q = input.nextInt();\n Deque<Proc> st = new ArrayDeque<Proc>(n);\n while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }\n \n int t = 0;\n while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }\n }\n \n private void print(Object[] xs) {\n StringBuilder sb = new StringBuilder();\n for (Object x : xs) sb.append(x.toString()).append(' ');\n System.out.println(sb.toString().trim());\n }\n \n private static class Proc {\n String name;\n int time;\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n public int getTime() {return time;}\n public int subTime(int t) {time -= t; return time;}\n public String getName() {return name;}\n }\n}",
"public class Main {\n \n public static void main(String[] args) {\n Main main = new Main();\n main.solv();\n }\n \n private void solv() {\n Scanner input = new Scanner(System.in);\n int n = input.nextInt();\n int q = input.nextInt();\n Deque<Proc> st = new ArrayDeque<Proc>(n);\n while (n-- > 0) {\n String name = input.next();\n int time = input.nextInt();\n st.add(new Proc(name, time));\n }\n \n int t = 0;\n while (st.isEmpty() == false) {\n Proc p = st.poll();\n if (p.getTime() <= q) {\n t += p.getTime();\n System.out.println(p.getName() + \" \" + t);\n } else {\n t += q;\n p.subTime(q);\n st.add(p);\n }\n }\n }\n \n private void print(Object[] xs) {\n StringBuilder sb = new StringBuilder();\n for (Object x : xs) sb.append(x.toString()).append(' ');\n System.out.println(sb.toString().trim());\n }\n \n private static class Proc {\n String name;\n int time;\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n public int getTime() {return time;}\n public int subTime(int t) {time -= t; return time;}\n public String getName() {return name;}\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Main main = new Main();
main.solv();
}
private void solv() {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int q = input.nextInt();
Deque<Proc> st = new ArrayDeque<Proc>(n);
while (n-- > 0) {
String name = input.next();
int time = input.nextInt();
st.add(new Proc(name, time));
}
int t = 0;
while (st.isEmpty() == false) {
Proc p = st.poll();
if (p.getTime() <= q) {
t += p.getTime();
System.out.println(p.getName() + " " + t);
} else {
t += q;
p.subTime(q);
st.add(p);
}
}
}
private void print(Object[] xs) {
StringBuilder sb = new StringBuilder();
for (Object x : xs) sb.append(x.toString()).append(' ');
System.out.println(sb.toString().trim());
}
private static class Proc {
String name;
int time;
public Proc(String name, int time) {
this.name = name;
this.time = time;
}
public int getTime() {return time;}
public int subTime(int t) {time -= t; return time;}
public String getName() {return name;}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
41,
13,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
14,
2,
4,
18,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
4,
18,
13,
13,
29,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
4,
18,
13,
4,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
134,
17
],
[
134,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
20,
26
],
[
26,
27
],
[
20,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
28,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
33,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
44,
45
],
[
45,
46
],
[
41,
47
],
[
33,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
51,
55
],
[
33,
56
],
[
56,
57
],
[
56,
58
],
[
33,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
60,
64
],
[
59,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
72,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
72,
76
],
[
72,
77
],
[
59,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
20,
83
],
[
18,
84
],
[
84,
85
],
[
18,
86
],
[
86,
87
],
[
134,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
90,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
90,
104
],
[
104,
105
],
[
104,
106
],
[
90,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
112,
113
],
[
112,
114
],
[
107,
115
],
[
115,
116
],
[
116,
117
],
[
107,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
90,
124
],
[
124,
125
],
[
125,
126
],
[
90,
127
],
[
127,
128
],
[
127,
129
],
[
127,
130
],
[
88,
131
],
[
131,
132
],
[
0,
133
],
[
133,
134
],
[
133,
135
]
] | [
"\nimport java.util.AbstractMap;\nimport java.util.LinkedList;\nimport java.util.Map;\nimport java.util.Queue;\nimport java.util.Scanner;\n\n// the simulation of the round robin scheduler\npublic class Main {\n\t// log in the order of termination\n\tpublic static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {\n\t\tint global_timer = 0;\n\n\t\t\n\t\tMap.Entry<String, Integer> budget;\n\t\tint time_consumpt;\n\t\t\n\t\twhile(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}\n\n\n\t\treturn;\n\t\t\n\t}\n\t\n\t\n\t\n\t\n\tpublic static void main(String [] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint len = cin.nextInt();\n\t\tint q = cin.nextInt();\n\n\n\t\tQueue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}\n\t\tcin.close();\n\t\t\n\t\tsimulate(budgets, q);\n\t\t\n\n\t\t\n\t}\n}",
"import java.util.AbstractMap;",
"AbstractMap",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Map;",
"Map",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t// log in the order of termination\n\tpublic static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {\n\t\tint global_timer = 0;\n\n\t\t\n\t\tMap.Entry<String, Integer> budget;\n\t\tint time_consumpt;\n\t\t\n\t\twhile(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}\n\n\n\t\treturn;\n\t\t\n\t}\n\t\n\t\n\t\n\t\n\tpublic static void main(String [] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint len = cin.nextInt();\n\t\tint q = cin.nextInt();\n\n\n\t\tQueue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}\n\t\tcin.close();\n\t\t\n\t\tsimulate(budgets, q);\n\t\t\n\n\t\t\n\t}\n}",
"Main",
"// log in the order of termination\n\tpublic static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {\n\t\tint global_timer = 0;\n\n\t\t\n\t\tMap.Entry<String, Integer> budget;\n\t\tint time_consumpt;\n\t\t\n\t\twhile(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}\n\n\n\t\treturn;\n\t\t\n\t}",
"simulate",
"{\n\t\tint global_timer = 0;\n\n\t\t\n\t\tMap.Entry<String, Integer> budget;\n\t\tint time_consumpt;\n\t\t\n\t\twhile(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}\n\n\n\t\treturn;\n\t\t\n\t}",
"int global_timer = 0;",
"global_timer",
"0",
"Map.Entry<String, Integer> budget;",
"budget",
"int time_consumpt;",
"time_consumpt",
"while(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}",
"!budgets.isEmpty()",
"budgets.isEmpty()",
"budgets.isEmpty",
"budgets",
"{\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}",
"budget = budgets.poll()",
"budget",
"budgets.poll()",
"budgets.poll",
"budgets",
"time_consumpt = Math.min(budget.getValue(), q)",
"time_consumpt",
"Math.min(budget.getValue(), q)",
"Math.min",
"Math",
"budget.getValue()",
"budget.getValue",
"budget",
"q",
"budget.setValue(budget.getValue() - time_consumpt)",
"budget.setValue",
"budget",
"budget.getValue() - time_consumpt",
"budget.getValue()",
"budget.getValue",
"budget",
"time_consumpt",
"global_timer += time_consumpt",
"global_timer",
"time_consumpt",
"if(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}",
"budget.getValue() == 0",
"budget.getValue()",
"budget.getValue",
"budget",
"0",
"{\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}",
"System.out.println(budget.getKey() +\" \"+global_timer)",
"System.out.println",
"System.out",
"System",
"System.out",
"budget.getKey() +\" \"+global_timer",
"budget.getKey() +\" \"+global_timer",
"budget.getKey()",
"budget.getKey",
"budget",
"\" \"",
"global_timer",
"{\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}",
"budgets.add(budget)",
"budgets.add",
"budgets",
"budget",
"return;",
"Queue<Map.Entry<String, Integer>> budgets",
"budgets",
"int q",
"q",
"public static void main(String [] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint len = cin.nextInt();\n\t\tint q = cin.nextInt();\n\n\n\t\tQueue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}\n\t\tcin.close();\n\t\t\n\t\tsimulate(budgets, q);\n\t\t\n\n\t\t\n\t}",
"main",
"{\n\t\tScanner cin = new Scanner(System.in);\n\t\tint len = cin.nextInt();\n\t\tint q = cin.nextInt();\n\n\n\t\tQueue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}\n\t\tcin.close();\n\t\t\n\t\tsimulate(budgets, q);\n\t\t\n\n\t\t\n\t}",
"Scanner cin = new Scanner(System.in);",
"cin",
"new Scanner(System.in)",
"int len = cin.nextInt();",
"len",
"cin.nextInt()",
"cin.nextInt",
"cin",
"int q = cin.nextInt();",
"q",
"cin.nextInt()",
"cin.nextInt",
"cin",
"Queue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;",
"budgets",
"new LinkedList<Map.Entry<String, Integer>>()",
"for(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < len",
"i",
"len",
"i++",
"i++",
"i",
"{\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}",
"{\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}",
"budgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()))",
"budgets.add",
"budgets",
"new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt())",
"cin.close()",
"cin.close",
"cin",
"simulate(budgets, q)",
"simulate",
"budgets",
"q",
"String [] args",
"args",
"public class Main {\n\t// log in the order of termination\n\tpublic static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {\n\t\tint global_timer = 0;\n\n\t\t\n\t\tMap.Entry<String, Integer> budget;\n\t\tint time_consumpt;\n\t\t\n\t\twhile(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}\n\n\n\t\treturn;\n\t\t\n\t}\n\t\n\t\n\t\n\t\n\tpublic static void main(String [] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint len = cin.nextInt();\n\t\tint q = cin.nextInt();\n\n\n\t\tQueue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}\n\t\tcin.close();\n\t\t\n\t\tsimulate(budgets, q);\n\t\t\n\n\t\t\n\t}\n}",
"public class Main {\n\t// log in the order of termination\n\tpublic static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {\n\t\tint global_timer = 0;\n\n\t\t\n\t\tMap.Entry<String, Integer> budget;\n\t\tint time_consumpt;\n\t\t\n\t\twhile(!budgets.isEmpty()) {\n\t\t\t\tbudget = budgets.poll();\n\t\t\t\ttime_consumpt = Math.min(budget.getValue(), q);\n\t\t\t\tbudget.setValue(budget.getValue() - time_consumpt);\n\t\t\t\tglobal_timer += time_consumpt;\n\t\t\t\tif(budget.getValue() == 0) {\n\t\t\t\t\tSystem.out.println(budget.getKey() +\" \"+global_timer);\n\t\t\t\t}else {\n\t\t\t\t\tbudgets.add(budget);\n\t\t\t\t}\n\t\t}\n\n\n\t\treturn;\n\t\t\n\t}\n\t\n\t\n\t\n\t\n\tpublic static void main(String [] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint len = cin.nextInt();\n\t\tint q = cin.nextInt();\n\n\n\t\tQueue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;\n\t\t\n\t\tfor(int i = 0; i < len; i++) {\n\t\t\tbudgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));\n\t\t}\n\t\tcin.close();\n\t\t\n\t\tsimulate(budgets, q);\n\t\t\n\n\t\t\n\t}\n}",
"Main"
] |
import java.util.AbstractMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
// the simulation of the round robin scheduler
public class Main {
// log in the order of termination
public static void simulate(Queue<Map.Entry<String, Integer>> budgets, int q) {
int global_timer = 0;
Map.Entry<String, Integer> budget;
int time_consumpt;
while(!budgets.isEmpty()) {
budget = budgets.poll();
time_consumpt = Math.min(budget.getValue(), q);
budget.setValue(budget.getValue() - time_consumpt);
global_timer += time_consumpt;
if(budget.getValue() == 0) {
System.out.println(budget.getKey() +" "+global_timer);
}else {
budgets.add(budget);
}
}
return;
}
public static void main(String [] args) {
Scanner cin = new Scanner(System.in);
int len = cin.nextInt();
int q = cin.nextInt();
Queue<Map.Entry<String, Integer>> budgets = new LinkedList<Map.Entry<String, Integer>>() ;
for(int i = 0; i < len; i++) {
budgets.add(new AbstractMap.SimpleEntry<String, Integer>(cin.next(), cin.nextInt()));
}
cin.close();
simulate(budgets, q);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
17,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
17,
17,
13,
17,
30,
0,
13,
13,
0,
13,
13,
0,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
22,
23
],
[
22,
24
],
[
0,
25
],
[
164,
26
],
[
164,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
29,
33
],
[
33,
34
],
[
33,
35
],
[
29,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
38,
43
],
[
29,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
49,
51
],
[
29,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
57,
58
],
[
57,
59
],
[
29,
60
],
[
60,
61
],
[
60,
62
],
[
29,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
68,
69
],
[
68,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
63,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
79,
84
],
[
29,
85
],
[
85,
86
],
[
85,
87
],
[
29,
89
],
[
89,
90
],
[
89,
91
],
[
29,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
93,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
98,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
110,
111
],
[
110,
112
],
[
98,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
130,
131
],
[
130,
132
],
[
125,
133
],
[
123,
134
],
[
121,
135
],
[
113,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
140,
142
],
[
136,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
136,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
29,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
27,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Queue;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tList<String[]> queue = new LinkedList<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tList<String[]> queue = new LinkedList<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"Main",
"public static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tList<String[]> queue = new LinkedList<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}",
"main",
"{\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tList<String[]> queue = new LinkedList<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}",
"BufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));",
"reader",
"new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in))",
"StringBuilder builder = new StringBuilder();",
"builder",
"new StringBuilder()",
"String[] line = reader.readLine().split(\" \");",
"line",
"reader.readLine().split(\" \")",
"reader.readLine().split",
"reader.readLine()",
"reader.readLine",
"reader",
"\" \"",
"int n = Integer.parseInt(line[0]);",
"n",
"Integer.parseInt(line[0])",
"Integer.parseInt",
"Integer",
"line[0]",
"line",
"0",
"int q = Integer.parseInt(line[1]);",
"q",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"List<String[]> queue = new LinkedList<String[]>();",
"queue",
"new LinkedList<String[]>()",
"for (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}",
"{\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}",
"queue.add(reader.readLine().split(\" \"))",
"queue.add",
"queue",
"reader.readLine().split(\" \")",
"reader.readLine().split",
"reader.readLine()",
"reader.readLine",
"reader",
"\" \"",
"String[] work = new String[2];",
"work",
"new String[2]",
"2",
"int elapse = 0;",
"elapse",
"0",
"while (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}",
"queue.size()!=0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}",
"work = queue.remove(0)",
"work",
"queue.remove(0)",
"queue.remove",
"queue",
"0",
"int time = Integer.parseInt(work[1]);",
"time",
"Integer.parseInt(work[1])",
"Integer.parseInt",
"Integer",
"work[1]",
"work",
"1",
"if (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t}",
"elapse += time",
"elapse",
"time",
"builder.append(work[0]).append(\" \").append(elapse).append(\"\\n\")",
"builder.append(work[0]).append(\" \").append(elapse).append",
"builder.append(work[0]).append(\" \").append(elapse)",
"builder.append(work[0]).append(\" \").append",
"builder.append(work[0]).append(\" \")",
"builder.append(work[0]).append",
"builder.append(work[0])",
"builder.append",
"builder",
"work[0]",
"work",
"0",
"\" \"",
"elapse",
"\"\\n\"",
"{\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}",
"time -= q",
"time",
"q",
"elapse += q",
"elapse",
"q",
"work[1] = String.valueOf(time)",
"work[1]",
"work",
"1",
"String.valueOf(time)",
"String.valueOf",
"String",
"time",
"queue.add(work)",
"queue.add",
"queue",
"work",
"System.out.print(builder)",
"System.out.print",
"System.out",
"System",
"System.out",
"builder",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tList<String[]> queue = new LinkedList<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tList<String[]> queue = new LinkedList<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile (queue.size()!=0) {\n\t\t\twork = queue.remove(0);\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\t\t/*\tqueue.forEach(a->System.out.println(Arrays.toString(a)));\n\t\t\tSystem.out.println(Arrays.toString(work) + \" -> work \" + elapse);\n\t\t\tSystem.out.println();*/\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"Main"
] |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class Main {
public static void main(String[] args) throws NumberFormatException,
IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
StringBuilder builder = new StringBuilder();
String[] line = reader.readLine().split(" ");
int n = Integer.parseInt(line[0]);
int q = Integer.parseInt(line[1]);
List<String[]> queue = new LinkedList<String[]>();
for (int i = 0; i < n; i++) {
queue.add(reader.readLine().split(" "));
}
String[] work = new String[2];
int elapse = 0;
while (queue.size()!=0) {
work = queue.remove(0);
int time = Integer.parseInt(work[1]);
if (time <= q) {
elapse += time;
builder.append(work[0]).append(" ").append(elapse).append("\n");
} else {
time -= q;
elapse += q;
work[1] = String.valueOf(time);
queue.add(work);
}
/* queue.forEach(a->System.out.println(Arrays.toString(a)));
System.out.println(Arrays.toString(work) + " -> work " + elapse);
System.out.println();*/
}
System.out.print(builder);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
18,
13,
13,
41,
13,
18,
13,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
4,
18,
13,
17,
13,
13,
4,
18,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
13,
17,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
0,
13,
17,
12,
13,
30,
41,
13,
20,
14,
2,
13,
17,
30,
0,
13,
0,
13,
13,
30,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
17,
30,
37,
20,
41,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
13,
17,
30,
0,
13,
17,
29,
13,
12,
13,
30,
29,
2,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
288,
17
],
[
288,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
23,
25
],
[
20,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
20,
31
],
[
31,
32
],
[
31,
33
],
[
20,
34
],
[
34,
35
],
[
34,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
40,
44
],
[
40,
45
],
[
20,
46
],
[
46,
47
],
[
47,
48
],
[
18,
49
],
[
49,
50
],
[
288,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
55,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
55,
66
],
[
66,
67
],
[
66,
68
],
[
55,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
69,
74
],
[
74,
75
],
[
74,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
69,
80
],
[
81,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
81,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
55,
96
],
[
96,
97
],
[
96,
98
],
[
55,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
99,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
116,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
110,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
135,
139
],
[
139,
140
],
[
139,
141
],
[
135,
142
],
[
53,
143
],
[
143,
144
],
[
53,
145
],
[
145,
146
],
[
53,
147
],
[
147,
148
],
[
51,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
149,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
160,
162
],
[
149,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
176,
178
],
[
169,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
179,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
185,
189
],
[
179,
190
],
[
190,
191
],
[
190,
192
],
[
163,
193
],
[
193,
194
],
[
149,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
202,
203
],
[
203,
204
],
[
197,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
207,
209
],
[
197,
210
],
[
210,
211
],
[
210,
212
],
[
212,
213
],
[
212,
214
],
[
197,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
215,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
197,
223
],
[
223,
224
],
[
149,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
149,
232
],
[
232,
233
],
[
232,
234
],
[
234,
235
],
[
232,
236
],
[
236,
237
],
[
232,
238
],
[
238,
239
],
[
232,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
243,
247
],
[
242,
248
],
[
248,
249
],
[
249,
250
],
[
249,
251
],
[
248,
252
],
[
242,
253
],
[
253,
254
],
[
254,
255
],
[
254,
256
],
[
253,
257
],
[
240,
258
],
[
258,
259
],
[
240,
260
],
[
260,
261
],
[
240,
262
],
[
262,
263
],
[
51,
264
],
[
264,
265
],
[
264,
266
],
[
266,
267
],
[
264,
268
],
[
268,
269
],
[
264,
270
],
[
270,
271
],
[
270,
272
],
[
272,
273
],
[
273,
274
],
[
274,
275
],
[
274,
276
],
[
273,
277
],
[
272,
278
],
[
278,
279
],
[
279,
280
],
[
279,
281
],
[
278,
282
],
[
270,
283
],
[
283,
284
],
[
270,
285
],
[
285,
286
],
[
0,
287
],
[
287,
288
],
[
287,
289
]
] | [
"import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n AizuQueue solver = new AizuQueue();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class AizuQueue {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }\n\n static class Queue {\n private Node head;\n private Node tail;\n\n public Queue() {\n head = tail = null;\n }\n\n public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }\n\n public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }\n\n public boolean isEmpty() {\n return head == null;\n }\n\n static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }\n\n }\n\n static class Pair {\n String id;\n int t;\n\n public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }\n\n }\n\n }\n}\n\n",
"import java.io.OutputStream;",
"OutputStream",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n AizuQueue solver = new AizuQueue();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class AizuQueue {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }\n\n static class Queue {\n private Node head;\n private Node tail;\n\n public Queue() {\n head = tail = null;\n }\n\n public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }\n\n public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }\n\n public boolean isEmpty() {\n return head == null;\n }\n\n static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }\n\n }\n\n static class Pair {\n String id;\n int t;\n\n public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }\n\n }\n\n }\n}",
"Main",
"public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n AizuQueue solver = new AizuQueue();\n solver.solve(1, in, out);\n out.close();\n }",
"main",
"{\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n AizuQueue solver = new AizuQueue();\n solver.solve(1, in, out);\n out.close();\n }",
"InputStream inputStream = System.in;",
"inputStream",
"System.in",
"System",
"System.in",
"OutputStream outputStream = System.out;",
"outputStream",
"System.out",
"System",
"System.out",
"Scanner in = new Scanner(inputStream);",
"in",
"new Scanner(inputStream)",
"PrintWriter out = new PrintWriter(outputStream);",
"out",
"new PrintWriter(outputStream)",
"AizuQueue solver = new AizuQueue();",
"solver",
"new AizuQueue()",
"solver.solve(1, in, out)",
"solver.solve",
"solver",
"1",
"in",
"out",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class AizuQueue {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }\n\n static class Queue {\n private Node head;\n private Node tail;\n\n public Queue() {\n head = tail = null;\n }\n\n public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }\n\n public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }\n\n public boolean isEmpty() {\n return head == null;\n }\n\n static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }\n\n }\n\n static class Pair {\n String id;\n int t;\n\n public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }\n\n }\n\n }",
"AizuQueue",
"public void solve(int testNumber, Scanner in, PrintWriter out) {\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }",
"solve",
"{\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }",
"final int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"final int q = in.nextInt();",
"q",
"in.nextInt()",
"in.nextInt",
"in",
"Queue queue = new Queue();",
"queue",
"new Queue()",
"for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }",
"{\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }",
"final String id = in.next();",
"id",
"in.next()",
"in.next",
"in",
"final int t = in.nextInt();",
"t",
"in.nextInt()",
"in.nextInt",
"in",
"queue.enqueue(new Pair(id, t))",
"queue.enqueue",
"queue",
"new Pair(id, t)",
"long curr = 0L;",
"curr",
"0L",
"while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }",
"Pair p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }",
"p.t > q",
"p.t",
"p",
"p.t",
"q",
"{\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n }",
"curr += q",
"curr",
"q",
"p.t -= q",
"p.t",
"p",
"p.t",
"q",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"{\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }",
"curr += p.t",
"curr",
"p.t",
"p",
"p.t",
"out.printf(\"%s %d\\n\", p.id, curr)",
"out.printf",
"out",
"\"%s %d\\n\"",
"p.id",
"p",
"p.id",
"curr",
"int testNumber",
"testNumber",
"Scanner in",
"in",
"PrintWriter out",
"out",
"static class Queue {\n private Node head;\n private Node tail;\n\n public Queue() {\n head = tail = null;\n }\n\n public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }\n\n public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }\n\n public boolean isEmpty() {\n return head == null;\n }\n\n static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }\n\n }",
"Queue",
"private Node head;",
"head",
"private Node tail;",
"tail",
"public Queue() {\n head = tail = null;\n }",
"Queue",
"{\n head = tail = null;\n }",
"head = tail = null",
"head",
"tail = null",
"tail",
"null",
"public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }",
"enqueue",
"{\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }",
"Node n = new Node(p, null, null);",
"n",
"new Node(p, null, null)",
"if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }",
"head == null",
"head",
"null",
"{\n head = tail = n;\n }",
"head = tail = n",
"head",
"tail = n",
"tail",
"n",
"{\n tail.next = n;\n n.prev = tail;\n tail = n;\n }",
"tail.next = n",
"tail.next",
"tail",
"tail.next",
"n",
"n.prev = tail",
"n.prev",
"n",
"n.prev",
"tail",
"tail = n",
"tail",
"n",
"final Pair p",
"p",
"public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }",
"dequeue",
"{\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }",
"if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }",
"head == null",
"head",
"null",
"{\n throw new IllegalStateException(\"empty queue\");\n }",
"throw new IllegalStateException(\"empty queue\");",
"new IllegalStateException(\"empty queue\")",
"final Pair p = head.key;",
"p",
"head.key",
"head",
"head.key",
"head = head.next",
"head",
"head.next",
"head",
"head.next",
"if (head == null) {\n tail = null;\n }",
"head == null",
"head",
"null",
"{\n tail = null;\n }",
"tail = null",
"tail",
"null",
"return p;",
"p",
"public boolean isEmpty() {\n return head == null;\n }",
"isEmpty",
"{\n return head == null;\n }",
"return head == null;",
"head == null",
"head",
"null",
"static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }",
"Node",
"Pair key;",
"key",
"Node next;",
"next",
"Node prev;",
"prev",
"public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }",
"Node",
"{\n this.key = key;\n this.prev = prev;\n this.next = next;\n }",
"this.key = key",
"this.key",
"this",
"this.key",
"key",
"this.prev = prev",
"this.prev",
"this",
"this.prev",
"prev",
"this.next = next",
"this.next",
"this",
"this.next",
"next",
"final Pair key",
"key",
"final Node prev",
"prev",
"final Node next",
"next",
"static class Pair {\n String id;\n int t;\n\n public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }\n\n }",
"Pair",
"String id;",
"id",
"int t;",
"t",
"public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }",
"Pair",
"{\n this.id = id;\n this.t = t;\n }",
"this.id = id",
"this.id",
"this",
"this.id",
"id",
"this.t = t",
"this.t",
"this",
"this.t",
"t",
"final String id",
"id",
"final int t",
"t",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n AizuQueue solver = new AizuQueue();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class AizuQueue {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }\n\n static class Queue {\n private Node head;\n private Node tail;\n\n public Queue() {\n head = tail = null;\n }\n\n public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }\n\n public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }\n\n public boolean isEmpty() {\n return head == null;\n }\n\n static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }\n\n }\n\n static class Pair {\n String id;\n int t;\n\n public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }\n\n }\n\n }\n}",
"public class Main {\n public static void main(String[] args) {\n InputStream inputStream = System.in;\n OutputStream outputStream = System.out;\n Scanner in = new Scanner(inputStream);\n PrintWriter out = new PrintWriter(outputStream);\n AizuQueue solver = new AizuQueue();\n solver.solve(1, in, out);\n out.close();\n }\n\n static class AizuQueue {\n public void solve(int testNumber, Scanner in, PrintWriter out) {\n final int n = in.nextInt();\n final int q = in.nextInt();\n\n\t\t\tQueue queue = new Queue();\n for (int i = 0; i < n; i++) {\n final String id = in.next();\n final int t = in.nextInt();\n\n queue.enqueue(new Pair(id, t));\n }\n\n long curr = 0L;\n while (!queue.isEmpty()) {\n Pair p = queue.dequeue();\n\n if (p.t > q) {\n curr += q;\n p.t -= q;\n queue.enqueue(p);\n } else {\n curr += p.t;\n out.printf(\"%s %d\\n\", p.id, curr);\n }\n }\n }\n\n static class Queue {\n private Node head;\n private Node tail;\n\n public Queue() {\n head = tail = null;\n }\n\n public void enqueue(final Pair p) {\n Node n = new Node(p, null, null);\n\n if (head == null) {\n head = tail = n;\n } else {\n tail.next = n;\n n.prev = tail;\n tail = n;\n }\n }\n\n public Pair dequeue() {\n if (head == null) {\n throw new IllegalStateException(\"empty queue\");\n }\n\n final Pair p = head.key;\n head = head.next;\n\n if (head == null) {\n tail = null;\n }\n\n return p;\n }\n\n public boolean isEmpty() {\n return head == null;\n }\n\n static class Node {\n\t\t\t\tPair key;\n Node next;\n Node prev;\n\n public Node(final Pair key, final Node prev, final Node next) {\n this.key = key;\n this.prev = prev;\n this.next = next;\n }\n\n }\n\n }\n\n static class Pair {\n String id;\n int t;\n\n public Pair(final String id, final int t) {\n this.id = id;\n this.t = t;\n }\n\n }\n\n }\n}",
"Main"
] | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
AizuQueue solver = new AizuQueue();
solver.solve(1, in, out);
out.close();
}
static class AizuQueue {
public void solve(int testNumber, Scanner in, PrintWriter out) {
final int n = in.nextInt();
final int q = in.nextInt();
Queue queue = new Queue();
for (int i = 0; i < n; i++) {
final String id = in.next();
final int t = in.nextInt();
queue.enqueue(new Pair(id, t));
}
long curr = 0L;
while (!queue.isEmpty()) {
Pair p = queue.dequeue();
if (p.t > q) {
curr += q;
p.t -= q;
queue.enqueue(p);
} else {
curr += p.t;
out.printf("%s %d\n", p.id, curr);
}
}
}
static class Queue {
private Node head;
private Node tail;
public Queue() {
head = tail = null;
}
public void enqueue(final Pair p) {
Node n = new Node(p, null, null);
if (head == null) {
head = tail = n;
} else {
tail.next = n;
n.prev = tail;
tail = n;
}
}
public Pair dequeue() {
if (head == null) {
throw new IllegalStateException("empty queue");
}
final Pair p = head.key;
head = head.next;
if (head == null) {
tail = null;
}
return p;
}
public boolean isEmpty() {
return head == null;
}
static class Node {
Pair key;
Node next;
Node prev;
public Node(final Pair key, final Node prev, final Node next) {
this.key = key;
this.prev = prev;
this.next = next;
}
}
}
static class Pair {
String id;
int t;
public Pair(final String id, final int t) {
this.id = id;
this.t = t;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
17,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
20,
4,
18,
13,
13,
42,
2,
0,
13,
4,
18,
13,
17,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
13,
17,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
4,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
7,
12
],
[
12,
13
],
[
12,
14
],
[
7,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
17,
23
],
[
23,
24
],
[
23,
25
],
[
17,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
28,
33
],
[
17,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
17,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
47,
49
],
[
17,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
55,
56
],
[
55,
57
],
[
50,
58
],
[
58,
59
],
[
59,
60
],
[
50,
61
],
[
62,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
17,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
70,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
85,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
95,
103
],
[
93,
104
],
[
91,
105
],
[
79,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
106,
112
],
[
112,
113
],
[
112,
114
],
[
106,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
17,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
15,
125
],
[
125,
126
],
[
0,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
127,
131
],
[
131,
132
],
[
127,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
135,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
135,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
152,
153
],
[
152,
154
],
[
133,
155
],
[
155,
156
],
[
127,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
159,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
157,
170
],
[
170,
171
],
[
157,
172
],
[
172,
173
]
] | [
"import java.io.*;\nimport java.util.*;\n\nclass Main {\n\tfinal static BufferedReader br = new BufferedReader(new InputStreamReader(\n\t\t\tSystem.in));\n\tfinal static StringBuilder out = new StringBuilder();\n\tpublic static void main(String[] Args) throws IOException {\n\t\tQueue<Process> p = new ArrayDeque<Process>();\n\t\tProcess work;\n\t\tint elapse = 0;\n\t\tString[] in = br.readLine().split(\"\\\\s+\");\n\t\tint n = Integer.parseInt(in[0]);\n\t\tint q = Integer.parseInt(in[1]);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}\n\t\twhile ((work = p.poll()) != null) {\n\t\t\tif (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(out);\n\t}\n}\n\nclass Process {\n\tString name;\n\tint time;\n\tpublic Process(String str) {\n\t\tString[] in = str.split(\"\\\\s+\");\n\t\tname = in[0];\n\t\ttime = Integer.parseInt(in[1]);\n\t}\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"class Main {\n\tfinal static BufferedReader br = new BufferedReader(new InputStreamReader(\n\t\t\tSystem.in));\n\tfinal static StringBuilder out = new StringBuilder();\n\tpublic static void main(String[] Args) throws IOException {\n\t\tQueue<Process> p = new ArrayDeque<Process>();\n\t\tProcess work;\n\t\tint elapse = 0;\n\t\tString[] in = br.readLine().split(\"\\\\s+\");\n\t\tint n = Integer.parseInt(in[0]);\n\t\tint q = Integer.parseInt(in[1]);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}\n\t\twhile ((work = p.poll()) != null) {\n\t\t\tif (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(out);\n\t}\n}",
"Main",
"final static BufferedReader br = new BufferedReader(new InputStreamReader(\n\t\t\tSystem.in));",
"br",
"new BufferedReader(new InputStreamReader(\n\t\t\tSystem.in))",
"final static StringBuilder out = new StringBuilder();",
"out",
"new StringBuilder()",
"public static void main(String[] Args) throws IOException {\n\t\tQueue<Process> p = new ArrayDeque<Process>();\n\t\tProcess work;\n\t\tint elapse = 0;\n\t\tString[] in = br.readLine().split(\"\\\\s+\");\n\t\tint n = Integer.parseInt(in[0]);\n\t\tint q = Integer.parseInt(in[1]);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}\n\t\twhile ((work = p.poll()) != null) {\n\t\t\tif (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(out);\n\t}",
"main",
"{\n\t\tQueue<Process> p = new ArrayDeque<Process>();\n\t\tProcess work;\n\t\tint elapse = 0;\n\t\tString[] in = br.readLine().split(\"\\\\s+\");\n\t\tint n = Integer.parseInt(in[0]);\n\t\tint q = Integer.parseInt(in[1]);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}\n\t\twhile ((work = p.poll()) != null) {\n\t\t\tif (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(out);\n\t}",
"Queue<Process> p = new ArrayDeque<Process>();",
"p",
"new ArrayDeque<Process>()",
"Process work;",
"work",
"int elapse = 0;",
"elapse",
"0",
"String[] in = br.readLine().split(\"\\\\s+\");",
"in",
"br.readLine().split(\"\\\\s+\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s+\"",
"int n = Integer.parseInt(in[0]);",
"n",
"Integer.parseInt(in[0])",
"Integer.parseInt",
"Integer",
"in[0]",
"in",
"0",
"int q = Integer.parseInt(in[1]);",
"q",
"Integer.parseInt(in[1])",
"Integer.parseInt",
"Integer",
"in[1]",
"in",
"1",
"for (int i = 0; i < n; i++) {\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}",
"{\n\t\t\twork = new Process(br.readLine());\n\t\t\tp.add(work);\n\t\t}",
"work = new Process(br.readLine())",
"work",
"new Process(br.readLine())",
"p.add(work)",
"p.add",
"p",
"work",
"while ((work = p.poll()) != null) {\n\t\t\tif (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}\n\t\t}",
"(work = p.poll()) != null",
"(work = p.poll())",
"work",
"p.poll()",
"p.poll",
"p",
"null",
"{\n\t\t\tif (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}\n\t\t}",
"if (work.time <= q) {\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t} else {\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}",
"work.time <= q",
"work.time",
"work",
"work.time",
"q",
"{\n\t\t\t\telapse += work.time;\n\t\t\t\tout.append(work.name).append(' ').append(elapse).append('\\n');\n\t\t\t}",
"elapse += work.time",
"elapse",
"work.time",
"work",
"work.time",
"out.append(work.name).append(' ').append(elapse).append('\\n')",
"out.append(work.name).append(' ').append(elapse).append",
"out.append(work.name).append(' ').append(elapse)",
"out.append(work.name).append(' ').append",
"out.append(work.name).append(' ')",
"out.append(work.name).append",
"out.append(work.name)",
"out.append",
"out",
"work.name",
"work",
"work.name",
"' '",
"elapse",
"'\\n'",
"{\n\t\t\t\twork.time -= q;\n\t\t\t\telapse += q;\n\t\t\t\tp.add(work);\n\t\t\t}",
"work.time -= q",
"work.time",
"work",
"work.time",
"q",
"elapse += q",
"elapse",
"q",
"p.add(work)",
"p.add",
"p",
"work",
"System.out.print(out)",
"System.out.print",
"System.out",
"System",
"System.out",
"out",
"String[] Args",
"Args",
"class Process {\n\tString name;\n\tint time;\n\tpublic Process(String str) {\n\t\tString[] in = str.split(\"\\\\s+\");\n\t\tname = in[0];\n\t\ttime = Integer.parseInt(in[1]);\n\t}\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String str) {\n\t\tString[] in = str.split(\"\\\\s+\");\n\t\tname = in[0];\n\t\ttime = Integer.parseInt(in[1]);\n\t}",
"Process",
"{\n\t\tString[] in = str.split(\"\\\\s+\");\n\t\tname = in[0];\n\t\ttime = Integer.parseInt(in[1]);\n\t}",
"String[] in = str.split(\"\\\\s+\");",
"in",
"str.split(\"\\\\s+\")",
"str.split",
"str",
"\"\\\\s+\"",
"name = in[0]",
"name",
"in[0]",
"in",
"0",
"time = Integer.parseInt(in[1])",
"time",
"Integer.parseInt(in[1])",
"Integer.parseInt",
"Integer",
"in[1]",
"in",
"1",
"String str",
"str",
"public Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time"
] | import java.io.*;
import java.util.*;
class Main {
final static BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
final static StringBuilder out = new StringBuilder();
public static void main(String[] Args) throws IOException {
Queue<Process> p = new ArrayDeque<Process>();
Process work;
int elapse = 0;
String[] in = br.readLine().split("\\s+");
int n = Integer.parseInt(in[0]);
int q = Integer.parseInt(in[1]);
for (int i = 0; i < n; i++) {
work = new Process(br.readLine());
p.add(work);
}
while ((work = p.poll()) != null) {
if (work.time <= q) {
elapse += work.time;
out.append(work.name).append(' ').append(elapse).append('\n');
} else {
work.time -= q;
elapse += q;
p.add(work);
}
}
System.out.print(out);
}
}
class Process {
String name;
int time;
public Process(String str) {
String[] in = str.split("\\s+");
name = in[0];
time = Integer.parseInt(in[1]);
}
public Process(String name, int time) {
this.name = name;
this.time = time;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
17,
41,
13,
17,
42,
2,
0,
13,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
17,
17,
13,
17,
30,
0,
13,
13,
0,
13,
13,
0,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
151,
17
],
[
151,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
29,
34
],
[
20,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
37,
40
],
[
40,
41
],
[
40,
42
],
[
20,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
51,
53
],
[
20,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
54,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
70,
75
],
[
20,
76
],
[
76,
77
],
[
76,
78
],
[
20,
80
],
[
80,
81
],
[
80,
82
],
[
20,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
84,
90
],
[
83,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
97,
98
],
[
97,
99
],
[
91,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
117,
119
],
[
112,
120
],
[
110,
121
],
[
108,
122
],
[
100,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
127,
128
],
[
127,
129
],
[
123,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
123,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
20,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
142,
147
],
[
18,
148
],
[
148,
149
],
[
0,
150
],
[
150,
151
],
[
150,
152
]
] | [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Queue;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tQueue<String[]> queue = new ArrayDeque<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tQueue<String[]> queue = new ArrayDeque<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"Main",
"public static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tQueue<String[]> queue = new ArrayDeque<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}",
"main",
"{\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tQueue<String[]> queue = new ArrayDeque<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}",
"BufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));",
"reader",
"new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in))",
"StringBuilder builder = new StringBuilder();",
"builder",
"new StringBuilder()",
"String[] line = reader.readLine().split(\" \");",
"line",
"reader.readLine().split(\" \")",
"reader.readLine().split",
"reader.readLine()",
"reader.readLine",
"reader",
"\" \"",
"int n = Integer.parseInt(line[0]);",
"n",
"Integer.parseInt(line[0])",
"Integer.parseInt",
"Integer",
"line[0]",
"line",
"0",
"int q = Integer.parseInt(line[1]);",
"q",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"Queue<String[]> queue = new ArrayDeque<String[]>();",
"queue",
"new ArrayDeque<String[]>()",
"for (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}",
"{\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}",
"queue.add(reader.readLine().split(\" \"))",
"queue.add",
"queue",
"reader.readLine().split(\" \")",
"reader.readLine().split",
"reader.readLine()",
"reader.readLine",
"reader",
"\" \"",
"String[] work = new String[2];",
"work",
"new String[2]",
"2",
"int elapse = 0;",
"elapse",
"0",
"while ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}",
"(work = queue.poll()) != null",
"(work = queue.poll())",
"work",
"queue.poll()",
"queue.poll",
"queue",
"null",
"{\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}",
"int time = Integer.parseInt(work[1]);",
"time",
"Integer.parseInt(work[1])",
"Integer.parseInt",
"Integer",
"work[1]",
"work",
"1",
"if (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t}",
"elapse += time",
"elapse",
"time",
"builder.append(work[0]).append(\" \").append(elapse).append(\"\\n\")",
"builder.append(work[0]).append(\" \").append(elapse).append",
"builder.append(work[0]).append(\" \").append(elapse)",
"builder.append(work[0]).append(\" \").append",
"builder.append(work[0]).append(\" \")",
"builder.append(work[0]).append",
"builder.append(work[0])",
"builder.append",
"builder",
"work[0]",
"work",
"0",
"\" \"",
"elapse",
"\"\\n\"",
"{\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}",
"time -= q",
"time",
"q",
"elapse += q",
"elapse",
"q",
"work[1] = String.valueOf(time)",
"work[1]",
"work",
"1",
"String.valueOf(time)",
"String.valueOf",
"String",
"time",
"queue.add(work)",
"queue.add",
"queue",
"work",
"System.out.print(builder)",
"System.out.print",
"System.out",
"System",
"System.out",
"builder",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tQueue<String[]> queue = new ArrayDeque<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws NumberFormatException,\n\t\t\tIOException {\n\t\tBufferedReader reader = new BufferedReader(new InputStreamReader(\n\t\t\t\tSystem.in));\n\t\tStringBuilder builder = new StringBuilder();\n\t\tString[] line = reader.readLine().split(\" \");\n\t\tint n = Integer.parseInt(line[0]);\n\t\tint q = Integer.parseInt(line[1]);\n\t\tQueue<String[]> queue = new ArrayDeque<String[]>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqueue.add(reader.readLine().split(\" \"));\n\t\t}\n\t\tString[] work = new String[2];\n\t\tint elapse = 0;\n\t\twhile ((work = queue.poll()) != null) {\n\t\t\tint time = Integer.parseInt(work[1]);\n\t\t\tif (time <= q) {\n\t\t\t\telapse += time;\n\t\t\t\tbuilder.append(work[0]).append(\" \").append(elapse).append(\"\\n\");\n\t\t\t} else {\n\t\t\t\ttime -= q;\n\t\t\t\telapse += q;\n\t\t\t\twork[1] = String.valueOf(time);\n\t\t\t\tqueue.add(work);\n\t\t\t}\n\n\t\t}\n\t\tSystem.out.print(builder);\n\t}\n}",
"Main"
] |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;
public class Main {
public static void main(String[] args) throws NumberFormatException,
IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
StringBuilder builder = new StringBuilder();
String[] line = reader.readLine().split(" ");
int n = Integer.parseInt(line[0]);
int q = Integer.parseInt(line[1]);
Queue<String[]> queue = new ArrayDeque<String[]>();
for (int i = 0; i < n; i++) {
queue.add(reader.readLine().split(" "));
}
String[] work = new String[2];
int elapse = 0;
while ((work = queue.poll()) != null) {
int time = Integer.parseInt(work[1]);
if (time <= q) {
elapse += time;
builder.append(work[0]).append(" ").append(elapse).append("\n");
} else {
time -= q;
elapse += q;
work[1] = String.valueOf(time);
queue.add(work);
}
}
System.out.print(builder);
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
41,
13,
20,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
42,
4,
18,
13,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
9,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
0,
13,
17,
0,
13,
40,
17,
0,
13,
17,
12,
13,
30,
0,
13,
2,
2,
13,
17,
13,
40,
13,
0,
18,
18,
13,
13,
13,
18,
13,
13,
0,
18,
18,
13,
13,
13,
18,
13,
13,
0,
18,
18,
13,
13,
13,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
40,
13,
29,
13,
12,
13,
30,
29,
2,
13,
17,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
255,
5
],
[
255,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
8,
14
],
[
14,
15
],
[
8,
16
],
[
16,
17
],
[
16,
18
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
8,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
38,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
42,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
55,
56
],
[
42,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
8,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
61,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
66,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
78,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
78,
93
],
[
66,
94
],
[
94,
95
],
[
94,
96
],
[
66,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
66,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
8,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
106,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
123,
128
],
[
128,
129
],
[
128,
130
],
[
6,
131
],
[
131,
132
],
[
0,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
133,
137
],
[
137,
138
],
[
133,
139
],
[
139,
140
],
[
0,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
146,
148
],
[
141,
150
],
[
150,
151
],
[
141,
152
],
[
152,
153
],
[
141,
154
],
[
154,
155
],
[
141,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
164,
165
],
[
164,
166
],
[
159,
167
],
[
167,
168
],
[
168,
169
],
[
159,
170
],
[
171,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
158,
177
],
[
177,
178
],
[
177,
179
],
[
158,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
158,
184
],
[
184,
185
],
[
184,
186
],
[
141,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
189,
197
],
[
197,
198
],
[
189,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
200,
204
],
[
199,
205
],
[
205,
206
],
[
205,
207
],
[
189,
208
],
[
208,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
209,
213
],
[
208,
214
],
[
214,
215
],
[
214,
216
],
[
189,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
218,
222
],
[
217,
223
],
[
223,
224
],
[
223,
225
],
[
187,
226
],
[
226,
227
],
[
141,
228
],
[
228,
229
],
[
228,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
233,
234
],
[
233,
235
],
[
230,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
238,
242
],
[
230,
243
],
[
243,
244
],
[
230,
245
],
[
245,
246
],
[
141,
247
],
[
247,
248
],
[
247,
249
],
[
249,
250
],
[
250,
251
],
[
251,
252
],
[
251,
253
],
[
0,
254
],
[
254,
255
],
[
254,
256
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint n, q, time_cost = 0;\n\t\tTask temp = new Task();\n\t\tQueue costQueue = new Queue(), endQueue = new Queue();\n\t\tn = cin.nextInt();\n\t\tq = cin.nextInt();\n\t\twhile (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}\n\t}\n}\n\nclass Task {\n\tString name;\n\tint costTime;\n\tint endTime;\n}\n\nclass Queue {\n\tint MAX = 100002;\n\tTask[] entry = new Task[MAX];\n\tint front;\n\tint rear;\n\tint count;\n\tpublic Queue() {\n\t\tfor (int i = 0; i < MAX; i++) {\n\t\t\tentry[i] = new Task();\n\t\t}\n\t\tfront = 0;\n\t\trear = -1;\n\t\tcount = 0;\n\t}\n\tpublic void insert(Task t) {\n\t\trear = (rear + 1) % MAX;\n\t\tcount++;\n\t\tentry[rear].name = t.name;\n\t\tentry[rear].costTime = t.costTime;\n\t\tentry[rear].endTime = t.endTime;\n\t}\n\tpublic Task remove() {\n\t\tTask temp = entry[front];\n\t\tfront = (front + 1) % MAX;\n\t\tcount--;\n\t\treturn temp;\n\t}\n\tpublic boolean empty() {\n\t\treturn (count == 0);\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint n, q, time_cost = 0;\n\t\tTask temp = new Task();\n\t\tQueue costQueue = new Queue(), endQueue = new Queue();\n\t\tn = cin.nextInt();\n\t\tq = cin.nextInt();\n\t\twhile (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint n, q, time_cost = 0;\n\t\tTask temp = new Task();\n\t\tQueue costQueue = new Queue(), endQueue = new Queue();\n\t\tn = cin.nextInt();\n\t\tq = cin.nextInt();\n\t\twhile (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}\n\t}",
"main",
"{\n\t\tScanner cin = new Scanner(System.in);\n\t\tint n, q, time_cost = 0;\n\t\tTask temp = new Task();\n\t\tQueue costQueue = new Queue(), endQueue = new Queue();\n\t\tn = cin.nextInt();\n\t\tq = cin.nextInt();\n\t\twhile (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}\n\t}",
"Scanner cin = new Scanner(System.in);",
"cin",
"new Scanner(System.in)",
"int n",
"n",
"q",
"q",
"time_cost = 0;",
"time_cost",
"0",
"Task temp = new Task();",
"temp",
"new Task()",
"Queue costQueue = new Queue()",
"costQueue",
"new Queue()",
"endQueue = new Queue();",
"endQueue",
"new Queue()",
"n = cin.nextInt()",
"n",
"cin.nextInt()",
"cin.nextInt",
"cin",
"q = cin.nextInt()",
"q",
"cin.nextInt()",
"cin.nextInt",
"cin",
"while (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}",
"cin.hasNext()",
"cin.hasNext",
"cin",
"{\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}",
"temp.name = cin.next()",
"temp.name",
"temp",
"temp.name",
"cin.next()",
"cin.next",
"cin",
"temp.costTime = cin.nextInt()",
"temp.costTime",
"temp",
"temp.costTime",
"cin.nextInt()",
"cin.nextInt",
"cin",
"costQueue.insert(temp)",
"costQueue.insert",
"costQueue",
"temp",
"while (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}",
"!costQueue.empty()",
"costQueue.empty()",
"costQueue.empty",
"costQueue",
"{\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}",
"temp = costQueue.remove()",
"temp",
"costQueue.remove()",
"costQueue.remove",
"costQueue",
"if (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}",
"temp.costTime <= q",
"temp.costTime",
"temp",
"temp.costTime",
"q",
"{\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}",
"time_cost += temp.costTime",
"time_cost",
"temp.costTime",
"temp",
"temp.costTime",
"temp.endTime = time_cost",
"temp.endTime",
"temp",
"temp.endTime",
"time_cost",
"endQueue.insert(temp)",
"endQueue.insert",
"endQueue",
"temp",
"continue;",
"time_cost += q",
"time_cost",
"q",
"temp.costTime -= q",
"temp.costTime",
"temp",
"temp.costTime",
"q",
"costQueue.insert(temp)",
"costQueue.insert",
"costQueue",
"temp",
"while (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}",
"!endQueue.empty()",
"endQueue.empty()",
"endQueue.empty",
"endQueue",
"{\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}",
"temp = endQueue.remove()",
"temp",
"endQueue.remove()",
"endQueue.remove",
"endQueue",
"System.out.println(temp.name + \" \" + temp.endTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.name + \" \" + temp.endTime",
"temp.name + \" \" + temp.endTime",
"temp.name",
"temp",
"temp.name",
"\" \"",
"temp.endTime",
"temp",
"temp.endTime",
"String[] args",
"args",
"class Task {\n\tString name;\n\tint costTime;\n\tint endTime;\n}",
"Task",
"String name;",
"name",
"int costTime;",
"costTime",
"int endTime;",
"endTime",
"class Queue {\n\tint MAX = 100002;\n\tTask[] entry = new Task[MAX];\n\tint front;\n\tint rear;\n\tint count;\n\tpublic Queue() {\n\t\tfor (int i = 0; i < MAX; i++) {\n\t\t\tentry[i] = new Task();\n\t\t}\n\t\tfront = 0;\n\t\trear = -1;\n\t\tcount = 0;\n\t}\n\tpublic void insert(Task t) {\n\t\trear = (rear + 1) % MAX;\n\t\tcount++;\n\t\tentry[rear].name = t.name;\n\t\tentry[rear].costTime = t.costTime;\n\t\tentry[rear].endTime = t.endTime;\n\t}\n\tpublic Task remove() {\n\t\tTask temp = entry[front];\n\t\tfront = (front + 1) % MAX;\n\t\tcount--;\n\t\treturn temp;\n\t}\n\tpublic boolean empty() {\n\t\treturn (count == 0);\n\t}\n}",
"Queue",
"int MAX = 100002;",
"MAX",
"100002",
"Task[] entry = new Task[MAX];",
"entry",
"new Task[MAX]",
"MAX",
"int front;",
"front",
"int rear;",
"rear",
"int count;",
"count",
"public Queue() {\n\t\tfor (int i = 0; i < MAX; i++) {\n\t\t\tentry[i] = new Task();\n\t\t}\n\t\tfront = 0;\n\t\trear = -1;\n\t\tcount = 0;\n\t}",
"Queue",
"{\n\t\tfor (int i = 0; i < MAX; i++) {\n\t\t\tentry[i] = new Task();\n\t\t}\n\t\tfront = 0;\n\t\trear = -1;\n\t\tcount = 0;\n\t}",
"for (int i = 0; i < MAX; i++) {\n\t\t\tentry[i] = new Task();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < MAX",
"i",
"MAX",
"i++",
"i++",
"i",
"{\n\t\t\tentry[i] = new Task();\n\t\t}",
"{\n\t\t\tentry[i] = new Task();\n\t\t}",
"entry[i] = new Task()",
"entry[i]",
"entry",
"i",
"new Task()",
"front = 0",
"front",
"0",
"rear = -1",
"rear",
"-1",
"1",
"count = 0",
"count",
"0",
"public void insert(Task t) {\n\t\trear = (rear + 1) % MAX;\n\t\tcount++;\n\t\tentry[rear].name = t.name;\n\t\tentry[rear].costTime = t.costTime;\n\t\tentry[rear].endTime = t.endTime;\n\t}",
"insert",
"{\n\t\trear = (rear + 1) % MAX;\n\t\tcount++;\n\t\tentry[rear].name = t.name;\n\t\tentry[rear].costTime = t.costTime;\n\t\tentry[rear].endTime = t.endTime;\n\t}",
"rear = (rear + 1) % MAX",
"rear",
"(rear + 1) % MAX",
"(rear + 1)",
"rear",
"1",
"MAX",
"count++",
"count",
"entry[rear].name = t.name",
"entry[rear].name",
"entry[rear]",
"entry",
"rear",
"entry[rear].name",
"t.name",
"t",
"t.name",
"entry[rear].costTime = t.costTime",
"entry[rear].costTime",
"entry[rear]",
"entry",
"rear",
"entry[rear].costTime",
"t.costTime",
"t",
"t.costTime",
"entry[rear].endTime = t.endTime",
"entry[rear].endTime",
"entry[rear]",
"entry",
"rear",
"entry[rear].endTime",
"t.endTime",
"t",
"t.endTime",
"Task t",
"t",
"public Task remove() {\n\t\tTask temp = entry[front];\n\t\tfront = (front + 1) % MAX;\n\t\tcount--;\n\t\treturn temp;\n\t}",
"remove",
"{\n\t\tTask temp = entry[front];\n\t\tfront = (front + 1) % MAX;\n\t\tcount--;\n\t\treturn temp;\n\t}",
"Task temp = entry[front];",
"temp",
"entry[front]",
"entry",
"front",
"front = (front + 1) % MAX",
"front",
"(front + 1) % MAX",
"(front + 1)",
"front",
"1",
"MAX",
"count--",
"count",
"return temp;",
"temp",
"public boolean empty() {\n\t\treturn (count == 0);\n\t}",
"empty",
"{\n\t\treturn (count == 0);\n\t}",
"return (count == 0);",
"(count == 0)",
"count",
"0",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint n, q, time_cost = 0;\n\t\tTask temp = new Task();\n\t\tQueue costQueue = new Queue(), endQueue = new Queue();\n\t\tn = cin.nextInt();\n\t\tq = cin.nextInt();\n\t\twhile (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner cin = new Scanner(System.in);\n\t\tint n, q, time_cost = 0;\n\t\tTask temp = new Task();\n\t\tQueue costQueue = new Queue(), endQueue = new Queue();\n\t\tn = cin.nextInt();\n\t\tq = cin.nextInt();\n\t\twhile (cin.hasNext()) {\n\t\t\ttemp.name = cin.next();\n\t\t\ttemp.costTime = cin.nextInt();\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!costQueue.empty()) {\n\t\t\ttemp = costQueue.remove();\n\t\t\tif (temp.costTime <= q) {\n\t\t\t\ttime_cost += temp.costTime;\n\t\t\t\ttemp.endTime = time_cost;\n\t\t\t\tendQueue.insert(temp);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttime_cost += q;\n\t\t\ttemp.costTime -= q;\n\t\t\tcostQueue.insert(temp);\n\t\t}\n\t\twhile (!endQueue.empty()) {\n\t\t\ttemp = endQueue.remove();\n\t\t\tSystem.out.println(temp.name + \" \" + temp.endTime);\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n, q, time_cost = 0;
Task temp = new Task();
Queue costQueue = new Queue(), endQueue = new Queue();
n = cin.nextInt();
q = cin.nextInt();
while (cin.hasNext()) {
temp.name = cin.next();
temp.costTime = cin.nextInt();
costQueue.insert(temp);
}
while (!costQueue.empty()) {
temp = costQueue.remove();
if (temp.costTime <= q) {
time_cost += temp.costTime;
temp.endTime = time_cost;
endQueue.insert(temp);
continue;
}
time_cost += q;
temp.costTime -= q;
costQueue.insert(temp);
}
while (!endQueue.empty()) {
temp = endQueue.remove();
System.out.println(temp.name + " " + temp.endTime);
}
}
}
class Task {
String name;
int costTime;
int endTime;
}
class Queue {
int MAX = 100002;
Task[] entry = new Task[MAX];
int front;
int rear;
int count;
public Queue() {
for (int i = 0; i < MAX; i++) {
entry[i] = new Task();
}
front = 0;
rear = -1;
count = 0;
}
public void insert(Task t) {
rear = (rear + 1) % MAX;
count++;
entry[rear].name = t.name;
entry[rear].costTime = t.costTime;
entry[rear].endTime = t.endTime;
}
public Task remove() {
Task temp = entry[front];
front = (front + 1) % MAX;
count--;
return temp;
}
public boolean empty() {
return (count == 0);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
0,
13,
13,
14,
2,
0,
18,
13,
13,
2,
18,
13,
13,
13,
17,
30,
4,
18,
13,
13,
9,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
160,
17
],
[
160,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
26,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
20,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
66,
71
],
[
63,
72
],
[
72,
73
],
[
72,
74
],
[
63,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
20,
79
],
[
79,
80
],
[
79,
81
],
[
20,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
88,
94
],
[
94,
95
],
[
94,
96
],
[
88,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
98,
108
],
[
97,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
109,
114
],
[
88,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
88,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
126,
131
],
[
18,
132
],
[
132,
133
],
[
160,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
134,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
144,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
142,
155
],
[
155,
156
],
[
142,
157
],
[
157,
158
],
[
0,
159
],
[
159,
160
],
[
159,
161
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.LinkedList;\nimport java.util.Queue;\n\npublic class Main {\n\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] firstRow = br.readLine().split(\"\\\\s\");\n\n // ????´???°\n int elementNum = Integer.parseInt(firstRow[0]);\n // ???????????????\n int quantum = Integer.parseInt(firstRow[1]);\n\n // ????????\\?????????????????????????????????????????????FIFO\n // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }\n\n // ??????????¨???????\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n /**\n * Process???????????????\n */\n private final static class Process {\n // ??????????????????public????????????\n public String name = null;\n public int processTime = 0;\n\n public Process(String name, int processTime) {\n this.name = name;\n this.processTime = processTime;\n }\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] firstRow = br.readLine().split(\"\\\\s\");\n\n // ????´???°\n int elementNum = Integer.parseInt(firstRow[0]);\n // ???????????????\n int quantum = Integer.parseInt(firstRow[1]);\n\n // ????????\\?????????????????????????????????????????????FIFO\n // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }\n\n // ??????????¨???????\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n /**\n * Process???????????????\n */\n private final static class Process {\n // ??????????????????public????????????\n public String name = null;\n public int processTime = 0;\n\n public Process(String name, int processTime) {\n this.name = name;\n this.processTime = processTime;\n }\n }\n}",
"Main",
"public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] firstRow = br.readLine().split(\"\\\\s\");\n\n // ????´???°\n int elementNum = Integer.parseInt(firstRow[0]);\n // ???????????????\n int quantum = Integer.parseInt(firstRow[1]);\n\n // ????????\\?????????????????????????????????????????????FIFO\n // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }\n\n // ??????????¨???????\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] firstRow = br.readLine().split(\"\\\\s\");\n\n // ????´???°\n int elementNum = Integer.parseInt(firstRow[0]);\n // ???????????????\n int quantum = Integer.parseInt(firstRow[1]);\n\n // ????????\\?????????????????????????????????????????????FIFO\n // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }\n\n // ??????????¨???????\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] firstRow = br.readLine().split(\"\\\\s\");",
"firstRow",
"br.readLine().split(\"\\\\s\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s\"",
"int elementNum = Integer.parseInt(firstRow[0]);",
"elementNum",
"Integer.parseInt(firstRow[0])",
"Integer.parseInt",
"Integer",
"firstRow[0]",
"firstRow",
"0",
"int quantum = Integer.parseInt(firstRow[1]);",
"quantum",
"Integer.parseInt(firstRow[1])",
"Integer.parseInt",
"Integer",
"firstRow[1]",
"firstRow",
"1",
"Queue<Process> que = new LinkedList<Process>();",
"que",
"new LinkedList<Process>()",
"for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < elementNum",
"i",
"elementNum",
"i++",
"i++",
"i",
"{\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }",
"{\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }",
"String[] stringArray = br.readLine().split(\"\\\\s\");",
"stringArray",
"br.readLine().split(\"\\\\s\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s\"",
"Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));",
"process",
"new Process(stringArray[0],\n Integer.parseInt(stringArray[1]))",
"que.offer(process)",
"que.offer",
"que",
"process",
"int resultTime = 0;",
"resultTime",
"0",
"while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }",
"que.size() > 0",
"que.size()",
"que.size",
"que",
"0",
"{\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }",
"Process process = que.poll();",
"process",
"que.poll()",
"que.poll",
"que",
"resultTime += quantum",
"resultTime",
"quantum",
"if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }",
"(process.processTime = process.processTime - quantum) > 0",
"(process.processTime = process.processTime - quantum)",
"process.processTime",
"process",
"process.processTime",
"process.processTime - quantum",
"process.processTime",
"process",
"process.processTime",
"quantum",
"0",
"{\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }",
"que.offer(process)",
"que.offer",
"que",
"process",
"continue; // else??????????????§",
"resultTime += process.processTime",
"resultTime",
"process.processTime",
"process",
"process.processTime",
"System.out.println(process.name + \" \" + resultTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + resultTime",
"process.name + \" \" + resultTime",
"process.name",
"process",
"process.name",
"\" \"",
"resultTime",
"String args[]",
"args",
"private final static class Process {\n // ??????????????????public????????????\n public String name = null;\n public int processTime = 0;\n\n public Process(String name, int processTime) {\n this.name = name;\n this.processTime = processTime;\n }\n }",
"Process",
"// ??????????????????public????????????\n public String name = null;",
"name",
"null",
"public int processTime = 0;",
"processTime",
"0",
"public Process(String name, int processTime) {\n this.name = name;\n this.processTime = processTime;\n }",
"Process",
"{\n this.name = name;\n this.processTime = processTime;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.processTime = processTime",
"this.processTime",
"this",
"this.processTime",
"processTime",
"String name",
"name",
"int processTime",
"processTime",
"public class Main {\n\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] firstRow = br.readLine().split(\"\\\\s\");\n\n // ????´???°\n int elementNum = Integer.parseInt(firstRow[0]);\n // ???????????????\n int quantum = Integer.parseInt(firstRow[1]);\n\n // ????????\\?????????????????????????????????????????????FIFO\n // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }\n\n // ??????????¨???????\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n /**\n * Process???????????????\n */\n private final static class Process {\n // ??????????????????public????????????\n public String name = null;\n public int processTime = 0;\n\n public Process(String name, int processTime) {\n this.name = name;\n this.processTime = processTime;\n }\n }\n}",
"public class Main {\n\n public static void main(String args[]) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] firstRow = br.readLine().split(\"\\\\s\");\n\n // ????´???°\n int elementNum = Integer.parseInt(firstRow[0]);\n // ???????????????\n int quantum = Integer.parseInt(firstRow[1]);\n\n // ????????\\?????????????????????????????????????????????FIFO\n // ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????\n Queue<Process> que = new LinkedList<Process>();\n for (int i = 0; i < elementNum; i++) {\n String[] stringArray = br.readLine().split(\"\\\\s\");\n // ???p1 150?????????????????¢?????§stringArray????????????????????????\n // p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????\n // ????????£??¨??????????????????????????????????????????\n Process process = new Process(stringArray[0],\n Integer.parseInt(stringArray[1]));\n que.offer(process);\n }\n\n // ??????????¨???????\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n // ????¨???????????????¨????????????\n resultTime += quantum;\n // ???????????????????????????\n if ((process.processTime = process.processTime - quantum) > 0) {\n // ??????????????????????????????????????????????????????????????´??????\n // ???????°?????????????????????¨??????????????????\n que.offer(process);\n continue; // else??????????????§\n }\n // processTime???(-20)??????????????£???????????°????????????????????????\n // ??????????¨??????????????????????\n resultTime += process.processTime;\n // ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????\n // ??¨???????????????????????????\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n /**\n * Process???????????????\n */\n private final static class Process {\n // ??????????????????public????????????\n public String name = null;\n public int processTime = 0;\n\n public Process(String name, int processTime) {\n this.name = name;\n this.processTime = processTime;\n }\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] firstRow = br.readLine().split("\\s");
// ????´???°
int elementNum = Integer.parseInt(firstRow[0]);
// ???????????????
int quantum = Integer.parseInt(firstRow[1]);
// ????????\?????????????????????????????????????????????FIFO
// ?????????stack,dequeue??§?????£????????§?????????queue??§???????????????????????£???????????????????????????
Queue<Process> que = new LinkedList<Process>();
for (int i = 0; i < elementNum; i++) {
String[] stringArray = br.readLine().split("\\s");
// ???p1 150?????????????????¢?????§stringArray????????????????????????
// p1?????????????????????,150?????????????????????????????????????????????????????¨??????????????????
// ????????£??¨??????????????????????????????????????????
Process process = new Process(stringArray[0],
Integer.parseInt(stringArray[1]));
que.offer(process);
}
// ??????????¨???????
int resultTime = 0;
while (que.size() > 0) {
Process process = que.poll();
// ????¨???????????????¨????????????
resultTime += quantum;
// ???????????????????????????
if ((process.processTime = process.processTime - quantum) > 0) {
// ??????????????????????????????????????????????????????????????´??????
// ???????°?????????????????????¨??????????????????
que.offer(process);
continue; // else??????????????§
}
// processTime???(-20)??????????????£???????????°????????????????????????
// ??????????¨??????????????????????
resultTime += process.processTime;
// ?????????????????????????????????????????´???????????????????????¨??????????????§???????????£?????????
// ??¨???????????????????????????
System.out.println(process.name + " " + resultTime);
}
}
/**
* Process???????????????
*/
private final static class Process {
// ??????????????????public????????????
public String name = null;
public int processTime = 0;
public Process(String name, int processTime) {
this.name = name;
this.processTime = processTime;
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
4,
18,
20,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
20,
17,
41,
13,
18,
13,
17,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
17,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
4,
18,
13,
13,
17,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
13,
2,
13,
13,
0,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
17,
12,
13,
30,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
18,
13,
17,
29,
40,
13,
23,
13,
12,
13,
30,
29,
18,
13,
13,
23,
13,
12,
13,
30,
29,
18,
13,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
2,
2,
13,
17,
13,
13,
12,
13,
30,
14,
4,
13,
37,
20,
41,
13,
18,
13,
40,
13,
0,
13,
13,
29,
13,
12,
13,
30,
14,
4,
13,
37,
20,
41,
13,
0,
18,
13,
40,
13,
13,
0,
13,
13,
29,
13,
23,
13,
6,
13,
41,
13,
20,
12,
13,
30,
29,
4,
18,
4,
18,
13,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
18,
13,
12,
13,
30,
41,
13,
17,
42,
2,
13,
18,
13,
13,
30,
28,
13,
4,
18,
4,
18,
13,
17,
30,
30,
14,
2,
13,
18,
13,
13,
30,
0,
18,
13,
40,
13,
4,
18,
13,
13,
29,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
371,
14
],
[
371,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
371,
20
],
[
20,
21
],
[
20,
22
],
[
371,
23
],
[
23,
24
],
[
23,
25
],
[
371,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
26,
32
],
[
32,
33
],
[
371,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
40,
42
],
[
36,
43
],
[
43,
44
],
[
43,
45
],
[
36,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
36,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
55,
57
],
[
36,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
60,
62
],
[
36,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
68,
69
],
[
68,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
63,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
36,
86
],
[
86,
87
],
[
86,
88
],
[
36,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
89,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
94,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
94,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
118,
127
],
[
116,
128
],
[
114,
129
],
[
106,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
130,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
135,
139
],
[
139,
140
],
[
139,
141
],
[
130,
142
],
[
142,
143
],
[
142,
144
],
[
36,
145
],
[
145,
146
],
[
146,
147
],
[
145,
148
],
[
148,
149
],
[
149,
150
],
[
36,
151
],
[
151,
152
],
[
152,
153
],
[
0,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
159,
160
],
[
159,
161
],
[
154,
163
],
[
163,
164
],
[
163,
165
],
[
154,
167
],
[
167,
168
],
[
167,
169
],
[
154,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
177,
178
],
[
177,
179
],
[
172,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
184,
185
],
[
185,
186
],
[
184,
187
],
[
187,
188
],
[
187,
189
],
[
172,
190
],
[
190,
191
],
[
191,
192
],
[
170,
193
],
[
193,
194
],
[
154,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
195,
202
],
[
202,
203
],
[
154,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
204,
211
],
[
211,
212
],
[
154,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
217,
219
],
[
216,
220
],
[
213,
221
],
[
221,
222
],
[
213,
223
],
[
223,
224
],
[
0,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
227,
229
],
[
225,
230
],
[
230,
231
],
[
230,
232
],
[
225,
234
],
[
234,
235
],
[
234,
236
],
[
225,
237
],
[
237,
238
],
[
237,
239
],
[
225,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
225,
247
],
[
247,
248
],
[
247,
249
],
[
249,
250
],
[
250,
251
],
[
251,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
252,
256
],
[
251,
257
],
[
225,
258
],
[
258,
259
],
[
258,
260
],
[
260,
261
],
[
261,
262
],
[
262,
263
],
[
261,
264
],
[
264,
265
],
[
260,
266
],
[
266,
267
],
[
266,
268
],
[
268,
269
],
[
268,
270
],
[
270,
271
],
[
260,
272
],
[
272,
273
],
[
272,
274
],
[
260,
275
],
[
275,
276
],
[
225,
277
],
[
277,
278
],
[
277,
279
],
[
279,
280
],
[
280,
281
],
[
281,
282
],
[
280,
283
],
[
283,
284
],
[
279,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
288,
289
],
[
288,
290
],
[
290,
291
],
[
287,
292
],
[
279,
293
],
[
293,
294
],
[
293,
295
],
[
279,
296
],
[
296,
297
],
[
277,
298
],
[
298,
299
],
[
0,
300
],
[
300,
301
],
[
300,
302
],
[
302,
303
],
[
302,
304
],
[
300,
305
],
[
305,
306
],
[
305,
307
],
[
307,
308
],
[
308,
309
],
[
309,
310
],
[
310,
311
],
[
311,
312
],
[
312,
313
],
[
309,
314
],
[
305,
315
],
[
315,
316
],
[
300,
317
],
[
317,
318
],
[
317,
319
],
[
319,
320
],
[
320,
321
],
[
321,
322
],
[
322,
323
],
[
321,
324
],
[
324,
325
],
[
325,
326
],
[
300,
327
],
[
327,
328
],
[
327,
329
],
[
329,
330
],
[
330,
331
],
[
330,
332
],
[
329,
333
],
[
333,
334
],
[
334,
335
],
[
334,
336
],
[
336,
337
],
[
336,
338
],
[
333,
339
],
[
339,
340
],
[
340,
341
],
[
340,
342
],
[
342,
343
],
[
343,
344
],
[
344,
345
],
[
345,
346
],
[
342,
347
],
[
340,
348
],
[
349,
349
],
[
349,
350
],
[
350,
351
],
[
351,
352
],
[
351,
353
],
[
353,
354
],
[
353,
355
],
[
350,
356
],
[
356,
357
],
[
357,
358
],
[
358,
359
],
[
358,
360
],
[
360,
361
],
[
357,
362
],
[
362,
363
],
[
363,
364
],
[
362,
365
],
[
329,
366
],
[
366,
367
],
[
327,
368
],
[
368,
369
],
[
0,
370
],
[
370,
371
],
[
370,
372
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.PrintWriter;\n \npublic class Main {\n\tprivate static final String EOF = System.lineSeparator();\n\tprivate MyIntQueue queue = new MyIntQueue();\n\tprivate ProcessManager pm = new ProcessManager();\n public static void main(String[] args) throws IOException {\n new Main().exec();\n }\n \n public void exec() throws IOException {\n \tSimpleInputUtil in = new SimpleInputUtil();\n PrintWriter out = new PrintWriter(System.out);\n StringBuilder sb = new StringBuilder();\n \t\n int[] tmp = in.readIntArray(new int[2]);\n \tint n = tmp[0];\n \tint q = tmp[1];\n \t\n \tfor(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}\n \t\n \tint totalTime = 0;\n \twhile(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}\n out.print(sb.toString());\n \tout.flush();\n }\n}\n\nclass ProcessManager {\n\tprivate static final int CAPACITY = 100000;\n\tprivate String[] names = new String[CAPACITY];\n\tprivate int[] times = new int[CAPACITY];\n\tprivate int ptr = 0;\n\t\n\tpublic int addProcess(String[] procInfo) {\n\t\tnames[ptr] = procInfo[0];\n\t\ttimes[ptr] = Integer.parseInt(procInfo[1]);\n\t\treturn ptr++;\n\t}\n\t\n\tpublic String getName(int procId) {\n\t\treturn names[procId];\n\t}\n\t\n\tpublic int getTime(int procId) {\n\t\treturn times[procId];\n\t}\n\t\n\tpublic void setTime(int procId, int time) {\n\t\ttimes[procId] = time;\n\t}\n}\n\nclass MyIntQueue {\n\tprivate static final int CAPACITY = 100000;\n\tprivate int[] queue = new int[CAPACITY];\n private int head = 0;\n private int tail = 0;\n \n public boolean isEmpty(){return head == tail;}\n public boolean isFull(){return (head+1)%CAPACITY == tail;}\n \n public int remove() {\n \tif(isEmpty()) throw new IllegalStateException();\n \tint ret = queue[tail++];\n \ttail %= CAPACITY;\n \treturn ret;\n }\n \n public int add(int value) {\n \tif(isFull()) throw new IllegalStateException();\n \tint ret = queue[head++] = value;\n \thead %= CAPACITY;\n \treturn ret;\n }\n}\n\nclass SimpleInputUtil {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public String[] readStrArray(String delim) throws NumberFormatException, IOException{\n \treturn br.readLine().split(delim);\n }\n \n public int readInt() throws NumberFormatException, IOException{\n \treturn Integer.parseInt(br.readLine());\n }\n \n public int[] readIntArray(int[] a) throws NumberFormatException, IOException{\n int i=0;\n while(i<a.length) {\n for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }\n }\n return a;\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"public class Main {\n\tprivate static final String EOF = System.lineSeparator();\n\tprivate MyIntQueue queue = new MyIntQueue();\n\tprivate ProcessManager pm = new ProcessManager();\n public static void main(String[] args) throws IOException {\n new Main().exec();\n }\n \n public void exec() throws IOException {\n \tSimpleInputUtil in = new SimpleInputUtil();\n PrintWriter out = new PrintWriter(System.out);\n StringBuilder sb = new StringBuilder();\n \t\n int[] tmp = in.readIntArray(new int[2]);\n \tint n = tmp[0];\n \tint q = tmp[1];\n \t\n \tfor(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}\n \t\n \tint totalTime = 0;\n \twhile(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}\n out.print(sb.toString());\n \tout.flush();\n }\n}",
"Main",
"private static final String EOF = System.lineSeparator();",
"EOF",
"System.lineSeparator()",
"System.lineSeparator",
"System",
"private MyIntQueue queue = new MyIntQueue();",
"queue",
"new MyIntQueue()",
"private ProcessManager pm = new ProcessManager();",
"pm",
"new ProcessManager()",
"public static void main(String[] args) throws IOException {\n new Main().exec();\n }",
"main",
"{\n new Main().exec();\n }",
"new Main().exec()",
"new Main().exec",
"new Main()",
"String[] args",
"args",
"public void exec() throws IOException {\n \tSimpleInputUtil in = new SimpleInputUtil();\n PrintWriter out = new PrintWriter(System.out);\n StringBuilder sb = new StringBuilder();\n \t\n int[] tmp = in.readIntArray(new int[2]);\n \tint n = tmp[0];\n \tint q = tmp[1];\n \t\n \tfor(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}\n \t\n \tint totalTime = 0;\n \twhile(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}\n out.print(sb.toString());\n \tout.flush();\n }",
"exec",
"{\n \tSimpleInputUtil in = new SimpleInputUtil();\n PrintWriter out = new PrintWriter(System.out);\n StringBuilder sb = new StringBuilder();\n \t\n int[] tmp = in.readIntArray(new int[2]);\n \tint n = tmp[0];\n \tint q = tmp[1];\n \t\n \tfor(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}\n \t\n \tint totalTime = 0;\n \twhile(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}\n out.print(sb.toString());\n \tout.flush();\n }",
"SimpleInputUtil in = new SimpleInputUtil();",
"in",
"new SimpleInputUtil()",
"PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int[] tmp = in.readIntArray(new int[2]);",
"tmp",
"in.readIntArray(new int[2])",
"in.readIntArray",
"in",
"new int[2]",
"2",
"int n = tmp[0];",
"n",
"tmp[0]",
"tmp",
"0",
"int q = tmp[1];",
"q",
"tmp[1]",
"tmp",
"1",
"for(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}",
"{\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}",
"queue.add(pm.addProcess(in.readStrArray(\" \")))",
"queue.add",
"queue",
"pm.addProcess(in.readStrArray(\" \"))",
"pm.addProcess",
"pm",
"in.readStrArray(\" \")",
"in.readStrArray",
"in",
"\" \"",
"int totalTime = 0;",
"totalTime",
"0",
"while(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}",
"int procId = queue.remove();",
"procId",
"queue.remove()",
"queue.remove",
"queue",
"int time = pm.getTime(procId);",
"time",
"pm.getTime(procId)",
"pm.getTime",
"pm",
"procId",
"if(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}",
"time <= q",
"time",
"q",
"{\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}",
"totalTime += time",
"totalTime",
"time",
"sb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF)",
"sb.append(pm.getName(procId)).append(\" \").append(totalTime).append",
"sb.append(pm.getName(procId)).append(\" \").append(totalTime)",
"sb.append(pm.getName(procId)).append(\" \").append",
"sb.append(pm.getName(procId)).append(\" \")",
"sb.append(pm.getName(procId)).append",
"sb.append(pm.getName(procId))",
"sb.append",
"sb",
"pm.getName(procId)",
"pm.getName",
"pm",
"procId",
"\" \"",
"totalTime",
"EOF",
"{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}",
"queue.add(procId)",
"queue.add",
"queue",
"procId",
"pm.setTime(procId, time - q)",
"pm.setTime",
"pm",
"procId",
"time - q",
"time",
"q",
"totalTime += q",
"totalTime",
"q",
"out.print(sb.toString())",
"out.print",
"out",
"sb.toString()",
"sb.toString",
"sb",
"out.flush()",
"out.flush",
"out",
"class ProcessManager {\n\tprivate static final int CAPACITY = 100000;\n\tprivate String[] names = new String[CAPACITY];\n\tprivate int[] times = new int[CAPACITY];\n\tprivate int ptr = 0;\n\t\n\tpublic int addProcess(String[] procInfo) {\n\t\tnames[ptr] = procInfo[0];\n\t\ttimes[ptr] = Integer.parseInt(procInfo[1]);\n\t\treturn ptr++;\n\t}\n\t\n\tpublic String getName(int procId) {\n\t\treturn names[procId];\n\t}\n\t\n\tpublic int getTime(int procId) {\n\t\treturn times[procId];\n\t}\n\t\n\tpublic void setTime(int procId, int time) {\n\t\ttimes[procId] = time;\n\t}\n}",
"ProcessManager",
"private static final int CAPACITY = 100000;",
"CAPACITY",
"100000",
"private String[] names = new String[CAPACITY];",
"names",
"new String[CAPACITY]",
"CAPACITY",
"private int[] times = new int[CAPACITY];",
"times",
"new int[CAPACITY]",
"CAPACITY",
"private int ptr = 0;",
"ptr",
"0",
"public int addProcess(String[] procInfo) {\n\t\tnames[ptr] = procInfo[0];\n\t\ttimes[ptr] = Integer.parseInt(procInfo[1]);\n\t\treturn ptr++;\n\t}",
"addProcess",
"{\n\t\tnames[ptr] = procInfo[0];\n\t\ttimes[ptr] = Integer.parseInt(procInfo[1]);\n\t\treturn ptr++;\n\t}",
"names[ptr] = procInfo[0]",
"names[ptr]",
"names",
"ptr",
"procInfo[0]",
"procInfo",
"0",
"times[ptr] = Integer.parseInt(procInfo[1])",
"times[ptr]",
"times",
"ptr",
"Integer.parseInt(procInfo[1])",
"Integer.parseInt",
"Integer",
"procInfo[1]",
"procInfo",
"1",
"return ptr++;",
"ptr++",
"ptr",
"String[] procInfo",
"procInfo",
"public String getName(int procId) {\n\t\treturn names[procId];\n\t}",
"getName",
"{\n\t\treturn names[procId];\n\t}",
"return names[procId];",
"names[procId]",
"names",
"procId",
"int procId",
"procId",
"public int getTime(int procId) {\n\t\treturn times[procId];\n\t}",
"getTime",
"{\n\t\treturn times[procId];\n\t}",
"return times[procId];",
"times[procId]",
"times",
"procId",
"int procId",
"procId",
"public void setTime(int procId, int time) {\n\t\ttimes[procId] = time;\n\t}",
"setTime",
"{\n\t\ttimes[procId] = time;\n\t}",
"times[procId] = time",
"times[procId]",
"times",
"procId",
"time",
"int procId",
"procId",
"int time",
"time",
"class MyIntQueue {\n\tprivate static final int CAPACITY = 100000;\n\tprivate int[] queue = new int[CAPACITY];\n private int head = 0;\n private int tail = 0;\n \n public boolean isEmpty(){return head == tail;}\n public boolean isFull(){return (head+1)%CAPACITY == tail;}\n \n public int remove() {\n \tif(isEmpty()) throw new IllegalStateException();\n \tint ret = queue[tail++];\n \ttail %= CAPACITY;\n \treturn ret;\n }\n \n public int add(int value) {\n \tif(isFull()) throw new IllegalStateException();\n \tint ret = queue[head++] = value;\n \thead %= CAPACITY;\n \treturn ret;\n }\n}",
"MyIntQueue",
"private static final int CAPACITY = 100000;",
"CAPACITY",
"100000",
"private int[] queue = new int[CAPACITY];",
"queue",
"new int[CAPACITY]",
"CAPACITY",
"private int head = 0;",
"head",
"0",
"private int tail = 0;",
"tail",
"0",
"public boolean isEmpty(){return head == tail;}",
"isEmpty",
"{return head == tail;}",
"return head == tail;",
"head == tail",
"head",
"tail",
"public boolean isFull(){return (head+1)%CAPACITY == tail;}",
"isFull",
"{return (head+1)%CAPACITY == tail;}",
"return (head+1)%CAPACITY == tail;",
"(head+1)%CAPACITY == tail",
"(head+1)%CAPACITY",
"(head+1)",
"head",
"1",
"CAPACITY",
"tail",
"public int remove() {\n \tif(isEmpty()) throw new IllegalStateException();\n \tint ret = queue[tail++];\n \ttail %= CAPACITY;\n \treturn ret;\n }",
"remove",
"{\n \tif(isEmpty()) throw new IllegalStateException();\n \tint ret = queue[tail++];\n \ttail %= CAPACITY;\n \treturn ret;\n }",
"if(isEmpty()) throw new IllegalStateException();",
"isEmpty()",
"isEmpty",
"throw new IllegalStateException();",
"new IllegalStateException()",
"int ret = queue[tail++];",
"ret",
"queue[tail++]",
"queue",
"tail++",
"tail",
"tail %= CAPACITY",
"tail",
"CAPACITY",
"return ret;",
"ret",
"public int add(int value) {\n \tif(isFull()) throw new IllegalStateException();\n \tint ret = queue[head++] = value;\n \thead %= CAPACITY;\n \treturn ret;\n }",
"add",
"{\n \tif(isFull()) throw new IllegalStateException();\n \tint ret = queue[head++] = value;\n \thead %= CAPACITY;\n \treturn ret;\n }",
"if(isFull()) throw new IllegalStateException();",
"isFull()",
"isFull",
"throw new IllegalStateException();",
"new IllegalStateException()",
"int ret = queue[head++] = value;",
"ret",
"queue[head++] = value",
"queue[head++]",
"queue",
"head++",
"head",
"value",
"head %= CAPACITY",
"head",
"CAPACITY",
"return ret;",
"ret",
"int value",
"value",
"class SimpleInputUtil {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n public String[] readStrArray(String delim) throws NumberFormatException, IOException{\n \treturn br.readLine().split(delim);\n }\n \n public int readInt() throws NumberFormatException, IOException{\n \treturn Integer.parseInt(br.readLine());\n }\n \n public int[] readIntArray(int[] a) throws NumberFormatException, IOException{\n int i=0;\n while(i<a.length) {\n for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }\n }\n return a;\n }\n}",
"SimpleInputUtil",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"public String[] readStrArray(String delim) throws NumberFormatException, IOException{\n \treturn br.readLine().split(delim);\n }",
"readStrArray",
"{\n \treturn br.readLine().split(delim);\n }",
"return br.readLine().split(delim);",
"br.readLine().split(delim)",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"delim",
"String delim",
"delim",
"public int readInt() throws NumberFormatException, IOException{\n \treturn Integer.parseInt(br.readLine());\n }",
"readInt",
"{\n \treturn Integer.parseInt(br.readLine());\n }",
"return Integer.parseInt(br.readLine());",
"Integer.parseInt(br.readLine())",
"Integer.parseInt",
"Integer",
"br.readLine()",
"br.readLine",
"br",
"public int[] readIntArray(int[] a) throws NumberFormatException, IOException{\n int i=0;\n while(i<a.length) {\n for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }\n }\n return a;\n }",
"readIntArray",
"{\n int i=0;\n while(i<a.length) {\n for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }\n }\n return a;\n }",
"int i=0;",
"i",
"0",
"while(i<a.length) {\n for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }\n }",
"i<a.length",
"i",
"a.length",
"a",
"a.length",
"{\n for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }\n }",
"for(String s: br.readLine().split(\" \")){\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }",
"String s",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"{\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }",
"{\n \tif(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}\n }",
"if(i<a.length) {\n a[i++] = Integer.parseInt(s);\n \t}",
"i<a.length",
"i",
"a.length",
"a",
"a.length",
"{\n a[i++] = Integer.parseInt(s);\n \t}",
"a[i++] = Integer.parseInt(s)",
"a[i++]",
"a",
"i++",
"i",
"Integer.parseInt(s)",
"Integer.parseInt",
"Integer",
"s",
"return a;",
"a",
"int[] a",
"a",
"public class Main {\n\tprivate static final String EOF = System.lineSeparator();\n\tprivate MyIntQueue queue = new MyIntQueue();\n\tprivate ProcessManager pm = new ProcessManager();\n public static void main(String[] args) throws IOException {\n new Main().exec();\n }\n \n public void exec() throws IOException {\n \tSimpleInputUtil in = new SimpleInputUtil();\n PrintWriter out = new PrintWriter(System.out);\n StringBuilder sb = new StringBuilder();\n \t\n int[] tmp = in.readIntArray(new int[2]);\n \tint n = tmp[0];\n \tint q = tmp[1];\n \t\n \tfor(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}\n \t\n \tint totalTime = 0;\n \twhile(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}\n out.print(sb.toString());\n \tout.flush();\n }\n}",
"public class Main {\n\tprivate static final String EOF = System.lineSeparator();\n\tprivate MyIntQueue queue = new MyIntQueue();\n\tprivate ProcessManager pm = new ProcessManager();\n public static void main(String[] args) throws IOException {\n new Main().exec();\n }\n \n public void exec() throws IOException {\n \tSimpleInputUtil in = new SimpleInputUtil();\n PrintWriter out = new PrintWriter(System.out);\n StringBuilder sb = new StringBuilder();\n \t\n int[] tmp = in.readIntArray(new int[2]);\n \tint n = tmp[0];\n \tint q = tmp[1];\n \t\n \tfor(int i=0; i<n; i++) {\n \t\tqueue.add(pm.addProcess(in.readStrArray(\" \")));\n \t}\n \t\n \tint totalTime = 0;\n \twhile(!queue.isEmpty()) {\n \t\tint procId = queue.remove();\n \t\tint time = pm.getTime(procId);\n \t\tif(time <= q) {\n \t\t\t//Process Finish\n \t\t\ttotalTime += time;\n \t\t\tsb.append(pm.getName(procId)).append(\" \").append(totalTime).append(EOF);\n \t\t}else{\n \t\t\t//Process Continue\n \t\t\tqueue.add(procId);\n \t\t\tpm.setTime(procId, time - q);\n \t\t\ttotalTime += q;\n \t\t}\n \t}\n out.print(sb.toString());\n \tout.flush();\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
private static final String EOF = System.lineSeparator();
private MyIntQueue queue = new MyIntQueue();
private ProcessManager pm = new ProcessManager();
public static void main(String[] args) throws IOException {
new Main().exec();
}
public void exec() throws IOException {
SimpleInputUtil in = new SimpleInputUtil();
PrintWriter out = new PrintWriter(System.out);
StringBuilder sb = new StringBuilder();
int[] tmp = in.readIntArray(new int[2]);
int n = tmp[0];
int q = tmp[1];
for(int i=0; i<n; i++) {
queue.add(pm.addProcess(in.readStrArray(" ")));
}
int totalTime = 0;
while(!queue.isEmpty()) {
int procId = queue.remove();
int time = pm.getTime(procId);
if(time <= q) {
//Process Finish
totalTime += time;
sb.append(pm.getName(procId)).append(" ").append(totalTime).append(EOF);
}else{
//Process Continue
queue.add(procId);
pm.setTime(procId, time - q);
totalTime += q;
}
}
out.print(sb.toString());
out.flush();
}
}
class ProcessManager {
private static final int CAPACITY = 100000;
private String[] names = new String[CAPACITY];
private int[] times = new int[CAPACITY];
private int ptr = 0;
public int addProcess(String[] procInfo) {
names[ptr] = procInfo[0];
times[ptr] = Integer.parseInt(procInfo[1]);
return ptr++;
}
public String getName(int procId) {
return names[procId];
}
public int getTime(int procId) {
return times[procId];
}
public void setTime(int procId, int time) {
times[procId] = time;
}
}
class MyIntQueue {
private static final int CAPACITY = 100000;
private int[] queue = new int[CAPACITY];
private int head = 0;
private int tail = 0;
public boolean isEmpty(){return head == tail;}
public boolean isFull(){return (head+1)%CAPACITY == tail;}
public int remove() {
if(isEmpty()) throw new IllegalStateException();
int ret = queue[tail++];
tail %= CAPACITY;
return ret;
}
public int add(int value) {
if(isFull()) throw new IllegalStateException();
int ret = queue[head++] = value;
head %= CAPACITY;
return ret;
}
}
class SimpleInputUtil {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public String[] readStrArray(String delim) throws NumberFormatException, IOException{
return br.readLine().split(delim);
}
public int readInt() throws NumberFormatException, IOException{
return Integer.parseInt(br.readLine());
}
public int[] readIntArray(int[] a) throws NumberFormatException, IOException{
int i=0;
while(i<a.length) {
for(String s: br.readLine().split(" ")){
if(i<a.length) {
a[i++] = Integer.parseInt(s);
}
}
}
return a;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
13,
0,
13,
40,
17,
23,
13,
12,
13,
30,
0,
18,
13,
40,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
40,
13,
17,
29,
13,
12,
13,
30,
29,
2,
13,
40,
17,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
245,
5
],
[
245,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
14,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
22,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
33,
34
],
[
33,
35
],
[
8,
36
],
[
36,
37
],
[
36,
38
],
[
8,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
54,
59
],
[
51,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
62,
64
],
[
51,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
70,
71
],
[
70,
72
],
[
51,
73
],
[
73,
74
],
[
73,
75
],
[
51,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
8,
80
],
[
80,
81
],
[
80,
82
],
[
8,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
83,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
88,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
94,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
94,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
88,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
88,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
119,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
119,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
137,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
137,
142
],
[
6,
143
],
[
143,
144
],
[
0,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
145,
149
],
[
149,
150
],
[
145,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
153,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
151,
164
],
[
164,
165
],
[
151,
166
],
[
166,
167
],
[
0,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
168,
172
],
[
172,
173
],
[
168,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
181
],
[
181,
182
],
[
181,
183
],
[
183,
184
],
[
174,
185
],
[
185,
186
],
[
168,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
190,
195
],
[
187,
196
],
[
196,
197
],
[
168,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
203,
205
],
[
200,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
206,
211
],
[
211,
212
],
[
211,
213
],
[
206,
214
],
[
214,
215
],
[
215,
216
],
[
206,
217
],
[
218,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
219,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
225,
227
],
[
200,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
228,
233
],
[
200,
234
],
[
234,
235
],
[
168,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
239,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
0,
244
],
[
244,
245
],
[
244,
246
]
] | [
"import java.util.Scanner;\npublic class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tMyQueue processes = new MyQueue(n);\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}\nclass Process {\n String name;\n int time;\n Process (String name, int time) {\n\tthis.name = name;\n\tthis.time = time;\n }\n}\nclass MyQueue {\n int top;\n Process[] processes;\n MyQueue (int n) {\n\tprocesses = new Process[n];\n\ttop = -1;\n }\n void enqueue (Process p) {\n\tprocesses[++top] = p;\n }\n Process dequeue () {\n\tProcess p = processes[0];\n\tfor (int i = 0; i < top; i++) {\n\t processes[i] = processes[i+1];\n\t}\n\tprocesses[top--] = null;\n\treturn p;\n }\n boolean isEmpty () {\n\treturn top == -1;\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tMyQueue processes = new MyQueue(n);\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}",
"Main",
"public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tMyQueue processes = new MyQueue(n);\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }",
"main",
"{\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tMyQueue processes = new MyQueue(n);\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"String[] initial = scan.nextLine().split(\" \");",
"initial",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"int n = Integer.parseInt(initial[0]);",
"n",
"Integer.parseInt(initial[0])",
"Integer.parseInt",
"Integer",
"initial[0]",
"initial",
"0",
"int q = Integer.parseInt(initial[1]);",
"q",
"Integer.parseInt(initial[1])",
"Integer.parseInt",
"Integer",
"initial[1]",
"initial",
"1",
"MyQueue processes = new MyQueue(n);",
"processes",
"new MyQueue(n)",
"for (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}",
"{\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}",
"String[] input = scan.nextLine().split(\" \");",
"input",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"String name = input[0];",
"name",
"input[0]",
"input",
"0",
"int time = Integer.parseInt(input[1]);",
"time",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"Process p = new Process(name, time);",
"p",
"new Process(name, time)",
"processes.enqueue(p)",
"processes.enqueue",
"processes",
"p",
"int processTime = 0;",
"processTime",
"0",
"while (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}",
"!processes.isEmpty()",
"processes.isEmpty()",
"processes.isEmpty",
"processes",
"{\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}",
"Process p = processes.dequeue();",
"p",
"processes.dequeue()",
"processes.dequeue",
"processes",
"if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\tprocessTime += q;\n\t }",
"processTime += q",
"processTime",
"q",
"{\n\t\tprocessTime += p.time;\n\t }",
"processTime += p.time",
"processTime",
"p.time",
"p",
"p.time",
"p.time = p.time - q",
"p.time",
"p",
"p.time",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }",
"p.time > 0",
"p.time",
"p",
"p.time",
"0",
"{\n\t\tprocesses.enqueue(p);\n\t }",
"processes.enqueue(p)",
"processes.enqueue",
"processes",
"p",
"{\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }",
"System.out.println(p.name + \" \" + processTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + processTime",
"p.name + \" \" + processTime",
"p.name",
"p",
"p.name",
"\" \"",
"processTime",
"String[] args",
"args",
"class Process {\n String name;\n int time;\n Process (String name, int time) {\n\tthis.name = name;\n\tthis.time = time;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process (String name, int time) {\n\tthis.name = name;\n\tthis.time = time;\n }",
"Process",
"{\n\tthis.name = name;\n\tthis.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"class MyQueue {\n int top;\n Process[] processes;\n MyQueue (int n) {\n\tprocesses = new Process[n];\n\ttop = -1;\n }\n void enqueue (Process p) {\n\tprocesses[++top] = p;\n }\n Process dequeue () {\n\tProcess p = processes[0];\n\tfor (int i = 0; i < top; i++) {\n\t processes[i] = processes[i+1];\n\t}\n\tprocesses[top--] = null;\n\treturn p;\n }\n boolean isEmpty () {\n\treturn top == -1;\n }\n}",
"MyQueue",
"int top;",
"top",
"Process[] processes;",
"processes",
"MyQueue (int n) {\n\tprocesses = new Process[n];\n\ttop = -1;\n }",
"MyQueue",
"{\n\tprocesses = new Process[n];\n\ttop = -1;\n }",
"processes = new Process[n]",
"processes",
"new Process[n]",
"n",
"top = -1",
"top",
"-1",
"1",
"int n",
"n",
"void enqueue (Process p) {\n\tprocesses[++top] = p;\n }",
"enqueue",
"{\n\tprocesses[++top] = p;\n }",
"processes[++top] = p",
"processes[++top]",
"processes",
"++top",
"top",
"p",
"Process p",
"p",
"Process dequeue () {\n\tProcess p = processes[0];\n\tfor (int i = 0; i < top; i++) {\n\t processes[i] = processes[i+1];\n\t}\n\tprocesses[top--] = null;\n\treturn p;\n }",
"dequeue",
"{\n\tProcess p = processes[0];\n\tfor (int i = 0; i < top; i++) {\n\t processes[i] = processes[i+1];\n\t}\n\tprocesses[top--] = null;\n\treturn p;\n }",
"Process p = processes[0];",
"p",
"processes[0]",
"processes",
"0",
"for (int i = 0; i < top; i++) {\n\t processes[i] = processes[i+1];\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < top",
"i",
"top",
"i++",
"i++",
"i",
"{\n\t processes[i] = processes[i+1];\n\t}",
"{\n\t processes[i] = processes[i+1];\n\t}",
"processes[i] = processes[i+1]",
"processes[i]",
"processes",
"i",
"processes[i+1]",
"processes",
"i+1",
"i",
"1",
"processes[top--] = null",
"processes[top--]",
"processes",
"top--",
"top",
"null",
"return p;",
"p",
"boolean isEmpty () {\n\treturn top == -1;\n }",
"isEmpty",
"{\n\treturn top == -1;\n }",
"return top == -1;",
"top == -1",
"top",
"-1",
"1",
"public class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tMyQueue processes = new MyQueue(n);\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}",
"public class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tMyQueue processes = new MyQueue(n);\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.enqueue(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.dequeue();\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.enqueue(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main (String[] args) {
Scanner scan = new Scanner(System.in);
String[] initial = scan.nextLine().split(" ");
int n = Integer.parseInt(initial[0]);
int q = Integer.parseInt(initial[1]);
MyQueue processes = new MyQueue(n);
for (int i = 0; i < n; i++) {
String[] input = scan.nextLine().split(" ");
String name = input[0];
int time = Integer.parseInt(input[1]);
Process p = new Process(name, time);
processes.enqueue(p);
}
int processTime = 0;
while (!processes.isEmpty()) {
Process p = processes.dequeue();
if (p.time > q) {
processTime += q;
} else {
processTime += p.time;
}
p.time = p.time - q;
if (p.time > 0) {
processes.enqueue(p);
} else {
System.out.println(p.name + " " + processTime);
}
}
}
}
class Process {
String name;
int time;
Process (String name, int time) {
this.name = name;
this.time = time;
}
}
class MyQueue {
int top;
Process[] processes;
MyQueue (int n) {
processes = new Process[n];
top = -1;
}
void enqueue (Process p) {
processes[++top] = p;
}
Process dequeue () {
Process p = processes[0];
for (int i = 0; i < top; i++) {
processes[i] = processes[i+1];
}
processes[top--] = null;
return p;
}
boolean isEmpty () {
return top == -1;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
20,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
14,
2,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
18,
13,
13,
17,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
13,
13,
23,
13,
12,
13,
30,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
172,
5
],
[
172,
6
],
[
6,
7
],
[
6,
8
],
[
172,
9
],
[
9,
10
],
[
9,
11
],
[
172,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
23,
26
],
[
26,
27
],
[
27,
28
],
[
14,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
35,
36
],
[
14,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
37,
42
],
[
42,
43
],
[
42,
44
],
[
37,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
49,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
49,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
61,
62
],
[
49,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
14,
67
],
[
67,
68
],
[
68,
69
],
[
14,
70
],
[
70,
71
],
[
70,
72
],
[
14,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
73,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
78,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
78,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
96,
100
],
[
78,
101
],
[
101,
102
],
[
101,
103
],
[
78,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
105,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
104,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
114,
120
],
[
120,
121
],
[
121,
122
],
[
114,
123
],
[
12,
124
],
[
124,
125
],
[
172,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
126,
130
],
[
130,
131
],
[
126,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
138,
139
],
[
138,
140
],
[
132,
141
],
[
141,
142
],
[
132,
143
],
[
143,
144
],
[
126,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
145,
151
],
[
151,
152
],
[
126,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
126,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
158,
164
],
[
164,
165
],
[
126,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
0,
171
],
[
171,
172
],
[
171,
173
]
] | [
"import java.util.*;\n\npublic class Main{\n\tfinal static int MOD = 1000000007;\n\tfinal static int INF = 1000000000;\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Process> que = new ArrayDeque<Process>();\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}\n\t\tsc.close();\n\t\tint t = 0;\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}\n\t}\n\t\n\t\n\t\n\tstatic class Process{\n\t\tString name; int time;\n\t\tpublic Process(String s, int t){\n\t\t\tname = s; time = t;\n\t\t}\n\t\tpublic void setName(String nm){\n\t\t\tname = nm;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn name;\n\t\t}\n\t\tpublic void setTime(int t){\n\t\t\ttime = t;\n\t\t}\n\t\tpublic int getTime(){\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tfinal static int MOD = 1000000007;\n\tfinal static int INF = 1000000000;\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Process> que = new ArrayDeque<Process>();\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}\n\t\tsc.close();\n\t\tint t = 0;\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}\n\t}\n\t\n\t\n\t\n\tstatic class Process{\n\t\tString name; int time;\n\t\tpublic Process(String s, int t){\n\t\t\tname = s; time = t;\n\t\t}\n\t\tpublic void setName(String nm){\n\t\t\tname = nm;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn name;\n\t\t}\n\t\tpublic void setTime(int t){\n\t\t\ttime = t;\n\t\t}\n\t\tpublic int getTime(){\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"Main",
"final static int MOD = 1000000007;",
"MOD",
"1000000007",
"final static int INF = 1000000000;",
"INF",
"1000000000",
"public static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Process> que = new ArrayDeque<Process>();\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}\n\t\tsc.close();\n\t\tint t = 0;\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Process> que = new ArrayDeque<Process>();\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}\n\t\tsc.close();\n\t\tint t = 0;\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<Process> que = new ArrayDeque<Process>();",
"que",
"new ArrayDeque<Process>()",
"int n = Integer.parseInt(sc.next());",
"n",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int q = Integer.parseInt(sc.next());",
"q",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"for(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"++i",
"++i",
"i",
"{\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}",
"{\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}",
"String nm = sc.next();",
"nm",
"sc.next()",
"sc.next",
"sc",
"int t = Integer.parseInt(sc.next());",
"t",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"que.add(new Process(nm, t))",
"que.add",
"que",
"new Process(nm, t)",
"sc.close()",
"sc.close",
"sc",
"int t = 0;",
"t",
"0",
"while(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}",
"Process cur = que.poll();",
"cur",
"que.poll()",
"que.poll",
"que",
"int prctime = Math.min(q, cur.getTime());",
"prctime",
"Math.min(q, cur.getTime())",
"Math.min",
"Math",
"q",
"cur.getTime()",
"cur.getTime",
"cur",
"cur.setTime(cur.getTime() - prctime)",
"cur.setTime",
"cur",
"cur.getTime() - prctime",
"cur.getTime()",
"cur.getTime",
"cur",
"prctime",
"t += prctime",
"t",
"prctime",
"if(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);",
"cur.getTime() > 0",
"cur.getTime()",
"cur.getTime",
"cur",
"0",
"que.add(cur)",
"que.add",
"que",
"cur",
"System.out.printf(\"%s %d\\n\", cur.getName(), t)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"cur.getName()",
"cur.getName",
"cur",
"t",
"String[] args",
"args",
"static class Process{\n\t\tString name; int time;\n\t\tpublic Process(String s, int t){\n\t\t\tname = s; time = t;\n\t\t}\n\t\tpublic void setName(String nm){\n\t\t\tname = nm;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn name;\n\t\t}\n\t\tpublic void setTime(int t){\n\t\t\ttime = t;\n\t\t}\n\t\tpublic int getTime(){\n\t\t\treturn time;\n\t\t}\n\t}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String s, int t){\n\t\t\tname = s; time = t;\n\t\t}",
"Process",
"{\n\t\t\tname = s; time = t;\n\t\t}",
"name = s",
"name",
"s",
"time = t",
"time",
"t",
"String s",
"s",
"int t",
"t",
"public void setName(String nm){\n\t\t\tname = nm;\n\t\t}",
"setName",
"{\n\t\t\tname = nm;\n\t\t}",
"name = nm",
"name",
"nm",
"String nm",
"nm",
"public String getName(){\n\t\t\treturn name;\n\t\t}",
"getName",
"{\n\t\t\treturn name;\n\t\t}",
"return name;",
"name",
"public void setTime(int t){\n\t\t\ttime = t;\n\t\t}",
"setTime",
"{\n\t\t\ttime = t;\n\t\t}",
"time = t",
"time",
"t",
"int t",
"t",
"public int getTime(){\n\t\t\treturn time;\n\t\t}",
"getTime",
"{\n\t\t\treturn time;\n\t\t}",
"return time;",
"time",
"public class Main{\n\tfinal static int MOD = 1000000007;\n\tfinal static int INF = 1000000000;\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Process> que = new ArrayDeque<Process>();\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}\n\t\tsc.close();\n\t\tint t = 0;\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}\n\t}\n\t\n\t\n\t\n\tstatic class Process{\n\t\tString name; int time;\n\t\tpublic Process(String s, int t){\n\t\t\tname = s; time = t;\n\t\t}\n\t\tpublic void setName(String nm){\n\t\t\tname = nm;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn name;\n\t\t}\n\t\tpublic void setTime(int t){\n\t\t\ttime = t;\n\t\t}\n\t\tpublic int getTime(){\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"public class Main{\n\tfinal static int MOD = 1000000007;\n\tfinal static int INF = 1000000000;\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Process> que = new ArrayDeque<Process>();\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tString nm = sc.next();\n\t\t\tint t = Integer.parseInt(sc.next());\n\t\t\tque.add(new Process(nm, t));\n\t\t}\n\t\tsc.close();\n\t\tint t = 0;\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess cur = que.poll();\n\t\t\tint prctime = Math.min(q, cur.getTime());\n\t\t\tcur.setTime(cur.getTime() - prctime);\n\t\t\tt += prctime;\n\t\t\tif(cur.getTime() > 0)\n\t\t\t\tque.add(cur);\n\t\t\telse System.out.printf(\"%s %d\\n\", cur.getName(), t);\n\t\t}\n\t}\n\t\n\t\n\t\n\tstatic class Process{\n\t\tString name; int time;\n\t\tpublic Process(String s, int t){\n\t\t\tname = s; time = t;\n\t\t}\n\t\tpublic void setName(String nm){\n\t\t\tname = nm;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn name;\n\t\t}\n\t\tpublic void setTime(int t){\n\t\t\ttime = t;\n\t\t}\n\t\tpublic int getTime(){\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main{
final static int MOD = 1000000007;
final static int INF = 1000000000;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Queue<Process> que = new ArrayDeque<Process>();
int n = Integer.parseInt(sc.next());
int q = Integer.parseInt(sc.next());
for(int i = 0; i < n; ++i){
String nm = sc.next();
int t = Integer.parseInt(sc.next());
que.add(new Process(nm, t));
}
sc.close();
int t = 0;
while(!que.isEmpty()){
Process cur = que.poll();
int prctime = Math.min(q, cur.getTime());
cur.setTime(cur.getTime() - prctime);
t += prctime;
if(cur.getTime() > 0)
que.add(cur);
else System.out.printf("%s %d\n", cur.getName(), t);
}
}
static class Process{
String name; int time;
public Process(String s, int t){
name = s; time = t;
}
public void setName(String nm){
name = nm;
}
public String getName(){
return name;
}
public void setTime(int t){
time = t;
}
public int getTime(){
return time;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
41,
13,
20,
42,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
138,
8
],
[
138,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
22,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
31,
32
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
11,
42
],
[
42,
43
],
[
42,
44
],
[
11,
45
],
[
45,
46
],
[
45,
47
],
[
11,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
52,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
52,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
11,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
68,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
85,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
91,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
97,
102
],
[
79,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
103,
109
],
[
109,
110
],
[
109,
111
],
[
103,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
9,
116
],
[
116,
117
],
[
138,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
118,
122
],
[
122,
123
],
[
118,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
130,
131
],
[
130,
132
],
[
124,
133
],
[
133,
134
],
[
124,
135
],
[
135,
136
],
[
0,
137
],
[
137,
138
],
[
137,
139
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tprivate static class Process{\n\t\tpublic String n;\n\t\tpublic int t;\n\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString first = in.nextLine();\n\t\tString[] components = first.split(\" \");\n\t\tint inputs = Integer.parseInt(components[0]);\n\t\tint quantum = Integer.parseInt(components[1]);\n\t\tint time = 0;\n\t\t\n\t\t//Creating the Queue of processes\n\t\tLinkedList<Process> q = new LinkedList<>();\n\t\twhile (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}\n\t\t\n\t\t//Running\n\t\twhile (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tprivate static class Process{\n\t\tpublic String n;\n\t\tpublic int t;\n\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString first = in.nextLine();\n\t\tString[] components = first.split(\" \");\n\t\tint inputs = Integer.parseInt(components[0]);\n\t\tint quantum = Integer.parseInt(components[1]);\n\t\tint time = 0;\n\t\t\n\t\t//Creating the Queue of processes\n\t\tLinkedList<Process> q = new LinkedList<>();\n\t\twhile (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}\n\t\t\n\t\t//Running\n\t\twhile (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString first = in.nextLine();\n\t\tString[] components = first.split(\" \");\n\t\tint inputs = Integer.parseInt(components[0]);\n\t\tint quantum = Integer.parseInt(components[1]);\n\t\tint time = 0;\n\t\t\n\t\t//Creating the Queue of processes\n\t\tLinkedList<Process> q = new LinkedList<>();\n\t\twhile (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}\n\t\t\n\t\t//Running\n\t\twhile (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tString first = in.nextLine();\n\t\tString[] components = first.split(\" \");\n\t\tint inputs = Integer.parseInt(components[0]);\n\t\tint quantum = Integer.parseInt(components[1]);\n\t\tint time = 0;\n\t\t\n\t\t//Creating the Queue of processes\n\t\tLinkedList<Process> q = new LinkedList<>();\n\t\twhile (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}\n\t\t\n\t\t//Running\n\t\twhile (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"String first = in.nextLine();",
"first",
"in.nextLine()",
"in.nextLine",
"in",
"String[] components = first.split(\" \");",
"components",
"first.split(\" \")",
"first.split",
"first",
"\" \"",
"int inputs = Integer.parseInt(components[0]);",
"inputs",
"Integer.parseInt(components[0])",
"Integer.parseInt",
"Integer",
"components[0]",
"components",
"0",
"int quantum = Integer.parseInt(components[1]);",
"quantum",
"Integer.parseInt(components[1])",
"Integer.parseInt",
"Integer",
"components[1]",
"components",
"1",
"int time = 0;",
"time",
"0",
"LinkedList<Process> q = new LinkedList<>();",
"q",
"new LinkedList<>()",
"while (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}",
"in.hasNextLine()",
"in.hasNextLine",
"in",
"{\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}",
"String i = in.nextLine();",
"i",
"in.nextLine()",
"in.nextLine",
"in",
"String[] c = i.split(\" \");",
"c",
"i.split(\" \")",
"i.split",
"i",
"\" \"",
"q.add(new Process(c[0], Integer.parseInt(c[1])))",
"q.add",
"q",
"new Process(c[0], Integer.parseInt(c[1]))",
"while (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}",
"Process curr = q.poll();",
"curr",
"q.poll()",
"q.poll",
"q",
"if (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}",
"curr.t <= quantum",
"curr.t",
"curr",
"curr.t",
"quantum",
"{\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t}",
"time += curr.t",
"time",
"curr.t",
"curr",
"curr.t",
"System.out.println(curr.n + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"curr.n + \" \" + time",
"curr.n + \" \" + time",
"curr.n",
"curr",
"curr.n",
"\" \"",
"time",
"{\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}",
"curr.t -= quantum",
"curr.t",
"curr",
"curr.t",
"quantum",
"time += quantum",
"time",
"quantum",
"q.add(curr)",
"q.add",
"q",
"curr",
"String[] args",
"args",
"private static class Process{\n\t\tpublic String n;\n\t\tpublic int t;\n\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}\n\t}",
"Process",
"public String n;",
"n",
"public int t;",
"t",
"public Process(String name, int time) {\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}",
"Process",
"{\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}",
"n = name",
"n",
"name",
"t = time",
"t",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\t\n\tprivate static class Process{\n\t\tpublic String n;\n\t\tpublic int t;\n\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString first = in.nextLine();\n\t\tString[] components = first.split(\" \");\n\t\tint inputs = Integer.parseInt(components[0]);\n\t\tint quantum = Integer.parseInt(components[1]);\n\t\tint time = 0;\n\t\t\n\t\t//Creating the Queue of processes\n\t\tLinkedList<Process> q = new LinkedList<>();\n\t\twhile (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}\n\t\t\n\t\t//Running\n\t\twhile (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\t\n\tprivate static class Process{\n\t\tpublic String n;\n\t\tpublic int t;\n\t\t\n\t\tpublic Process(String name, int time) {\n\t\t\tn = name;\n\t\t\tt = time;\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString first = in.nextLine();\n\t\tString[] components = first.split(\" \");\n\t\tint inputs = Integer.parseInt(components[0]);\n\t\tint quantum = Integer.parseInt(components[1]);\n\t\tint time = 0;\n\t\t\n\t\t//Creating the Queue of processes\n\t\tLinkedList<Process> q = new LinkedList<>();\n\t\twhile (in.hasNextLine()) {\n\t\t\tString i = in.nextLine();\n\t\t\tString[] c = i.split(\" \");\n\t\t\tq.add(new Process(c[0], Integer.parseInt(c[1])));\n\t\t}\n\t\t\n\t\t//Running\n\t\twhile (!q.isEmpty()) {\n\t\t\tProcess curr = q.poll();\n\t\t\tif (curr.t <= quantum) {\n\t\t\t\ttime += curr.t;\n\t\t\t\tSystem.out.println(curr.n + \" \" + time);\n\t\t\t} else {\n\t\t\t\tcurr.t -= quantum;\n\t\t\t\ttime += quantum;\n\t\t\t\tq.add(curr);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
public class Main {
private static class Process{
public String n;
public int t;
public Process(String name, int time) {
n = name;
t = time;
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String first = in.nextLine();
String[] components = first.split(" ");
int inputs = Integer.parseInt(components[0]);
int quantum = Integer.parseInt(components[1]);
int time = 0;
//Creating the Queue of processes
LinkedList<Process> q = new LinkedList<>();
while (in.hasNextLine()) {
String i = in.nextLine();
String[] c = i.split(" ");
q.add(new Process(c[0], Integer.parseInt(c[1])));
}
//Running
while (!q.isEmpty()) {
Process curr = q.poll();
if (curr.t <= quantum) {
time += curr.t;
System.out.println(curr.n + " " + time);
} else {
curr.t -= quantum;
time += quantum;
q.add(curr);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
20,
12,
13,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
17,
4,
13,
13,
4,
18,
13,
18,
13,
17,
13,
23,
13,
12,
13,
30,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
4,
18,
13,
2,
2,
2,
18,
13,
17,
17,
2,
13,
13,
17,
4,
18,
18,
13,
13,
2,
2,
18,
13,
17,
17,
2,
13,
13,
0,
13,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
2,
18,
13,
17,
17,
13,
0,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
191,
11
],
[
191,
12
],
[
12,
13
],
[
12,
14
],
[
191,
15
],
[
15,
16
],
[
15,
17
],
[
191,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
20,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
20,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
41,
46
],
[
46,
47
],
[
46,
48
],
[
41,
49
],
[
49,
50
],
[
50,
51
],
[
41,
52
],
[
53,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
59,
60
],
[
20,
61
],
[
61,
62
],
[
62,
63
],
[
20,
64
],
[
64,
65
],
[
64,
66
],
[
20,
67
],
[
67,
68
],
[
67,
69
],
[
67,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
73,
74
],
[
73,
75
],
[
67,
76
],
[
18,
77
],
[
77,
78
],
[
191,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
85,
90
],
[
90,
91
],
[
90,
92
],
[
85,
93
],
[
93,
94
],
[
94,
95
],
[
85,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
101,
102
],
[
101,
103
],
[
81,
104
],
[
104,
105
],
[
104,
106
],
[
81,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
107,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
115,
120
],
[
112,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
126,
127
],
[
126,
128
],
[
112,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
139,
138
],
[
144,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
144,
144
],
[
144,
145
],
[
144,
146
],
[
139,
147
],
[
133,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
154,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
154,
159
],
[
159,
160
],
[
159,
161
],
[
133,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
164,
166
],
[
129,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
171,
172
],
[
172,
173
],
[
171,
174
],
[
175,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
175,
180
],
[
112,
181
],
[
181,
182
],
[
181,
183
],
[
79,
184
],
[
184,
185
],
[
79,
186
],
[
186,
187
],
[
79,
188
],
[
188,
189
],
[
0,
190
],
[
190,
191
],
[
190,
192
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\n/**\n * ZAKIREN第5章\n *\n * @author K.Yamauchi\n *\n */\npublic class Main {\n\n\t/** 入力用 */\n\tprivate static Scanner scan = new Scanner(System.in);\n\n\t/** 出力用 */\n\tprivate static StringBuilder stringBuilder = new StringBuilder();\n\n\t/**\n\t * メイン。\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\t// 1行目の読み込み\n\t\tString[] firstLine = scan.nextLine().split(\" \");\n\t\tint size = Integer.parseInt(firstLine[0]);\n\n\t\t// 2行目以降(プロセスとクオンタム)の読み込み\n\t\tString[] processes = new String[size];\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\t\tscan = null;\n\n\t\t// 計算を実行\n\t\tcalculation(size, Integer.parseInt(firstLine[1]), processes);\n\n\t\t// 結果出力\n//\t\tSystem.out.println(stringBuilder.toString());\n\n\t}\n\n\t/**\n\t *\n\t * @param size\n\t * @param quantum\n\t * @param processes\n\t */\n\tprivate static void calculation(int size, int quantum, String[] processes) {\n\n\t\t// 計算用キュー\n\t\tQueue<String> queue = new ArrayDeque<>();\n\n\t\t// キューにプロセスを設定\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\n\t\t// 経過時間\n\t\tint elapsedTime = 0;\n\n\t\t// キューの中身がなくなるまで計算\n\t\twhile (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}\n\n\t}\n\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\t/** 入力用 */\n\tprivate static Scanner scan = new Scanner(System.in);\n\n\t/** 出力用 */\n\tprivate static StringBuilder stringBuilder = new StringBuilder();\n\n\t/**\n\t * メイン。\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\t// 1行目の読み込み\n\t\tString[] firstLine = scan.nextLine().split(\" \");\n\t\tint size = Integer.parseInt(firstLine[0]);\n\n\t\t// 2行目以降(プロセスとクオンタム)の読み込み\n\t\tString[] processes = new String[size];\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\t\tscan = null;\n\n\t\t// 計算を実行\n\t\tcalculation(size, Integer.parseInt(firstLine[1]), processes);\n\n\t\t// 結果出力\n//\t\tSystem.out.println(stringBuilder.toString());\n\n\t}\n\n\t/**\n\t *\n\t * @param size\n\t * @param quantum\n\t * @param processes\n\t */\n\tprivate static void calculation(int size, int quantum, String[] processes) {\n\n\t\t// 計算用キュー\n\t\tQueue<String> queue = new ArrayDeque<>();\n\n\t\t// キューにプロセスを設定\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\n\t\t// 経過時間\n\t\tint elapsedTime = 0;\n\n\t\t// キューの中身がなくなるまで計算\n\t\twhile (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}\n\n\t}\n\n}",
"Main",
"/** 入力用 */\n\tprivate static Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"/** 出力用 */\n\tprivate static StringBuilder stringBuilder = new StringBuilder();",
"stringBuilder",
"new StringBuilder()",
"/**\n\t * メイン。\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\t// 1行目の読み込み\n\t\tString[] firstLine = scan.nextLine().split(\" \");\n\t\tint size = Integer.parseInt(firstLine[0]);\n\n\t\t// 2行目以降(プロセスとクオンタム)の読み込み\n\t\tString[] processes = new String[size];\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\t\tscan = null;\n\n\t\t// 計算を実行\n\t\tcalculation(size, Integer.parseInt(firstLine[1]), processes);\n\n\t\t// 結果出力\n//\t\tSystem.out.println(stringBuilder.toString());\n\n\t}",
"main",
"{\n\n\t\t// 1行目の読み込み\n\t\tString[] firstLine = scan.nextLine().split(\" \");\n\t\tint size = Integer.parseInt(firstLine[0]);\n\n\t\t// 2行目以降(プロセスとクオンタム)の読み込み\n\t\tString[] processes = new String[size];\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\t\tscan = null;\n\n\t\t// 計算を実行\n\t\tcalculation(size, Integer.parseInt(firstLine[1]), processes);\n\n\t\t// 結果出力\n//\t\tSystem.out.println(stringBuilder.toString());\n\n\t}",
"String[] firstLine = scan.nextLine().split(\" \");",
"firstLine",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"int size = Integer.parseInt(firstLine[0]);",
"size",
"Integer.parseInt(firstLine[0])",
"Integer.parseInt",
"Integer",
"firstLine[0]",
"firstLine",
"0",
"String[] processes = new String[size];",
"processes",
"new String[size]",
"size",
"for (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < size",
"i",
"size",
"i++",
"i++",
"i",
"{\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}",
"{\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}",
"processes[i] = scan.nextLine()",
"processes[i]",
"processes",
"i",
"scan.nextLine()",
"scan.nextLine",
"scan",
"scan.close()",
"scan.close",
"scan",
"scan = null",
"scan",
"null",
"calculation(size, Integer.parseInt(firstLine[1]), processes)",
"calculation",
"size",
"Integer.parseInt(firstLine[1])",
"Integer.parseInt",
"Integer",
"firstLine[1]",
"firstLine",
"1",
"processes",
"String[] args",
"args",
"/**\n\t *\n\t * @param size\n\t * @param quantum\n\t * @param processes\n\t */\n\tprivate static void calculation(int size, int quantum, String[] processes) {\n\n\t\t// 計算用キュー\n\t\tQueue<String> queue = new ArrayDeque<>();\n\n\t\t// キューにプロセスを設定\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\n\t\t// 経過時間\n\t\tint elapsedTime = 0;\n\n\t\t// キューの中身がなくなるまで計算\n\t\twhile (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}\n\n\t}",
"calculation",
"{\n\n\t\t// 計算用キュー\n\t\tQueue<String> queue = new ArrayDeque<>();\n\n\t\t// キューにプロセスを設定\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\n\t\t// 経過時間\n\t\tint elapsedTime = 0;\n\n\t\t// キューの中身がなくなるまで計算\n\t\twhile (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}\n\n\t}",
"Queue<String> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"for (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < size",
"i",
"size",
"i++",
"i++",
"i",
"{\n\t\t\tqueue.add(processes[i]);\n\t\t}",
"{\n\t\t\tqueue.add(processes[i]);\n\t\t}",
"queue.add(processes[i])",
"queue.add",
"queue",
"processes[i]",
"processes",
"i",
"int elapsedTime = 0;",
"elapsedTime",
"0",
"while (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}",
"String[] process = queue.poll().split(\" \");",
"process",
"queue.poll().split(\" \")",
"queue.poll().split",
"queue.poll()",
"queue.poll",
"queue",
"\" \"",
"int remainedTime = Integer.parseInt(process[1]);",
"remainedTime",
"Integer.parseInt(process[1])",
"Integer.parseInt",
"Integer",
"process[1]",
"process",
"1",
"if (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}",
"remainedTime <= quantum",
"remainedTime",
"quantum",
"{\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t}",
"stringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\")",
"stringBuilder.append",
"stringBuilder",
"process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\"",
"(elapsedTime + remainedTime)",
"process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\"",
"process[0]",
"process",
"0",
"\" \"",
"(elapsedTime + remainedTime)",
"elapsedTime",
"remainedTime",
"\"\\n\"",
"System.out.println(process[0] + \" \" + (elapsedTime + remainedTime))",
"System.out.println",
"System.out",
"System",
"System.out",
"process[0] + \" \" + (elapsedTime + remainedTime)",
"process[0] + \" \" + (elapsedTime + remainedTime)",
"process[0]",
"process",
"0",
"\" \"",
"(elapsedTime + remainedTime)",
"elapsedTime",
"remainedTime",
"elapsedTime -= (quantum - remainedTime)",
"elapsedTime",
"(quantum - remainedTime)",
"quantum",
"remainedTime",
"{\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}",
"remainedTime -= quantum",
"remainedTime",
"quantum",
"queue.add(process[0] + \" \" + remainedTime)",
"queue.add",
"queue",
"process[0] + \" \" + remainedTime",
"process[0] + \" \" + remainedTime",
"process[0]",
"process",
"0",
"\" \"",
"remainedTime",
"elapsedTime += quantum",
"elapsedTime",
"quantum",
"int size",
"size",
"int quantum",
"quantum",
"String[] processes",
"processes",
"public class Main {\n\n\t/** 入力用 */\n\tprivate static Scanner scan = new Scanner(System.in);\n\n\t/** 出力用 */\n\tprivate static StringBuilder stringBuilder = new StringBuilder();\n\n\t/**\n\t * メイン。\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\t// 1行目の読み込み\n\t\tString[] firstLine = scan.nextLine().split(\" \");\n\t\tint size = Integer.parseInt(firstLine[0]);\n\n\t\t// 2行目以降(プロセスとクオンタム)の読み込み\n\t\tString[] processes = new String[size];\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\t\tscan = null;\n\n\t\t// 計算を実行\n\t\tcalculation(size, Integer.parseInt(firstLine[1]), processes);\n\n\t\t// 結果出力\n//\t\tSystem.out.println(stringBuilder.toString());\n\n\t}\n\n\t/**\n\t *\n\t * @param size\n\t * @param quantum\n\t * @param processes\n\t */\n\tprivate static void calculation(int size, int quantum, String[] processes) {\n\n\t\t// 計算用キュー\n\t\tQueue<String> queue = new ArrayDeque<>();\n\n\t\t// キューにプロセスを設定\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\n\t\t// 経過時間\n\t\tint elapsedTime = 0;\n\n\t\t// キューの中身がなくなるまで計算\n\t\twhile (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}\n\n\t}\n\n}",
"public class Main {\n\n\t/** 入力用 */\n\tprivate static Scanner scan = new Scanner(System.in);\n\n\t/** 出力用 */\n\tprivate static StringBuilder stringBuilder = new StringBuilder();\n\n\t/**\n\t * メイン。\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\n\t\t// 1行目の読み込み\n\t\tString[] firstLine = scan.nextLine().split(\" \");\n\t\tint size = Integer.parseInt(firstLine[0]);\n\n\t\t// 2行目以降(プロセスとクオンタム)の読み込み\n\t\tString[] processes = new String[size];\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tprocesses[i] = scan.nextLine();\n\t\t}\n\n\t\t// 読み込み終了\n\t\tscan.close();\n\t\tscan = null;\n\n\t\t// 計算を実行\n\t\tcalculation(size, Integer.parseInt(firstLine[1]), processes);\n\n\t\t// 結果出力\n//\t\tSystem.out.println(stringBuilder.toString());\n\n\t}\n\n\t/**\n\t *\n\t * @param size\n\t * @param quantum\n\t * @param processes\n\t */\n\tprivate static void calculation(int size, int quantum, String[] processes) {\n\n\t\t// 計算用キュー\n\t\tQueue<String> queue = new ArrayDeque<>();\n\n\t\t// キューにプロセスを設定\n\t\tfor (int i = 0; i < size; i++) {\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\n\t\t// 経過時間\n\t\tint elapsedTime = 0;\n\n\t\t// キューの中身がなくなるまで計算\n\t\twhile (!queue.isEmpty()) {\n\t\t\t// キューからプロセスを一つ取得\n\t\t\tString[] process = queue.poll().split(\" \");\n\t\t\t// 取得したプロセスの残り時間\n\t\t\tint remainedTime = Integer.parseInt(process[1]);\n\n\t\t\tif (remainedTime <= quantum) {\n\t\t\t\t// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了\n\t\t\t\tstringBuilder.append(process[0] + \" \" + (elapsedTime + remainedTime) + \"\\n\");\n\t\t\t\tSystem.out.println(process[0] + \" \" + (elapsedTime + remainedTime));\n\t\t\t\telapsedTime -= (quantum - remainedTime);\n\t\t\t} else {\n\t\t\t\t// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録\n\t\t\t\tremainedTime -= quantum;\n\t\t\t\tqueue.add(process[0] + \" \" + remainedTime);\n\t\t\t}\n\t\t\telapsedTime += quantum;\n\t\t}\n\n\t}\n\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
/**
* ZAKIREN第5章
*
* @author K.Yamauchi
*
*/
public class Main {
/** 入力用 */
private static Scanner scan = new Scanner(System.in);
/** 出力用 */
private static StringBuilder stringBuilder = new StringBuilder();
/**
* メイン。
* @param args
*/
public static void main(String[] args) {
// 1行目の読み込み
String[] firstLine = scan.nextLine().split(" ");
int size = Integer.parseInt(firstLine[0]);
// 2行目以降(プロセスとクオンタム)の読み込み
String[] processes = new String[size];
for (int i = 0; i < size; i++) {
processes[i] = scan.nextLine();
}
// 読み込み終了
scan.close();
scan = null;
// 計算を実行
calculation(size, Integer.parseInt(firstLine[1]), processes);
// 結果出力
// System.out.println(stringBuilder.toString());
}
/**
*
* @param size
* @param quantum
* @param processes
*/
private static void calculation(int size, int quantum, String[] processes) {
// 計算用キュー
Queue<String> queue = new ArrayDeque<>();
// キューにプロセスを設定
for (int i = 0; i < size; i++) {
queue.add(processes[i]);
}
// 経過時間
int elapsedTime = 0;
// キューの中身がなくなるまで計算
while (!queue.isEmpty()) {
// キューからプロセスを一つ取得
String[] process = queue.poll().split(" ");
// 取得したプロセスの残り時間
int remainedTime = Integer.parseInt(process[1]);
if (remainedTime <= quantum) {
// プロセスの残り時間がクオンタム以下であれば、そのプロセスは終了
stringBuilder.append(process[0] + " " + (elapsedTime + remainedTime) + "\n");
System.out.println(process[0] + " " + (elapsedTime + remainedTime));
elapsedTime -= (quantum - remainedTime);
} else {
// プロセスの残り時間がクオンタムより大きければ、クオンタム分残り時間を減らし、再度キューに登録
remainedTime -= quantum;
queue.add(process[0] + " " + remainedTime);
}
elapsedTime += quantum;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
4,
13,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
17,
41,
13,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
4,
18,
13,
17,
13,
17,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
165,
8
],
[
165,
9
],
[
9,
10
],
[
9,
11
],
[
165,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
26,
31
],
[
14,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
37,
39
],
[
14,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
14,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
53,
54
],
[
53,
55
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
48,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
63,
68
],
[
60,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
72,
73
],
[
72,
74
],
[
60,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
14,
84
],
[
84,
85
],
[
84,
86
],
[
84,
87
],
[
84,
88
],
[
12,
89
],
[
89,
90
],
[
165,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
99,
100
],
[
93,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
107,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
130,
131
],
[
131,
132
],
[
125,
133
],
[
123,
134
],
[
121,
135
],
[
113,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
140,
141
],
[
140,
142
],
[
136,
143
],
[
143,
144
],
[
144,
145
],
[
143,
146
],
[
146,
147
],
[
147,
148
],
[
136,
149
],
[
149,
150
],
[
149,
151
],
[
93,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
152,
157
],
[
91,
158
],
[
158,
159
],
[
91,
160
],
[
160,
161
],
[
91,
162
],
[
162,
163
],
[
0,
164
],
[
164,
165
],
[
164,
166
]
] | [
"import java.io.*;\nimport java.util.*;\n\npublic class Main\n{\n\tstatic StringBuilder sb = new StringBuilder();\n\tpublic static void main(String[] args)throws IOException\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t//Scanner sc = new Scanner(System.in);\n\t\tDeque<String> nameQue = new ArrayDeque<>();\n\t\tDeque<Integer> workQue = new ArrayDeque<>();\n\t\tString[] rem = br.readLine().split(\" \"); \n\t\tint n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());\n\t\tint time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());\n\t\t//int[][] data = new int[n][2];\n\t\t//String[] stemp ;\n\t\tfor(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}\n\t\troundSche(nameQue,workQue,time);\n\t}\n\tpublic static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)\n\t{\n\t\tint pos , prog = 0;\n\t\tint temp ;\n\t\twhile(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t\t\n\t}\n\t\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main\n{\n\tstatic StringBuilder sb = new StringBuilder();\n\tpublic static void main(String[] args)throws IOException\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t//Scanner sc = new Scanner(System.in);\n\t\tDeque<String> nameQue = new ArrayDeque<>();\n\t\tDeque<Integer> workQue = new ArrayDeque<>();\n\t\tString[] rem = br.readLine().split(\" \"); \n\t\tint n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());\n\t\tint time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());\n\t\t//int[][] data = new int[n][2];\n\t\t//String[] stemp ;\n\t\tfor(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}\n\t\troundSche(nameQue,workQue,time);\n\t}\n\tpublic static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)\n\t{\n\t\tint pos , prog = 0;\n\t\tint temp ;\n\t\twhile(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t\t\n\t}\n\t\n}",
"Main",
"static StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"public static void main(String[] args)throws IOException\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t//Scanner sc = new Scanner(System.in);\n\t\tDeque<String> nameQue = new ArrayDeque<>();\n\t\tDeque<Integer> workQue = new ArrayDeque<>();\n\t\tString[] rem = br.readLine().split(\" \"); \n\t\tint n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());\n\t\tint time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());\n\t\t//int[][] data = new int[n][2];\n\t\t//String[] stemp ;\n\t\tfor(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}\n\t\troundSche(nameQue,workQue,time);\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t//Scanner sc = new Scanner(System.in);\n\t\tDeque<String> nameQue = new ArrayDeque<>();\n\t\tDeque<Integer> workQue = new ArrayDeque<>();\n\t\tString[] rem = br.readLine().split(\" \"); \n\t\tint n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());\n\t\tint time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());\n\t\t//int[][] data = new int[n][2];\n\t\t//String[] stemp ;\n\t\tfor(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}\n\t\troundSche(nameQue,workQue,time);\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"Deque<String> nameQue = new ArrayDeque<>();",
"nameQue",
"new ArrayDeque<>()",
"Deque<Integer> workQue = new ArrayDeque<>();",
"workQue",
"new ArrayDeque<>()",
"String[] rem = br.readLine().split(\" \");",
"rem",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(rem[0]);",
"n",
"Integer.parseInt(rem[0])",
"Integer.parseInt",
"Integer",
"rem[0]",
"rem",
"0",
"int time = Integer.parseInt(rem[1]);",
"time",
"Integer.parseInt(rem[1])",
"Integer.parseInt",
"Integer",
"rem[1]",
"rem",
"1",
"for(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}",
"int i= 0 ;",
"int i= 0 ;",
"i",
"0",
"i< n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}",
"{\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}",
"rem = br.readLine().split(\" \")",
"rem",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"nameQue.offer(rem[0])",
"nameQue.offer",
"nameQue",
"rem[0]",
"rem",
"0",
"workQue.offer(Integer.parseInt(rem[1]))",
"workQue.offer",
"workQue",
"Integer.parseInt(rem[1])",
"Integer.parseInt",
"Integer",
"rem[1]",
"rem",
"1",
"roundSche(nameQue,workQue,time)",
"roundSche",
"nameQue",
"workQue",
"time",
"String[] args",
"args",
"public static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)\n\t{\n\t\tint pos , prog = 0;\n\t\tint temp ;\n\t\twhile(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t\t\n\t}",
"roundSche",
"{\n\t\tint pos , prog = 0;\n\t\tint temp ;\n\t\twhile(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t\t\n\t}",
"int pos",
"pos",
"prog = 0;",
"prog",
"0",
"int temp ;",
"temp",
"while(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}",
"workQ.size() != 0",
"workQ.size()",
"workQ.size",
"workQ",
"0",
"{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}",
"temp = workQ.poll()",
"temp",
"workQ.poll()",
"workQ.poll",
"workQ",
"if(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}",
"temp <= time",
"temp",
"time",
"{\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}",
"prog += temp",
"prog",
"temp",
"sb.append(nameQ.poll()).append(' ').append(prog).append('\\n')",
"sb.append(nameQ.poll()).append(' ').append(prog).append",
"sb.append(nameQ.poll()).append(' ').append(prog)",
"sb.append(nameQ.poll()).append(' ').append",
"sb.append(nameQ.poll()).append(' ')",
"sb.append(nameQ.poll()).append",
"sb.append(nameQ.poll())",
"sb.append",
"sb",
"nameQ.poll()",
"nameQ.poll",
"nameQ",
"' '",
"prog",
"'\\n'",
"{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}",
"workQ.offer(temp - time)",
"workQ.offer",
"workQ",
"temp - time",
"temp",
"time",
"nameQ.offer(nameQ.poll())",
"nameQ.offer",
"nameQ",
"nameQ.poll()",
"nameQ.poll",
"nameQ",
"prog += time",
"prog",
"time",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"Deque<String> nameQ",
"nameQ",
"Deque<Integer> workQ",
"workQ",
"int time",
"time",
"public class Main\n{\n\tstatic StringBuilder sb = new StringBuilder();\n\tpublic static void main(String[] args)throws IOException\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t//Scanner sc = new Scanner(System.in);\n\t\tDeque<String> nameQue = new ArrayDeque<>();\n\t\tDeque<Integer> workQue = new ArrayDeque<>();\n\t\tString[] rem = br.readLine().split(\" \"); \n\t\tint n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());\n\t\tint time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());\n\t\t//int[][] data = new int[n][2];\n\t\t//String[] stemp ;\n\t\tfor(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}\n\t\troundSche(nameQue,workQue,time);\n\t}\n\tpublic static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)\n\t{\n\t\tint pos , prog = 0;\n\t\tint temp ;\n\t\twhile(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t\t\n\t}\n\t\n}",
"public class Main\n{\n\tstatic StringBuilder sb = new StringBuilder();\n\tpublic static void main(String[] args)throws IOException\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t//Scanner sc = new Scanner(System.in);\n\t\tDeque<String> nameQue = new ArrayDeque<>();\n\t\tDeque<Integer> workQue = new ArrayDeque<>();\n\t\tString[] rem = br.readLine().split(\" \"); \n\t\tint n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());\n\t\tint time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());\n\t\t//int[][] data = new int[n][2];\n\t\t//String[] stemp ;\n\t\tfor(int i= 0 ; i< n ; i++){\n\t\t\trem = br.readLine().split(\" \"); \n\t\t\tnameQue.offer(rem[0]);\n\t\t\tworkQue.offer(Integer.parseInt(rem[1]));\n\t\t}\n\t\troundSche(nameQue,workQue,time);\n\t}\n\tpublic static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)\n\t{\n\t\tint pos , prog = 0;\n\t\tint temp ;\n\t\twhile(workQ.size() != 0)\n\t\t{\n\t\t\ttemp = workQ.poll();\n\t\t\tif(temp <= time){\n\t\t\t\tprog += temp;\n\t\t\t\tsb.append(nameQ.poll()).append(' ').append(prog).append('\\n');\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\tworkQ.offer(temp - time);\n\t\t\t\tnameQ.offer(nameQ.poll());\n\t\t\t\tprog += time;\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(sb);\n\t\t\n\t}\n\t\n}",
"Main"
] | import java.io.*;
import java.util.*;
public class Main
{
static StringBuilder sb = new StringBuilder();
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//Scanner sc = new Scanner(System.in);
Deque<String> nameQue = new ArrayDeque<>();
Deque<Integer> workQue = new ArrayDeque<>();
String[] rem = br.readLine().split(" ");
int n = Integer.parseInt(rem[0]);//Integer.parseInt(sc.next());
int time = Integer.parseInt(rem[1]); //Integer.parseInt(sc.next());
//int[][] data = new int[n][2];
//String[] stemp ;
for(int i= 0 ; i< n ; i++){
rem = br.readLine().split(" ");
nameQue.offer(rem[0]);
workQue.offer(Integer.parseInt(rem[1]));
}
roundSche(nameQue,workQue,time);
}
public static void roundSche(Deque<String> nameQ , Deque<Integer> workQ , int time)
{
int pos , prog = 0;
int temp ;
while(workQ.size() != 0)
{
temp = workQ.poll();
if(temp <= time){
prog += temp;
sb.append(nameQ.poll()).append(' ').append(prog).append('\n');
}
else
{
workQ.offer(temp - time);
nameQ.offer(nameQ.poll());
prog += time;
}
}
System.out.print(sb);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
12,
13,
30,
0,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
40,
4,
18,
13,
30,
14,
2,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
4,
18,
13,
17,
0,
13,
2,
13,
4,
18,
13,
4,
18,
18,
13,
13,
13,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
2,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
120,
8
],
[
120,
9
],
[
9,
10
],
[
120,
11
],
[
11,
12
],
[
11,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
13,
17
],
[
17,
18
],
[
17,
19
],
[
13,
20
],
[
20,
21
],
[
20,
22
],
[
13,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
13,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
13,
33
],
[
33,
34
],
[
33,
35
],
[
13,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
36,
41
],
[
41,
42
],
[
41,
43
],
[
36,
44
],
[
44,
45
],
[
45,
46
],
[
36,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
53,
54
],
[
48,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
59,
60
],
[
13,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
61,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
68,
72
],
[
67,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
74,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
79,
83
],
[
73,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
73,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
91,
96
],
[
67,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
101,
102
],
[
102,
103
],
[
97,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
107,
111
],
[
97,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
11,
117
],
[
117,
118
],
[
0,
119
],
[
119,
120
],
[
119,
121
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\n\npublic class Main {\n\tprivate static Scanner sc;\n\tpublic static void main(String[] args){\n\t\tsc=new Scanner(System.in);\n\t\tLinkedList<String> name=new LinkedList<String>();\n\t\tLinkedList<Integer> time=new LinkedList<Integer>();\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\t\twhile(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}\n\t}\n\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tprivate static Scanner sc;\n\tpublic static void main(String[] args){\n\t\tsc=new Scanner(System.in);\n\t\tLinkedList<String> name=new LinkedList<String>();\n\t\tLinkedList<Integer> time=new LinkedList<Integer>();\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\t\twhile(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}\n\t}\n\n}",
"Main",
"private static Scanner sc;",
"sc",
"public static void main(String[] args){\n\t\tsc=new Scanner(System.in);\n\t\tLinkedList<String> name=new LinkedList<String>();\n\t\tLinkedList<Integer> time=new LinkedList<Integer>();\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\t\twhile(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tsc=new Scanner(System.in);\n\t\tLinkedList<String> name=new LinkedList<String>();\n\t\tLinkedList<Integer> time=new LinkedList<Integer>();\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\t\twhile(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}\n\t}",
"sc=new Scanner(System.in)",
"sc",
"new Scanner(System.in)",
"LinkedList<String> name=new LinkedList<String>();",
"name",
"new LinkedList<String>()",
"LinkedList<Integer> time=new LinkedList<Integer>();",
"time",
"new LinkedList<Integer>()",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q=sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int t=0;",
"t",
"0",
"for(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}",
"name.add(sc.next())",
"name.add",
"name",
"sc.next()",
"sc.next",
"sc",
"time.add(sc.nextInt())",
"time.add",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}",
"!name.isEmpty()",
"name.isEmpty()",
"name.isEmpty",
"name",
"{\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}",
"if(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}",
"time.peek()<=q",
"time.peek()",
"time.peek",
"time",
"q",
"{\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}",
"System.out.print(name.poll()+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"name.poll()+\" \"",
"name.poll()",
"name.poll",
"name",
"\" \"",
"t=t+time.poll()",
"t",
"t+time.poll()",
"t",
"time.poll()",
"time.poll",
"time",
"System.out.println(t)",
"System.out.println",
"System.out",
"System",
"System.out",
"t",
"{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}",
"name.add(name.poll())",
"name.add",
"name",
"name.poll()",
"name.poll",
"name",
"time.add(time.poll()-q)",
"time.add",
"time",
"time.poll()-q",
"time.poll()",
"time.poll",
"time",
"q",
"t=t+q",
"t",
"t+q",
"t",
"q",
"String[] args",
"args",
"public class Main {\n\tprivate static Scanner sc;\n\tpublic static void main(String[] args){\n\t\tsc=new Scanner(System.in);\n\t\tLinkedList<String> name=new LinkedList<String>();\n\t\tLinkedList<Integer> time=new LinkedList<Integer>();\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\t\twhile(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}\n\t}\n\n}",
"public class Main {\n\tprivate static Scanner sc;\n\tpublic static void main(String[] args){\n\t\tsc=new Scanner(System.in);\n\t\tLinkedList<String> name=new LinkedList<String>();\n\t\tLinkedList<Integer> time=new LinkedList<Integer>();\n\t\tint n=sc.nextInt();\n\t\tint q=sc.nextInt();\n\t\tint t=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tname.add(sc.next());\n\t\t\ttime.add(sc.nextInt());\n\t\t}\n\t\twhile(!name.isEmpty()){\n\t\t\tif(time.peek()<=q){\n\t\t\t\tSystem.out.print(name.poll()+\" \");\n\t\t\t\tt=t+time.poll();\n\t\t\t\tSystem.out.println(t);\n\t\t\t}else{\n\t\t\t\tname.add(name.poll());\n\t\t\t\ttime.add(time.poll()-q);\n\t\t\t\tt=t+q;\n\t\t\t}\n\t\t}\n\t}\n\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
public class Main {
private static Scanner sc;
public static void main(String[] args){
sc=new Scanner(System.in);
LinkedList<String> name=new LinkedList<String>();
LinkedList<Integer> time=new LinkedList<Integer>();
int n=sc.nextInt();
int q=sc.nextInt();
int t=0;
for(int i=0;i<n;i++){
name.add(sc.next());
time.add(sc.nextInt());
}
while(!name.isEmpty()){
if(time.peek()<=q){
System.out.print(name.poll()+" ");
t=t+time.poll();
System.out.println(t);
}else{
name.add(name.poll());
time.add(time.poll()-q);
t=t+q;
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
20,
23,
13,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
14,
4,
13,
30,
37,
20,
41,
13,
18,
13,
13,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
29,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
0,
18,
13,
13,
13,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
23,
13,
12,
13,
30,
29,
2,
2,
13,
17,
2,
13,
13,
12,
13,
30,
29,
2,
13,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
242,
5
],
[
242,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
22,
25
],
[
25,
26
],
[
26,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
31,
33
],
[
8,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
34,
39
],
[
39,
40
],
[
39,
41
],
[
34,
42
],
[
42,
43
],
[
43,
44
],
[
34,
45
],
[
46,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
46,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
57,
58
],
[
58,
59
],
[
46,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
74,
74
],
[
74,
75
],
[
74,
76
],
[
74,
77
],
[
60,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
8,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
86,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
103,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
115,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
115,
120
],
[
97,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
6,
129
],
[
129,
130
],
[
242,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
136,
137
],
[
136,
138
],
[
131,
140
],
[
140,
141
],
[
140,
142
],
[
131,
143
],
[
143,
144
],
[
143,
145
],
[
131,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
152,
153
],
[
153,
154
],
[
148,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
157,
159
],
[
148,
160
],
[
160,
161
],
[
160,
162
],
[
148,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
148,
171
],
[
171,
172
],
[
131,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
179,
180
],
[
180,
181
],
[
175,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
175,
187
],
[
187,
188
],
[
187,
189
],
[
175,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
173,
198
],
[
198,
199
],
[
131,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
204,
208
],
[
208,
209
],
[
208,
210
],
[
131,
211
],
[
211,
212
],
[
211,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
242,
218
],
[
218,
219
],
[
218,
220
],
[
220,
221
],
[
218,
222
],
[
222,
223
],
[
218,
224
],
[
224,
225
],
[
224,
226
],
[
226,
227
],
[
227,
228
],
[
228,
229
],
[
228,
230
],
[
227,
231
],
[
226,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
232,
236
],
[
224,
237
],
[
237,
238
],
[
224,
239
],
[
239,
240
],
[
0,
241
],
[
241,
242
],
[
241,
243
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int size = Integer.parseInt(scanner.next());\n int quantum = Integer.parseInt(scanner.next());\n int sum = 0;\n Queue queue = new Queue();\n for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }\n\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }\n }\n\n static class Queue {\n static final int SIZE = 100000;\n Process[] array = new Process[SIZE];\n int head = 0;\n int tail = 0;\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }\n\n void enqueue(Process process) {\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }\n\n boolean isFull() {\n return head + 1 == (tail % SIZE);\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n }\n\n static class Process {\n String name;\n int quantum;\n\n Process(String name, int quantum) {\n this.name = name;\n this.quantum = quantum;\n }\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int size = Integer.parseInt(scanner.next());\n int quantum = Integer.parseInt(scanner.next());\n int sum = 0;\n Queue queue = new Queue();\n for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }\n\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }\n }\n\n static class Queue {\n static final int SIZE = 100000;\n Process[] array = new Process[SIZE];\n int head = 0;\n int tail = 0;\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }\n\n void enqueue(Process process) {\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }\n\n boolean isFull() {\n return head + 1 == (tail % SIZE);\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n }\n\n static class Process {\n String name;\n int quantum;\n\n Process(String name, int quantum) {\n this.name = name;\n this.quantum = quantum;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int size = Integer.parseInt(scanner.next());\n int quantum = Integer.parseInt(scanner.next());\n int sum = 0;\n Queue queue = new Queue();\n for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }\n\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n int size = Integer.parseInt(scanner.next());\n int quantum = Integer.parseInt(scanner.next());\n int sum = 0;\n Queue queue = new Queue();\n for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }\n\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int size = Integer.parseInt(scanner.next());",
"size",
"Integer.parseInt(scanner.next())",
"Integer.parseInt",
"Integer",
"scanner.next()",
"scanner.next",
"scanner",
"int quantum = Integer.parseInt(scanner.next());",
"quantum",
"Integer.parseInt(scanner.next())",
"Integer.parseInt",
"Integer",
"scanner.next()",
"scanner.next",
"scanner",
"int sum = 0;",
"sum",
"0",
"Queue queue = new Queue();",
"queue",
"new Queue()",
"for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < size",
"i",
"size",
"i++",
"i++",
"i",
"{\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }",
"{\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }",
"String name = scanner.next();",
"name",
"scanner.next()",
"scanner.next",
"scanner",
"int time = Integer.parseInt(scanner.next());",
"time",
"Integer.parseInt(scanner.next())",
"Integer.parseInt",
"Integer",
"scanner.next()",
"scanner.next",
"scanner",
"if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }",
"time <= quantum",
"time",
"quantum",
"{\n sum += time;\n System.out.println(name + \" \" + sum);\n }",
"sum += time",
"sum",
"time",
"System.out.println(name + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + sum",
"name + \" \" + sum",
"name",
"\" \"",
"sum",
"{\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }",
"sum += quantum",
"sum",
"quantum",
"queue.enqueue(new Process(name, time - quantum))",
"queue.enqueue",
"queue",
"new Process(name, time - quantum)",
"while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }",
"Process process = queue.dequeue();",
"process",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }",
"process.quantum <= quantum",
"process.quantum",
"process",
"process.quantum",
"quantum",
"{\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n }",
"sum += process.quantum",
"sum",
"process.quantum",
"process",
"process.quantum",
"System.out.println(process.name + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + sum",
"process.name + \" \" + sum",
"process.name",
"process",
"process.name",
"\" \"",
"sum",
"{\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }",
"sum += quantum",
"sum",
"quantum",
"queue.enqueue(new Process(process.name, process.quantum - quantum))",
"queue.enqueue",
"queue",
"new Process(process.name, process.quantum - quantum)",
"String[] args",
"args",
"static class Queue {\n static final int SIZE = 100000;\n Process[] array = new Process[SIZE];\n int head = 0;\n int tail = 0;\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }\n\n void enqueue(Process process) {\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }\n\n boolean isFull() {\n return head + 1 == (tail % SIZE);\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n }",
"Queue",
"static final int SIZE = 100000;",
"SIZE",
"100000",
"Process[] array = new Process[SIZE];",
"array",
"new Process[SIZE]",
"SIZE",
"int head = 0;",
"head",
"0",
"int tail = 0;",
"tail",
"0",
"Process dequeue() {\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }",
"dequeue",
"{\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }",
"if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }",
"isEmpty()",
"isEmpty",
"{\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }",
"throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");",
"new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\")",
"Process value = array[tail];",
"value",
"array[tail]",
"array",
"tail",
"tail += 1",
"tail",
"1",
"if (tail == SIZE) {\n tail -= SIZE;\n }",
"tail == SIZE",
"tail",
"SIZE",
"{\n tail -= SIZE;\n }",
"tail -= SIZE",
"tail",
"SIZE",
"return value;",
"value",
"void enqueue(Process process) {\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }",
"enqueue",
"{\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }",
"if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }",
"isFull()",
"isFull",
"{\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }",
"throw new IllegalStateException(\"You enqueued to full queue.\");",
"new IllegalStateException(\"You enqueued to full queue.\")",
"array[head] = process",
"array[head]",
"array",
"head",
"process",
"head += 1",
"head",
"1",
"if (head == SIZE) {\n head -= SIZE;\n }",
"head == SIZE",
"head",
"SIZE",
"{\n head -= SIZE;\n }",
"head -= SIZE",
"head",
"SIZE",
"Process process",
"process",
"boolean isFull() {\n return head + 1 == (tail % SIZE);\n }",
"isFull",
"{\n return head + 1 == (tail % SIZE);\n }",
"return head + 1 == (tail % SIZE);",
"head + 1 == (tail % SIZE)",
"head + 1",
"head",
"1",
"(tail % SIZE)",
"tail",
"SIZE",
"boolean isEmpty() {\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"static class Process {\n String name;\n int quantum;\n\n Process(String name, int quantum) {\n this.name = name;\n this.quantum = quantum;\n }\n }",
"Process",
"String name;",
"name",
"int quantum;",
"quantum",
"Process(String name, int quantum) {\n this.name = name;\n this.quantum = quantum;\n }",
"Process",
"{\n this.name = name;\n this.quantum = quantum;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.quantum = quantum",
"this.quantum",
"this",
"this.quantum",
"quantum",
"String name",
"name",
"int quantum",
"quantum",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int size = Integer.parseInt(scanner.next());\n int quantum = Integer.parseInt(scanner.next());\n int sum = 0;\n Queue queue = new Queue();\n for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }\n\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }\n }\n\n static class Queue {\n static final int SIZE = 100000;\n Process[] array = new Process[SIZE];\n int head = 0;\n int tail = 0;\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }\n\n void enqueue(Process process) {\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }\n\n boolean isFull() {\n return head + 1 == (tail % SIZE);\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n }\n\n static class Process {\n String name;\n int quantum;\n\n Process(String name, int quantum) {\n this.name = name;\n this.quantum = quantum;\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int size = Integer.parseInt(scanner.next());\n int quantum = Integer.parseInt(scanner.next());\n int sum = 0;\n Queue queue = new Queue();\n for (int i = 0; i < size; i++) {\n String name = scanner.next();\n int time = Integer.parseInt(scanner.next());\n if (time <= quantum) {\n sum += time;\n System.out.println(name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(name, time - quantum));\n }\n }\n\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n if (process.quantum <= quantum) {\n sum += process.quantum;\n System.out.println(process.name + \" \" + sum);\n } else {\n sum += quantum;\n queue.enqueue(new Process(process.name, process.quantum - quantum));\n }\n }\n }\n\n static class Queue {\n static final int SIZE = 100000;\n Process[] array = new Process[SIZE];\n int head = 0;\n int tail = 0;\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IllegalStateException(\"You dequeued from empty \" +\n \"queue.\");\n }\n Process value = array[tail];\n tail += 1;\n if (tail == SIZE) {\n tail -= SIZE;\n }\n return value;\n }\n\n void enqueue(Process process) {\n if (isFull()) {\n throw new IllegalStateException(\"You enqueued to full queue.\");\n }\n array[head] = process;\n head += 1;\n if (head == SIZE) {\n head -= SIZE;\n }\n }\n\n boolean isFull() {\n return head + 1 == (tail % SIZE);\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n }\n\n static class Process {\n String name;\n int quantum;\n\n Process(String name, int quantum) {\n this.name = name;\n this.quantum = quantum;\n }\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int size = Integer.parseInt(scanner.next());
int quantum = Integer.parseInt(scanner.next());
int sum = 0;
Queue queue = new Queue();
for (int i = 0; i < size; i++) {
String name = scanner.next();
int time = Integer.parseInt(scanner.next());
if (time <= quantum) {
sum += time;
System.out.println(name + " " + sum);
} else {
sum += quantum;
queue.enqueue(new Process(name, time - quantum));
}
}
while (!queue.isEmpty()) {
Process process = queue.dequeue();
if (process.quantum <= quantum) {
sum += process.quantum;
System.out.println(process.name + " " + sum);
} else {
sum += quantum;
queue.enqueue(new Process(process.name, process.quantum - quantum));
}
}
}
static class Queue {
static final int SIZE = 100000;
Process[] array = new Process[SIZE];
int head = 0;
int tail = 0;
Process dequeue() {
if (isEmpty()) {
throw new IllegalStateException("You dequeued from empty " +
"queue.");
}
Process value = array[tail];
tail += 1;
if (tail == SIZE) {
tail -= SIZE;
}
return value;
}
void enqueue(Process process) {
if (isFull()) {
throw new IllegalStateException("You enqueued to full queue.");
}
array[head] = process;
head += 1;
if (head == SIZE) {
head -= SIZE;
}
}
boolean isFull() {
return head + 1 == (tail % SIZE);
}
boolean isEmpty() {
return head == tail;
}
}
static class Process {
String name;
int quantum;
Process(String name, int quantum) {
this.name = name;
this.quantum = quantum;
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
2,
13,
13,
14,
2,
13,
17,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
17,
17,
13,
30,
0,
13,
13,
0,
18,
13,
17,
4,
18,
13,
2,
13,
40,
17,
4,
18,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
142,
11
],
[
142,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
21,
22
],
[
18,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
23,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
23,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
39,
41
],
[
23,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
50,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
56,
61
],
[
42,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
66,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
62,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
12,
81
],
[
81,
82
],
[
12,
83
],
[
83,
84
],
[
142,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
87,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
87,
101
],
[
101,
102
],
[
102,
103
],
[
87,
104
],
[
104,
105
],
[
104,
106
],
[
87,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
112,
113
],
[
112,
114
],
[
107,
115
],
[
115,
116
],
[
116,
117
],
[
107,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
122,
127
],
[
119,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
87,
132
],
[
132,
133
],
[
133,
134
],
[
87,
135
],
[
135,
136
],
[
135,
137
],
[
135,
138
],
[
85,
139
],
[
139,
140
],
[
0,
141
],
[
141,
142
],
[
141,
143
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void runSchedule(Queue<String[]> tasks, int quantum) {\n\t\tint totalTime = 0;\n\t\t\n\t\twhile (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint nTasks = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\t\tscan.nextLine();\n\t\t\n\t\tQueue<String[]> tasks = new ArrayDeque<>();\n\t\t\n\t\tfor (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}\n\t\tscan.close();\n\t\t\n\t\trunSchedule(tasks, quantum);\n\t}\n\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static void runSchedule(Queue<String[]> tasks, int quantum) {\n\t\tint totalTime = 0;\n\t\t\n\t\twhile (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint nTasks = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\t\tscan.nextLine();\n\t\t\n\t\tQueue<String[]> tasks = new ArrayDeque<>();\n\t\t\n\t\tfor (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}\n\t\tscan.close();\n\t\t\n\t\trunSchedule(tasks, quantum);\n\t}\n\n}",
"Main",
"public static void runSchedule(Queue<String[]> tasks, int quantum) {\n\t\tint totalTime = 0;\n\t\t\n\t\twhile (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}",
"runSchedule",
"{\n\t\tint totalTime = 0;\n\t\t\n\t\twhile (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}",
"int totalTime = 0;",
"totalTime",
"0",
"while (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}",
"!tasks.isEmpty()",
"tasks.isEmpty()",
"tasks.isEmpty",
"tasks",
"{\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}",
"String[] elem = tasks.poll();",
"elem",
"tasks.poll()",
"tasks.poll",
"tasks",
"int reqTime = Integer.valueOf(elem[1]);",
"reqTime",
"Integer.valueOf(elem[1])",
"Integer.valueOf",
"Integer",
"elem[1]",
"elem",
"1",
"int timeElapsed = quantum - reqTime;",
"timeElapsed",
"quantum - reqTime",
"quantum",
"reqTime",
"if (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}",
"timeElapsed >= 0",
"timeElapsed",
"0",
"{\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t}",
"totalTime += reqTime",
"totalTime",
"reqTime",
"System.out.println(elem[0] + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"elem[0] + \" \" + totalTime",
"elem[0] + \" \" + totalTime",
"elem[0]",
"elem",
"0",
"\" \"",
"totalTime",
"{\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}",
"totalTime += quantum",
"totalTime",
"quantum",
"elem[1] = String.valueOf(timeElapsed * -1)",
"elem[1]",
"elem",
"1",
"String.valueOf(timeElapsed * -1)",
"String.valueOf",
"String",
"timeElapsed * -1",
"timeElapsed",
"-1",
"1",
"tasks.add(elem)",
"tasks.add",
"tasks",
"elem",
"Queue<String[]> tasks",
"tasks",
"int quantum",
"quantum",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint nTasks = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\t\tscan.nextLine();\n\t\t\n\t\tQueue<String[]> tasks = new ArrayDeque<>();\n\t\t\n\t\tfor (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}\n\t\tscan.close();\n\t\t\n\t\trunSchedule(tasks, quantum);\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tint nTasks = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\t\tscan.nextLine();\n\t\t\n\t\tQueue<String[]> tasks = new ArrayDeque<>();\n\t\t\n\t\tfor (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}\n\t\tscan.close();\n\t\t\n\t\trunSchedule(tasks, quantum);\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int nTasks = scan.nextInt();",
"nTasks",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int quantum = scan.nextInt();",
"quantum",
"scan.nextInt()",
"scan.nextInt",
"scan",
"scan.nextLine()",
"scan.nextLine",
"scan",
"Queue<String[]> tasks = new ArrayDeque<>();",
"tasks",
"new ArrayDeque<>()",
"for (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < nTasks",
"i",
"nTasks",
"i++",
"i++",
"i",
"{\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}",
"{\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}",
"String[] str = scan.nextLine().split(\" \");",
"str",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"tasks.add(str)",
"tasks.add",
"tasks",
"str",
"scan.close()",
"scan.close",
"scan",
"runSchedule(tasks, quantum)",
"runSchedule",
"tasks",
"quantum",
"String[] args",
"args",
"public class Main {\n\t\n\tpublic static void runSchedule(Queue<String[]> tasks, int quantum) {\n\t\tint totalTime = 0;\n\t\t\n\t\twhile (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint nTasks = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\t\tscan.nextLine();\n\t\t\n\t\tQueue<String[]> tasks = new ArrayDeque<>();\n\t\t\n\t\tfor (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}\n\t\tscan.close();\n\t\t\n\t\trunSchedule(tasks, quantum);\n\t}\n\n}",
"public class Main {\n\t\n\tpublic static void runSchedule(Queue<String[]> tasks, int quantum) {\n\t\tint totalTime = 0;\n\t\t\n\t\twhile (!tasks.isEmpty()) {\n\t\t\tString[] elem = tasks.poll();\n\t\t\tint reqTime = Integer.valueOf(elem[1]);\n\t\t\tint timeElapsed = quantum - reqTime;\n\t\t\t\n\t\t\tif (timeElapsed >= 0) {\n\t\t\t\ttotalTime += reqTime;\n\t\t\t\tSystem.out.println(elem[0] + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\telem[1] = String.valueOf(timeElapsed * -1);\n\t\t\t\ttasks.add(elem);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t}\n\t\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint nTasks = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\t\tscan.nextLine();\n\t\t\n\t\tQueue<String[]> tasks = new ArrayDeque<>();\n\t\t\n\t\tfor (int i = 0; i < nTasks; i++) {\n\t\t\tString[] str = scan.nextLine().split(\" \");\n\t\t\ttasks.add(str);\n\t\t}\n\t\tscan.close();\n\t\t\n\t\trunSchedule(tasks, quantum);\n\t}\n\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void runSchedule(Queue<String[]> tasks, int quantum) {
int totalTime = 0;
while (!tasks.isEmpty()) {
String[] elem = tasks.poll();
int reqTime = Integer.valueOf(elem[1]);
int timeElapsed = quantum - reqTime;
if (timeElapsed >= 0) {
totalTime += reqTime;
System.out.println(elem[0] + " " + totalTime);
} else {
totalTime += quantum;
elem[1] = String.valueOf(timeElapsed * -1);
tasks.add(elem);
}
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int nTasks = scan.nextInt();
int quantum = scan.nextInt();
scan.nextLine();
Queue<String[]> tasks = new ArrayDeque<>();
for (int i = 0; i < nTasks; i++) {
String[] str = scan.nextLine().split(" ");
tasks.add(str);
}
scan.close();
runSchedule(tasks, quantum);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
19,
18,
13,
4,
18,
13,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
181,
11
],
[
181,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
31
],
[
31,
32
],
[
31,
33
],
[
14,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
34,
39
],
[
39,
40
],
[
39,
41
],
[
34,
42
],
[
42,
43
],
[
43,
44
],
[
34,
45
],
[
46,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
46,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
14,
56
],
[
56,
57
],
[
56,
58
],
[
56,
59
],
[
12,
60
],
[
60,
61
],
[
181,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
69,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
74,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
81,
85
],
[
80,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
98,
98
],
[
98,
99
],
[
98,
100
],
[
98,
101
],
[
80,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
109,
113
],
[
102,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
62,
118
],
[
118,
119
],
[
62,
120
],
[
120,
121
],
[
181,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
122,
126
],
[
126,
127
],
[
122,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
128,
141
],
[
141,
142
],
[
128,
143
],
[
143,
144
],
[
122,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
122,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
122,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
155,
163
],
[
163,
164
],
[
122,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
165,
173
],
[
173,
174
],
[
122,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
0,
180
],
[
180,
181
],
[
180,
182
]
] | [
"\nimport java.util.Scanner;\nimport java.util.LinkedList;\nimport java.util.Queue;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint numProcesses = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tMain r = new Main();\n\t\tQueue<Process> q = new LinkedList<Process>();\n\n\t\tfor (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}\n\n\t\tperformQOps(q, quantum);\n\t}\n\n\tpublic static void performQOps(Queue<Process> q, int quantum) {\n\t\tint totalTime = 0;\n\n\t\twhile (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate class Process {\n\n\t\tString name;\n\t\tint timeRemaining;\n\n\t\tpublic Process(String name, int timeRemaining) {\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic int getTimeRemaining() {\n\t\t\treturn timeRemaining;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\tpublic void setTimeRemaining(int timeRemaining) {\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn name;\n\t\t}\n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint numProcesses = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tMain r = new Main();\n\t\tQueue<Process> q = new LinkedList<Process>();\n\n\t\tfor (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}\n\n\t\tperformQOps(q, quantum);\n\t}\n\n\tpublic static void performQOps(Queue<Process> q, int quantum) {\n\t\tint totalTime = 0;\n\n\t\twhile (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate class Process {\n\n\t\tString name;\n\t\tint timeRemaining;\n\n\t\tpublic Process(String name, int timeRemaining) {\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic int getTimeRemaining() {\n\t\t\treturn timeRemaining;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\tpublic void setTimeRemaining(int timeRemaining) {\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn name;\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint numProcesses = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tMain r = new Main();\n\t\tQueue<Process> q = new LinkedList<Process>();\n\n\t\tfor (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}\n\n\t\tperformQOps(q, quantum);\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tint numProcesses = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tMain r = new Main();\n\t\tQueue<Process> q = new LinkedList<Process>();\n\n\t\tfor (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}\n\n\t\tperformQOps(q, quantum);\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int numProcesses = in.nextInt();",
"numProcesses",
"in.nextInt()",
"in.nextInt",
"in",
"int quantum = in.nextInt();",
"quantum",
"in.nextInt()",
"in.nextInt",
"in",
"Main r = new Main();",
"r",
"new Main()",
"Queue<Process> q = new LinkedList<Process>();",
"q",
"new LinkedList<Process>()",
"for (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= numProcesses",
"i",
"numProcesses",
"i++",
"i++",
"i",
"{\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}",
"{\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}",
"Process p = r.new Process(in.next(), in.nextInt());",
"p",
"r.new Process(in.next(), in.nextInt())",
"r",
"r",
"q.add(p)",
"q.add",
"q",
"p",
"performQOps(q, quantum)",
"performQOps",
"q",
"quantum",
"String[] args",
"args",
"public static void performQOps(Queue<Process> q, int quantum) {\n\t\tint totalTime = 0;\n\n\t\twhile (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}\n\t}",
"performQOps",
"{\n\t\tint totalTime = 0;\n\n\t\twhile (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}\n\t}",
"int totalTime = 0;",
"totalTime",
"0",
"while (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}",
"q.size() != 0",
"q.size()",
"q.size",
"q",
"0",
"{\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}",
"Process cur = q.poll();",
"cur",
"q.poll()",
"q.poll",
"q",
"if (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}",
"cur.getTimeRemaining() <= quantum",
"cur.getTimeRemaining()",
"cur.getTimeRemaining",
"cur",
"quantum",
"{\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t}",
"totalTime += cur.getTimeRemaining()",
"totalTime",
"cur.getTimeRemaining()",
"cur.getTimeRemaining",
"cur",
"System.out.println(cur + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"cur + \" \" + totalTime",
"cur + \" \" + totalTime",
"cur",
"\" \"",
"totalTime",
"{\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}",
"totalTime += quantum",
"totalTime",
"quantum",
"cur.setTimeRemaining(cur.getTimeRemaining() - quantum)",
"cur.setTimeRemaining",
"cur",
"cur.getTimeRemaining() - quantum",
"cur.getTimeRemaining()",
"cur.getTimeRemaining",
"cur",
"quantum",
"q.add(cur)",
"q.add",
"q",
"cur",
"Queue<Process> q",
"q",
"int quantum",
"quantum",
"private class Process {\n\n\t\tString name;\n\t\tint timeRemaining;\n\n\t\tpublic Process(String name, int timeRemaining) {\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic int getTimeRemaining() {\n\t\t\treturn timeRemaining;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\tpublic void setTimeRemaining(int timeRemaining) {\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn name;\n\t\t}\n\t}",
"Process",
"String name;",
"name",
"int timeRemaining;",
"timeRemaining",
"public Process(String name, int timeRemaining) {\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}",
"Process",
"{\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.timeRemaining = timeRemaining",
"this.timeRemaining",
"this",
"this.timeRemaining",
"timeRemaining",
"String name",
"name",
"int timeRemaining",
"timeRemaining",
"public String getName() {\n\t\t\treturn name;\n\t\t}",
"getName",
"{\n\t\t\treturn name;\n\t\t}",
"return name;",
"name",
"public int getTimeRemaining() {\n\t\t\treturn timeRemaining;\n\t\t}",
"getTimeRemaining",
"{\n\t\t\treturn timeRemaining;\n\t\t}",
"return timeRemaining;",
"timeRemaining",
"public void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}",
"setName",
"{\n\t\t\tthis.name = name;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"public void setTimeRemaining(int timeRemaining) {\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}",
"setTimeRemaining",
"{\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}",
"this.timeRemaining = timeRemaining",
"this.timeRemaining",
"this",
"this.timeRemaining",
"timeRemaining",
"int timeRemaining",
"timeRemaining",
"public String toString() {\n\t\t\treturn name;\n\t\t}",
"toString",
"{\n\t\t\treturn name;\n\t\t}",
"return name;",
"name",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint numProcesses = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tMain r = new Main();\n\t\tQueue<Process> q = new LinkedList<Process>();\n\n\t\tfor (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}\n\n\t\tperformQOps(q, quantum);\n\t}\n\n\tpublic static void performQOps(Queue<Process> q, int quantum) {\n\t\tint totalTime = 0;\n\n\t\twhile (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate class Process {\n\n\t\tString name;\n\t\tint timeRemaining;\n\n\t\tpublic Process(String name, int timeRemaining) {\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic int getTimeRemaining() {\n\t\t\treturn timeRemaining;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\tpublic void setTimeRemaining(int timeRemaining) {\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn name;\n\t\t}\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint numProcesses = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tMain r = new Main();\n\t\tQueue<Process> q = new LinkedList<Process>();\n\n\t\tfor (int i = 1; i <= numProcesses; i++) {\n\t\t\tProcess p = r.new Process(in.next(), in.nextInt());\n\t\t\tq.add(p);\n\t\t}\n\n\t\tperformQOps(q, quantum);\n\t}\n\n\tpublic static void performQOps(Queue<Process> q, int quantum) {\n\t\tint totalTime = 0;\n\n\t\twhile (q.size() != 0) {\n\n\t\t\tProcess cur = q.poll();\n\n\t\t\tif (cur.getTimeRemaining() <= quantum) {\n\t\t\t\ttotalTime += cur.getTimeRemaining();\n\t\t\t\tSystem.out.println(cur + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\ttotalTime += quantum;\n\t\t\t\tcur.setTimeRemaining(cur.getTimeRemaining() - quantum);\n\t\t\t\tq.add(cur);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate class Process {\n\n\t\tString name;\n\t\tint timeRemaining;\n\n\t\tpublic Process(String name, int timeRemaining) {\n\t\t\tthis.name = name;\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic int getTimeRemaining() {\n\t\t\treturn timeRemaining;\n\t\t}\n\n\t\tpublic void setName(String name) {\n\t\t\tthis.name = name;\n\t\t}\n\n\t\tpublic void setTimeRemaining(int timeRemaining) {\n\t\t\tthis.timeRemaining = timeRemaining;\n\t\t}\n\n\t\tpublic String toString() {\n\t\t\treturn name;\n\t\t}\n\t}\n}",
"Main"
] |
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int numProcesses = in.nextInt();
int quantum = in.nextInt();
Main r = new Main();
Queue<Process> q = new LinkedList<Process>();
for (int i = 1; i <= numProcesses; i++) {
Process p = r.new Process(in.next(), in.nextInt());
q.add(p);
}
performQOps(q, quantum);
}
public static void performQOps(Queue<Process> q, int quantum) {
int totalTime = 0;
while (q.size() != 0) {
Process cur = q.poll();
if (cur.getTimeRemaining() <= quantum) {
totalTime += cur.getTimeRemaining();
System.out.println(cur + " " + totalTime);
} else {
totalTime += quantum;
cur.setTimeRemaining(cur.getTimeRemaining() - quantum);
q.add(cur);
}
}
}
private class Process {
String name;
int timeRemaining;
public Process(String name, int timeRemaining) {
this.name = name;
this.timeRemaining = timeRemaining;
}
public String getName() {
return name;
}
public int getTimeRemaining() {
return timeRemaining;
}
public void setName(String name) {
this.name = name;
}
public void setTimeRemaining(int timeRemaining) {
this.timeRemaining = timeRemaining;
}
public String toString() {
return name;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
38,
30,
41,
13,
20,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
2,
0,
13,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
17,
14,
13,
30,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
17,
30,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
40,
13,
14,
2,
13,
13,
30,
3,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
17,
42,
17,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
3,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
162,
11
],
[
162,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
22,
26
],
[
26,
27
],
[
22,
28
],
[
28,
29
],
[
28,
30
],
[
22,
31
],
[
31,
32
],
[
31,
33
],
[
22,
34
],
[
34,
35
],
[
34,
36
],
[
22,
37
],
[
37,
38
],
[
37,
39
],
[
22,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
41,
47
],
[
40,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
48,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
63,
65
],
[
57,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
71,
73
],
[
57,
74
],
[
74,
75
],
[
74,
76
],
[
55,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
77,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
90,
91
],
[
90,
92
],
[
77,
93
],
[
93,
94
],
[
77,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
22,
101
],
[
101,
102
],
[
101,
103
],
[
22,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
104,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
115,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
115,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
126,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
135,
143
],
[
143,
144
],
[
144,
145
],
[
143,
146
],
[
146,
147
],
[
146,
148
],
[
109,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
155,
155
],
[
155,
156
],
[
155,
157
],
[
155,
158
],
[
12,
159
],
[
159,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n // TODO ?????????????????????????????????????????????\n // System.out.println(\"0\".compareTo(\"1\"));\n\t\tArrayDeque<String> queue1 = new ArrayDeque<String>();\n\t\tArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();\n\t\t\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }\n\t}\n\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n // TODO ?????????????????????????????????????????????\n // System.out.println(\"0\".compareTo(\"1\"));\n\t\tArrayDeque<String> queue1 = new ArrayDeque<String>();\n\t\tArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();\n\t\t\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }\n\t}\n\n\n}",
"Main",
"public static void main(String[] args) throws Exception {\n // TODO ?????????????????????????????????????????????\n // System.out.println(\"0\".compareTo(\"1\"));\n\t\tArrayDeque<String> queue1 = new ArrayDeque<String>();\n\t\tArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();\n\t\t\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }\n\t}",
"main",
"{\n // TODO ?????????????????????????????????????????????\n // System.out.println(\"0\".compareTo(\"1\"));\n\t\tArrayDeque<String> queue1 = new ArrayDeque<String>();\n\t\tArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();\n\t\t\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }\n\t}",
"ArrayDeque<String> queue1 = new ArrayDeque<String>();",
"queue1",
"new ArrayDeque<String>()",
"ArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();",
"queue2",
"new ArrayDeque<Integer>()",
"try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }",
"{\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"String line;",
"line",
"int n=0",
"n",
"0",
"tam=0",
"tam",
"0",
"i=0;",
"i",
"0",
"boolean first=true;",
"first",
"true",
"while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }",
"(line = br.readLine()) != null",
"(line = br.readLine())",
"line",
"br.readLine()",
"br.readLine",
"br",
"null",
"{\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }",
"String[] str=line.split(\" \");",
"str",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"if(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t}",
"first",
"{\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}",
"n=Integer.parseInt(str[0])",
"n",
"Integer.parseInt(str[0])",
"Integer.parseInt",
"Integer",
"str[0]",
"str",
"0",
"tam=Integer.parseInt(str[1])",
"tam",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"first=false",
"first",
"false",
"{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t}",
"queue1.add(str[0])",
"queue1.add",
"queue1",
"str[0]",
"str",
"0",
"queue2.add(Integer.parseInt(str[1]))",
"queue2.add",
"queue2",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"i++",
"i",
"if(i==n){\n \t\t\tbreak;\n \t\t}",
"i==n",
"i",
"n",
"{\n \t\t\tbreak;\n \t\t}",
"break;",
"int store=0;",
"store",
"0",
"while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }",
"!queue1.isEmpty()",
"queue1.isEmpty()",
"queue1.isEmpty",
"queue1",
"{\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }",
"String str=\"\";",
"str",
"\"\"",
"while(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}",
"true",
"{\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}",
"int a=queue2.poll();",
"a",
"queue2.poll()",
"queue2.poll",
"queue2",
"str=queue1.poll()",
"str",
"queue1.poll()",
"queue1.poll",
"queue1",
"if(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}",
"a<=tam",
"a",
"tam",
"{\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}",
"store+=a",
"store",
"a",
"break;",
"{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}",
"store+=tam",
"store",
"tam",
"queue1.add(str)",
"queue1.add",
"queue1",
"str",
"queue2.add(a-tam)",
"queue2.add",
"queue2",
"a-tam",
"a",
"tam",
"System.out.println(str+\" \"+store)",
"System.out.println",
"System.out",
"System",
"System.out",
"str+\" \"+store",
"str+\" \"+store",
"str",
"\" \"",
"store",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n // TODO ?????????????????????????????????????????????\n // System.out.println(\"0\".compareTo(\"1\"));\n\t\tArrayDeque<String> queue1 = new ArrayDeque<String>();\n\t\tArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();\n\t\t\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }\n\t}\n\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n // TODO ?????????????????????????????????????????????\n // System.out.println(\"0\".compareTo(\"1\"));\n\t\tArrayDeque<String> queue1 = new ArrayDeque<String>();\n\t\tArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();\n\t\t\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n String line;\n int n=0,tam=0,i=0;\n boolean first=true;\n while ((line = br.readLine()) != null) {\n \tString[] str=line.split(\" \");\n \tif(first){\n \t\tn=Integer.parseInt(str[0]);\n \t\ttam=Integer.parseInt(str[1]);\n \t\tfirst=false;\n \t}else{\n \t\tqueue1.add(str[0]);\n \t\tqueue2.add(Integer.parseInt(str[1]));\n \t\ti++;\n \t\tif(i==n){\n \t\t\tbreak;\n \t\t}\n \t} \t\n }\n int store=0;\n while(!queue1.isEmpty()){\n \tString str=\"\";\n \twhile(true){\n \t\tint a=queue2.poll();\n \t\tstr=queue1.poll();\n \t\tif(a<=tam){\n \t\t\tstore+=a;\n \t\t\tbreak;\n \t\t}else{\n \t\t\tstore+=tam;\n \t\t\tqueue1.add(str);\n \t\t\tqueue2.add(a-tam);\n \t\t}\n \t}\n \tSystem.out.println(str+\" \"+store);\n }\n }\n\t}\n\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
public class Main {
public static void main(String[] args) throws Exception {
// TODO ?????????????????????????????????????????????
// System.out.println("0".compareTo("1"));
ArrayDeque<String> queue1 = new ArrayDeque<String>();
ArrayDeque<Integer> queue2 = new ArrayDeque<Integer>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String line;
int n=0,tam=0,i=0;
boolean first=true;
while ((line = br.readLine()) != null) {
String[] str=line.split(" ");
if(first){
n=Integer.parseInt(str[0]);
tam=Integer.parseInt(str[1]);
first=false;
}else{
queue1.add(str[0]);
queue2.add(Integer.parseInt(str[1]));
i++;
if(i==n){
break;
}
}
}
int store=0;
while(!queue1.isEmpty()){
String str="";
while(true){
int a=queue2.poll();
str=queue1.poll();
if(a<=tam){
store+=a;
break;
}else{
store+=tam;
queue1.add(str);
queue2.add(a-tam);
}
}
System.out.println(str+" "+store);
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
40,
13,
42,
2,
4,
13,
17,
30,
0,
13,
4,
13,
14,
2,
2,
13,
13,
17,
30,
4,
13,
2,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
17,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
14,
2,
13,
2,
13,
17,
30,
0,
13,
17,
30,
40,
13,
23,
13,
12,
13,
30,
14,
2,
13,
2,
13,
17,
30,
0,
13,
17,
29,
18,
13,
2,
13,
17,
29,
18,
13,
40,
13,
12,
13,
30,
29,
2,
13,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
4,
9
],
[
9,
10
],
[
9,
11
],
[
4,
13
],
[
13,
14
],
[
13,
15
],
[
4,
17
],
[
17,
18
],
[
17,
19
],
[
4,
20
],
[
20,
21
],
[
20,
22
],
[
4,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
25,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
25,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
25,
39
],
[
39,
40
],
[
25,
41
],
[
41,
42
],
[
41,
43
],
[
25,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
49,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
44,
55
],
[
56,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
62,
63
],
[
56,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
56,
71
],
[
71,
72
],
[
25,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
73,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
78,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
92,
94
],
[
89,
95
],
[
95,
96
],
[
95,
97
],
[
83,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
108,
114
],
[
108,
115
],
[
23,
116
],
[
116,
117
],
[
4,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
120,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
137,
139
],
[
126,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
147,
149
],
[
120,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
150,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
150,
160
],
[
160,
161
],
[
161,
162
],
[
118,
163
],
[
163,
164
],
[
4,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
171,
173
],
[
168,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
174,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
181,
183
],
[
167,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
4,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
]
] | [
"import java.util.*;\n\nclass Main {\n\n static int LENGTH = 100000;\n static int [] queue = new int[LENGTH];\n static String [] name = new String[LENGTH];\n static int tail = 0;\n static int head = 0;\n public static void main(String args[]){\n //宣言\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n int out;\n int count=0;\n //input\n for(int i = 0; i<n; i++){\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }\n //loop\n while(isEmpty() != true){\n out = dequeue();\n if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }\n }\n }\n //enqueue\n static void enqueue(int num){\n queue[tail] = num;\n if(head != 0){\n name[tail] = name[head-1];//\n }else{\n name[tail] = name[LENGTH-1];\n }\n if(tail == LENGTH-1){\n tail=0;\n }else{\n tail++;\n }\n }\n //dequeue\n static int dequeue(){\n if(head == LENGTH-1){\n head = 0;\n return queue[LENGTH-1];\n }\n return queue[head++];\n }\n //キューの中身がなくなったかどうかの判定\n static boolean isEmpty(){\n return head == tail;\n }\n\n}",
"import java.util.*;",
"util.*",
"java",
"class Main {\n\n static int LENGTH = 100000;\n static int [] queue = new int[LENGTH];\n static String [] name = new String[LENGTH];\n static int tail = 0;\n static int head = 0;\n public static void main(String args[]){\n //宣言\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n int out;\n int count=0;\n //input\n for(int i = 0; i<n; i++){\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }\n //loop\n while(isEmpty() != true){\n out = dequeue();\n if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }\n }\n }\n //enqueue\n static void enqueue(int num){\n queue[tail] = num;\n if(head != 0){\n name[tail] = name[head-1];//\n }else{\n name[tail] = name[LENGTH-1];\n }\n if(tail == LENGTH-1){\n tail=0;\n }else{\n tail++;\n }\n }\n //dequeue\n static int dequeue(){\n if(head == LENGTH-1){\n head = 0;\n return queue[LENGTH-1];\n }\n return queue[head++];\n }\n //キューの中身がなくなったかどうかの判定\n static boolean isEmpty(){\n return head == tail;\n }\n\n}",
"Main",
"static int LENGTH = 100000;",
"LENGTH",
"100000",
"static int [] queue = new int[LENGTH];",
"queue",
"new int[LENGTH]",
"LENGTH",
"static String [] name = new String[LENGTH];",
"name",
"new String[LENGTH]",
"LENGTH",
"static int tail = 0;",
"tail",
"0",
"static int head = 0;",
"head",
"0",
"public static void main(String args[]){\n //宣言\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n int out;\n int count=0;\n //input\n for(int i = 0; i<n; i++){\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }\n //loop\n while(isEmpty() != true){\n out = dequeue();\n if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }\n }\n }",
"main",
"{\n //宣言\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int max = sc.nextInt();\n int out;\n int count=0;\n //input\n for(int i = 0; i<n; i++){\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }\n //loop\n while(isEmpty() != true){\n out = dequeue();\n if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int max = sc.nextInt();",
"max",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int out;",
"out",
"int count=0;",
"count",
"0",
"for(int i = 0; i<n; i++){\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }",
"{\n name[i] = sc.next();\n queue[i] = sc.nextInt();\n tail++;\n }",
"name[i] = sc.next()",
"name[i]",
"name",
"i",
"sc.next()",
"sc.next",
"sc",
"queue[i] = sc.nextInt()",
"queue[i]",
"queue",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"tail++",
"tail",
"while(isEmpty() != true){\n out = dequeue();\n if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }\n }",
"isEmpty() != true",
"isEmpty()",
"isEmpty",
"true",
"{\n out = dequeue();\n if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }\n }",
"out = dequeue()",
"out",
"dequeue()",
"dequeue",
"if((out-max)>0){\n enqueue(out-max);//\n count += max;\n }else{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }",
"(out-max)>0",
"(out-max)",
"out",
"max",
"0",
"{\n enqueue(out-max);//\n count += max;\n }",
"enqueue(out-max)",
"enqueue",
"out-max",
"out",
"max",
"count += max",
"count",
"max",
"{\n count += out;\n System.out.println(name[head-1]+\" \"+count);\n }",
"count += out",
"count",
"out",
"System.out.println(name[head-1]+\" \"+count)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[head-1]+\" \"+count",
"name[head-1]+\" \"+count",
"name[head-1]",
"name",
"head-1",
"head",
"1",
"\" \"",
"count",
"String args[]",
"args",
"//enqueue\n static void enqueue(int num){\n queue[tail] = num;\n if(head != 0){\n name[tail] = name[head-1];//\n }else{\n name[tail] = name[LENGTH-1];\n }\n if(tail == LENGTH-1){\n tail=0;\n }else{\n tail++;\n }\n }",
"enqueue",
"{\n queue[tail] = num;\n if(head != 0){\n name[tail] = name[head-1];//\n }else{\n name[tail] = name[LENGTH-1];\n }\n if(tail == LENGTH-1){\n tail=0;\n }else{\n tail++;\n }\n }",
"queue[tail] = num",
"queue[tail]",
"queue",
"tail",
"num",
"if(head != 0){\n name[tail] = name[head-1];//\n }else{\n name[tail] = name[LENGTH-1];\n }",
"head != 0",
"head",
"0",
"{\n name[tail] = name[head-1];//\n }",
"name[tail] = name[head-1]",
"name[tail]",
"name",
"tail",
"name[head-1]",
"name",
"head-1",
"head",
"1",
"{\n name[tail] = name[LENGTH-1];\n }",
"name[tail] = name[LENGTH-1]",
"name[tail]",
"name",
"tail",
"name[LENGTH-1]",
"name",
"LENGTH-1",
"LENGTH",
"1",
"if(tail == LENGTH-1){\n tail=0;\n }else{\n tail++;\n }",
"tail == LENGTH-1",
"tail",
"LENGTH-1",
"LENGTH",
"1",
"{\n tail=0;\n }",
"tail=0",
"tail",
"0",
"{\n tail++;\n }",
"tail++",
"tail",
"int num",
"num",
"//dequeue\n static int dequeue(){\n if(head == LENGTH-1){\n head = 0;\n return queue[LENGTH-1];\n }\n return queue[head++];\n }",
"dequeue",
"{\n if(head == LENGTH-1){\n head = 0;\n return queue[LENGTH-1];\n }\n return queue[head++];\n }",
"if(head == LENGTH-1){\n head = 0;\n return queue[LENGTH-1];\n }",
"head == LENGTH-1",
"head",
"LENGTH-1",
"LENGTH",
"1",
"{\n head = 0;\n return queue[LENGTH-1];\n }",
"head = 0",
"head",
"0",
"return queue[LENGTH-1];",
"queue[LENGTH-1]",
"queue",
"LENGTH-1",
"LENGTH",
"1",
"return queue[head++];",
"queue[head++]",
"queue",
"head++",
"head",
"//キューの中身がなくなったかどうかの判定\n static boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail"
] | import java.util.*;
class Main {
static int LENGTH = 100000;
static int [] queue = new int[LENGTH];
static String [] name = new String[LENGTH];
static int tail = 0;
static int head = 0;
public static void main(String args[]){
//宣言
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int max = sc.nextInt();
int out;
int count=0;
//input
for(int i = 0; i<n; i++){
name[i] = sc.next();
queue[i] = sc.nextInt();
tail++;
}
//loop
while(isEmpty() != true){
out = dequeue();
if((out-max)>0){
enqueue(out-max);//
count += max;
}else{
count += out;
System.out.println(name[head-1]+" "+count);
}
}
}
//enqueue
static void enqueue(int num){
queue[tail] = num;
if(head != 0){
name[tail] = name[head-1];//
}else{
name[tail] = name[LENGTH-1];
}
if(tail == LENGTH-1){
tail=0;
}else{
tail++;
}
}
//dequeue
static int dequeue(){
if(head == LENGTH-1){
head = 0;
return queue[LENGTH-1];
}
return queue[head++];
}
//キューの中身がなくなったかどうかの判定
static boolean isEmpty(){
return head == tail;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
13,
18,
13,
13,
30,
3,
14,
2,
13,
18,
13,
13,
30,
40,
13,
3,
4,
18,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
107,
5
],
[
107,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
21,
26
],
[
26,
27
],
[
26,
28
],
[
21,
29
],
[
29,
30
],
[
30,
31
],
[
21,
32
],
[
33,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
8,
46
],
[
46,
47
],
[
46,
48
],
[
8,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
67,
72
],
[
72,
73
],
[
72,
74
],
[
67,
75
],
[
75,
76
],
[
76,
77
],
[
67,
78
],
[
79,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
80,
86
],
[
86,
87
],
[
80,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
91,
93
],
[
88,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
8,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
6,
104
],
[
104,
105
],
[
0,
106
],
[
106,
107
],
[
106,
108
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] S = new long[n];\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}\n\n\t\tint q = sc.nextInt();\n\t\tint count = 0;\n\n\t\tfor(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] S = new long[n];\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}\n\n\t\tint q = sc.nextInt();\n\t\tint count = 0;\n\n\t\tfor(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] S = new long[n];\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}\n\n\t\tint q = sc.nextInt();\n\t\tint count = 0;\n\n\t\tfor(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] S = new long[n];\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}\n\n\t\tint q = sc.nextInt();\n\t\tint count = 0;\n\n\t\tfor(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"long[] S = new long[n];",
"S",
"new long[n]",
"n",
"for(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tS[i] = sc.nextLong();\n\t\t}",
"{\n\t\t\tS[i] = sc.nextLong();\n\t\t}",
"S[i] = sc.nextLong()",
"S[i]",
"S",
"i",
"sc.nextLong()",
"sc.nextLong",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"for(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"int j = 0;",
"int j = 0;",
"j",
"0",
"j < q",
"j",
"q",
"j++",
"j++",
"j",
"{\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"long T = sc.nextLong();",
"T",
"sc.nextLong()",
"sc.nextLong",
"sc",
"for(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"if(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"T < S[i]",
"T",
"S[i]",
"S",
"i",
"{\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"break;",
"if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"T == S[i]",
"T",
"S[i]",
"S",
"i",
"{\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"count++",
"count",
"break;",
"System.out.println(count)",
"System.out.println",
"System.out",
"System",
"System.out",
"count",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] S = new long[n];\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}\n\n\t\tint q = sc.nextInt();\n\t\tint count = 0;\n\n\t\tfor(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tlong[] S = new long[n];\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tS[i] = sc.nextLong();\n\t\t}\n\n\t\tint q = sc.nextInt();\n\t\tint count = 0;\n\n\t\tfor(int j = 0; j < q; j++) {\n\t\t\tlong T = sc.nextLong();\n\t\t\tfor(int i = 0; i < n; i++) {\n\t\t\t\tif(T < S[i]) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else if(T == S[i]) {\n\t\t\t\t\tcount++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(count);\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] S = new long[n];
for(int i = 0; i < n; i++) {
S[i] = sc.nextLong();
}
int q = sc.nextInt();
int count = 0;
for(int j = 0; j < q; j++) {
long T = sc.nextLong();
for(int i = 0; i < n; i++) {
if(T < S[i]) {
break;
} else if(T == S[i]) {
count++;
break;
}
}
}
System.out.println(count);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
2,
18,
13,
13,
18,
13,
2,
13,
17,
2,
18,
13,
13,
18,
13,
17,
30,
14,
4,
13,
13,
17,
2,
13,
17,
18,
13,
13,
30,
40,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
41,
13,
2,
2,
13,
13,
17,
14,
2,
18,
13,
13,
13,
30,
29,
17,
14,
2,
18,
13,
13,
13,
30,
29,
4,
13,
13,
13,
2,
13,
17,
13,
30,
29,
4,
13,
13,
2,
13,
17,
13,
13,
30,
29,
17,
23,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
191,
5
],
[
191,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
8,
21
],
[
21,
22
],
[
8,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
23,
28
],
[
28,
29
],
[
28,
30
],
[
23,
31
],
[
31,
32
],
[
32,
33
],
[
23,
34
],
[
35,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
8,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
8,
48
],
[
48,
49
],
[
48,
50
],
[
8,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
57,
59
],
[
52,
60
],
[
60,
61
],
[
61,
62
],
[
52,
63
],
[
64,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
70,
71
],
[
8,
72
],
[
72,
73
],
[
72,
74
],
[
8,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
80,
81
],
[
80,
82
],
[
75,
83
],
[
83,
84
],
[
84,
85
],
[
75,
86
],
[
87,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
89,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
103,
105
],
[
88,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
108,
111
],
[
108,
112
],
[
112,
113
],
[
112,
114
],
[
108,
115
],
[
115,
116
],
[
115,
117
],
[
107,
118
],
[
118,
119
],
[
119,
120
],
[
8,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
6,
127
],
[
127,
128
],
[
191,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
136,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
144,
150
],
[
150,
151
],
[
151,
152
],
[
144,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
153,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
161,
164
],
[
161,
165
],
[
165,
166
],
[
165,
167
],
[
161,
168
],
[
153,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
171,
174
],
[
174,
175
],
[
174,
176
],
[
171,
177
],
[
171,
178
],
[
132,
179
],
[
179,
180
],
[
180,
181
],
[
129,
182
],
[
182,
183
],
[
129,
184
],
[
184,
185
],
[
129,
186
],
[
186,
187
],
[
129,
188
],
[
188,
189
],
[
0,
190
],
[
190,
191
],
[
190,
192
]
] | [
"import java.util.Scanner;\npublic class Main{\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int [] s = new int[n];\n int [] t;\n for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }\n int q = scan.nextInt();\n t = new int[q];\n for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }\n int counter = 0;\n for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }\n System.out.println(counter);\n }\n public static boolean binarysearch(int arr[], int l, int r, int x){\n if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int [] s = new int[n];\n int [] t;\n for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }\n int q = scan.nextInt();\n t = new int[q];\n for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }\n int counter = 0;\n for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }\n System.out.println(counter);\n }\n public static boolean binarysearch(int arr[], int l, int r, int x){\n if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int [] s = new int[n];\n int [] t;\n for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }\n int q = scan.nextInt();\n t = new int[q];\n for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }\n int counter = 0;\n for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }\n System.out.println(counter);\n }",
"main",
"{\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int [] s = new int[n];\n int [] t;\n for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }\n int q = scan.nextInt();\n t = new int[q];\n for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }\n int counter = 0;\n for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }\n System.out.println(counter);\n }",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int [] s = new int[n];",
"s",
"new int[n]",
"n",
"int [] t;",
"t",
"for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }",
"int x = 0;",
"int x = 0;",
"x",
"0",
"x < n",
"x",
"n",
"x++",
"x++",
"x",
"{\n s[x] = scan.nextInt();\n }",
"{\n s[x] = scan.nextInt();\n }",
"s[x] = scan.nextInt()",
"s[x]",
"s",
"x",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"t = new int[q]",
"t",
"new int[q]",
"q",
"for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }",
"int x = 0;",
"int x = 0;",
"x",
"0",
"x < q",
"x",
"q",
"x++",
"x++",
"x",
"{\n t[x] = scan.nextInt();\n }",
"{\n t[x] = scan.nextInt();\n }",
"t[x] = scan.nextInt()",
"t[x]",
"t",
"x",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int counter = 0;",
"counter",
"0",
"for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }",
"int x = 0;",
"int x = 0;",
"x",
"0",
"x < q",
"x",
"q",
"x++",
"x++",
"x",
"{\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }",
"{\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }",
"if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }",
"t[x] <= s[n -1] && t[x] >= s[0]",
"t[x] <= s[n -1]",
"t[x]",
"t",
"x",
"s[n -1]",
"s",
"n -1",
"n",
"1",
"t[x] >= s[0]",
"t[x]",
"t",
"x",
"s[0]",
"s",
"0",
"{\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }",
"if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }",
"binarysearch(s, 0, n - 1, t[x])",
"binarysearch",
"s",
"0",
"n - 1",
"n",
"1",
"t[x]",
"t",
"x",
"{\n counter++;\n }",
"counter++",
"counter",
"System.out.println(counter)",
"System.out.println",
"System.out",
"System",
"System.out",
"counter",
"String[] args",
"args",
"public static boolean binarysearch(int arr[], int l, int r, int x){\n if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }\n }",
"binarysearch",
"{\n if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }\n }",
"if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }",
"r >=l",
"r",
"l",
"{\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }",
"int mid = (l + r)/2;",
"mid",
"(l + r)/2",
"(l + r)",
"l",
"r",
"2",
"if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }",
"arr[mid] == x",
"arr[mid]",
"arr",
"mid",
"x",
"{\n return true;\n }",
"return true;",
"true",
"if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }",
"arr[mid] > x",
"arr[mid]",
"arr",
"mid",
"x",
"{\n return binarysearch(arr, l, mid -1, x);\n }",
"return binarysearch(arr, l, mid -1, x);",
"binarysearch(arr, l, mid -1, x)",
"binarysearch",
"arr",
"l",
"mid -1",
"mid",
"1",
"x",
"{\n return binarysearch(arr, mid + 1, r, x);\n }",
"return binarysearch(arr, mid + 1, r, x);",
"binarysearch(arr, mid + 1, r, x)",
"binarysearch",
"arr",
"mid + 1",
"mid",
"1",
"r",
"x",
"{\n return false;\n }",
"return false;",
"false",
"int arr[]",
"arr",
"int l",
"l",
"int r",
"r",
"int x",
"x",
"public class Main{\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int [] s = new int[n];\n int [] t;\n for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }\n int q = scan.nextInt();\n t = new int[q];\n for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }\n int counter = 0;\n for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }\n System.out.println(counter);\n }\n public static boolean binarysearch(int arr[], int l, int r, int x){\n if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }\n }\n}",
"public class Main{\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int [] s = new int[n];\n int [] t;\n for (int x = 0; x < n; x++){\n s[x] = scan.nextInt();\n }\n int q = scan.nextInt();\n t = new int[q];\n for (int x = 0; x < q; x++){\n t[x] = scan.nextInt();\n }\n int counter = 0;\n for (int x = 0; x < q; x++){\n if(t[x] <= s[n -1] && t[x] >= s[0]){\n if(binarysearch(s, 0, n - 1, t[x])){\n counter++;\n }\n }\n }\n System.out.println(counter);\n }\n public static boolean binarysearch(int arr[], int l, int r, int x){\n if(r >=l){\n int mid = (l + r)/2;\n if(arr[mid] == x){\n return true;\n }\n else if(arr[mid] > x){\n return binarysearch(arr, l, mid -1, x);\n }\n else{\n return binarysearch(arr, mid + 1, r, x);\n }\n }\n else{\n return false;\n }\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int [] s = new int[n];
int [] t;
for (int x = 0; x < n; x++){
s[x] = scan.nextInt();
}
int q = scan.nextInt();
t = new int[q];
for (int x = 0; x < q; x++){
t[x] = scan.nextInt();
}
int counter = 0;
for (int x = 0; x < q; x++){
if(t[x] <= s[n -1] && t[x] >= s[0]){
if(binarysearch(s, 0, n - 1, t[x])){
counter++;
}
}
}
System.out.println(counter);
}
public static boolean binarysearch(int arr[], int l, int r, int x){
if(r >=l){
int mid = (l + r)/2;
if(arr[mid] == x){
return true;
}
else if(arr[mid] > x){
return binarysearch(arr, l, mid -1, x);
}
else{
return binarysearch(arr, mid + 1, r, x);
}
}
else{
return false;
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
20,
2,
13,
17,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
18,
13,
13,
14,
2,
4,
13,
13,
13,
13,
17,
30,
40,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
13,
42,
2,
13,
13,
30,
0,
13,
2,
2,
13,
13,
17,
14,
2,
18,
13,
13,
13,
30,
29,
17,
14,
2,
13,
18,
13,
13,
30,
0,
13,
13,
30,
0,
13,
2,
13,
17,
29,
40,
17,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
174,
5
],
[
174,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
20,
21
],
[
20,
22
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
8,
26
],
[
26,
27
],
[
26,
28
],
[
8,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
29,
34
],
[
34,
35
],
[
34,
36
],
[
29,
37
],
[
37,
38
],
[
38,
39
],
[
29,
40
],
[
41,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
42,
46
],
[
46,
47
],
[
47,
48
],
[
8,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
8,
54
],
[
54,
55
],
[
54,
56
],
[
8,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
58,
63
],
[
63,
64
],
[
63,
65
],
[
58,
66
],
[
66,
67
],
[
67,
68
],
[
58,
69
],
[
70,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
8,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
83,
84
],
[
83,
85
],
[
78,
86
],
[
86,
87
],
[
87,
88
],
[
78,
89
],
[
90,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
98,
101
],
[
98,
102
],
[
97,
103
],
[
96,
104
],
[
104,
105
],
[
105,
106
],
[
8,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
6,
113
],
[
113,
114
],
[
174,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
121,
123
],
[
117,
124
],
[
124,
125
],
[
124,
126
],
[
117,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
131,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
139,
145
],
[
145,
146
],
[
146,
147
],
[
139,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
151,
153
],
[
148,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
148,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
117,
164
],
[
164,
165
],
[
165,
166
],
[
115,
167
],
[
167,
168
],
[
115,
169
],
[
169,
170
],
[
115,
171
],
[
171,
172
],
[
0,
173
],
[
173,
174
],
[
173,
175
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint S[] = new int[n+1];\n\t\tint key = 0;\n\t\tint ans = 0;\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}\n\t\tint q = sc.nextInt();\n\t\tint T[] = new int[q];\n\t\tfor(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static int binarySearch(int A[], int key, int n){\n\t\tint mid = 0;\n\t\tint left = 0;\n\t\tint right = n;\n\t\twhile (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint S[] = new int[n+1];\n\t\tint key = 0;\n\t\tint ans = 0;\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}\n\t\tint q = sc.nextInt();\n\t\tint T[] = new int[q];\n\t\tfor(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static int binarySearch(int A[], int key, int n){\n\t\tint mid = 0;\n\t\tint left = 0;\n\t\tint right = n;\n\t\twhile (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n}",
"Main",
"public static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint S[] = new int[n+1];\n\t\tint key = 0;\n\t\tint ans = 0;\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}\n\t\tint q = sc.nextInt();\n\t\tint T[] = new int[q];\n\t\tfor(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint S[] = new int[n+1];\n\t\tint key = 0;\n\t\tint ans = 0;\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}\n\t\tint q = sc.nextInt();\n\t\tint T[] = new int[q];\n\t\tfor(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int S[] = new int[n+1];",
"S",
"new int[n+1]",
"n+1",
"n",
"1",
"int key = 0;",
"key",
"0",
"int ans = 0;",
"ans",
"0",
"for(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tS[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tS[i] = sc.nextInt();\n\t\t}",
"S[i] = sc.nextInt()",
"S[i]",
"S",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int T[] = new int[q];",
"T",
"new int[q]",
"q",
"for(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<q",
"i",
"q",
"i++",
"i++",
"i",
"{\n\t\t\tT[i] = sc.nextInt();\n\t\t}",
"{\n\t\t\tT[i] = sc.nextInt();\n\t\t}",
"T[i] = sc.nextInt()",
"T[i]",
"T",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<q",
"i",
"q",
"i++",
"i++",
"i",
"{\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}",
"{\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}",
"key = T[i]",
"key",
"T[i]",
"T",
"i",
"if(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}",
"binarySearch(S, key, n) == 1",
"binarySearch(S, key, n)",
"binarySearch",
"S",
"key",
"n",
"1",
"{\n\t\t\t\tans++;\n\t\t\t}",
"ans++",
"ans",
"System.out.println(ans)",
"System.out.println",
"System.out",
"System",
"System.out",
"ans",
"String arg[]",
"arg",
"public static int binarySearch(int A[], int key, int n){\n\t\tint mid = 0;\n\t\tint left = 0;\n\t\tint right = n;\n\t\twhile (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}",
"binarySearch",
"{\n\t\tint mid = 0;\n\t\tint left = 0;\n\t\tint right = n;\n\t\twhile (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}",
"int mid = 0;",
"mid",
"0",
"int left = 0;",
"left",
"0",
"int right = n;",
"right",
"n",
"while (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}",
"left < right",
"left",
"right",
"{\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}",
"mid = (left + right) / 2",
"mid",
"(left + right) / 2",
"(left + right)",
"left",
"right",
"2",
"if(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}",
"A[mid]==key",
"A[mid]",
"A",
"mid",
"key",
"{\n\t\t\t\treturn 1;\n\t\t\t}",
"return 1;",
"1",
"if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}",
"key < A[mid]",
"key",
"A[mid]",
"A",
"mid",
"{\n\t\t\t\tright = mid;\n\t\t\t}",
"right = mid",
"right",
"mid",
"{\n\t\t\t\tleft = mid + 1;\n\t\t\t}",
"left = mid + 1",
"left",
"mid + 1",
"mid",
"1",
"return -1;",
"-1",
"1",
"int A[]",
"A",
"int key",
"key",
"int n",
"n",
"public class Main {\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint S[] = new int[n+1];\n\t\tint key = 0;\n\t\tint ans = 0;\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}\n\t\tint q = sc.nextInt();\n\t\tint T[] = new int[q];\n\t\tfor(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static int binarySearch(int A[], int key, int n){\n\t\tint mid = 0;\n\t\tint left = 0;\n\t\tint right = n;\n\t\twhile (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint S[] = new int[n+1];\n\t\tint key = 0;\n\t\tint ans = 0;\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tS[i] = sc.nextInt();\n\t\t}\n\t\tint q = sc.nextInt();\n\t\tint T[] = new int[q];\n\t\tfor(int i=0; i<q; i++){\n\t\t\tT[i] = sc.nextInt();\n\t\t}\n\t\tfor(int i=0; i<q; i++){\n\t\t\tkey = T[i];\n\t\t\tif(binarySearch(S, key, n) == 1){\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t\tSystem.out.println(ans);\n\t}\n\t\n\tpublic static int binarySearch(int A[], int key, int n){\n\t\tint mid = 0;\n\t\tint left = 0;\n\t\tint right = n;\n\t\twhile (left < right){\n\t\t\tmid = (left + right) / 2;\n\t\t\tif(A[mid]==key){\n\t\t\t\treturn 1;\n\t\t\t} else if(key < A[mid]){\n\t\t\t\tright = mid;\n\t\t\t} else {\n\t\t\t\tleft = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String arg[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int S[] = new int[n+1];
int key = 0;
int ans = 0;
for(int i=0; i<n; i++){
S[i] = sc.nextInt();
}
int q = sc.nextInt();
int T[] = new int[q];
for(int i=0; i<q; i++){
T[i] = sc.nextInt();
}
for(int i=0; i<q; i++){
key = T[i];
if(binarySearch(S, key, n) == 1){
ans++;
}
}
System.out.println(ans);
}
public static int binarySearch(int A[], int key, int n){
int mid = 0;
int left = 0;
int right = n;
while (left < right){
mid = (left + right) / 2;
if(A[mid]==key){
return 1;
} else if(key < A[mid]){
right = mid;
} else {
left = mid + 1;
}
}
return -1;
}
}
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.