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,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
0,
13,
20,
17,
4,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
13,
20,
41,
13,
17,
41,
13,
20,
42,
40,
4,
13,
30,
41,
13,
4,
13,
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,
4,
18,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
0,
13,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
30,
0,
13,
17,
30,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
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
],
[
209,
5
],
[
209,
6
],
[
6,
7
],
[
209,
8
],
[
8,
9
],
[
209,
10
],
[
10,
11
],
[
209,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
31,
32
],
[
32,
33
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
14,
38
],
[
38,
39
],
[
14,
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
],
[
53,
55
],
[
14,
56
],
[
56,
57
],
[
56,
58
],
[
14,
59
],
[
59,
60
],
[
59,
61
],
[
14,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
66,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
92,
94
],
[
87,
95
],
[
85,
96
],
[
83,
97
],
[
97,
98
],
[
98,
99
],
[
71,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
100,
109
],
[
109,
110
],
[
109,
111
],
[
14,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
112,
117
],
[
12,
118
],
[
118,
119
],
[
209,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
209,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
209,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
137,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
148,
149
],
[
148,
150
],
[
143,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
143,
155
],
[
155,
156
],
[
156,
157
],
[
135,
158
],
[
158,
159
],
[
209,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
165,
167
],
[
162,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
173,
174
],
[
173,
175
],
[
168,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
168,
180
],
[
180,
181
],
[
181,
182
],
[
162,
183
],
[
183,
184
],
[
209,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
185,
189
],
[
189,
190
],
[
185,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
194,
198
],
[
193,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
199,
203
],
[
191,
204
],
[
204,
205
],
[
191,
206
],
[
206,
207
],
[
0,
208
],
[
208,
209
],
[
208,
210
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n \n static Pair[] queue;\n static int head;\n static int tail;\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int q = Integer.parseInt(sc.next());\n \n queue = new Pair[100010];\n initialize();\n for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }\n \n int t = 0;\n StringBuilder sb = new StringBuilder();\n while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }\n \n System.out.print(sb);\n }\n \n static void initialize(){\n head = tail = 0;\n }\n \n static boolean isEmpty(){\n return head == tail;\n }\n \n static void enqueue(Pair x){\n \n queue[tail] = x;\n if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }\n \n static Pair dequeue(){\n \n Pair x = queue[head];\n if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }\n \n static class Pair{\n String name;\n int time;\n\n public Pair(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n \n static Pair[] queue;\n static int head;\n static int tail;\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int q = Integer.parseInt(sc.next());\n \n queue = new Pair[100010];\n initialize();\n for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }\n \n int t = 0;\n StringBuilder sb = new StringBuilder();\n while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }\n \n System.out.print(sb);\n }\n \n static void initialize(){\n head = tail = 0;\n }\n \n static boolean isEmpty(){\n return head == tail;\n }\n \n static void enqueue(Pair x){\n \n queue[tail] = x;\n if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }\n \n static Pair dequeue(){\n \n Pair x = queue[head];\n if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }\n \n static class Pair{\n String name;\n int time;\n\n public Pair(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n}",
"Main",
"static Pair[] queue;",
"queue",
"static int head;",
"head",
"static int tail;",
"tail",
"public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int q = Integer.parseInt(sc.next());\n \n queue = new Pair[100010];\n initialize();\n for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }\n \n int t = 0;\n StringBuilder sb = new StringBuilder();\n while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }\n \n System.out.print(sb);\n }",
"main",
"{\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int q = Integer.parseInt(sc.next());\n \n queue = new Pair[100010];\n initialize();\n for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }\n \n int t = 0;\n StringBuilder sb = new StringBuilder();\n while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }\n \n System.out.print(sb);\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"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",
"queue = new Pair[100010]",
"queue",
"new Pair[100010]",
"100010",
"initialize()",
"initialize",
"for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }",
"{\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }",
"enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())))",
"enqueue",
"new Pair(sc.next(), Integer.parseInt(sc.next()))",
"int t = 0;",
"t",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }",
"Pair x = dequeue();",
"x",
"dequeue()",
"dequeue",
"if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }",
"x.time <= q",
"x.time",
"x",
"x.time",
"q",
"{\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }",
"t += x.time",
"t",
"x.time",
"x",
"x.time",
"sb.append(x.name).append(\" \").append(t).append(System.lineSeparator())",
"sb.append(x.name).append(\" \").append(t).append",
"sb.append(x.name).append(\" \").append(t)",
"sb.append(x.name).append(\" \").append",
"sb.append(x.name).append(\" \")",
"sb.append(x.name).append",
"sb.append(x.name)",
"sb.append",
"sb",
"x.name",
"x",
"x.name",
"\" \"",
"t",
"System.lineSeparator()",
"System.lineSeparator",
"System",
"{\n t += q;\n x.time -= q;\n enqueue(x);\n }",
"t += q",
"t",
"q",
"x.time -= q",
"x.time",
"x",
"x.time",
"q",
"enqueue(x)",
"enqueue",
"x",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"String[] args",
"args",
"static void initialize(){\n head = tail = 0;\n }",
"initialize",
"{\n head = tail = 0;\n }",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"static boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"static void enqueue(Pair x){\n \n queue[tail] = x;\n if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }",
"enqueue",
"{\n \n queue[tail] = x;\n if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }",
"queue[tail] = x",
"queue[tail]",
"queue",
"tail",
"x",
"if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }",
"tail+1 == queue.length",
"tail+1",
"tail",
"1",
"queue.length",
"queue",
"queue.length",
"{\n tail = 0;\n }",
"tail = 0",
"tail",
"0",
"{\n tail++;\n }",
"tail++",
"tail",
"Pair x",
"x",
"static Pair dequeue(){\n \n Pair x = queue[head];\n if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }",
"dequeue",
"{\n \n Pair x = queue[head];\n if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }",
"Pair x = queue[head];",
"x",
"queue[head]",
"queue",
"head",
"if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }",
"head+1 == queue.length",
"head+1",
"head",
"1",
"queue.length",
"queue",
"queue.length",
"{\n head = 0;\n }",
"head = 0",
"head",
"0",
"{\n head++;\n }",
"head++",
"head",
"return x;",
"x",
"static class Pair{\n String name;\n int time;\n\n public Pair(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }",
"Pair",
"String name;",
"name",
"int time;",
"time",
"public Pair(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Pair",
"{\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 class Main {\n \n static Pair[] queue;\n static int head;\n static int tail;\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int q = Integer.parseInt(sc.next());\n \n queue = new Pair[100010];\n initialize();\n for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }\n \n int t = 0;\n StringBuilder sb = new StringBuilder();\n while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }\n \n System.out.print(sb);\n }\n \n static void initialize(){\n head = tail = 0;\n }\n \n static boolean isEmpty(){\n return head == tail;\n }\n \n static void enqueue(Pair x){\n \n queue[tail] = x;\n if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }\n \n static Pair dequeue(){\n \n Pair x = queue[head];\n if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }\n \n static class Pair{\n String name;\n int time;\n\n public Pair(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n}",
"public class Main {\n \n static Pair[] queue;\n static int head;\n static int tail;\n\n public static void main(String[] args) {\n \n Scanner sc = new Scanner(System.in);\n \n int n = Integer.parseInt(sc.next());\n int q = Integer.parseInt(sc.next());\n \n queue = new Pair[100010];\n initialize();\n for(int i = 0; i < n; i++){\n enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));\n }\n \n int t = 0;\n StringBuilder sb = new StringBuilder();\n while(!isEmpty()){\n Pair x = dequeue();\n if(x.time <= q){\n t += x.time;\n sb.append(x.name).append(\" \").append(t).append(System.lineSeparator());\n }else{\n t += q;\n x.time -= q;\n enqueue(x);\n }\n }\n \n System.out.print(sb);\n }\n \n static void initialize(){\n head = tail = 0;\n }\n \n static boolean isEmpty(){\n return head == tail;\n }\n \n static void enqueue(Pair x){\n \n queue[tail] = x;\n if(tail+1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }\n \n static Pair dequeue(){\n \n Pair x = queue[head];\n if(head+1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }\n \n static class Pair{\n String name;\n int time;\n\n public Pair(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static Pair[] queue;
static int head;
static int tail;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = Integer.parseInt(sc.next());
int q = Integer.parseInt(sc.next());
queue = new Pair[100010];
initialize();
for(int i = 0; i < n; i++){
enqueue(new Pair(sc.next(), Integer.parseInt(sc.next())));
}
int t = 0;
StringBuilder sb = new StringBuilder();
while(!isEmpty()){
Pair x = dequeue();
if(x.time <= q){
t += x.time;
sb.append(x.name).append(" ").append(t).append(System.lineSeparator());
}else{
t += q;
x.time -= q;
enqueue(x);
}
}
System.out.print(sb);
}
static void initialize(){
head = tail = 0;
}
static boolean isEmpty(){
return head == tail;
}
static void enqueue(Pair x){
queue[tail] = x;
if(tail+1 == queue.length){
tail = 0;
}else{
tail++;
}
}
static Pair dequeue(){
Pair x = queue[head];
if(head+1 == queue.length){
head = 0;
}else{
head++;
}
return x;
}
static class Pair{
String name;
int time;
public Pair(String name, int time) {
this.name = name;
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,
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,
17,
41,
13,
20,
13,
41,
13,
17,
41,
13,
2,
13,
17,
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,
41,
13,
20,
41,
13,
41,
13,
41,
13,
0,
13,
17,
42,
2,
17,
13,
30,
0,
13,
18,
18,
13,
13,
13,
0,
13,
18,
18,
13,
13,
13,
14,
2,
13,
13,
30,
0,
18,
13,
13,
17,
40,
13,
4,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
2,
13,
13,
4,
18,
13,
17,
0,
13,
13,
30,
40,
13,
14,
2,
13,
13,
30,
0,
13,
17,
0,
18,
13,
13,
20,
0,
13,
13,
40,
13,
14,
2,
13,
13,
30,
0,
13,
17,
4,
18,
18,
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
],
[
14,
15
],
[
14,
16
],
[
13,
17
],
[
12,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
10,
23
],
[
23,
24
],
[
10,
25
],
[
25,
26
],
[
0,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
35,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
48,
53
],
[
45,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
59,
61
],
[
45,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
67,
68
],
[
67,
69
],
[
45,
70
],
[
70,
71
],
[
70,
72
],
[
45,
73
],
[
73,
74
],
[
73,
75
],
[
45,
77
],
[
77,
78
],
[
77,
79
],
[
45,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
45,
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
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
100,
105
],
[
97,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
45,
111
],
[
111,
112
],
[
111,
113
],
[
45,
114
],
[
114,
115
],
[
45,
116
],
[
116,
117
],
[
45,
118
],
[
118,
119
],
[
45,
120
],
[
120,
121
],
[
120,
122
],
[
45,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
127,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
127,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
146,
152
],
[
152,
153
],
[
146,
154
],
[
154,
155
],
[
155,
156
],
[
154,
157
],
[
146,
158
],
[
158,
159
],
[
159,
160
],
[
158,
161
],
[
146,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
165,
166
],
[
165,
167
],
[
146,
168
],
[
168,
169
],
[
169,
170
],
[
168,
171
],
[
146,
172
],
[
172,
173
],
[
172,
174
],
[
142,
175
],
[
175,
176
],
[
176,
177
],
[
175,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
175,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
175,
191
],
[
191,
192
],
[
191,
193
],
[
127,
194
],
[
194,
195
],
[
127,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
196,
200
],
[
200,
201
],
[
201,
202
],
[
201,
203
],
[
45,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
204,
209
],
[
29,
210
],
[
210,
211
]
] | [
"import java.io.*;\n\nclass Ps {\n\tString name;\n\tInteger t;\n\t\n\tpublic Ps( String name, Integer t )\n\t{\n\t\tthis.name = name;\n\t\tthis.t = t;\n\t}\n}\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\t\n\t\t\tfinal int LEN = 100005;\n\t\t\tPs[] queue = new Ps[LEN];\n\t\t\tint head = 0, tail = n-1;\t\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\n\t\t\tString name;\n int time, t;\n \ttime = 0;\n while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\n }\n System.out.print( output );\n \n } catch( IOException e ) {\n System.err.println( e );\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"class Ps {\n\tString name;\n\tInteger t;\n\t\n\tpublic Ps( String name, Integer t )\n\t{\n\t\tthis.name = name;\n\t\tthis.t = t;\n\t}\n}",
"Ps",
"String name;",
"name",
"Integer t;",
"t",
"public Ps( String name, Integer t )\n\t{\n\t\tthis.name = name;\n\t\tthis.t = t;\n\t}",
"Ps",
"{\n\t\tthis.name = name;\n\t\tthis.t = t;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.t = t",
"this.t",
"this",
"this.t",
"t",
"String name",
"name",
"Integer t",
"t",
"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\t\n\t\t\tfinal int LEN = 100005;\n\t\t\tPs[] queue = new Ps[LEN];\n\t\t\tint head = 0, tail = n-1;\t\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\n\t\t\tString name;\n int time, t;\n \ttime = 0;\n while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\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\t\n\t\t\tfinal int LEN = 100005;\n\t\t\tPs[] queue = new Ps[LEN];\n\t\t\tint head = 0, tail = n-1;\t\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\n\t\t\tString name;\n int time, t;\n \ttime = 0;\n while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\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\t\n\t\t\tfinal int LEN = 100005;\n\t\t\tPs[] queue = new Ps[LEN];\n\t\t\tint head = 0, tail = n-1;\t\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\n\t\t\tString name;\n int time, t;\n \ttime = 0;\n while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\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\t\n\t\t\tfinal int LEN = 100005;\n\t\t\tPs[] queue = new Ps[LEN];\n\t\t\tint head = 0, tail = n-1;\t\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\n\t\t\tString name;\n int time, t;\n \ttime = 0;\n while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\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\t\n\t\t\tfinal int LEN = 100005;\n\t\t\tPs[] queue = new Ps[LEN];\n\t\t\tint head = 0, tail = n-1;\t\t\t\t\n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }\n\n StringBuilder output = new\tStringBuilder( );\n\t\t\tString name;\n int time, t;\n \ttime = 0;\n while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\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",
"final int LEN = 100005;",
"LEN",
"100005",
"Ps[] queue = new Ps[LEN];",
"queue",
"new Ps[LEN]",
"LEN",
"int head = 0",
"head",
"0",
"tail = n-1;",
"tail",
"n-1",
"n",
"1",
"for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], 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 queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }",
"{\n str = kb.readLine().split( \" \" );\n queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );\n }",
"str = kb.readLine().split( \" \" )",
"str",
"kb.readLine().split( \" \" )",
"kb.readLine().split",
"kb.readLine()",
"kb.readLine",
"kb",
"\" \"",
"queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) )",
"queue[i]",
"queue",
"i",
"new Ps( str[0], Integer.parseInt( str[1] ) )",
"StringBuilder output = new\tStringBuilder( );",
"output",
"new\tStringBuilder( )",
"String name;",
"name",
"int time",
"time",
"t;",
"t",
"time = 0",
"time",
"0",
"while( 0 != n ) {\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\n }",
"0 != n",
"0",
"n",
"{\n\t \tname = queue[ head ].name;\n \tt = queue[ head ].t;\n \tif( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}\n \t\thead++;\n \t\tif( LEN == head ) { head = 0; }\n }",
"name = queue[ head ].name",
"name",
"queue[ head ].name",
"queue[ head ]",
"queue",
"head",
"queue[ head ].name",
"t = queue[ head ].t",
"t",
"queue[ head ].t",
"queue[ head ]",
"queue",
"head",
"queue[ head ].t",
"if( t <= q ) {\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t} else {\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}",
"t <= q",
"t",
"q",
"{\n \t\tqueue[ head ] = null;\n \t\tn--;\n \t\toutput.append( name );\n \t\toutput.append( \" \" );\n \t\toutput.append( time + t );\n \t\toutput.append( \"\\n\" );\n \t\ttime += t; \t\t\n \t}",
"queue[ head ] = null",
"queue[ head ]",
"queue",
"head",
"null",
"n--",
"n",
"output.append( name )",
"output.append",
"output",
"name",
"output.append( \" \" )",
"output.append",
"output",
"\" \"",
"output.append( time + t )",
"output.append",
"output",
"time + t",
"time",
"t",
"output.append( \"\\n\" )",
"output.append",
"output",
"\"\\n\"",
"time += t",
"time",
"t",
"{\n \t\ttail++;\n \t\tif( LEN == tail ) { tail = 0; }\n\t \t\tqueue[tail] = new Ps( name, t - q );\n\t time += q; \n \t}",
"tail++",
"tail",
"if( LEN == tail ) { tail = 0; }",
"LEN == tail",
"LEN",
"tail",
"{ tail = 0; }",
"tail = 0",
"tail",
"0",
"queue[tail] = new Ps( name, t - q )",
"queue[tail]",
"queue",
"tail",
"new Ps( name, t - q )",
"time += q",
"time",
"q",
"head++",
"head",
"if( LEN == head ) { head = 0; }",
"LEN == head",
"LEN",
"head",
"{ head = 0; }",
"head = 0",
"head",
"0",
"System.out.print( output )",
"System.out.print",
"System.out",
"System",
"System.out",
"output",
"String[] args",
"args"
] | import java.io.*;
class Ps {
String name;
Integer t;
public Ps( String name, Integer t )
{
this.name = name;
this.t = t;
}
}
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] );
final int LEN = 100005;
Ps[] queue = new Ps[LEN];
int head = 0, tail = n-1;
for( int i=0; i<n; i++ ) {
str = kb.readLine().split( " " );
queue[i] = new Ps( str[0], Integer.parseInt( str[1] ) );
}
StringBuilder output = new StringBuilder( );
String name;
int time, t;
time = 0;
while( 0 != n ) {
name = queue[ head ].name;
t = queue[ head ].t;
if( t <= q ) {
queue[ head ] = null;
n--;
output.append( name );
output.append( " " );
output.append( time + t );
output.append( "\n" );
time += t;
} else {
tail++;
if( LEN == tail ) { tail = 0; }
queue[tail] = new Ps( name, t - q );
time += q;
}
head++;
if( LEN == head ) { head = 0; }
}
System.out.print( output );
} catch( IOException e ) {
System.err.println( e );
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
17,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
18,
13,
13,
20,
0,
13,
17,
0,
13,
17,
42,
2,
13,
17,
30,
14,
2,
18,
18,
13,
13,
13,
13,
30,
0,
18,
18,
13,
13,
13,
13,
0,
13,
13,
30,
0,
13,
18,
18,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
18,
13,
13,
13,
17,
13,
11,
1,
0,
13,
13,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
40,
13,
40,
13,
14,
2,
13,
13,
3,
40,
13,
14,
2,
13,
13,
30,
0,
13,
17,
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
],
[
4,
11
],
[
11,
12
],
[
11,
13
],
[
13,
14
],
[
14,
15
],
[
14,
16
],
[
13,
17
],
[
17,
18
],
[
17,
19
],
[
11,
20
],
[
20,
21
],
[
11,
22
],
[
22,
23
],
[
4,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
27,
32
],
[
33,
33
],
[
33,
34
],
[
33,
35
],
[
33,
36
],
[
0,
37
],
[
201,
38
],
[
201,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
41,
47
],
[
47,
48
],
[
41,
49
],
[
49,
50
],
[
41,
51
],
[
51,
52
],
[
41,
53
],
[
53,
54
],
[
41,
55
],
[
55,
56
],
[
55,
57
],
[
41,
58
],
[
58,
59
],
[
58,
60
],
[
41,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
41,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
41,
71
],
[
71,
72
],
[
71,
73
],
[
41,
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
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
87,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
87,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
41,
103
],
[
103,
104
],
[
103,
105
],
[
41,
106
],
[
106,
107
],
[
106,
108
],
[
41,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
115,
121
],
[
114,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
123,
129
],
[
122,
130
],
[
130,
131
],
[
130,
132
],
[
114,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
133,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
147,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
147,
153
],
[
147,
154
],
[
133,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
155,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
162,
164
],
[
155,
165
],
[
165,
166
],
[
166,
167
],
[
155,
168
],
[
169,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
170,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
176,
178
],
[
133,
179
],
[
179,
180
],
[
133,
181
],
[
181,
182
],
[
113,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
113,
188
],
[
188,
189
],
[
113,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
39,
198
],
[
198,
199
],
[
0,
200
],
[
200,
201
],
[
200,
202
]
] | [
"import java.util.Scanner;\nclass Queue{\n\tString name=\"\";\n\tint time;\n\tpublic Queue(String str,int t) {\n\t\tname=str;\n\t\ttime=t;\n\t}\n\tpublic void Show() {\n\t\tSystem.out.println(name+\" \"+time);\n\t}\n}\n\npublic class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int i,j,n,q,t,count=0;\n String str=\"\";\n n=scan.nextInt();\n q=scan.nextInt();\n Queue[] queue=new Queue[n];\n for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }\n i=0;\n t=0;\n while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Queue{\n\tString name=\"\";\n\tint time;\n\tpublic Queue(String str,int t) {\n\t\tname=str;\n\t\ttime=t;\n\t}\n\tpublic void Show() {\n\t\tSystem.out.println(name+\" \"+time);\n\t}\n}",
"Queue",
"String name=\"\";",
"name",
"\"\"",
"int time;",
"time",
"public Queue(String str,int t) {\n\t\tname=str;\n\t\ttime=t;\n\t}",
"Queue",
"{\n\t\tname=str;\n\t\ttime=t;\n\t}",
"name=str",
"name",
"str",
"time=t",
"time",
"t",
"String str",
"str",
"int t",
"t",
"public void Show() {\n\t\tSystem.out.println(name+\" \"+time);\n\t}",
"Show",
"{\n\t\tSystem.out.println(name+\" \"+time);\n\t}",
"System.out.println(name+\" \"+time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name+\" \"+time",
"name+\" \"+time",
"name",
"\" \"",
"time",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int i,j,n,q,t,count=0;\n String str=\"\";\n n=scan.nextInt();\n q=scan.nextInt();\n Queue[] queue=new Queue[n];\n for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }\n i=0;\n t=0;\n while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }\n\t}\n}",
"Main",
"public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int i,j,n,q,t,count=0;\n String str=\"\";\n n=scan.nextInt();\n q=scan.nextInt();\n Queue[] queue=new Queue[n];\n for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }\n i=0;\n t=0;\n while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }\n\t}",
"main",
"{\n Scanner scan=new Scanner(System.in);\n int i,j,n,q,t,count=0;\n String str=\"\";\n n=scan.nextInt();\n q=scan.nextInt();\n Queue[] queue=new Queue[n];\n for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }\n i=0;\n t=0;\n while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }\n\t}",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int i",
"i",
"j",
"j",
"n",
"n",
"q",
"q",
"t",
"t",
"count=0;",
"count",
"0",
"String str=\"\";",
"str",
"\"\"",
"n=scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"q=scan.nextInt()",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Queue[] queue=new Queue[n];",
"queue",
"new Queue[n]",
"n",
"for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }",
"{\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }",
"str=scan.next()",
"str",
"scan.next()",
"scan.next",
"scan",
"t=scan.nextInt()",
"t",
"scan.nextInt()",
"scan.nextInt",
"scan",
"queue[i]=new Queue(str,t)",
"queue[i]",
"queue",
"i",
"new Queue(str,t)",
"i=0",
"i",
"0",
"t=0",
"t",
"0",
"while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }",
"n>=0",
"n",
"0",
"{\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }",
"if(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}",
"queue[i].time>q",
"queue[i].time",
"queue[i]",
"queue",
"i",
"queue[i].time",
"q",
"{\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}",
"queue[i].time-=q",
"queue[i].time",
"queue[i]",
"queue",
"i",
"queue[i].time",
"q",
"t+=q",
"t",
"q",
"{\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}",
"t+=queue[i].time",
"t",
"queue[i].time",
"queue[i]",
"queue",
"i",
"queue[i].time",
"System.out.println(queue[i].name+\" \"+t)",
"System.out.println",
"System.out",
"System",
"System.out",
"queue[i].name+\" \"+t",
"queue[i].name+\" \"+t",
"queue[i].name",
"queue[i]",
"queue",
"i",
"queue[i].name",
"\" \"",
"t",
"for(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}",
"j=i;",
"j=i",
"j",
"i",
"j<n-1",
"j",
"n-1",
"n",
"1",
"j++",
"j++",
"j",
"{\n \t\t\tqueue[j]=queue[j+1];\n \t\t}",
"{\n \t\t\tqueue[j]=queue[j+1];\n \t\t}",
"queue[j]=queue[j+1]",
"queue[j]",
"queue",
"j",
"queue[j+1]",
"queue",
"j+1",
"j",
"1",
"i--",
"i",
"n--",
"n",
"if(count==n)break;",
"count==n",
"count",
"n",
"break;",
"i++",
"i",
"if(i>=n) {\n \t\ti=0;\n \t}",
"i>=n",
"i",
"n",
"{\n \t\ti=0;\n \t}",
"i=0",
"i",
"0",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int i,j,n,q,t,count=0;\n String str=\"\";\n n=scan.nextInt();\n q=scan.nextInt();\n Queue[] queue=new Queue[n];\n for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }\n i=0;\n t=0;\n while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }\n\t}\n}",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int i,j,n,q,t,count=0;\n String str=\"\";\n n=scan.nextInt();\n q=scan.nextInt();\n Queue[] queue=new Queue[n];\n for(i=0;i<n;i++) {\n \tstr=scan.next();\n \tt=scan.nextInt();\n \tqueue[i]=new Queue(str,t);\n }\n i=0;\n t=0;\n while(n>=0) {\n \tif(queue[i].time>q) {\n \t\tqueue[i].time-=q;\n \t\tt+=q;\n \t}\n \telse {\n \t\tt+=queue[i].time;\n \tSystem.out.println(queue[i].name+\" \"+t);\n \t\tfor(j=i;j<n-1;j++) {\n \t\t\tqueue[j]=queue[j+1];\n \t\t}\n \t\ti--;\n \t\tn--;\n \t}\n \tif(count==n)break;\n \ti++;\n \tif(i>=n) {\n \t\ti=0;\n \t}\n }\n\t}\n}",
"Main"
] | import java.util.Scanner;
class Queue{
String name="";
int time;
public Queue(String str,int t) {
name=str;
time=t;
}
public void Show() {
System.out.println(name+" "+time);
}
}
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int i,j,n,q,t,count=0;
String str="";
n=scan.nextInt();
q=scan.nextInt();
Queue[] queue=new Queue[n];
for(i=0;i<n;i++) {
str=scan.next();
t=scan.nextInt();
queue[i]=new Queue(str,t);
}
i=0;
t=0;
while(n>=0) {
if(queue[i].time>q) {
queue[i].time-=q;
t+=q;
}
else {
t+=queue[i].time;
System.out.println(queue[i].name+" "+t);
for(j=i;j<n-1;j++) {
queue[j]=queue[j+1];
}
i--;
n--;
}
if(count==n)break;
i++;
if(i>=n) {
i=0;
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
29,
18,
36,
13,
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,
20,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
0,
18,
13,
13,
4,
18,
4,
18,
13,
17,
14,
2,
13,
13,
30,
4,
18,
13,
17,
0,
18,
13,
13,
2,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
4,
18,
13,
17,
17,
13,
4,
18,
13,
17,
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
],
[
14,
15
],
[
14,
16
],
[
4,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
0,
24
],
[
24,
25
],
[
24,
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
],
[
45,
47
],
[
28,
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
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
60,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
60,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
28,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
88,
97
],
[
97,
98
],
[
97,
99
],
[
88,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
88,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
114,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
123,
125
],
[
114,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
114,
130
],
[
130,
131
],
[
130,
132
],
[
110,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
143,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
143,
150
],
[
143,
151
],
[
133,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
26,
156
],
[
156,
157
]
] | [
"import java.util.*;\nclass Process{\n public String name;\n public int time;\n public String getName(){\n\treturn this.name;\n }\n public int getTime(){\n\treturn this.time;\n }\n}\nclass Main{\n\n public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint n = sc.nextInt(),q = sc.nextInt();\n\tint ttltime = 0;\n\t\n ArrayList<Process> p = new ArrayList<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}\n\t\n\twhile(p.size() > 0){\n\t int T = p.get(0).getTime();\n\t Process ptmp2 = new Process();\n\t ptmp2.name = p.get(0).getName();\n\t if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t } \n\t}\n \n }\n\n}",
"import java.util.*;",
"util.*",
"java",
"class Process{\n public String name;\n public int time;\n public String getName(){\n\treturn this.name;\n }\n public int getTime(){\n\treturn this.time;\n }\n}",
"Process",
"public String name;",
"name",
"public int time;",
"time",
"public String getName(){\n\treturn this.name;\n }",
"getName",
"{\n\treturn this.name;\n }",
"return this.name;",
"this.name",
"this",
"this.name",
"public int getTime(){\n\treturn this.time;\n }",
"getTime",
"{\n\treturn this.time;\n }",
"return this.time;",
"this.time",
"this",
"this.time",
"class Main{\n\n public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint n = sc.nextInt(),q = sc.nextInt();\n\tint ttltime = 0;\n\t\n ArrayList<Process> p = new ArrayList<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}\n\t\n\twhile(p.size() > 0){\n\t int T = p.get(0).getTime();\n\t Process ptmp2 = new Process();\n\t ptmp2.name = p.get(0).getName();\n\t if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t } \n\t}\n \n }\n\n}",
"Main",
"public static void main(String[] args) {\n\tScanner sc = new Scanner(System.in);\n\tint n = sc.nextInt(),q = sc.nextInt();\n\tint ttltime = 0;\n\t\n ArrayList<Process> p = new ArrayList<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}\n\t\n\twhile(p.size() > 0){\n\t int T = p.get(0).getTime();\n\t Process ptmp2 = new Process();\n\t ptmp2.name = p.get(0).getName();\n\t if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t } \n\t}\n \n }",
"main",
"{\n\tScanner sc = new Scanner(System.in);\n\tint n = sc.nextInt(),q = sc.nextInt();\n\tint ttltime = 0;\n\t\n ArrayList<Process> p = new ArrayList<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}\n\t\n\twhile(p.size() > 0){\n\t int T = p.get(0).getTime();\n\t Process ptmp2 = new Process();\n\t ptmp2.name = p.get(0).getName();\n\t if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t } \n\t}\n \n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int ttltime = 0;",
"ttltime",
"0",
"ArrayList<Process> p = new ArrayList<Process>();",
"p",
"new ArrayList<Process>()",
"for(int i = 0;i < n;i++){\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}",
"{\n\t Process ptmp = new Process();\n\t ptmp.name = sc.next();\n\t ptmp.time = sc.nextInt();\n\t p.add(ptmp);\n\t}",
"Process ptmp = new Process();",
"ptmp",
"new Process()",
"ptmp.name = sc.next()",
"ptmp.name",
"ptmp",
"ptmp.name",
"sc.next()",
"sc.next",
"sc",
"ptmp.time = sc.nextInt()",
"ptmp.time",
"ptmp",
"ptmp.time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"p.add(ptmp)",
"p.add",
"p",
"ptmp",
"while(p.size() > 0){\n\t int T = p.get(0).getTime();\n\t Process ptmp2 = new Process();\n\t ptmp2.name = p.get(0).getName();\n\t if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t } \n\t}",
"p.size() > 0",
"p.size()",
"p.size",
"p",
"0",
"{\n\t int T = p.get(0).getTime();\n\t Process ptmp2 = new Process();\n\t ptmp2.name = p.get(0).getName();\n\t if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t } \n\t}",
"int T = p.get(0).getTime();",
"T",
"p.get(0).getTime()",
"p.get(0).getTime",
"p.get(0)",
"p.get",
"p",
"0",
"Process ptmp2 = new Process();",
"ptmp2",
"new Process()",
"ptmp2.name = p.get(0).getName()",
"ptmp2.name",
"ptmp2",
"ptmp2.name",
"p.get(0).getName()",
"p.get(0).getName",
"p.get(0)",
"p.get",
"p",
"0",
"if(T > q){\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }\n\t else{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t }",
"T > q",
"T",
"q",
"{\n\t\tp.remove(0);\n\t\tptmp2.time = T - q;\n\t\tp.add(ptmp2);\n\t\tttltime += q;\n\t }",
"p.remove(0)",
"p.remove",
"p",
"0",
"ptmp2.time = T - q",
"ptmp2.time",
"ptmp2",
"ptmp2.time",
"T - q",
"T",
"q",
"p.add(ptmp2)",
"p.add",
"p",
"ptmp2",
"ttltime += q",
"ttltime",
"q",
"{\n\t\tttltime += T;\n\t\tSystem.out.println(p.get(0).getName()+\" \"+ttltime);\n\t\tp.remove(0);\n\t }",
"ttltime += T",
"ttltime",
"T",
"System.out.println(p.get(0).getName()+\" \"+ttltime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.get(0).getName()+\" \"+ttltime",
"p.get(0).getName()+\" \"+ttltime",
"p.get(0).getName()",
"p.get(0).getName",
"p.get(0)",
"p.get",
"p",
"0",
"\" \"",
"ttltime",
"p.remove(0)",
"p.remove",
"p",
"0",
"String[] args",
"args"
] | import java.util.*;
class Process{
public String name;
public int time;
public String getName(){
return this.name;
}
public int getTime(){
return this.time;
}
}
class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(),q = sc.nextInt();
int ttltime = 0;
ArrayList<Process> p = new ArrayList<Process>();
for(int i = 0;i < n;i++){
Process ptmp = new Process();
ptmp.name = sc.next();
ptmp.time = sc.nextInt();
p.add(ptmp);
}
while(p.size() > 0){
int T = p.get(0).getTime();
Process ptmp2 = new Process();
ptmp2.name = p.get(0).getName();
if(T > q){
p.remove(0);
ptmp2.time = T - q;
p.add(ptmp2);
ttltime += q;
}
else{
ttltime += T;
System.out.println(p.get(0).getName()+" "+ttltime);
p.remove(0);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
4,
18,
20,
23,
13,
12,
13,
30,
41,
13,
20,
42,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
41,
13,
17,
41,
13,
18,
13,
13,
42,
2,
13,
17,
30,
14,
2,
2,
2,
13,
2,
13,
17,
2,
13,
13,
2,
13,
17,
30,
41,
13,
20,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
4,
18,
18,
13,
13,
17,
30,
9,
0,
18,
13,
13,
20,
40,
13,
0,
13,
13,
0,
13,
18,
13,
13,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
4,
18,
18,
13,
13,
14,
2,
13,
17,
30,
40,
13,
9,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
18,
13,
13,
17,
13,
4,
18,
18,
13,
40,
13,
17,
40,
13,
9,
0,
13,
13,
4,
18,
18,
13,
40,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
14,
2,
4,
18,
18,
13,
13,
17,
30,
9,
4,
18,
18,
13,
13,
2,
2,
4,
18,
18,
13,
13,
17,
2,
13,
4,
18,
18,
13,
13,
3,
6,
13,
41,
13,
41,
13,
12,
13,
30,
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,
29,
18,
36,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
322,
5
],
[
322,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
10,
11
],
[
6,
12
],
[
12,
13
],
[
322,
14
],
[
14,
15
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
20,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
24,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
24,
35
],
[
35,
36
],
[
35,
37
],
[
24,
39
],
[
39,
40
],
[
39,
41
],
[
24,
42
],
[
42,
43
],
[
42,
44
],
[
24,
45
],
[
45,
46
],
[
45,
47
],
[
24,
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
],
[
24,
66
],
[
66,
67
],
[
66,
68
],
[
24,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
24,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
79,
80
],
[
81,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
81,
90
],
[
90,
91
],
[
90,
92
],
[
79,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
106,
107
],
[
106,
108
],
[
101,
109
],
[
109,
110
],
[
110,
111
],
[
101,
112
],
[
113,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
115,
121
],
[
114,
122
],
[
122,
123
],
[
113,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
113,
129
],
[
129,
130
],
[
93,
131
],
[
131,
132
],
[
131,
133
],
[
93,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
93,
139
],
[
139,
140
],
[
139,
141
],
[
78,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
78,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
78,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
162,
163
],
[
161,
164
],
[
157,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
173,
178
],
[
179,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
179,
185
],
[
179,
186
],
[
169,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
187,
193
],
[
169,
194
],
[
194,
195
],
[
169,
196
],
[
78,
197
],
[
197,
198
],
[
197,
199
],
[
78,
200
],
[
200,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
200,
206
],
[
24,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
207,
212
],
[
212,
213
],
[
212,
214
],
[
207,
215
],
[
215,
216
],
[
216,
217
],
[
207,
218
],
[
219,
219
],
[
219,
220
],
[
220,
221
],
[
221,
222
],
[
222,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
221,
227
],
[
220,
228
],
[
228,
229
],
[
219,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
230,
235
],
[
236,
236
],
[
236,
237
],
[
237,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
236,
242
],
[
236,
243
],
[
243,
244
],
[
243,
245
],
[
245,
246
],
[
246,
247
],
[
247,
248
],
[
247,
249
],
[
219,
250
],
[
322,
251
],
[
251,
252
],
[
251,
253
],
[
253,
254
],
[
251,
255
],
[
255,
256
],
[
251,
257
],
[
257,
258
],
[
257,
259
],
[
251,
260
],
[
260,
261
],
[
260,
262
],
[
262,
263
],
[
263,
264
],
[
264,
265
],
[
264,
266
],
[
263,
267
],
[
262,
268
],
[
268,
269
],
[
269,
270
],
[
269,
271
],
[
268,
272
],
[
260,
273
],
[
273,
274
],
[
260,
275
],
[
275,
276
],
[
251,
277
],
[
277,
278
],
[
277,
279
],
[
279,
280
],
[
280,
281
],
[
281,
282
],
[
281,
283
],
[
251,
284
],
[
284,
285
],
[
284,
286
],
[
286,
287
],
[
287,
288
],
[
288,
289
],
[
288,
290
],
[
287,
291
],
[
284,
292
],
[
292,
293
],
[
251,
294
],
[
294,
295
],
[
294,
296
],
[
296,
297
],
[
297,
298
],
[
298,
299
],
[
298,
300
],
[
251,
301
],
[
301,
302
],
[
301,
303
],
[
303,
304
],
[
304,
305
],
[
305,
306
],
[
305,
307
],
[
304,
308
],
[
301,
309
],
[
309,
310
],
[
251,
311
],
[
311,
312
],
[
311,
313
],
[
313,
314
],
[
314,
315
],
[
315,
316
],
[
315,
317
],
[
314,
318
],
[
311,
319
],
[
319,
320
],
[
0,
321
],
[
321,
322
],
[
321,
323
]
] | [
"import java.util.Scanner;\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tnew Main().run();\n\t}\n\tpublic void run(){\n\t\tScanner scan = new Scanner(System.in);\n\t\twhile(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tclass Process{\n\t\tString name;\n\t\tint time;\n\t\tpublic Process(){\n\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}\n\t\tpublic int getTime(){\n\t\t\treturn this.time;\n\t\t}\n\t\tpublic void setTime(int time){\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn this.name;\n\t\t}\n\t\tpublic void minusTime(int time){\n\t\t\tthis.time -= time;\n\t\t}\n\t\tpublic void setName(String name){\n\t\t\tthis.name = name;\n\t\t}\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tnew Main().run();\n\t}\n\tpublic void run(){\n\t\tScanner scan = new Scanner(System.in);\n\t\twhile(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tclass Process{\n\t\tString name;\n\t\tint time;\n\t\tpublic Process(){\n\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}\n\t\tpublic int getTime(){\n\t\t\treturn this.time;\n\t\t}\n\t\tpublic void setTime(int time){\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn this.name;\n\t\t}\n\t\tpublic void minusTime(int time){\n\t\t\tthis.time -= time;\n\t\t}\n\t\tpublic void setName(String name){\n\t\t\tthis.name = name;\n\t\t}\n\t}\n}",
"Main",
"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",
"public void run(){\n\t\tScanner scan = new Scanner(System.in);\n\t\twhile(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"run",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\twhile(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"while(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"scan.hasNext()",
"scan.hasNext",
"scan",
"{\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int sTime = scan.nextInt();",
"sTime",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Process[] schedule = new Process[n];",
"schedule",
"new Process[n]",
"n",
"int count = n;",
"count",
"n",
"int j = 0;",
"j",
"0",
"int sumTime = 0;",
"sumTime",
"0",
"for(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}",
"{\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}",
"schedule[i] = new Process(scan.next(),scan.nextInt())",
"schedule[i]",
"schedule",
"i",
"new Process(scan.next(),scan.nextInt())",
"int a = 0;",
"a",
"0",
"int len = schedule.length;",
"len",
"schedule.length",
"schedule",
"schedule.length",
"while(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}",
"count > 1",
"count",
"1",
"{\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}",
"if(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}",
"count < len/2 && j == len && count > 1000",
"count < len/2 && j == len && count > 1000",
"count < len/2",
"count",
"len/2",
"len",
"2",
"j == len",
"j",
"len",
"count > 1000",
"count",
"1000",
"{\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}",
"Process[] newSchedule = new Process[count];",
"newSchedule",
"new Process[count]",
"count",
"int k = 0;",
"k",
"0",
"for(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < len",
"i",
"len",
"i++",
"i++",
"i",
"{\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}",
"{\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}",
"if(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}",
"schedule[i].getTime() == 0",
"schedule[i].getTime()",
"schedule[i].getTime",
"schedule[i]",
"schedule",
"i",
"0",
"{\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}",
"continue;",
"newSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime())",
"newSchedule[k]",
"newSchedule",
"k",
"new Process(schedule[i].getName(),schedule[i].getTime())",
"k++",
"k",
"schedule = newSchedule",
"schedule",
"newSchedule",
"len = schedule.length",
"len",
"schedule.length",
"schedule",
"schedule.length",
"j = 0",
"j",
"0",
"if(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}",
"j >= len",
"j",
"len",
"{\n\t\t\t\t\tj %= len;\n\t\t\t\t}",
"j %= len",
"j",
"len",
"a = schedule[j].getTime()",
"a",
"schedule[j].getTime()",
"schedule[j].getTime",
"schedule[j]",
"schedule",
"j",
"if(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"a == 0",
"a",
"0",
"{\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"j++",
"j",
"continue;",
"if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"a <= sTime",
"a",
"sTime",
"{\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"sumTime += a",
"sumTime",
"a",
"System.out.println(schedule[j].getName() + \" \" + sumTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"schedule[j].getName() + \" \" + sumTime",
"schedule[j].getName() + \" \" + sumTime",
"schedule[j].getName()",
"schedule[j].getName",
"schedule[j]",
"schedule",
"j",
"\" \"",
"sumTime",
"schedule[j++].setTime(0)",
"schedule[j++].setTime",
"schedule[j++]",
"schedule",
"j++",
"j",
"0",
"count--",
"count",
"continue;",
"sumTime += sTime",
"sumTime",
"sTime",
"schedule[j++].minusTime(sTime)",
"schedule[j++].minusTime",
"schedule[j++]",
"schedule",
"j++",
"j",
"sTime",
"for(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < len",
"i",
"len",
"i++",
"i++",
"i",
"{\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}",
"{\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}",
"if(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"schedule[i].getTime() == 0",
"schedule[i].getTime()",
"schedule[i].getTime",
"schedule[i]",
"schedule",
"i",
"0",
"{\n\t\t\t\t\tcontinue;\n\t\t\t\t}",
"continue;",
"System.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()))",
"System.out.println",
"System.out",
"System",
"System.out",
"schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime())",
"schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime())",
"schedule[i].getName()",
"schedule[i].getName",
"schedule[i]",
"schedule",
"i",
"\" \"",
"(sumTime+schedule[i].getTime())",
"sumTime",
"schedule[i].getTime()",
"schedule[i].getTime",
"schedule[i]",
"schedule",
"i",
"break;",
"class Process{\n\t\tString name;\n\t\tint time;\n\t\tpublic Process(){\n\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}\n\t\tpublic int getTime(){\n\t\t\treturn this.time;\n\t\t}\n\t\tpublic void setTime(int time){\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn this.name;\n\t\t}\n\t\tpublic void minusTime(int time){\n\t\t\tthis.time -= time;\n\t\t}\n\t\tpublic void setName(String name){\n\t\t\tthis.name = name;\n\t\t}\n\t}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(){\n\t\t}",
"Process",
"{\n\t\t}",
"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 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 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 void minusTime(int time){\n\t\t\tthis.time -= time;\n\t\t}",
"minusTime",
"{\n\t\t\tthis.time -= time;\n\t\t}",
"this.time -= time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"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 class Main{\n\tpublic static void main(String[] args){\n\t\tnew Main().run();\n\t}\n\tpublic void run(){\n\t\tScanner scan = new Scanner(System.in);\n\t\twhile(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tclass Process{\n\t\tString name;\n\t\tint time;\n\t\tpublic Process(){\n\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}\n\t\tpublic int getTime(){\n\t\t\treturn this.time;\n\t\t}\n\t\tpublic void setTime(int time){\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn this.name;\n\t\t}\n\t\tpublic void minusTime(int time){\n\t\t\tthis.time -= time;\n\t\t}\n\t\tpublic void setName(String name){\n\t\t\tthis.name = name;\n\t\t}\n\t}\n}",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tnew Main().run();\n\t}\n\tpublic void run(){\n\t\tScanner scan = new Scanner(System.in);\n\t\twhile(scan.hasNext()){\n\t\t\tint n = scan.nextInt();\n\t\t\tint sTime = scan.nextInt();\n\t\t\tProcess[] schedule = new Process[n];\n\t\t\tint count = n;\n\t\t\tint j = 0;\n\t\t\tint sumTime = 0;\n\t\t\tfor(int i = 0;i < n;i++){\n\t\t\t\tschedule[i] = new Process(scan.next(),scan.nextInt());\n\t\t\t}\n\t\t\tint a = 0;\n\t\t\tint len = schedule.length;\n\t\t\twhile(count > 1){\n\t\t\t\tif(count < len/2 && j == len && count > 1000){\n\t\t\t\t\tProcess[] newSchedule = new Process[count];\n\t\t\t\t\tint k = 0;\n\t\t\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnewSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());\n\t\t\t\t\t\tk++;\n\t\t\t\t\t}\n\t\t\t\t\tschedule = newSchedule;\n\t\t\t\t\tlen = schedule.length;\n\t\t\t\t\tj = 0;\n\t\t\t\t}\n\t\t\t\tif(j >= len){\n\t\t\t\t\tj %= len;\n\t\t\t\t}\n\t\t\t\ta = schedule[j].getTime();\n\t\t\t\tif(a == 0){\n\t\t\t\t\tj++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}else if(a <= sTime){\n\t\t\t\t\tsumTime += a;\n\t\t\t\t\tSystem.out.println(schedule[j].getName() + \" \" + sumTime);\n\t\t\t\t\tschedule[j++].setTime(0);\n\t\t\t\t\tcount--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsumTime += sTime;\n\t\t\t\tschedule[j++].minusTime(sTime);\n\t\t\t}\n\t\t\tfor(int i = 0;i < len;i++){\n\t\t\t\tif(schedule[i].getTime() == 0){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tSystem.out.println(schedule[i].getName() + \" \" +(sumTime+schedule[i].getTime()));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tclass Process{\n\t\tString name;\n\t\tint time;\n\t\tpublic Process(){\n\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}\n\t\tpublic int getTime(){\n\t\t\treturn this.time;\n\t\t}\n\t\tpublic void setTime(int time){\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName(){\n\t\t\treturn this.name;\n\t\t}\n\t\tpublic void minusTime(int time){\n\t\t\tthis.time -= time;\n\t\t}\n\t\tpublic void setName(String name){\n\t\t\tthis.name = name;\n\t\t}\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args){
new Main().run();
}
public void run(){
Scanner scan = new Scanner(System.in);
while(scan.hasNext()){
int n = scan.nextInt();
int sTime = scan.nextInt();
Process[] schedule = new Process[n];
int count = n;
int j = 0;
int sumTime = 0;
for(int i = 0;i < n;i++){
schedule[i] = new Process(scan.next(),scan.nextInt());
}
int a = 0;
int len = schedule.length;
while(count > 1){
if(count < len/2 && j == len && count > 1000){
Process[] newSchedule = new Process[count];
int k = 0;
for(int i = 0;i < len;i++){
if(schedule[i].getTime() == 0){
continue;
}
newSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());
k++;
}
schedule = newSchedule;
len = schedule.length;
j = 0;
}
if(j >= len){
j %= len;
}
a = schedule[j].getTime();
if(a == 0){
j++;
continue;
}else if(a <= sTime){
sumTime += a;
System.out.println(schedule[j].getName() + " " + sumTime);
schedule[j++].setTime(0);
count--;
continue;
}
sumTime += sTime;
schedule[j++].minusTime(sTime);
}
for(int i = 0;i < len;i++){
if(schedule[i].getTime() == 0){
continue;
}
System.out.println(schedule[i].getName() + " " +(sumTime+schedule[i].getTime()));
break;
}
}
}
class Process{
String name;
int time;
public Process(){
}
public Process(String name,int time){
this.name = name;
this.time = time;
}
public int getTime(){
return this.time;
}
public void setTime(int time){
this.time = time;
}
public String getName(){
return this.name;
}
public void minusTime(int time){
this.time -= time;
}
public void setName(String name){
this.name = name;
}
}
} |
[
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,
2,
13,
17,
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,
41,
13,
17,
41,
13,
17,
41,
13,
13,
41,
13,
17,
42,
40,
13,
30,
14,
2,
2,
18,
18,
13,
13,
13,
13,
17,
30,
0,
13,
18,
18,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
18,
13,
13,
13,
17,
13,
30,
0,
18,
18,
13,
13,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
2,
13,
17,
0,
13,
13,
0,
13,
2,
2,
13,
17,
2,
13,
17,
14,
2,
13,
13,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
192,
11
],
[
192,
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
],
[
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
],
[
70,
72
],
[
69,
73
],
[
14,
74
],
[
74,
75
],
[
74,
76
],
[
14,
77
],
[
77,
78
],
[
77,
79
],
[
14,
80
],
[
80,
81
],
[
80,
82
],
[
14,
83
],
[
83,
84
],
[
83,
85
],
[
14,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
92,
98
],
[
91,
99
],
[
90,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
100,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
114,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
114,
120
],
[
114,
121
],
[
90,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
123,
129
],
[
122,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
134,
136
],
[
122,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
143,
145
],
[
122,
146
],
[
146,
147
],
[
146,
148
],
[
89,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
155,
157
],
[
89,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
12,
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
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
176,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
174,
187
],
[
187,
188
],
[
174,
189
],
[
189,
190
],
[
0,
191
],
[
191,
192
],
[
191,
193
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\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[] tmp = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(tmp[0]);\n\t\tint qTime = Integer.parseInt(tmp[1]);\n\n\t\tProcess[] pAry = new Process[n+1];\n\n\t\tfor(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}\n\n\t\tboolean isFinished = false;\n\t\tint top = 0;\n\t\tint tail = n;\n\t\tint cureentTime = 0;\n\n\t\twhile(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process {\n\n\tpublic Process(String name,int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic String name;\n\tpublic int time;\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 void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] tmp = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(tmp[0]);\n\t\tint qTime = Integer.parseInt(tmp[1]);\n\n\t\tProcess[] pAry = new Process[n+1];\n\n\t\tfor(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}\n\n\t\tboolean isFinished = false;\n\t\tint top = 0;\n\t\tint tail = n;\n\t\tint cureentTime = 0;\n\n\t\twhile(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\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\t\tString[] tmp = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(tmp[0]);\n\t\tint qTime = Integer.parseInt(tmp[1]);\n\n\t\tProcess[] pAry = new Process[n+1];\n\n\t\tfor(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}\n\n\t\tboolean isFinished = false;\n\t\tint top = 0;\n\t\tint tail = n;\n\t\tint cureentTime = 0;\n\n\t\twhile(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] tmp = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(tmp[0]);\n\t\tint qTime = Integer.parseInt(tmp[1]);\n\n\t\tProcess[] pAry = new Process[n+1];\n\n\t\tfor(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}\n\n\t\tboolean isFinished = false;\n\t\tint top = 0;\n\t\tint tail = n;\n\t\tint cureentTime = 0;\n\n\t\twhile(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\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[] tmp = br.readLine().split(\" \");",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(tmp[0]);",
"n",
"Integer.parseInt(tmp[0])",
"Integer.parseInt",
"Integer",
"tmp[0]",
"tmp",
"0",
"int qTime = Integer.parseInt(tmp[1]);",
"qTime",
"Integer.parseInt(tmp[1])",
"Integer.parseInt",
"Integer",
"tmp[1]",
"tmp",
"1",
"Process[] pAry = new Process[n+1];",
"pAry",
"new Process[n+1]",
"n+1",
"n",
"1",
"for(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}",
"{\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}",
"tmp = br.readLine().split(\" \")",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]))",
"pAry[i]",
"pAry",
"i",
"new Process(tmp[0],Integer.parseInt(tmp[1]))",
"boolean isFinished = false;",
"isFinished",
"false",
"int top = 0;",
"top",
"0",
"int tail = n;",
"tail",
"n",
"int cureentTime = 0;",
"cureentTime",
"0",
"while(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\n\t\t\t}\n\t\t}",
"!isFinished",
"isFinished",
"{\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\n\t\t\t}\n\t\t}",
"if(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}",
"pAry[top].time - qTime <= 0",
"pAry[top].time - qTime",
"pAry[top].time",
"pAry[top]",
"pAry",
"top",
"pAry[top].time",
"qTime",
"0",
"{\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}",
"cureentTime += pAry[top].time",
"cureentTime",
"pAry[top].time",
"pAry[top]",
"pAry",
"top",
"pAry[top].time",
"System.out.println(pAry[top].name + \" \" + cureentTime )",
"System.out.println",
"System.out",
"System",
"System.out",
"pAry[top].name + \" \" + cureentTime",
"pAry[top].name + \" \" + cureentTime",
"pAry[top].name",
"pAry[top]",
"pAry",
"top",
"pAry[top].name",
"\" \"",
"cureentTime",
"{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}",
"pAry[top].time -= qTime",
"pAry[top].time",
"pAry[top]",
"pAry",
"top",
"pAry[top].time",
"qTime",
"pAry[tail] = pAry[top]",
"pAry[tail]",
"pAry",
"tail",
"pAry[top]",
"pAry",
"top",
"tail = (tail + 1) % (n + 1)",
"tail",
"(tail + 1) % (n + 1)",
"(tail + 1)",
"tail",
"1",
"(n + 1)",
"n",
"1",
"cureentTime += qTime",
"cureentTime",
"qTime",
"top = (top + 1) % (n + 1)",
"top",
"(top + 1) % (n + 1)",
"(top + 1)",
"top",
"1",
"(n + 1)",
"n",
"1",
"if(top == tail){\n\t\t\t\tisFinished = true;\n\t\t\t}",
"top == tail",
"top",
"tail",
"{\n\t\t\t\tisFinished = true;\n\t\t\t}",
"isFinished = true",
"isFinished",
"true",
"String[] args",
"args",
"class Process {\n\n\tpublic Process(String name,int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic String name;\n\tpublic int time;\n}",
"Process",
"public String name;",
"name",
"public 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\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString[] tmp = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(tmp[0]);\n\t\tint qTime = Integer.parseInt(tmp[1]);\n\n\t\tProcess[] pAry = new Process[n+1];\n\n\t\tfor(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}\n\n\t\tboolean isFinished = false;\n\t\tint top = 0;\n\t\tint tail = n;\n\t\tint cureentTime = 0;\n\n\t\twhile(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\n\t\t\t}\n\t\t}\n\t}\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[] tmp = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(tmp[0]);\n\t\tint qTime = Integer.parseInt(tmp[1]);\n\n\t\tProcess[] pAry = new Process[n+1];\n\n\t\tfor(int i = 0 ; i < n ; i++){\n\t\t\ttmp = br.readLine().split(\" \");\n\t\t\tpAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));\n\t\t}\n\n\t\tboolean isFinished = false;\n\t\tint top = 0;\n\t\tint tail = n;\n\t\tint cureentTime = 0;\n\n\t\twhile(!isFinished){\n\n\t\t\tif(pAry[top].time - qTime <= 0){\n\t\t\t\tcureentTime += pAry[top].time;\n\t\t\t\tSystem.out.println(pAry[top].name + \" \" + cureentTime );\n\t\t\t}else{\n\t\t\t\tpAry[top].time -= qTime;\n\t\t\t\tpAry[tail] = pAry[top];\n\t\t\t\ttail = (tail + 1) % (n + 1);\n\t\t\t\tcureentTime += qTime;\n\t\t\t}\n\t\t\ttop = (top + 1) % (n + 1);\n\t\t\tif(top == tail){\n\t\t\t\tisFinished = true;\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 void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] tmp = br.readLine().split(" ");
int n = Integer.parseInt(tmp[0]);
int qTime = Integer.parseInt(tmp[1]);
Process[] pAry = new Process[n+1];
for(int i = 0 ; i < n ; i++){
tmp = br.readLine().split(" ");
pAry[i] = new Process(tmp[0],Integer.parseInt(tmp[1]));
}
boolean isFinished = false;
int top = 0;
int tail = n;
int cureentTime = 0;
while(!isFinished){
if(pAry[top].time - qTime <= 0){
cureentTime += pAry[top].time;
System.out.println(pAry[top].name + " " + cureentTime );
}else{
pAry[top].time -= qTime;
pAry[tail] = pAry[top];
tail = (tail + 1) % (n + 1);
cureentTime += qTime;
}
top = (top + 1) % (n + 1);
if(top == tail){
isFinished = true;
}
}
}
}
class Process {
public Process(String name,int time) {
this.name = name;
this.time = time;
}
public String name;
public int time;
} |
[
7,
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,
0,
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,
2,
4,
18,
13,
17,
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,
4,
18,
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,
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,
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
],
[
185,
14
],
[
185,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
17,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
17,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
17,
45
],
[
45,
46
],
[
45,
47
],
[
17,
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
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
60,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
79,
81
],
[
60,
82
],
[
82,
83
],
[
82,
84
],
[
60,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
17,
89
],
[
89,
90
],
[
89,
91
],
[
17,
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
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
98,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
123,
127
],
[
123,
128
],
[
109,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
129,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
15,
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
],
[
179,
181
],
[
176,
182
],
[
182,
183
],
[
0,
184
],
[
184,
185
],
[
184,
186
]
] | [
"import java.io.BufferedReader;\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 Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] l = br.readLine().split(\" \");\n int n = Integer.parseInt(l[0]);\n int q = Integer.parseInt(l[1]);\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }\n\n int allTime = 0;\n\n while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }\n }\n}\n\nclass Process {\n\n private String name;\n\n private int time;\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 int getTime() {\n return time;\n }\n\n public void reduceTime(int dt) {\n time -= dt;\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"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 Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] l = br.readLine().split(\" \");\n int n = Integer.parseInt(l[0]);\n int q = Integer.parseInt(l[1]);\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }\n\n int allTime = 0;\n\n while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] l = br.readLine().split(\" \");\n int n = Integer.parseInt(l[0]);\n int q = Integer.parseInt(l[1]);\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }\n\n int allTime = 0;\n\n while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] l = br.readLine().split(\" \");\n int n = Integer.parseInt(l[0]);\n int q = Integer.parseInt(l[1]);\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }\n\n int allTime = 0;\n\n while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] l = br.readLine().split(\" \");",
"l",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(l[0]);",
"n",
"Integer.parseInt(l[0])",
"Integer.parseInt",
"Integer",
"l[0]",
"l",
"0",
"int q = Integer.parseInt(l[1]);",
"q",
"Integer.parseInt(l[1])",
"Integer.parseInt",
"Integer",
"l[1]",
"l",
"1",
"Queue<Process> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }",
"{\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }",
"l = br.readLine().split(\" \")",
"l",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"String name = l[0];",
"name",
"l[0]",
"l",
"0",
"int time = Integer.parseInt(l[1]);",
"time",
"Integer.parseInt(l[1])",
"Integer.parseInt",
"Integer",
"l[1]",
"l",
"1",
"Process process = new Process(name, time);",
"process",
"new Process(name, time)",
"queue.offer(process)",
"queue.offer",
"queue",
"process",
"int allTime = 0;",
"allTime",
"0",
"while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }",
"Process process = queue.poll();",
"process",
"queue.poll()",
"queue.poll",
"queue",
"int time = process.getTime();",
"time",
"process.getTime()",
"process.getTime",
"process",
"if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }",
"time <= q",
"time",
"q",
"{\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n }",
"allTime += time",
"allTime",
"time",
"System.out.println(process.getName() + \" \" + allTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.getName() + \" \" + allTime",
"process.getName() + \" \" + allTime",
"process.getName()",
"process.getName",
"process",
"\" \"",
"allTime",
"{\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }",
"allTime += q",
"allTime",
"q",
"process.reduceTime(q)",
"process.reduceTime",
"process",
"q",
"queue.offer(process)",
"queue.offer",
"queue",
"process",
"String[] args",
"args",
"class Process {\n\n private String name;\n\n private int time;\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 int getTime() {\n return time;\n }\n\n public void reduceTime(int dt) {\n time -= dt;\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 String getName() {\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public int getTime() {\n return time;\n }",
"getTime",
"{\n return time;\n }",
"return time;",
"time",
"public void reduceTime(int dt) {\n time -= dt;\n }",
"reduceTime",
"{\n time -= dt;\n }",
"time -= dt",
"time",
"dt",
"int dt",
"dt",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] l = br.readLine().split(\" \");\n int n = Integer.parseInt(l[0]);\n int q = Integer.parseInt(l[1]);\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }\n\n int allTime = 0;\n\n while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] l = br.readLine().split(\" \");\n int n = Integer.parseInt(l[0]);\n int q = Integer.parseInt(l[1]);\n Queue<Process> queue = new LinkedList<>();\n\n for (int i = 0; i < n; i++) {\n l = br.readLine().split(\" \");\n String name = l[0];\n int time = Integer.parseInt(l[1]);\n Process process = new Process(name, time);\n queue.offer(process);\n }\n\n int allTime = 0;\n\n while (queue.size() > 0) {\n Process process = queue.poll();\n int time = process.getTime();\n if (time <= q) {\n allTime += time;\n System.out.println(process.getName() + \" \" + allTime);\n } else {\n allTime += q;\n process.reduceTime(q);\n queue.offer(process);\n }\n }\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] l = br.readLine().split(" ");
int n = Integer.parseInt(l[0]);
int q = Integer.parseInt(l[1]);
Queue<Process> queue = new LinkedList<>();
for (int i = 0; i < n; i++) {
l = br.readLine().split(" ");
String name = l[0];
int time = Integer.parseInt(l[1]);
Process process = new Process(name, time);
queue.offer(process);
}
int allTime = 0;
while (queue.size() > 0) {
Process process = queue.poll();
int time = process.getTime();
if (time <= q) {
allTime += time;
System.out.println(process.getName() + " " + allTime);
} else {
allTime += q;
process.reduceTime(q);
queue.offer(process);
}
}
}
}
class Process {
private String name;
private int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public String getName() {
return name;
}
public int getTime() {
return time;
}
public void reduceTime(int dt) {
time -= dt;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
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,
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,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
8,
2,
13,
13,
13,
13,
14,
2,
13,
13,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
30,
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
],
[
130,
8
],
[
130,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
11,
14
],
[
14,
15
],
[
11,
16
],
[
16,
17
],
[
16,
18
],
[
11,
19
],
[
19,
20
],
[
19,
21
],
[
11,
22
],
[
22,
23
],
[
22,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
11,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
11,
38
],
[
38,
39
],
[
39,
40
],
[
11,
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
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
56,
61
],
[
53,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
65,
66
],
[
65,
67
],
[
53,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
74,
75
],
[
74,
76
],
[
11,
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
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
95,
100
],
[
82,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
109,
110
],
[
109,
111
],
[
105,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
101,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
123,
123
],
[
123,
124
],
[
123,
125
],
[
123,
126
],
[
9,
127
],
[
127,
128
],
[
0,
129
],
[
129,
130
],
[
129,
131
]
] | [
"import java.io.*;\nimport java.util.*;\n\npublic class Main {\n public static void main(String args[]) {\n int n, q, time = 0;\n Queue<String> queueName = new ArrayDeque<String>();\n Queue<Integer> queueTime = new ArrayDeque<Integer>();\n Scanner sc = new Scanner(System.in);\n\n n = sc.nextInt();\n q = sc.nextInt();\n sc.nextLine();\n\n for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }\n\n while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String args[]) {\n int n, q, time = 0;\n Queue<String> queueName = new ArrayDeque<String>();\n Queue<Integer> queueTime = new ArrayDeque<Integer>();\n Scanner sc = new Scanner(System.in);\n\n n = sc.nextInt();\n q = sc.nextInt();\n sc.nextLine();\n\n for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }\n\n while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }\n }\n}",
"Main",
"public static void main(String args[]) {\n int n, q, time = 0;\n Queue<String> queueName = new ArrayDeque<String>();\n Queue<Integer> queueTime = new ArrayDeque<Integer>();\n Scanner sc = new Scanner(System.in);\n\n n = sc.nextInt();\n q = sc.nextInt();\n sc.nextLine();\n\n for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }\n\n while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }\n }",
"main",
"{\n int n, q, time = 0;\n Queue<String> queueName = new ArrayDeque<String>();\n Queue<Integer> queueTime = new ArrayDeque<Integer>();\n Scanner sc = new Scanner(System.in);\n\n n = sc.nextInt();\n q = sc.nextInt();\n sc.nextLine();\n\n for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }\n\n while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }\n }",
"int n",
"n",
"q",
"q",
"time = 0;",
"time",
"0",
"Queue<String> queueName = new ArrayDeque<String>();",
"queueName",
"new ArrayDeque<String>()",
"Queue<Integer> queueTime = new ArrayDeque<Integer>();",
"queueTime",
"new ArrayDeque<Integer>()",
"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",
"sc.nextLine()",
"sc.nextLine",
"sc",
"for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }",
"{\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }",
"String s[] = sc.nextLine().split(\" \");",
"s",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"queueName.add(s[0])",
"queueName.add",
"queueName",
"s[0]",
"s",
"0",
"queueTime.add(Integer.parseInt(s[1]))",
"queueTime.add",
"queueTime",
"Integer.parseInt(s[1])",
"Integer.parseInt",
"Integer",
"s[1]",
"s",
"1",
"while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }",
"!queueName.isEmpty()",
"queueName.isEmpty()",
"queueName.isEmpty",
"queueName",
"{\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }",
"String qn = queueName.poll();",
"qn",
"queueName.poll()",
"queueName.poll",
"queueName",
"int t = queueTime.poll();",
"t",
"queueTime.poll()",
"queueTime.poll",
"queueTime",
"time += (t > q)? q: t",
"time",
"(t > q)? q: t",
"(t > q)",
"t",
"q",
"q",
"t",
"if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }",
"t > q",
"t",
"q",
"{\n queueTime.add(t - q);\n queueName.add(qn);\n }",
"queueTime.add(t - q)",
"queueTime.add",
"queueTime",
"t - q",
"t",
"q",
"queueName.add(qn)",
"queueName.add",
"queueName",
"qn",
"{\n System.out.println(qn + \" \" + time);\n }",
"System.out.println(qn + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"qn + \" \" + time",
"qn + \" \" + time",
"qn",
"\" \"",
"time",
"String args[]",
"args",
"public class Main {\n public static void main(String args[]) {\n int n, q, time = 0;\n Queue<String> queueName = new ArrayDeque<String>();\n Queue<Integer> queueTime = new ArrayDeque<Integer>();\n Scanner sc = new Scanner(System.in);\n\n n = sc.nextInt();\n q = sc.nextInt();\n sc.nextLine();\n\n for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }\n\n while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }\n }\n}",
"public class Main {\n public static void main(String args[]) {\n int n, q, time = 0;\n Queue<String> queueName = new ArrayDeque<String>();\n Queue<Integer> queueTime = new ArrayDeque<Integer>();\n Scanner sc = new Scanner(System.in);\n\n n = sc.nextInt();\n q = sc.nextInt();\n sc.nextLine();\n\n for (int i = 0; i < n; i++) {\n String s[] = sc.nextLine().split(\" \");\n queueName.add(s[0]);\n queueTime.add(Integer.parseInt(s[1]));\n }\n\n while (!queueName.isEmpty()) {\n String qn = queueName.poll();\n int t = queueTime.poll();\n\n time += (t > q)? q: t;\n\n if (t > q) {\n queueTime.add(t - q);\n queueName.add(qn);\n } else {\n System.out.println(qn + \" \" + time);\n }\n }\n }\n}",
"Main"
] | import java.io.*;
import java.util.*;
public class Main {
public static void main(String args[]) {
int n, q, time = 0;
Queue<String> queueName = new ArrayDeque<String>();
Queue<Integer> queueTime = new ArrayDeque<Integer>();
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
q = sc.nextInt();
sc.nextLine();
for (int i = 0; i < n; i++) {
String s[] = sc.nextLine().split(" ");
queueName.add(s[0]);
queueTime.add(Integer.parseInt(s[1]));
}
while (!queueName.isEmpty()) {
String qn = queueName.poll();
int t = queueTime.poll();
time += (t > q)? q: t;
if (t > q) {
queueTime.add(t - q);
queueName.add(qn);
} else {
System.out.println(qn + " " + time);
}
}
}
} |
[
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,
17,
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,
42,
40,
4,
18,
13,
30,
14,
2,
4,
18,
13,
13,
30,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
4,
18,
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
],
[
117,
11
],
[
117,
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
],
[
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
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
49,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
60,
61
],
[
14,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
62,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
69,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
78,
82
],
[
74,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
87,
88
],
[
74,
89
],
[
89,
90
],
[
89,
91
],
[
68,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
92,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
12,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<String> nameQueue = new ArrayDeque<>();\n\t\tQueue<Integer> timeQueue = new ArrayDeque<>();\n\t\tint time = 0;\n\n\t\t// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ\n\t\tint num = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\n\t\t// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}\n\n\t\t// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}\n\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\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<String> nameQueue = new ArrayDeque<>();\n\t\tQueue<Integer> timeQueue = new ArrayDeque<>();\n\t\tint time = 0;\n\n\t\t// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ\n\t\tint num = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\n\t\t// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}\n\n\t\t// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<String> nameQueue = new ArrayDeque<>();\n\t\tQueue<Integer> timeQueue = new ArrayDeque<>();\n\t\tint time = 0;\n\n\t\t// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ\n\t\tint num = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\n\t\t// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}\n\n\t\t// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<String> nameQueue = new ArrayDeque<>();\n\t\tQueue<Integer> timeQueue = new ArrayDeque<>();\n\t\tint time = 0;\n\n\t\t// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ\n\t\tint num = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\n\t\t// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}\n\n\t\t// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}\n\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"Queue<String> nameQueue = new ArrayDeque<>();",
"nameQueue",
"new ArrayDeque<>()",
"Queue<Integer> timeQueue = new ArrayDeque<>();",
"timeQueue",
"new ArrayDeque<>()",
"int time = 0;",
"time",
"0",
"int num = scan.nextInt();",
"num",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int quantum = scan.nextInt();",
"quantum",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}",
"{\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}",
"nameQueue.add(scan.next())",
"nameQueue.add",
"nameQueue",
"scan.next()",
"scan.next",
"scan",
"timeQueue.add(scan.nextInt())",
"timeQueue.add",
"timeQueue",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}",
"!timeQueue.isEmpty()",
"timeQueue.isEmpty()",
"timeQueue.isEmpty",
"timeQueue",
"{\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}",
"if(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}",
"timeQueue.peek() > quantum",
"timeQueue.peek()",
"timeQueue.peek",
"timeQueue",
"quantum",
"{\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t}",
"timeQueue.add(timeQueue.poll() - quantum)",
"timeQueue.add",
"timeQueue",
"timeQueue.poll() - quantum",
"timeQueue.poll()",
"timeQueue.poll",
"timeQueue",
"quantum",
"nameQueue.add(nameQueue.poll())",
"nameQueue.add",
"nameQueue",
"nameQueue.poll()",
"nameQueue.poll",
"nameQueue",
"time += quantum",
"time",
"quantum",
"{\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}",
"time += timeQueue.poll()",
"time",
"timeQueue.poll()",
"timeQueue.poll",
"timeQueue",
"System.out.print(nameQueue.poll() + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"nameQueue.poll() + \" \"",
"nameQueue.poll()",
"nameQueue.poll",
"nameQueue",
"\" \"",
"System.out.println(time)",
"System.out.println",
"System.out",
"System",
"System.out",
"time",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<String> nameQueue = new ArrayDeque<>();\n\t\tQueue<Integer> timeQueue = new ArrayDeque<>();\n\t\tint time = 0;\n\n\t\t// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ\n\t\tint num = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\n\t\t// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}\n\n\t\t// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\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 scan = new Scanner(System.in);\n\t\tQueue<String> nameQueue = new ArrayDeque<>();\n\t\tQueue<Integer> timeQueue = new ArrayDeque<>();\n\t\tint time = 0;\n\n\t\t// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ\n\t\tint num = scan.nextInt();\n\t\tint quantum = scan.nextInt();\n\n\t\t// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnameQueue.add(scan.next());\n\t\t\ttimeQueue.add(scan.nextInt());\n\t\t}\n\n\t\t// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile(!timeQueue.isEmpty()) {\n\t\t\tif(timeQueue.peek() > quantum) {\n\t\t\t\ttimeQueue.add(timeQueue.poll() - quantum);\n\t\t\t\tnameQueue.add(nameQueue.poll());\n\t\t\t\ttime += quantum;\n\t\t\t} else {\n\t\t\t\ttime += timeQueue.poll();\n\t\t\t\tSystem.out.print(nameQueue.poll() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t}\n\n\t\t}\n\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);
Queue<String> nameQueue = new ArrayDeque<>();
Queue<Integer> timeQueue = new ArrayDeque<>();
int time = 0;
// ใใญใปในๆฐใจใฏใชใณใฟใ ใ่ชญใฟ่พผใ
int num = scan.nextInt();
int quantum = scan.nextInt();
// ๅใใญใปในใฎๆ
ๅ ฑใ่ชญใฟ่พผใ
for(int i = 0; i < num; i++) {
nameQueue.add(scan.next());
timeQueue.add(scan.nextInt());
}
// ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ
while(!timeQueue.isEmpty()) {
if(timeQueue.peek() > quantum) {
timeQueue.add(timeQueue.poll() - quantum);
nameQueue.add(nameQueue.poll());
time += quantum;
} else {
time += timeQueue.poll();
System.out.print(nameQueue.poll() + " ");
System.out.println(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,
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,
13,
13,
13,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
42,
2,
13,
13,
30,
0,
13,
17,
0,
13,
17,
11,
1,
0,
13,
17,
2,
13,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
2,
18,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
40,
13,
0,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
14,
13,
30,
0,
18,
13,
2,
13,
13,
18,
13,
13,
0,
18,
13,
2,
13,
13,
18,
13,
13,
9,
0,
13,
13,
40,
13,
23,
13,
23,
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,
26
],
[
26,
27
],
[
26,
28
],
[
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
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
42,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
55,
56
],
[
8,
57
],
[
57,
58
],
[
57,
59
],
[
57,
60
],
[
57,
61
],
[
57,
62
],
[
8,
63
],
[
63,
64
],
[
64,
65
],
[
6,
66
],
[
66,
67
],
[
4,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
73,
74
],
[
70,
75
],
[
75,
76
],
[
75,
77
],
[
70,
78
],
[
78,
79
],
[
70,
80
],
[
80,
81
],
[
80,
82
],
[
70,
83
],
[
83,
84
],
[
83,
85
],
[
70,
87
],
[
87,
88
],
[
87,
89
],
[
70,
90
],
[
90,
91
],
[
90,
92
],
[
70,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
101,
103
],
[
97,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
104,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
104,
114
],
[
114,
115
],
[
115,
116
],
[
104,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
118,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
142,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
142,
147
],
[
130,
148
],
[
148,
149
],
[
130,
150
],
[
150,
151
],
[
150,
152
],
[
126,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
153,
159
],
[
159,
160
],
[
159,
161
],
[
153,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
168,
170
],
[
165,
171
],
[
171,
172
],
[
171,
173
],
[
164,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
177,
179
],
[
174,
180
],
[
180,
181
],
[
180,
182
],
[
118,
183
],
[
97,
184
],
[
184,
185
],
[
184,
186
],
[
97,
187
],
[
187,
188
],
[
68,
189
],
[
189,
190
],
[
68,
191
],
[
191,
192
],
[
68,
193
],
[
193,
194
],
[
68,
195
],
[
195,
196
]
] | [
"import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}\n\n\tpublic static void Queue( String[] pro, int[] array,int num,int time){\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tint judge[] = new int[num];\n\t\tboolean judge_end = false;\n\t\tint count = 0;\n\t\t\n\t\twhile( end_count < num ){\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\n\t\t\t//System.out.println(count + \"้ฑ็ฎ\");\t\t//ๅบๅ\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\n\t\t\tcount ++;\n\t\t}\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}\n\n\tpublic static void Queue( String[] pro, int[] array,int num,int time){\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tint judge[] = new int[num];\n\t\tboolean judge_end = false;\n\t\tint count = 0;\n\t\t\n\t\twhile( end_count < num ){\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\n\t\t\t//System.out.println(count + \"้ฑ็ฎ\");\t\t//ๅบๅ\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\n\t\t\tcount ++;\n\t\t}\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int num = scanner.nextInt();",
"num",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int time = scanner.nextInt();",
"time",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] array = new int[num];",
"array",
"new int[num]",
"num",
"String[] pro = new String[num];",
"pro",
"new String[num]",
"num",
"for(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i ++",
"i ++",
"i",
"{\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}",
"{\n\t\t\tpro[i] = scanner.next();\n\t\t\tarray[i] = scanner.nextInt();\n\t\t}",
"pro[i] = scanner.next()",
"pro[i]",
"pro",
"i",
"scanner.next()",
"scanner.next",
"scanner",
"array[i] = scanner.nextInt()",
"array[i]",
"array",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"Queue(pro, array,num,time)",
"Queue",
"pro",
"array",
"num",
"time",
"scanner.close()",
"scanner.close",
"scanner",
"String args[]",
"args",
"public static void Queue( String[] pro, int[] array,int num,int time){\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tint judge[] = new int[num];\n\t\tboolean judge_end = false;\n\t\tint count = 0;\n\t\t\n\t\twhile( end_count < num ){\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\n\t\t\t//System.out.println(count + \"้ฑ็ฎ\");\t\t//ๅบๅ\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\n\t\t\tcount ++;\n\t\t}\n\t}",
"Queue",
"{\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tint judge[] = new int[num];\n\t\tboolean judge_end = false;\n\t\tint count = 0;\n\t\t\n\t\twhile( end_count < num ){\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\n\t\t\t//System.out.println(count + \"้ฑ็ฎ\");\t\t//ๅบๅ\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\n\t\t\tcount ++;\n\t\t}\n\t}",
"int sub;",
"sub",
"int i;",
"i",
"int end_count = 0;",
"end_count",
"0",
"int end_count_now;",
"end_count_now",
"int time_count = 0;",
"time_count",
"0",
"int judge[] = new int[num];",
"judge",
"new int[num]",
"num",
"boolean judge_end = false;",
"judge_end",
"false",
"int count = 0;",
"count",
"0",
"while( end_count < num ){\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\n\t\t\t//System.out.println(count + \"้ฑ็ฎ\");\t\t//ๅบๅ\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\n\t\t\tcount ++;\n\t\t}",
"end_count < num",
"end_count",
"num",
"{\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\n\t\t\t//System.out.println(count + \"้ฑ็ฎ\");\t\t//ๅบๅ\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\n\t\t\tcount ++;\n\t\t}",
"end_count_now = 0",
"end_count_now",
"0",
"judge_end = false",
"judge_end",
"false",
"for( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}",
"i = 0;",
"i = 0",
"i",
"0",
"i < num - end_count",
"i",
"num - end_count",
"num",
"end_count",
"i ++",
"i ++",
"i",
"{\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}",
"{\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}",
"sub = array[i] - time",
"sub",
"array[i] - time",
"array[i]",
"array",
"i",
"time",
"if(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}",
"sub <= 0",
"sub",
"0",
"{\n\t\t\t\t\ttime_count += array[i];\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๅบๅ\n\t\t\t\t\tend_count_now ++;\n\t\t\t\t\tjudge_end = true;\n\t\t\t\t}",
"time_count += array[i]",
"time_count",
"array[i]",
"array",
"i",
"System.out.println(pro[i] + \" \" + time_count)",
"System.out.println",
"System.out",
"System",
"System.out",
"pro[i] + \" \" + time_count",
"pro[i] + \" \" + time_count",
"pro[i]",
"pro",
"i",
"\" \"",
"time_count",
"end_count_now ++",
"end_count_now",
"judge_end = true",
"judge_end",
"true",
"{\n\t\t\t\t\tarray[i] -= time;\n\t\t\t\t\ttime_count += time;\n\t\t\t\t\tif(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}\n\t\t\t\t}",
"array[i] -= time",
"array[i]",
"array",
"i",
"time",
"time_count += time",
"time_count",
"time",
"if(judge_end) {\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}",
"judge_end",
"{\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\n\t\t\t\t\t}",
"array[i - end_count_now] = array[i]",
"array[i - end_count_now]",
"array",
"i - end_count_now",
"i",
"end_count_now",
"array[i]",
"array",
"i",
"pro[i - end_count_now] = pro[i]",
"pro[i - end_count_now]",
"pro",
"i - end_count_now",
"i",
"end_count_now",
"pro[i]",
"pro",
"i",
"continue;",
"end_count += end_count_now",
"end_count",
"end_count_now",
"count ++",
"count",
"String[] pro",
"pro",
"int[] array",
"array",
"int num",
"num",
"int time",
"time"
] | import java.util.Scanner;
class Main {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();//่ฆ็ด ๆฐ
int time = scanner.nextInt();//่ฆ็ด ๆฐ
int[] array = new int[num];
String[] pro = new String[num];
for(int i = 0; i < num; i ++ ){
pro[i] = scanner.next();
array[i] = scanner.nextInt();
}
Queue(pro, array,num,time);
scanner.close();
}
public static void Queue( String[] pro, int[] array,int num,int time){
int sub;
int i;
int end_count = 0;
int end_count_now;
int time_count = 0;
int judge[] = new int[num];
boolean judge_end = false;
int count = 0;
while( end_count < num ){
end_count_now = 0;
judge_end = false;
//System.out.println(count + "้ฑ็ฎ"); //ๅบๅ
for( i = 0; i < num - end_count; i ++ ){
sub = array[i] - time;
if(sub <= 0){
time_count += array[i];
System.out.println(pro[i] + " " + time_count); //ๅบๅ
end_count_now ++;
judge_end = true;
}else{
array[i] -= time;
time_count += time;
if(judge_end) {
array[i - end_count_now] = array[i];
pro[i - end_count_now] = pro[i];
}
}
continue;
}
end_count += end_count_now;
count ++;
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
17,
0,
18,
36,
13,
17,
0,
18,
36,
13,
13,
0,
18,
36,
13,
17,
0,
18,
36,
13,
20,
2,
13,
17,
0,
18,
36,
13,
2,
13,
17,
23,
13,
23,
13,
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,
40,
13,
0,
13,
13,
30,
4,
18,
18,
13,
13,
17,
23,
13,
12,
13,
30,
14,
40,
4,
13,
30,
41,
13,
13,
40,
13,
0,
13,
13,
29,
18,
13,
13,
30,
4,
18,
18,
13,
13,
17,
29,
17,
12,
13,
30,
41,
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,
2,
2,
13,
17,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
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,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
42,
40,
4,
18,
13,
30,
4,
18,
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
],
[
4,
12
],
[
12,
13
],
[
4,
14
],
[
14,
15
],
[
4,
16
],
[
16,
17
],
[
4,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
20,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
20,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
35
],
[
20,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
20,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
46,
47
],
[
46,
48
],
[
20,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
18,
56
],
[
56,
57
],
[
18,
58
],
[
58,
59
],
[
4,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
4,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
4,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
85,
91
],
[
91,
92
],
[
85,
93
],
[
93,
94
],
[
93,
95
],
[
81,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
78,
103
],
[
103,
104
],
[
4,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
108,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
112,
118
],
[
118,
119
],
[
118,
120
],
[
112,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
108,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
125,
132
],
[
132,
133
],
[
4,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
139,
144
],
[
136,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
147,
149
],
[
136,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
155,
156
],
[
155,
157
],
[
136,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
166,
167
],
[
167,
168
],
[
166,
169
],
[
170,
170
],
[
170,
171
],
[
170,
172
],
[
170,
173
],
[
173,
174
],
[
173,
175
],
[
158,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
180,
185
],
[
186,
186
],
[
186,
187
],
[
186,
188
],
[
186,
189
],
[
134,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
196,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
202,
207
],
[
196,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
210,
213
],
[
213,
214
],
[
213,
215
],
[
196,
216
],
[
216,
217
],
[
216,
218
],
[
218,
219
],
[
219,
220
],
[
218,
221
],
[
221,
222
],
[
221,
223
],
[
196,
224
],
[
224,
225
],
[
224,
226
],
[
196,
227
],
[
227,
228
],
[
227,
229
],
[
196,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
230,
235
],
[
235,
236
],
[
235,
237
],
[
230,
238
],
[
238,
239
],
[
239,
240
],
[
230,
241
],
[
242,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
243,
246
],
[
246,
247
],
[
247,
248
],
[
196,
249
],
[
249,
250
],
[
250,
251
],
[
251,
252
],
[
252,
253
],
[
249,
254
],
[
254,
255
],
[
255,
256
],
[
256,
257
],
[
255,
258
],
[
194,
259
],
[
259,
260
]
] | [
"import java.io.*;\nclass Que {\n int queStart;\n int queTail;\n int procTime;\n String[] arry;\n int elapsedTime;\n int max;\n public Que(int procTime, int maxLen) {\n this.queStart = 0;\n this.queTail = 0;\n this.procTime = procTime;\n this.elapsedTime = 0;\n this.arry = new String[maxLen+1];\n this.max = maxLen+1;\n }\n public boolean isEmpty() {\n return queStart == queTail;\n }\n public boolean isFull() {\n return queStart == (queTail+1) % max;\n }\n public void enqueue (String arg){\n if(!(isFull())) {\n arry[queTail] = arg;\n queTail++;\n queTail %= max;\n } else {\n System.out.println(\"full\");\n }\n }\n public String dequeue() {\n if(!isEmpty()){\n int now = queStart;\n queStart++;\n queStart %= max;\n return arry[now];\n } else {\n System.out.println(\"empty\");\n return null;\n }\n }\n public void eval(Que que){\n String[]ary = que.dequeue().split(\" \");\n String val = ary[0];\n int necessTime = Integer.parseInt(ary[1]);\n if(necessTime > procTime) {\n elapsedTime += procTime;\n que.enqueue(val+ \" \" + (necessTime-procTime));\n } else {\n elapsedTime += necessTime;\n System.out.println(val + \" \" + elapsedTime);\n }\n }\n}\n\nclass Main {\n public static void main(String...args)throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String [] init = br.readLine().split(\" \");\n int count = Integer.valueOf(init[0]);\n int procTime = Integer.valueOf(init[1]);\n \n int elapsedTime = 0;\n Que que = new Que(procTime, count);\n for(int i = 0; i < count; i++) {\n que.enqueue(br.readLine());\n }\n while(!que.isEmpty()){\n que.eval(que);\n }\n }\n}\n \n",
"import java.io.*;",
"io.*",
"java",
"class Que {\n int queStart;\n int queTail;\n int procTime;\n String[] arry;\n int elapsedTime;\n int max;\n public Que(int procTime, int maxLen) {\n this.queStart = 0;\n this.queTail = 0;\n this.procTime = procTime;\n this.elapsedTime = 0;\n this.arry = new String[maxLen+1];\n this.max = maxLen+1;\n }\n public boolean isEmpty() {\n return queStart == queTail;\n }\n public boolean isFull() {\n return queStart == (queTail+1) % max;\n }\n public void enqueue (String arg){\n if(!(isFull())) {\n arry[queTail] = arg;\n queTail++;\n queTail %= max;\n } else {\n System.out.println(\"full\");\n }\n }\n public String dequeue() {\n if(!isEmpty()){\n int now = queStart;\n queStart++;\n queStart %= max;\n return arry[now];\n } else {\n System.out.println(\"empty\");\n return null;\n }\n }\n public void eval(Que que){\n String[]ary = que.dequeue().split(\" \");\n String val = ary[0];\n int necessTime = Integer.parseInt(ary[1]);\n if(necessTime > procTime) {\n elapsedTime += procTime;\n que.enqueue(val+ \" \" + (necessTime-procTime));\n } else {\n elapsedTime += necessTime;\n System.out.println(val + \" \" + elapsedTime);\n }\n }\n}",
"Que",
"int queStart;",
"queStart",
"int queTail;",
"queTail",
"int procTime;",
"procTime",
"String[] arry;",
"arry",
"int elapsedTime;",
"elapsedTime",
"int max;",
"max",
"public Que(int procTime, int maxLen) {\n this.queStart = 0;\n this.queTail = 0;\n this.procTime = procTime;\n this.elapsedTime = 0;\n this.arry = new String[maxLen+1];\n this.max = maxLen+1;\n }",
"Que",
"{\n this.queStart = 0;\n this.queTail = 0;\n this.procTime = procTime;\n this.elapsedTime = 0;\n this.arry = new String[maxLen+1];\n this.max = maxLen+1;\n }",
"this.queStart = 0",
"this.queStart",
"this",
"this.queStart",
"0",
"this.queTail = 0",
"this.queTail",
"this",
"this.queTail",
"0",
"this.procTime = procTime",
"this.procTime",
"this",
"this.procTime",
"procTime",
"this.elapsedTime = 0",
"this.elapsedTime",
"this",
"this.elapsedTime",
"0",
"this.arry = new String[maxLen+1]",
"this.arry",
"this",
"this.arry",
"new String[maxLen+1]",
"maxLen+1",
"maxLen",
"1",
"this.max = maxLen+1",
"this.max",
"this",
"this.max",
"maxLen+1",
"maxLen",
"1",
"int procTime",
"procTime",
"int maxLen",
"maxLen",
"public boolean isEmpty() {\n return queStart == queTail;\n }",
"isEmpty",
"{\n return queStart == queTail;\n }",
"return queStart == queTail;",
"queStart == queTail",
"queStart",
"queTail",
"public boolean isFull() {\n return queStart == (queTail+1) % max;\n }",
"isFull",
"{\n return queStart == (queTail+1) % max;\n }",
"return queStart == (queTail+1) % max;",
"queStart == (queTail+1) % max",
"queStart",
"(queTail+1) % max",
"(queTail+1)",
"queTail",
"1",
"max",
"public void enqueue (String arg){\n if(!(isFull())) {\n arry[queTail] = arg;\n queTail++;\n queTail %= max;\n } else {\n System.out.println(\"full\");\n }\n }",
"enqueue",
"{\n if(!(isFull())) {\n arry[queTail] = arg;\n queTail++;\n queTail %= max;\n } else {\n System.out.println(\"full\");\n }\n }",
"if(!(isFull())) {\n arry[queTail] = arg;\n queTail++;\n queTail %= max;\n } else {\n System.out.println(\"full\");\n }",
"!(isFull())",
"(isFull())",
"isFull",
"{\n arry[queTail] = arg;\n queTail++;\n queTail %= max;\n }",
"arry[queTail] = arg",
"arry[queTail]",
"arry",
"queTail",
"arg",
"queTail++",
"queTail",
"queTail %= max",
"queTail",
"max",
"{\n System.out.println(\"full\");\n }",
"System.out.println(\"full\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"full\"",
"String arg",
"arg",
"public String dequeue() {\n if(!isEmpty()){\n int now = queStart;\n queStart++;\n queStart %= max;\n return arry[now];\n } else {\n System.out.println(\"empty\");\n return null;\n }\n }",
"dequeue",
"{\n if(!isEmpty()){\n int now = queStart;\n queStart++;\n queStart %= max;\n return arry[now];\n } else {\n System.out.println(\"empty\");\n return null;\n }\n }",
"if(!isEmpty()){\n int now = queStart;\n queStart++;\n queStart %= max;\n return arry[now];\n } else {\n System.out.println(\"empty\");\n return null;\n }",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n int now = queStart;\n queStart++;\n queStart %= max;\n return arry[now];\n }",
"int now = queStart;",
"now",
"queStart",
"queStart++",
"queStart",
"queStart %= max",
"queStart",
"max",
"return arry[now];",
"arry[now]",
"arry",
"now",
"{\n System.out.println(\"empty\");\n return null;\n }",
"System.out.println(\"empty\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"empty\"",
"return null;",
"null",
"public void eval(Que que){\n String[]ary = que.dequeue().split(\" \");\n String val = ary[0];\n int necessTime = Integer.parseInt(ary[1]);\n if(necessTime > procTime) {\n elapsedTime += procTime;\n que.enqueue(val+ \" \" + (necessTime-procTime));\n } else {\n elapsedTime += necessTime;\n System.out.println(val + \" \" + elapsedTime);\n }\n }",
"eval",
"{\n String[]ary = que.dequeue().split(\" \");\n String val = ary[0];\n int necessTime = Integer.parseInt(ary[1]);\n if(necessTime > procTime) {\n elapsedTime += procTime;\n que.enqueue(val+ \" \" + (necessTime-procTime));\n } else {\n elapsedTime += necessTime;\n System.out.println(val + \" \" + elapsedTime);\n }\n }",
"String[]ary = que.dequeue().split(\" \");",
"ary",
"que.dequeue().split(\" \")",
"que.dequeue().split",
"que.dequeue()",
"que.dequeue",
"que",
"\" \"",
"String val = ary[0];",
"val",
"ary[0]",
"ary",
"0",
"int necessTime = Integer.parseInt(ary[1]);",
"necessTime",
"Integer.parseInt(ary[1])",
"Integer.parseInt",
"Integer",
"ary[1]",
"ary",
"1",
"if(necessTime > procTime) {\n elapsedTime += procTime;\n que.enqueue(val+ \" \" + (necessTime-procTime));\n } else {\n elapsedTime += necessTime;\n System.out.println(val + \" \" + elapsedTime);\n }",
"necessTime > procTime",
"necessTime",
"procTime",
"{\n elapsedTime += procTime;\n que.enqueue(val+ \" \" + (necessTime-procTime));\n }",
"elapsedTime += procTime",
"elapsedTime",
"procTime",
"que.enqueue(val+ \" \" + (necessTime-procTime))",
"que.enqueue",
"que",
"val+ \" \" + (necessTime-procTime)",
"val+ \" \" + (necessTime-procTime)",
"val",
"\" \"",
"(necessTime-procTime)",
"necessTime",
"procTime",
"{\n elapsedTime += necessTime;\n System.out.println(val + \" \" + elapsedTime);\n }",
"elapsedTime += necessTime",
"elapsedTime",
"necessTime",
"System.out.println(val + \" \" + elapsedTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"val + \" \" + elapsedTime",
"val + \" \" + elapsedTime",
"val",
"\" \"",
"elapsedTime",
"Que que",
"que",
"class Main {\n public static void main(String...args)throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String [] init = br.readLine().split(\" \");\n int count = Integer.valueOf(init[0]);\n int procTime = Integer.valueOf(init[1]);\n \n int elapsedTime = 0;\n Que que = new Que(procTime, count);\n for(int i = 0; i < count; i++) {\n que.enqueue(br.readLine());\n }\n while(!que.isEmpty()){\n que.eval(que);\n }\n }\n}",
"Main",
"public static void main(String...args)throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String [] init = br.readLine().split(\" \");\n int count = Integer.valueOf(init[0]);\n int procTime = Integer.valueOf(init[1]);\n \n int elapsedTime = 0;\n Que que = new Que(procTime, count);\n for(int i = 0; i < count; i++) {\n que.enqueue(br.readLine());\n }\n while(!que.isEmpty()){\n que.eval(que);\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String [] init = br.readLine().split(\" \");\n int count = Integer.valueOf(init[0]);\n int procTime = Integer.valueOf(init[1]);\n \n int elapsedTime = 0;\n Que que = new Que(procTime, count);\n for(int i = 0; i < count; i++) {\n que.enqueue(br.readLine());\n }\n while(!que.isEmpty()){\n que.eval(que);\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String [] init = br.readLine().split(\" \");",
"init",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int count = Integer.valueOf(init[0]);",
"count",
"Integer.valueOf(init[0])",
"Integer.valueOf",
"Integer",
"init[0]",
"init",
"0",
"int procTime = Integer.valueOf(init[1]);",
"procTime",
"Integer.valueOf(init[1])",
"Integer.valueOf",
"Integer",
"init[1]",
"init",
"1",
"int elapsedTime = 0;",
"elapsedTime",
"0",
"Que que = new Que(procTime, count);",
"que",
"new Que(procTime, count)",
"for(int i = 0; i < count; i++) {\n que.enqueue(br.readLine());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < count",
"i",
"count",
"i++",
"i++",
"i",
"{\n que.enqueue(br.readLine());\n }",
"{\n que.enqueue(br.readLine());\n }",
"que.enqueue(br.readLine())",
"que.enqueue",
"que",
"br.readLine()",
"br.readLine",
"br",
"while(!que.isEmpty()){\n que.eval(que);\n }",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n que.eval(que);\n }",
"que.eval(que)",
"que.eval",
"que",
"que",
"String...args",
"args"
] | import java.io.*;
class Que {
int queStart;
int queTail;
int procTime;
String[] arry;
int elapsedTime;
int max;
public Que(int procTime, int maxLen) {
this.queStart = 0;
this.queTail = 0;
this.procTime = procTime;
this.elapsedTime = 0;
this.arry = new String[maxLen+1];
this.max = maxLen+1;
}
public boolean isEmpty() {
return queStart == queTail;
}
public boolean isFull() {
return queStart == (queTail+1) % max;
}
public void enqueue (String arg){
if(!(isFull())) {
arry[queTail] = arg;
queTail++;
queTail %= max;
} else {
System.out.println("full");
}
}
public String dequeue() {
if(!isEmpty()){
int now = queStart;
queStart++;
queStart %= max;
return arry[now];
} else {
System.out.println("empty");
return null;
}
}
public void eval(Que que){
String[]ary = que.dequeue().split(" ");
String val = ary[0];
int necessTime = Integer.parseInt(ary[1]);
if(necessTime > procTime) {
elapsedTime += procTime;
que.enqueue(val+ " " + (necessTime-procTime));
} else {
elapsedTime += necessTime;
System.out.println(val + " " + elapsedTime);
}
}
}
class Main {
public static void main(String...args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String [] init = br.readLine().split(" ");
int count = Integer.valueOf(init[0]);
int procTime = Integer.valueOf(init[1]);
int elapsedTime = 0;
Que que = new Que(procTime, count);
for(int i = 0; i < count; i++) {
que.enqueue(br.readLine());
}
while(!que.isEmpty()){
que.eval(que);
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
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,
6,
13,
12,
13,
30,
12,
13,
30,
41,
13,
17,
41,
13,
4,
18,
13,
13,
41,
13,
4,
18,
13,
13,
14,
2,
4,
18,
13,
17,
17,
30,
0,
13,
2,
13,
13,
14,
2,
4,
18,
13,
17,
17,
30,
0,
13,
2,
13,
13,
14,
2,
4,
18,
13,
17,
17,
30,
0,
13,
2,
13,
13,
14,
2,
4,
18,
13,
17,
17,
30,
0,
13,
2,
13,
13,
29,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
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
],
[
14,
16
],
[
11,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
11,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
11,
27
],
[
27,
28
],
[
27,
29
],
[
11,
30
],
[
30,
31
],
[
30,
32
],
[
11,
33
],
[
33,
34
],
[
33,
35
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
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
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
57,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
69,
70
],
[
70,
71
],
[
11,
72
],
[
72,
73
],
[
72,
74
],
[
11,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
11,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
11,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
88,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
94,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
108,
113
],
[
94,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
94,
119
],
[
119,
120
],
[
119,
121
],
[
94,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
88,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
130,
136
],
[
136,
137
],
[
136,
138
],
[
130,
139
],
[
139,
140
],
[
139,
141
],
[
130,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
130,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
154,
155
],
[
154,
156
],
[
130,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
161,
163
],
[
130,
164
],
[
164,
165
],
[
164,
166
],
[
130,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
9,
175
],
[
175,
176
],
[
0,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
179,
181
],
[
177,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
191,
192
],
[
190,
193
],
[
184,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
196,
199
],
[
184,
200
],
[
200,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
202,
205
],
[
201,
206
],
[
200,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
210,
212
],
[
184,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
215,
218
],
[
214,
219
],
[
213,
220
],
[
220,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
223,
225
],
[
184,
226
],
[
226,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
228,
231
],
[
227,
232
],
[
226,
233
],
[
233,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
236,
238
],
[
184,
239
],
[
239,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
241,
244
],
[
240,
245
],
[
239,
246
],
[
246,
247
],
[
247,
248
],
[
247,
249
],
[
249,
250
],
[
249,
251
],
[
184,
252
],
[
252,
253
],
[
182,
254
],
[
254,
255
],
[
182,
256
],
[
256,
257
],
[
182,
258
],
[
258,
259
],
[
177,
260
],
[
260,
261
],
[
260,
262
],
[
262,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
265,
267
],
[
263,
268
],
[
268,
269
],
[
268,
270
],
[
270,
271
],
[
270,
272
],
[
263,
273
],
[
273,
274
],
[
274,
275
],
[
263,
276
],
[
277,
277
],
[
277,
278
],
[
278,
279
],
[
279,
280
],
[
280,
281
],
[
280,
282
],
[
278,
283
],
[
283,
284
],
[
283,
285
],
[
260,
286
],
[
286,
287
]
] | [
"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\tmathClass keisan;\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 amari = 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\n\n\n\n\t}\n}\nclass mathClass{\n\n\tpublic mathClass(){\n\n\t}\n\n\t//?????????????????????\n\tpublic int shisokuEnzan(String stringX,String stringY,String op){\n\t\tint ret =0;\n\t\tint x =Integer.parseInt(stringX);\n\t\tint y =Integer.parseInt(stringY);\n//\t\tSystem.out.println(x+\" \"+op+\" \"+y+\" wo okonau\");\n\n\t\tif(op.charAt(0) == '+'){\n\t\t\tret = x + y;\n\t\t}\n\t\tif(op.charAt(0) == '-'){\n\t\t\tret = x - y;\n\t\t}\n\t\tif(op.charAt(0) == '*'){\n\t\t\tret = x * y;\n\t\t}\n\t\tif(op.charAt(0) == '/'){\n\t\t\tret = x / y;\n\t\t}\n\t\treturn ret;\n\t}\n\n\t//???????????ยจ?????????\n\tpublic void disp(int[] ary){\n\t\tfor(int i=0;i<ary.length;i++){\n\t\t\tSystem.out.println(ary[i]);\n\t\t}\n\t}\n\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\tmathClass keisan;\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 amari = 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\n\n\n\n\t}\n}",
"Main",
"public static void main(String[] args)throws NumberFormatException, IOException{\n//\t\tSystem.out.println(\" \");\n\t\tmathClass keisan;\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 amari = 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\n\n\n\n\t}",
"main",
"{\n//\t\tSystem.out.println(\" \");\n\t\tmathClass keisan;\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 amari = 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\n\n\n\n\t}",
"mathClass keisan;",
"keisan",
"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 amari = 0;",
"amari",
"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",
"class mathClass{\n\n\tpublic mathClass(){\n\n\t}\n\n\t//?????????????????????\n\tpublic int shisokuEnzan(String stringX,String stringY,String op){\n\t\tint ret =0;\n\t\tint x =Integer.parseInt(stringX);\n\t\tint y =Integer.parseInt(stringY);\n//\t\tSystem.out.println(x+\" \"+op+\" \"+y+\" wo okonau\");\n\n\t\tif(op.charAt(0) == '+'){\n\t\t\tret = x + y;\n\t\t}\n\t\tif(op.charAt(0) == '-'){\n\t\t\tret = x - y;\n\t\t}\n\t\tif(op.charAt(0) == '*'){\n\t\t\tret = x * y;\n\t\t}\n\t\tif(op.charAt(0) == '/'){\n\t\t\tret = x / y;\n\t\t}\n\t\treturn ret;\n\t}\n\n\t//???????????ยจ?????????\n\tpublic void disp(int[] ary){\n\t\tfor(int i=0;i<ary.length;i++){\n\t\t\tSystem.out.println(ary[i]);\n\t\t}\n\t}\n\n}",
"mathClass",
"public mathClass(){\n\n\t}",
"mathClass",
"{\n\n\t}",
"//?????????????????????\n\tpublic int shisokuEnzan(String stringX,String stringY,String op){\n\t\tint ret =0;\n\t\tint x =Integer.parseInt(stringX);\n\t\tint y =Integer.parseInt(stringY);\n//\t\tSystem.out.println(x+\" \"+op+\" \"+y+\" wo okonau\");\n\n\t\tif(op.charAt(0) == '+'){\n\t\t\tret = x + y;\n\t\t}\n\t\tif(op.charAt(0) == '-'){\n\t\t\tret = x - y;\n\t\t}\n\t\tif(op.charAt(0) == '*'){\n\t\t\tret = x * y;\n\t\t}\n\t\tif(op.charAt(0) == '/'){\n\t\t\tret = x / y;\n\t\t}\n\t\treturn ret;\n\t}",
"shisokuEnzan",
"{\n\t\tint ret =0;\n\t\tint x =Integer.parseInt(stringX);\n\t\tint y =Integer.parseInt(stringY);\n//\t\tSystem.out.println(x+\" \"+op+\" \"+y+\" wo okonau\");\n\n\t\tif(op.charAt(0) == '+'){\n\t\t\tret = x + y;\n\t\t}\n\t\tif(op.charAt(0) == '-'){\n\t\t\tret = x - y;\n\t\t}\n\t\tif(op.charAt(0) == '*'){\n\t\t\tret = x * y;\n\t\t}\n\t\tif(op.charAt(0) == '/'){\n\t\t\tret = x / y;\n\t\t}\n\t\treturn ret;\n\t}",
"int ret =0;",
"ret",
"0",
"int x =Integer.parseInt(stringX);",
"x",
"Integer.parseInt(stringX)",
"Integer.parseInt",
"Integer",
"stringX",
"int y =Integer.parseInt(stringY);",
"y",
"Integer.parseInt(stringY)",
"Integer.parseInt",
"Integer",
"stringY",
"if(op.charAt(0) == '+'){\n\t\t\tret = x + y;\n\t\t}",
"op.charAt(0) == '+'",
"op.charAt(0)",
"op.charAt",
"op",
"0",
"'+'",
"{\n\t\t\tret = x + y;\n\t\t}",
"ret = x + y",
"ret",
"x + y",
"x",
"y",
"if(op.charAt(0) == '-'){\n\t\t\tret = x - y;\n\t\t}",
"op.charAt(0) == '-'",
"op.charAt(0)",
"op.charAt",
"op",
"0",
"'-'",
"{\n\t\t\tret = x - y;\n\t\t}",
"ret = x - y",
"ret",
"x - y",
"x",
"y",
"if(op.charAt(0) == '*'){\n\t\t\tret = x * y;\n\t\t}",
"op.charAt(0) == '*'",
"op.charAt(0)",
"op.charAt",
"op",
"0",
"'*'",
"{\n\t\t\tret = x * y;\n\t\t}",
"ret = x * y",
"ret",
"x * y",
"x",
"y",
"if(op.charAt(0) == '/'){\n\t\t\tret = x / y;\n\t\t}",
"op.charAt(0) == '/'",
"op.charAt(0)",
"op.charAt",
"op",
"0",
"'/'",
"{\n\t\t\tret = x / y;\n\t\t}",
"ret = x / y",
"ret",
"x / y",
"x",
"y",
"return ret;",
"ret",
"String stringX",
"stringX",
"String stringY",
"stringY",
"String op",
"op",
"//???????????ยจ?????????\n\tpublic void disp(int[] ary){\n\t\tfor(int i=0;i<ary.length;i++){\n\t\t\tSystem.out.println(ary[i]);\n\t\t}\n\t}",
"disp",
"{\n\t\tfor(int i=0;i<ary.length;i++){\n\t\t\tSystem.out.println(ary[i]);\n\t\t}\n\t}",
"for(int i=0;i<ary.length;i++){\n\t\t\tSystem.out.println(ary[i]);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<ary.length",
"i",
"ary.length",
"ary",
"ary.length",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(ary[i]);\n\t\t}",
"{\n\t\t\tSystem.out.println(ary[i]);\n\t\t}",
"System.out.println(ary[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"ary[i]",
"ary",
"i",
"int[] ary",
"ary"
] | import java.io.IOException;
import java.util.Scanner;
class Main{
public static void main(String[] args)throws NumberFormatException, IOException{
// System.out.println(" ");
mathClass keisan;
Scanner scan = new Scanner(System.in);
int queueAmount = scan.nextInt();
int qTime = scan.nextInt();
int totalTime = 0;
int amari = 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);
}
}
}
class mathClass{
public mathClass(){
}
//?????????????????????
public int shisokuEnzan(String stringX,String stringY,String op){
int ret =0;
int x =Integer.parseInt(stringX);
int y =Integer.parseInt(stringY);
// System.out.println(x+" "+op+" "+y+" wo okonau");
if(op.charAt(0) == '+'){
ret = x + y;
}
if(op.charAt(0) == '-'){
ret = x - y;
}
if(op.charAt(0) == '*'){
ret = x * y;
}
if(op.charAt(0) == '/'){
ret = x / y;
}
return ret;
}
//???????????ยจ?????????
public void disp(int[] ary){
for(int i=0;i<ary.length;i++){
System.out.println(ary[i]);
}
}
} |
[
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,
20,
41,
13,
4,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
17,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
41,
13,
18,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
13,
18,
13,
13,
30,
4,
18,
13,
20,
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,
29,
4,
18,
4,
18,
4,
18,
13,
17,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
17,
41,
13,
18,
13,
13,
41,
13,
20,
13,
42,
2,
40,
13,
17,
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,
18,
13,
13,
41,
13,
20,
13,
42,
2,
40,
13,
17,
30,
0,
18,
13,
13,
4,
18,
13,
18,
13,
13,
29,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
29,
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,
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
],
[
252,
20
],
[
252,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
23,
37
],
[
37,
38
],
[
37,
39
],
[
23,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
40,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
47,
49
],
[
40,
50
],
[
50,
51
],
[
51,
52
],
[
40,
53
],
[
54,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
57,
62
],
[
54,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
23,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
69,
71
],
[
23,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
72,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
89,
94
],
[
94,
95
],
[
94,
96
],
[
83,
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
],
[
252,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
123,
129
],
[
117,
130
],
[
130,
131
],
[
252,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
134,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
143,
145
],
[
134,
146
],
[
146,
147
],
[
146,
148
],
[
134,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
150,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
163,
164
],
[
163,
165
],
[
134,
166
],
[
166,
167
],
[
132,
168
],
[
168,
169
],
[
252,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
175,
178
],
[
172,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
181,
183
],
[
172,
184
],
[
184,
185
],
[
184,
186
],
[
172,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
189,
192
],
[
188,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
194,
198
],
[
198,
199
],
[
199,
200
],
[
198,
201
],
[
201,
202
],
[
201,
203
],
[
172,
204
],
[
204,
205
],
[
170,
206
],
[
206,
207
],
[
252,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
212,
215
],
[
208,
216
],
[
216,
217
],
[
252,
218
],
[
218,
219
],
[
218,
220
],
[
220,
221
],
[
221,
222
],
[
222,
223
],
[
223,
224
],
[
222,
225
],
[
218,
226
],
[
226,
227
],
[
0,
228
],
[
228,
229
],
[
228,
230
],
[
230,
231
],
[
228,
232
],
[
232,
233
],
[
228,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
237,
238
],
[
238,
239
],
[
238,
240
],
[
237,
241
],
[
236,
242
],
[
242,
243
],
[
243,
244
],
[
243,
245
],
[
242,
246
],
[
234,
247
],
[
247,
248
],
[
234,
249
],
[
249,
250
],
[
0,
251
],
[
251,
252
],
[
251,
253
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.regex.Pattern;\n\npublic class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n Deque<Process> ad = new ArrayDeque<Process>();\n int[] n = createListInt(br.readLine());\n int totalTime = 0;\n for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }\n int m = n[1];\n while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }\n\n }\n\n static boolean isNumber(String num) {\n return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();\n }\n\n static int[] createListInt(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n int[] list = new int[n];\n while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }\n return list;\n }\n\n static long[] createListLong(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n long[] list = new long[n];\n while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }\n return list;\n }\n\n static int ip(String s) {\n return Integer.parseInt(s);\n }\n\n static long lp(String s) {\n return Long.parseLong(s);\n }\n}\n\nclass Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = name;\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.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.regex.Pattern;",
"Pattern",
"java.util.regex",
"public class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n Deque<Process> ad = new ArrayDeque<Process>();\n int[] n = createListInt(br.readLine());\n int totalTime = 0;\n for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }\n int m = n[1];\n while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }\n\n }\n\n static boolean isNumber(String num) {\n return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();\n }\n\n static int[] createListInt(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n int[] list = new int[n];\n while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }\n return list;\n }\n\n static long[] createListLong(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n long[] list = new long[n];\n while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }\n return list;\n }\n\n static int ip(String s) {\n return Integer.parseInt(s);\n }\n\n static long lp(String s) {\n return Long.parseLong(s);\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n Deque<Process> ad = new ArrayDeque<Process>();\n int[] n = createListInt(br.readLine());\n int totalTime = 0;\n for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }\n int m = n[1];\n while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }\n\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n Deque<Process> ad = new ArrayDeque<Process>();\n int[] n = createListInt(br.readLine());\n int totalTime = 0;\n for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }\n int m = n[1];\n while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }\n\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"Deque<Process> ad = new ArrayDeque<Process>();",
"ad",
"new ArrayDeque<Process>()",
"int[] n = createListInt(br.readLine());",
"n",
"createListInt(br.readLine())",
"createListInt",
"br.readLine()",
"br.readLine",
"br",
"int totalTime = 0;",
"totalTime",
"0",
"for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n[0]",
"i",
"n[0]",
"n",
"0",
"i++",
"i++",
"i",
"{\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }",
"{\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }",
"String[] lines = br.readLine().split(\" \");",
"lines",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"ad.add(new Process(lines[0], ip(lines[1])))",
"ad.add",
"ad",
"new Process(lines[0], ip(lines[1]))",
"int m = n[1];",
"m",
"n[1]",
"n",
"1",
"while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }",
"!ad.isEmpty()",
"ad.isEmpty()",
"ad.isEmpty",
"ad",
"{\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }",
"Process t = ad.poll();",
"t",
"ad.poll()",
"ad.poll",
"ad",
"if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }",
"m < t.time",
"m",
"t.time",
"t",
"t.time",
"{\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n }",
"ad.add(new Process(t.name, t.time - m))",
"ad.add",
"ad",
"new Process(t.name, t.time - m)",
"totalTime+=m",
"totalTime",
"m",
"{\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }",
"totalTime+=t.time",
"totalTime",
"t.time",
"t",
"t.time",
"System.out.println(t.name+\" \"+totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"t.name+\" \"+totalTime",
"t.name+\" \"+totalTime",
"t.name",
"t",
"t.name",
"\" \"",
"totalTime",
"String[] args",
"args",
"static boolean isNumber(String num) {\n return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();\n }",
"isNumber",
"{\n return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();\n }",
"return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();",
"Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find()",
"Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find",
"Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num)",
"Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher",
"Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\")",
"Pattern.compile",
"Pattern",
"\"^\\\\-?[0-9]*\\\\.?[0-9]+$\"",
"num",
"String num",
"num",
"static int[] createListInt(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n int[] list = new int[n];\n while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }\n return list;\n }",
"createListInt",
"{\n String[] lines = line.split(\" \");\n int n = lines.length;\n int[] list = new int[n];\n while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }\n return list;\n }",
"String[] lines = line.split(\" \");",
"lines",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"int n = lines.length;",
"n",
"lines.length",
"lines",
"lines.length",
"int[] list = new int[n];",
"list",
"new int[n]",
"n",
"while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }",
"n-- > 0",
"n--",
"n",
"0",
"{\n list[n] = Integer.parseInt(lines[n]);\n }",
"list[n] = Integer.parseInt(lines[n])",
"list[n]",
"list",
"n",
"Integer.parseInt(lines[n])",
"Integer.parseInt",
"Integer",
"lines[n]",
"lines",
"n",
"return list;",
"list",
"String line",
"line",
"static long[] createListLong(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n long[] list = new long[n];\n while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }\n return list;\n }",
"createListLong",
"{\n String[] lines = line.split(\" \");\n int n = lines.length;\n long[] list = new long[n];\n while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }\n return list;\n }",
"String[] lines = line.split(\" \");",
"lines",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"int n = lines.length;",
"n",
"lines.length",
"lines",
"lines.length",
"long[] list = new long[n];",
"list",
"new long[n]",
"n",
"while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }",
"n-- > 0",
"n--",
"n",
"0",
"{\n list[n] = Long.parseLong(lines[n]);\n }",
"list[n] = Long.parseLong(lines[n])",
"list[n]",
"list",
"n",
"Long.parseLong(lines[n])",
"Long.parseLong",
"Long",
"lines[n]",
"lines",
"n",
"return list;",
"list",
"String line",
"line",
"static int ip(String s) {\n return Integer.parseInt(s);\n }",
"ip",
"{\n return Integer.parseInt(s);\n }",
"return Integer.parseInt(s);",
"Integer.parseInt(s)",
"Integer.parseInt",
"Integer",
"s",
"String s",
"s",
"static long lp(String s) {\n return Long.parseLong(s);\n }",
"lp",
"{\n return Long.parseLong(s);\n }",
"return Long.parseLong(s);",
"Long.parseLong(s)",
"Long.parseLong",
"Long",
"s",
"String s",
"s",
"class Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = name;\n this.time = 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",
"public class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n Deque<Process> ad = new ArrayDeque<Process>();\n int[] n = createListInt(br.readLine());\n int totalTime = 0;\n for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }\n int m = n[1];\n while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }\n\n }\n\n static boolean isNumber(String num) {\n return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();\n }\n\n static int[] createListInt(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n int[] list = new int[n];\n while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }\n return list;\n }\n\n static long[] createListLong(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n long[] list = new long[n];\n while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }\n return list;\n }\n\n static int ip(String s) {\n return Integer.parseInt(s);\n }\n\n static long lp(String s) {\n return Long.parseLong(s);\n }\n}",
"public class Main {\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n Deque<Process> ad = new ArrayDeque<Process>();\n int[] n = createListInt(br.readLine());\n int totalTime = 0;\n for (int i = 0; i < n[0]; i++) {\n String[] lines = br.readLine().split(\" \");\n ad.add(new Process(lines[0], ip(lines[1])));\n }\n int m = n[1];\n while (!ad.isEmpty()) {\n Process t = ad.poll();\n if (m < t.time) {\n ad.add(new Process(t.name, t.time - m));\n totalTime+=m;\n } else {\n totalTime+=t.time;\n System.out.println(t.name+\" \"+totalTime);\n }\n }\n\n }\n\n static boolean isNumber(String num) {\n return Pattern.compile(\"^\\\\-?[0-9]*\\\\.?[0-9]+$\").matcher(num).find();\n }\n\n static int[] createListInt(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n int[] list = new int[n];\n while (n-- > 0) {\n list[n] = Integer.parseInt(lines[n]);\n }\n return list;\n }\n\n static long[] createListLong(String line) {\n String[] lines = line.split(\" \");\n int n = lines.length;\n long[] list = new long[n];\n while (n-- > 0) {\n list[n] = Long.parseLong(lines[n]);\n }\n return list;\n }\n\n static int ip(String s) {\n return Integer.parseInt(s);\n }\n\n static long lp(String s) {\n return Long.parseLong(s);\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Deque<Process> ad = new ArrayDeque<Process>();
int[] n = createListInt(br.readLine());
int totalTime = 0;
for (int i = 0; i < n[0]; i++) {
String[] lines = br.readLine().split(" ");
ad.add(new Process(lines[0], ip(lines[1])));
}
int m = n[1];
while (!ad.isEmpty()) {
Process t = ad.poll();
if (m < t.time) {
ad.add(new Process(t.name, t.time - m));
totalTime+=m;
} else {
totalTime+=t.time;
System.out.println(t.name+" "+totalTime);
}
}
}
static boolean isNumber(String num) {
return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
}
static int[] createListInt(String line) {
String[] lines = line.split(" ");
int n = lines.length;
int[] list = new int[n];
while (n-- > 0) {
list[n] = Integer.parseInt(lines[n]);
}
return list;
}
static long[] createListLong(String line) {
String[] lines = line.split(" ");
int n = lines.length;
long[] list = new long[n];
while (n-- > 0) {
list[n] = Long.parseLong(lines[n]);
}
return list;
}
static int ip(String s) {
return Integer.parseInt(s);
}
static long lp(String s) {
return Long.parseLong(s);
}
}
class Process {
String name;
int time;
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,
20,
13,
41,
13,
20,
13,
41,
13,
17,
41,
13,
2,
13,
17,
41,
13,
17,
41,
13,
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,
17,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
0,
13,
2,
2,
13,
17,
13,
40,
13,
30,
0,
13,
13,
0,
13,
2,
2,
13,
17,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
146,
5
],
[
146,
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,
26
],
[
26,
27
],
[
26,
28
],
[
8,
30
],
[
30,
31
],
[
30,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
35,
37
],
[
8,
38
],
[
38,
39
],
[
38,
40
],
[
8,
41
],
[
41,
42
],
[
41,
43
],
[
8,
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
],
[
8,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
88,
93
],
[
94,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
94,
99
],
[
82,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
82,
107
],
[
107,
108
],
[
76,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
109,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
109,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
109,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
6,
143
],
[
143,
144
],
[
0,
145
],
[
145,
146
],
[
145,
147
]
] | [
"import java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n \tint n = scan.nextInt();\n \tint q = scan.nextInt();\n \tint[] tqueue = new int[n];\n \tString[] nqueue = new String[n];\n \tint start = 0;\n \tint end = n - 1;\n \tint now = 0;\n \tint how = n;\n \t\n \tfor(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}\n \t\n \twhile(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}\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 \tint n = scan.nextInt();\n \tint q = scan.nextInt();\n \tint[] tqueue = new int[n];\n \tString[] nqueue = new String[n];\n \tint start = 0;\n \tint end = n - 1;\n \tint now = 0;\n \tint how = n;\n \t\n \tfor(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}\n \t\n \twhile(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n \tint n = scan.nextInt();\n \tint q = scan.nextInt();\n \tint[] tqueue = new int[n];\n \tString[] nqueue = new String[n];\n \tint start = 0;\n \tint end = n - 1;\n \tint now = 0;\n \tint how = n;\n \t\n \tfor(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}\n \t\n \twhile(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}\n }",
"main",
"{\n Scanner scan = new Scanner(System.in);\n \tint n = scan.nextInt();\n \tint q = scan.nextInt();\n \tint[] tqueue = new int[n];\n \tString[] nqueue = new String[n];\n \tint start = 0;\n \tint end = n - 1;\n \tint now = 0;\n \tint how = n;\n \t\n \tfor(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}\n \t\n \twhile(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}\n }",
"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[] tqueue = new int[n];",
"tqueue",
"new int[n]",
"n",
"String[] nqueue = new String[n];",
"nqueue",
"new String[n]",
"n",
"int start = 0;",
"start",
"0",
"int end = n - 1;",
"end",
"n - 1",
"n",
"1",
"int now = 0;",
"now",
"0",
"int how = n;",
"how",
"n",
"for(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}",
"{\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}",
"nqueue[i] = scan.next()",
"nqueue[i]",
"nqueue",
"i",
"scan.next()",
"scan.next",
"scan",
"tqueue[i] = scan.nextInt()",
"tqueue[i]",
"tqueue",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}",
"how > 0",
"how",
"0",
"{\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}",
"if(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}",
"tqueue[start] <= q",
"tqueue[start]",
"tqueue",
"start",
"q",
"{\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}",
"now += tqueue[start]",
"now",
"tqueue[start]",
"tqueue",
"start",
"System.out.println(nqueue[start]+\" \"+now)",
"System.out.println",
"System.out",
"System",
"System.out",
"nqueue[start]+\" \"+now",
"nqueue[start]+\" \"+now",
"nqueue[start]",
"nqueue",
"start",
"\" \"",
"now",
"start = (start + 1)%n",
"start",
"(start + 1)%n",
"(start + 1)",
"start",
"1",
"n",
"how--",
"how",
"{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}",
"now += q",
"now",
"q",
"end = (end + 1)%n",
"end",
"(end + 1)%n",
"(end + 1)",
"end",
"1",
"n",
"tqueue[end] = tqueue[start] - q",
"tqueue[end]",
"tqueue",
"end",
"tqueue[start] - q",
"tqueue[start]",
"tqueue",
"start",
"q",
"nqueue[end] = nqueue[start]",
"nqueue[end]",
"nqueue",
"end",
"nqueue[start]",
"nqueue",
"start",
"start = (start + 1)%n",
"start",
"(start + 1)%n",
"(start + 1)",
"start",
"1",
"n",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n \tint n = scan.nextInt();\n \tint q = scan.nextInt();\n \tint[] tqueue = new int[n];\n \tString[] nqueue = new String[n];\n \tint start = 0;\n \tint end = n - 1;\n \tint now = 0;\n \tint how = n;\n \t\n \tfor(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}\n \t\n \twhile(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner scan = new Scanner(System.in);\n \tint n = scan.nextInt();\n \tint q = scan.nextInt();\n \tint[] tqueue = new int[n];\n \tString[] nqueue = new String[n];\n \tint start = 0;\n \tint end = n - 1;\n \tint now = 0;\n \tint how = n;\n \t\n \tfor(int i = 0; i < n; i++){\n \t\tnqueue[i] = scan.next();\n \t\ttqueue[i] = scan.nextInt();\n \t}\n \t\n \twhile(how > 0){\n \t\tif(tqueue[start] <= q){\n \t\t\tnow += tqueue[start];\n \t\t\tSystem.out.println(nqueue[start]+\" \"+now);\n \t\t\tstart = (start + 1)%n;\n \t\t\thow--;\n \t\t}else{\n \t\t\tnow += q;\n \t\t\tend = (end + 1)%n;\n \t\t\ttqueue[end] = tqueue[start] - q;\n \t\t\tnqueue[end] = nqueue[start];\n \t\t\tstart = (start + 1)%n;\n \t\t}\n \t}\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 q = scan.nextInt();
int[] tqueue = new int[n];
String[] nqueue = new String[n];
int start = 0;
int end = n - 1;
int now = 0;
int how = n;
for(int i = 0; i < n; i++){
nqueue[i] = scan.next();
tqueue[i] = scan.nextInt();
}
while(how > 0){
if(tqueue[start] <= q){
now += tqueue[start];
System.out.println(nqueue[start]+" "+now);
start = (start + 1)%n;
how--;
}else{
now += q;
end = (end + 1)%n;
tqueue[end] = tqueue[start] - q;
nqueue[end] = nqueue[start];
start = (start + 1)%n;
}
}
}
}
|
[
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,
4,
18,
13,
4,
18,
13,
41,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
18,
13,
17,
14,
2,
13,
13,
30,
4,
18,
13,
2,
2,
13,
17,
2,
13,
13,
0,
13,
13,
30,
0,
13,
13,
0,
13,
13,
4,
18,
13,
2,
2,
13,
17,
13,
42,
2,
4,
18,
13,
17,
30,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
143,
5
],
[
143,
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
],
[
53,
54
],
[
52,
55
],
[
55,
56
],
[
56,
57
],
[
8,
58
],
[
58,
59
],
[
58,
60
],
[
8,
61
],
[
61,
62
],
[
61,
63
],
[
8,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
73,
78
],
[
70,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
84,
86
],
[
70,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
70,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
101,
101
],
[
101,
102
],
[
101,
103
],
[
101,
104
],
[
104,
105
],
[
104,
106
],
[
96,
107
],
[
107,
108
],
[
107,
109
],
[
92,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
114,
116
],
[
110,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
121,
121
],
[
121,
122
],
[
121,
123
],
[
121,
124
],
[
8,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
126,
130
],
[
125,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
137,
138
],
[
138,
139
],
[
6,
140
],
[
140,
141
],
[
0,
142
],
[
142,
143
],
[
142,
144
]
] | [
"\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scin = new Scanner(System.in);\n\t\tString[] baseInput = scin.nextLine().split(\" \");\n\t\t\n\t\tint numberOfProcesses = Integer.parseInt(baseInput[0]);\n\t\tint timeSlotLength = Integer.parseInt(baseInput[1]);\n\t\t\n\t\tQueue<String> queue = new LinkedList<>();\n\t\t\n\t\tfor (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}\n\t\t\n\t\t//now run it\n\t\tQueue<String> finished = new LinkedList<>();\n\t\tint totalElapsedTime = 0;\n\t\t\n\t\twhile (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}\n\t}\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scin = new Scanner(System.in);\n\t\tString[] baseInput = scin.nextLine().split(\" \");\n\t\t\n\t\tint numberOfProcesses = Integer.parseInt(baseInput[0]);\n\t\tint timeSlotLength = Integer.parseInt(baseInput[1]);\n\t\t\n\t\tQueue<String> queue = new LinkedList<>();\n\t\t\n\t\tfor (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}\n\t\t\n\t\t//now run it\n\t\tQueue<String> finished = new LinkedList<>();\n\t\tint totalElapsedTime = 0;\n\t\t\n\t\twhile (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scin = new Scanner(System.in);\n\t\tString[] baseInput = scin.nextLine().split(\" \");\n\t\t\n\t\tint numberOfProcesses = Integer.parseInt(baseInput[0]);\n\t\tint timeSlotLength = Integer.parseInt(baseInput[1]);\n\t\t\n\t\tQueue<String> queue = new LinkedList<>();\n\t\t\n\t\tfor (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}\n\t\t\n\t\t//now run it\n\t\tQueue<String> finished = new LinkedList<>();\n\t\tint totalElapsedTime = 0;\n\t\t\n\t\twhile (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}\n\t}",
"main",
"{\n\t\tScanner scin = new Scanner(System.in);\n\t\tString[] baseInput = scin.nextLine().split(\" \");\n\t\t\n\t\tint numberOfProcesses = Integer.parseInt(baseInput[0]);\n\t\tint timeSlotLength = Integer.parseInt(baseInput[1]);\n\t\t\n\t\tQueue<String> queue = new LinkedList<>();\n\t\t\n\t\tfor (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}\n\t\t\n\t\t//now run it\n\t\tQueue<String> finished = new LinkedList<>();\n\t\tint totalElapsedTime = 0;\n\t\t\n\t\twhile (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}\n\t}",
"Scanner scin = new Scanner(System.in);",
"scin",
"new Scanner(System.in)",
"String[] baseInput = scin.nextLine().split(\" \");",
"baseInput",
"scin.nextLine().split(\" \")",
"scin.nextLine().split",
"scin.nextLine()",
"scin.nextLine",
"scin",
"\" \"",
"int numberOfProcesses = Integer.parseInt(baseInput[0]);",
"numberOfProcesses",
"Integer.parseInt(baseInput[0])",
"Integer.parseInt",
"Integer",
"baseInput[0]",
"baseInput",
"0",
"int timeSlotLength = Integer.parseInt(baseInput[1]);",
"timeSlotLength",
"Integer.parseInt(baseInput[1])",
"Integer.parseInt",
"Integer",
"baseInput[1]",
"baseInput",
"1",
"Queue<String> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numberOfProcesses",
"i",
"numberOfProcesses",
"i++",
"i++",
"i",
"{\n\t\t\tqueue.add(scin.nextLine());\n\t\t}",
"{\n\t\t\tqueue.add(scin.nextLine());\n\t\t}",
"queue.add(scin.nextLine())",
"queue.add",
"queue",
"scin.nextLine()",
"scin.nextLine",
"scin",
"Queue<String> finished = new LinkedList<>();",
"finished",
"new LinkedList<>()",
"int totalElapsedTime = 0;",
"totalElapsedTime",
"0",
"while (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}",
"queue.isEmpty() == false",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"false",
"{\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}",
"String[] rawParts = queue.remove().split(\" \");",
"rawParts",
"queue.remove().split(\" \")",
"queue.remove().split",
"queue.remove()",
"queue.remove",
"queue",
"\" \"",
"int durrationLeft = Integer.parseInt(rawParts[1]);",
"durrationLeft",
"Integer.parseInt(rawParts[1])",
"Integer.parseInt",
"Integer",
"rawParts[1]",
"rawParts",
"1",
"String name = rawParts[0];",
"name",
"rawParts[0]",
"rawParts",
"0",
"if (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}",
"durrationLeft <= timeSlotLength",
"durrationLeft",
"timeSlotLength",
"{\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}",
"finished.add(name + \" \" +(totalElapsedTime + durrationLeft))",
"finished.add",
"finished",
"name + \" \" +(totalElapsedTime + durrationLeft)",
"name + \" \" +(totalElapsedTime + durrationLeft)",
"name",
"\" \"",
"(totalElapsedTime + durrationLeft)",
"totalElapsedTime",
"durrationLeft",
"totalElapsedTime += durrationLeft",
"totalElapsedTime",
"durrationLeft",
"{\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}",
"durrationLeft -= timeSlotLength",
"durrationLeft",
"timeSlotLength",
"totalElapsedTime += timeSlotLength",
"totalElapsedTime",
"timeSlotLength",
"queue.add(name + \" \" +durrationLeft)",
"queue.add",
"queue",
"name + \" \" +durrationLeft",
"name + \" \" +durrationLeft",
"name",
"\" \"",
"durrationLeft",
"while (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}",
"finished.isEmpty() == false",
"finished.isEmpty()",
"finished.isEmpty",
"finished",
"false",
"{\n\t\t\tSystem.out.println(finished.remove());\n\t\t}",
"System.out.println(finished.remove())",
"System.out.println",
"System.out",
"System",
"System.out",
"finished.remove()",
"finished.remove",
"finished",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scin = new Scanner(System.in);\n\t\tString[] baseInput = scin.nextLine().split(\" \");\n\t\t\n\t\tint numberOfProcesses = Integer.parseInt(baseInput[0]);\n\t\tint timeSlotLength = Integer.parseInt(baseInput[1]);\n\t\t\n\t\tQueue<String> queue = new LinkedList<>();\n\t\t\n\t\tfor (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}\n\t\t\n\t\t//now run it\n\t\tQueue<String> finished = new LinkedList<>();\n\t\tint totalElapsedTime = 0;\n\t\t\n\t\twhile (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scin = new Scanner(System.in);\n\t\tString[] baseInput = scin.nextLine().split(\" \");\n\t\t\n\t\tint numberOfProcesses = Integer.parseInt(baseInput[0]);\n\t\tint timeSlotLength = Integer.parseInt(baseInput[1]);\n\t\t\n\t\tQueue<String> queue = new LinkedList<>();\n\t\t\n\t\tfor (int i = 0; i < numberOfProcesses; i++) {\n\t\t\tqueue.add(scin.nextLine());\n\t\t}\n\t\t\n\t\t//now run it\n\t\tQueue<String> finished = new LinkedList<>();\n\t\tint totalElapsedTime = 0;\n\t\t\n\t\twhile (queue.isEmpty() == false) {\n\t\t\tString[] rawParts = queue.remove().split(\" \");\n\t\t\tint durrationLeft = Integer.parseInt(rawParts[1]);\n\t\t\tString name = rawParts[0];\n\t\t\t\n\t\t\tif (durrationLeft <= timeSlotLength) {\n\t\t\t\tfinished.add(name + \" \" +(totalElapsedTime + durrationLeft));\n\t\t\t\ttotalElapsedTime += durrationLeft;\n\t\t\t}else {\n\t\t\t\tdurrationLeft -= timeSlotLength;\n\t\t\t\t\n\t\t\t\ttotalElapsedTime += timeSlotLength;\n\t\t\t\t\n\t\t\t\tqueue.add(name + \" \" +durrationLeft);\n\t\t\t}\n\t\t}\n\t\t\n\t\twhile (finished.isEmpty() == false) {\n\t\t\tSystem.out.println(finished.remove());\n\t\t}\n\t}\n}",
"Main"
] |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scin = new Scanner(System.in);
String[] baseInput = scin.nextLine().split(" ");
int numberOfProcesses = Integer.parseInt(baseInput[0]);
int timeSlotLength = Integer.parseInt(baseInput[1]);
Queue<String> queue = new LinkedList<>();
for (int i = 0; i < numberOfProcesses; i++) {
queue.add(scin.nextLine());
}
//now run it
Queue<String> finished = new LinkedList<>();
int totalElapsedTime = 0;
while (queue.isEmpty() == false) {
String[] rawParts = queue.remove().split(" ");
int durrationLeft = Integer.parseInt(rawParts[1]);
String name = rawParts[0];
if (durrationLeft <= timeSlotLength) {
finished.add(name + " " +(totalElapsedTime + durrationLeft));
totalElapsedTime += durrationLeft;
}else {
durrationLeft -= timeSlotLength;
totalElapsedTime += timeSlotLength;
queue.add(name + " " +durrationLeft);
}
}
while (finished.isEmpty() == false) {
System.out.println(finished.remove());
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
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,
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,
13,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
4,
18,
13,
12,
13,
30,
4,
18,
18,
13,
13,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
20,
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
],
[
139,
14
],
[
139,
15
],
[
15,
16
],
[
15,
17
],
[
139,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
20,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
20,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
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
],
[
53,
56
],
[
56,
57
],
[
57,
58
],
[
52,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
63,
64
],
[
20,
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
],
[
70,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
95,
95
],
[
95,
96
],
[
95,
97
],
[
95,
98
],
[
81,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
99,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
110,
111
],
[
110,
112
],
[
20,
113
],
[
113,
114
],
[
114,
115
],
[
139,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
116,
128
],
[
128,
129
],
[
139,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
130,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Arrays;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\n\tint time = 0;\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> Qi = new ArrayDeque<>();\n\t\tDeque<String> Qs = new ArrayDeque<>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}\n\t\twhile(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsc.close();\n\t}\n\n\tvoid debug(Object... o) {\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tint time = 0;\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> Qi = new ArrayDeque<>();\n\t\tDeque<String> Qs = new ArrayDeque<>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}\n\t\twhile(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsc.close();\n\t}\n\n\tvoid debug(Object... o) {\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main",
"int time = 0;",
"time",
"0",
"void run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> Qi = new ArrayDeque<>();\n\t\tDeque<String> Qs = new ArrayDeque<>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}\n\t\twhile(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsc.close();\n\t}",
"run",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> Qi = new ArrayDeque<>();\n\t\tDeque<String> Qs = new ArrayDeque<>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}\n\t\twhile(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Deque<Integer> Qi = new ArrayDeque<>();",
"Qi",
"new ArrayDeque<>()",
"Deque<String> Qs = new ArrayDeque<>();",
"Qs",
"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\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}",
"{\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}",
"Qs.addLast(sc.next())",
"Qs.addLast",
"Qs",
"sc.next()",
"sc.next",
"sc",
"Qi.addLast(sc.nextInt())",
"Qi.addLast",
"Qi",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}",
"!Qs.isEmpty()",
"Qs.isEmpty()",
"Qs.isEmpty",
"Qs",
"{\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}",
"int a = Qi.poll();",
"a",
"Qi.poll()",
"Qi.poll",
"Qi",
"String s = Qs.poll();",
"s",
"Qs.poll()",
"Qs.poll",
"Qs",
"if(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}",
"a <= q",
"a",
"q",
"{\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}",
"time += a",
"time",
"a",
"System.out.println(s + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"s + \" \" + time",
"s + \" \" + time",
"s",
"\" \"",
"time",
"{\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}",
"time += q",
"time",
"q",
"Qs.addLast(s)",
"Qs.addLast",
"Qs",
"s",
"Qi.addLast(a - q)",
"Qi.addLast",
"Qi",
"a - q",
"a",
"q",
"sc.close()",
"sc.close",
"sc",
"void debug(Object... o) {\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}",
"debug",
"{\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}",
"System.out.println(Arrays.deepToString(o))",
"System.out.println",
"System.out",
"System",
"System.out",
"Arrays.deepToString(o)",
"Arrays.deepToString",
"Arrays",
"o",
"Object... o",
"o",
"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",
"public class Main {\n\tint time = 0;\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> Qi = new ArrayDeque<>();\n\t\tDeque<String> Qs = new ArrayDeque<>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}\n\t\twhile(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsc.close();\n\t}\n\n\tvoid debug(Object... o) {\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"public class Main {\n\tint time = 0;\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> Qi = new ArrayDeque<>();\n\t\tDeque<String> Qs = new ArrayDeque<>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tQs.addLast(sc.next());\n\t\t\tQi.addLast(sc.nextInt());\n\t\t}\n\t\twhile(!Qs.isEmpty()) {\n\t\t\tint a = Qi.poll();\n\t\t\tString s = Qs.poll();\n\t\t\tif(a <= q) {\n\t\t\t\ttime += a;\n\t\t\t\tSystem.out.println(s + \" \" + time);\n\t\t\t}else {\n\t\t\t\ttime += q;\n\t\t\t\tQs.addLast(s);\n\t\t\t\tQi.addLast(a - q);\n\t\t\t}\n\t\t}\n\t\t\n\t\tsc.close();\n\t}\n\n\tvoid debug(Object... o) {\n\t\tSystem.out.println(Arrays.deepToString(o));\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;
public class Main {
int time = 0;
void run() {
Scanner sc = new Scanner(System.in);
Deque<Integer> Qi = new ArrayDeque<>();
Deque<String> Qs = new ArrayDeque<>();
int n = sc.nextInt();
int q = sc.nextInt();
for(int i = 0; i < n; i++) {
Qs.addLast(sc.next());
Qi.addLast(sc.nextInt());
}
while(!Qs.isEmpty()) {
int a = Qi.poll();
String s = Qs.poll();
if(a <= q) {
time += a;
System.out.println(s + " " + time);
}else {
time += q;
Qs.addLast(s);
Qi.addLast(a - q);
}
}
sc.close();
}
void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}
public static void main(String[] args) {
new Main().run();
}
}
|
[
7,
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,
17,
41,
13,
17,
41,
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
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
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
17,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
17,
32
],
[
32,
33
],
[
32,
34
],
[
17,
35
],
[
35,
36
],
[
35,
37
],
[
17,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
43,
44
],
[
43,
45
],
[
17,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
51,
52
],
[
51,
53
],
[
17,
54
],
[
54,
55
],
[
54,
56
],
[
17,
57
],
[
57,
58
],
[
57,
59
],
[
17,
60
],
[
60,
61
],
[
60,
62
],
[
17,
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
],
[
75,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
75,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
90,
91
],
[
90,
92
],
[
75,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
99,
100
],
[
99,
101
],
[
17,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
108,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
108,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
127,
128
],
[
127,
129
],
[
123,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
123,
134
],
[
134,
135
],
[
134,
136
],
[
119,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
147,
147
],
[
147,
148
],
[
147,
149
],
[
147,
150
],
[
15,
151
],
[
151,
152
]
] | [
"/* package whatever; // don't place package name! */\n\nimport java.util.*;\nimport java.lang.*;\nimport java.lang.reflect.Array;\nimport java.io.*;\n\n/* Name of the class has to be \"Main\" only if the class is public. */\nclass Main\n{\n\tpublic static void main (String[] args) throws java.lang.Exception\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString s=br.readLine();\n\t\tString[] str = s.split(\" \");\n\t\tlong timer = 0;\n\t\tint time = 0;\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\tString name = new String();\n\t\tQueue<Integer> queue = new LinkedList<Integer>();\n\t\tQueue<String> namequeue = new LinkedList<String>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}\n\t\twhile(queue.isEmpty()!=true){\n\t\t\ttime=queue.poll();\n\t\t\tname=namequeue.poll();\n\t\t\tif(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"import java.lang.reflect.Array;",
"Array",
"java.lang.reflect",
"import java.io.*;",
"io.*",
"java",
"class Main\n{\n\tpublic static void main (String[] args) throws java.lang.Exception\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString s=br.readLine();\n\t\tString[] str = s.split(\" \");\n\t\tlong timer = 0;\n\t\tint time = 0;\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\tString name = new String();\n\t\tQueue<Integer> queue = new LinkedList<Integer>();\n\t\tQueue<String> namequeue = new LinkedList<String>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}\n\t\twhile(queue.isEmpty()!=true){\n\t\t\ttime=queue.poll();\n\t\t\tname=namequeue.poll();\n\t\t\tif(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main (String[] args) throws java.lang.Exception\n\t{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString s=br.readLine();\n\t\tString[] str = s.split(\" \");\n\t\tlong timer = 0;\n\t\tint time = 0;\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\tString name = new String();\n\t\tQueue<Integer> queue = new LinkedList<Integer>();\n\t\tQueue<String> namequeue = new LinkedList<String>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}\n\t\twhile(queue.isEmpty()!=true){\n\t\t\ttime=queue.poll();\n\t\t\tname=namequeue.poll();\n\t\t\tif(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString s=br.readLine();\n\t\tString[] str = s.split(\" \");\n\t\tlong timer = 0;\n\t\tint time = 0;\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\tString name = new String();\n\t\tQueue<Integer> queue = new LinkedList<Integer>();\n\t\tQueue<String> namequeue = new LinkedList<String>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}\n\t\twhile(queue.isEmpty()!=true){\n\t\t\ttime=queue.poll();\n\t\t\tname=namequeue.poll();\n\t\t\tif(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\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 s=br.readLine();",
"s",
"br.readLine()",
"br.readLine",
"br",
"String[] str = s.split(\" \");",
"str",
"s.split(\" \")",
"s.split",
"s",
"\" \"",
"long timer = 0;",
"timer",
"0",
"int time = 0;",
"time",
"0",
"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",
"String name = new String();",
"name",
"new String()",
"Queue<Integer> queue = new LinkedList<Integer>();",
"queue",
"new LinkedList<Integer>()",
"Queue<String> namequeue = new LinkedList<String>();",
"namequeue",
"new LinkedList<String>()",
"for(int i=0;i<n;i++){\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}",
"{\n\t\t\ts = br.readLine();\n\t\t\tstr = s.split(\" \");\n\t\t\tnamequeue.add(str[0]);\n\t\t\tqueue.add(Integer.parseInt(str[1]));\n\t\t}",
"s = br.readLine()",
"s",
"br.readLine()",
"br.readLine",
"br",
"str = s.split(\" \")",
"str",
"s.split(\" \")",
"s.split",
"s",
"\" \"",
"namequeue.add(str[0])",
"namequeue.add",
"namequeue",
"str[0]",
"str",
"0",
"queue.add(Integer.parseInt(str[1]))",
"queue.add",
"queue",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"while(queue.isEmpty()!=true){\n\t\t\ttime=queue.poll();\n\t\t\tname=namequeue.poll();\n\t\t\tif(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}\n\t\t}",
"queue.isEmpty()!=true",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"true",
"{\n\t\t\ttime=queue.poll();\n\t\t\tname=namequeue.poll();\n\t\t\tif(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}\n\t\t}",
"time=queue.poll()",
"time",
"queue.poll()",
"queue.poll",
"queue",
"name=namequeue.poll()",
"name",
"namequeue.poll()",
"namequeue.poll",
"namequeue",
"if(time>q){\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}",
"time>q",
"time",
"q",
"{\n\t\t\t\tqueue.add(time-q);\n\t\t\t\tnamequeue.add(name);\n\t\t\t\ttimer+=q;\n\t\t\t}",
"queue.add(time-q)",
"queue.add",
"queue",
"time-q",
"time",
"q",
"namequeue.add(name)",
"namequeue.add",
"namequeue",
"name",
"timer+=q",
"timer",
"q",
"{\n\t\t\t\ttimer+=time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t}",
"timer+=time",
"timer",
"time",
"System.out.println(name+\" \"+timer)",
"System.out.println",
"System.out",
"System",
"System.out",
"name+\" \"+timer",
"name+\" \"+timer",
"name",
"\" \"",
"timer",
"String[] args",
"args"
] | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.lang.reflect.Array;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s=br.readLine();
String[] str = s.split(" ");
long timer = 0;
int time = 0;
int n = Integer.parseInt(str[0]);
int q = Integer.parseInt(str[1]);
String name = new String();
Queue<Integer> queue = new LinkedList<Integer>();
Queue<String> namequeue = new LinkedList<String>();
for(int i=0;i<n;i++){
s = br.readLine();
str = s.split(" ");
namequeue.add(str[0]);
queue.add(Integer.parseInt(str[1]));
}
while(queue.isEmpty()!=true){
time=queue.poll();
name=namequeue.poll();
if(time>q){
queue.add(time-q);
namequeue.add(name);
timer+=q;
}
else{
timer+=time;
System.out.println(name+" "+timer);
}
}
}
} |
[
7,
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,
13,
41,
13,
20,
13,
41,
13,
20,
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,
42,
2,
4,
18,
13,
17,
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
],
[
119,
5
],
[
119,
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,
29
],
[
29,
30
],
[
29,
31
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
8,
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
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
54,
55
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
61,
62
],
[
48,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
8,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
68,
72
],
[
67,
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
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
85,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
85,
95
],
[
95,
96
],
[
95,
97
],
[
79,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
101,
103
],
[
98,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
104,
109
],
[
110,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
110,
115
],
[
6,
116
],
[
116,
117
],
[
0,
118
],
[
118,
119
],
[
118,
120
]
] | [
"import java.util.*;\n\npublic class Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int timenow = 0;\n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] times = new int[n];\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }\n while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\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 int timenow = 0;\n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] times = new int[n];\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }\n while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }\n }\n}",
"Main",
"public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int timenow = 0;\n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] times = new int[n];\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }\n while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int timenow = 0;\n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] times = new int[n];\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }\n while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int timenow = 0;",
"timenow",
"0",
"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[] times = new int[n];",
"times",
"new int[n]",
"n",
"LinkedList<Integer> queue = new LinkedList<Integer>();",
"queue",
"new LinkedList<Integer>()",
"for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }",
"{\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }",
"names[i] = sc.next()",
"names[i]",
"names",
"i",
"sc.next()",
"sc.next",
"sc",
"times[i] = sc.nextInt()",
"times[i]",
"times",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"queue.add(i)",
"queue.add",
"queue",
"i",
"while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }",
"queue.size()!=0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }",
"int p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }",
"times[p]>q",
"times[p]",
"times",
"p",
"q",
"{\n times[p] -= q;\n queue.add(p);\n timenow += q;\n }",
"times[p] -= q",
"times[p]",
"times",
"p",
"q",
"queue.add(p)",
"queue.add",
"queue",
"p",
"timenow += q",
"timenow",
"q",
"{\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }",
"timenow += times[p]",
"timenow",
"times[p]",
"times",
"p",
"System.out.println(names[p]+\" \"+timenow)",
"System.out.println",
"System.out",
"System",
"System.out",
"names[p]+\" \"+timenow",
"names[p]+\" \"+timenow",
"names[p]",
"names",
"p",
"\" \"",
"timenow",
"String args[]",
"args",
"public class Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int timenow = 0;\n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] times = new int[n];\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }\n while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }\n }\n}",
"public class Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n int timenow = 0;\n int n = sc.nextInt();\n int q = sc.nextInt();\n String[] names = new String[n];\n int[] times = new int[n];\n LinkedList<Integer> queue = new LinkedList<Integer>();\n for (int i = 0; i < n; i++){\n names[i] = sc.next();\n times[i] = sc.nextInt();\n queue.add(i);\n }\n while (queue.size()!=0){\n int p = queue.poll();\n if (times[p]>q) {\n times[p] -= q;\n queue.add(p);\n timenow += q;\n } else {\n timenow += times[p];\n System.out.println(names[p]+\" \"+timenow);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int timenow = 0;
int n = sc.nextInt();
int q = sc.nextInt();
String[] names = new String[n];
int[] times = new int[n];
LinkedList<Integer> queue = new LinkedList<Integer>();
for (int i = 0; i < n; i++){
names[i] = sc.next();
times[i] = sc.nextInt();
queue.add(i);
}
while (queue.size()!=0){
int p = queue.poll();
if (times[p]>q) {
times[p] -= q;
queue.add(p);
timenow += q;
} else {
timenow += times[p];
System.out.println(names[p]+" "+timenow);
}
}
}
} |
[
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,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
0,
13,
13,
14,
4,
18,
13,
30,
4,
18,
18,
13,
13,
17,
4,
18,
13,
13,
30,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
13,
20,
2,
13,
17,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
40,
13,
14,
2,
13,
18,
13,
13,
30,
0,
13,
17,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
17,
40,
13,
14,
2,
13,
18,
13,
13,
30,
0,
13,
17,
29,
13,
12,
13,
30,
29,
2,
13,
13,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
4,
18,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
2,
13,
4,
18,
13,
2,
13,
13,
17,
0,
13,
4,
18,
13,
2,
13,
13,
17,
29,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
2,
13,
17,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
260,
11
],
[
260,
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
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
60,
65
],
[
57,
66
],
[
66,
67
],
[
67,
68
],
[
66,
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
],
[
78,
90
],
[
90,
91
],
[
90,
92
],
[
78,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
98,
104
],
[
104,
105
],
[
105,
106
],
[
98,
107
],
[
93,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
12,
113
],
[
113,
114
],
[
260,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
115,
119
],
[
119,
120
],
[
119,
121
],
[
115,
122
],
[
122,
123
],
[
122,
124
],
[
115,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
131,
132
],
[
131,
133
],
[
125,
134
],
[
134,
135
],
[
115,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
138,
144
],
[
144,
145
],
[
138,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
149,
151
],
[
146,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
136,
156
],
[
156,
157
],
[
115,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
160,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
166,
170
],
[
160,
171
],
[
171,
172
],
[
160,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
176,
178
],
[
173,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
160,
183
],
[
183,
184
],
[
115,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
260,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
194,
196
],
[
192,
197
],
[
197,
198
],
[
197,
199
],
[
192,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
202,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
208,
212
],
[
212,
213
],
[
213,
214
],
[
212,
215
],
[
200,
216
],
[
216,
217
],
[
200,
218
],
[
218,
219
],
[
192,
220
],
[
220,
221
],
[
220,
222
],
[
222,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
228,
229
],
[
227,
230
],
[
230,
231
],
[
230,
232
],
[
227,
233
],
[
222,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
237,
238
],
[
236,
239
],
[
239,
240
],
[
239,
241
],
[
236,
242
],
[
222,
243
],
[
243,
244
],
[
220,
245
],
[
245,
246
],
[
192,
247
],
[
247,
248
],
[
247,
249
],
[
249,
250
],
[
250,
251
],
[
192,
252
],
[
252,
253
],
[
252,
254
],
[
254,
255
],
[
255,
256
],
[
256,
257
],
[
256,
258
],
[
0,
259
],
[
259,
260
],
[
259,
261
]
] | [
"import java.util.Scanner;\nimport java.util.Arrays;\nimport java.util.StringJoiner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] processInfo = scanner.nextLine().split(\" \");\n \n int processCount = Integer.parseInt(processInfo[0]);\n int quantum = Integer.parseInt(processInfo[1]);\n \n Queue queue = new Queue(processCount);\n \n for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }\n int totalTime = 0;\n \n while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }\n \n }\n \n private static class Queue {\n \n private Process[] data;\n private int top = 0;\n private int last = 0;\n \n public Queue(int size) {\n data = new Process[size + 1];\n }\n \n public void push(Process p) {\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }\n \n public Process poll() {\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }\n \n public boolean isEmpty() {\n return top == last;\n }\n \n }\n \n private static class Process {\n private String name = null;\n private int time = 0;\n public Process(String name, String time) {\n this.name = name;\n this.time = Integer.parseInt(time);\n }\n \n public int doTask(int quantum) {\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }\n \n public String getName() {\n return name;\n }\n \n public boolean hasDone() {\n return time <= 0;\n }\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.StringJoiner;",
"StringJoiner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] processInfo = scanner.nextLine().split(\" \");\n \n int processCount = Integer.parseInt(processInfo[0]);\n int quantum = Integer.parseInt(processInfo[1]);\n \n Queue queue = new Queue(processCount);\n \n for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }\n int totalTime = 0;\n \n while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }\n \n }\n \n private static class Queue {\n \n private Process[] data;\n private int top = 0;\n private int last = 0;\n \n public Queue(int size) {\n data = new Process[size + 1];\n }\n \n public void push(Process p) {\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }\n \n public Process poll() {\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }\n \n public boolean isEmpty() {\n return top == last;\n }\n \n }\n \n private static class Process {\n private String name = null;\n private int time = 0;\n public Process(String name, String time) {\n this.name = name;\n this.time = Integer.parseInt(time);\n }\n \n public int doTask(int quantum) {\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }\n \n public String getName() {\n return name;\n }\n \n public boolean hasDone() {\n return time <= 0;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] processInfo = scanner.nextLine().split(\" \");\n \n int processCount = Integer.parseInt(processInfo[0]);\n int quantum = Integer.parseInt(processInfo[1]);\n \n Queue queue = new Queue(processCount);\n \n for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }\n int totalTime = 0;\n \n while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }\n \n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n String[] processInfo = scanner.nextLine().split(\" \");\n \n int processCount = Integer.parseInt(processInfo[0]);\n int quantum = Integer.parseInt(processInfo[1]);\n \n Queue queue = new Queue(processCount);\n \n for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }\n int totalTime = 0;\n \n while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }\n \n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"String[] processInfo = scanner.nextLine().split(\" \");",
"processInfo",
"scanner.nextLine().split(\" \")",
"scanner.nextLine().split",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"\" \"",
"int processCount = Integer.parseInt(processInfo[0]);",
"processCount",
"Integer.parseInt(processInfo[0])",
"Integer.parseInt",
"Integer",
"processInfo[0]",
"processInfo",
"0",
"int quantum = Integer.parseInt(processInfo[1]);",
"quantum",
"Integer.parseInt(processInfo[1])",
"Integer.parseInt",
"Integer",
"processInfo[1]",
"processInfo",
"1",
"Queue queue = new Queue(processCount);",
"queue",
"new Queue(processCount)",
"for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < processCount",
"i",
"processCount",
"i++",
"i++",
"i",
"{\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }",
"{\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }",
"String[] p = scanner.nextLine().split(\" \");",
"p",
"scanner.nextLine().split(\" \")",
"scanner.nextLine().split",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"\" \"",
"queue.push(new Process(p[0], p[1]))",
"queue.push",
"queue",
"new Process(p[0], p[1])",
"int totalTime = 0;",
"totalTime",
"0",
"while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }",
"Process p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"int spend = p.doTask(quantum);",
"spend",
"p.doTask(quantum)",
"p.doTask",
"p",
"quantum",
"totalTime += spend",
"totalTime",
"spend",
"if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }",
"p.hasDone()",
"p.hasDone",
"p",
"{\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n }",
"System.out.printf(\"%s %d%n\", p.getName(), totalTime)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d%n\"",
"p.getName()",
"p.getName",
"p",
"totalTime",
"{\n queue.push(p);\n }",
"queue.push(p)",
"queue.push",
"queue",
"p",
"String[] args",
"args",
"private static class Queue {\n \n private Process[] data;\n private int top = 0;\n private int last = 0;\n \n public Queue(int size) {\n data = new Process[size + 1];\n }\n \n public void push(Process p) {\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }\n \n public Process poll() {\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }\n \n public boolean isEmpty() {\n return top == last;\n }\n \n }",
"Queue",
"private Process[] data;",
"data",
"private int top = 0;",
"top",
"0",
"private int last = 0;",
"last",
"0",
"public Queue(int size) {\n data = new Process[size + 1];\n }",
"Queue",
"{\n data = new Process[size + 1];\n }",
"data = new Process[size + 1]",
"data",
"new Process[size + 1]",
"size + 1",
"size",
"1",
"int size",
"size",
"public void push(Process p) {\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }",
"push",
"{\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }",
"data[last] = p",
"data[last]",
"data",
"last",
"p",
"last++",
"last",
"if (last >= data.length) {\n last = 0;\n }",
"last >= data.length",
"last",
"data.length",
"data",
"data.length",
"{\n last = 0;\n }",
"last = 0",
"last",
"0",
"Process p",
"p",
"public Process poll() {\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }",
"poll",
"{\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }",
"Process p = data[top];",
"p",
"data[top]",
"data",
"top",
"data[top] = null",
"data[top]",
"data",
"top",
"null",
"top++",
"top",
"if (top >= data.length) {\n top = 0;\n }",
"top >= data.length",
"top",
"data.length",
"data",
"data.length",
"{\n top = 0;\n }",
"top = 0",
"top",
"0",
"return p;",
"p",
"public boolean isEmpty() {\n return top == last;\n }",
"isEmpty",
"{\n return top == last;\n }",
"return top == last;",
"top == last",
"top",
"last",
"private static class Process {\n private String name = null;\n private int time = 0;\n public Process(String name, String time) {\n this.name = name;\n this.time = Integer.parseInt(time);\n }\n \n public int doTask(int quantum) {\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }\n \n public String getName() {\n return name;\n }\n \n public boolean hasDone() {\n return time <= 0;\n }\n }",
"Process",
"private String name = null;",
"name",
"null",
"private int time = 0;",
"time",
"0",
"public Process(String name, String time) {\n this.name = name;\n this.time = Integer.parseInt(time);\n }",
"Process",
"{\n this.name = name;\n this.time = Integer.parseInt(time);\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = Integer.parseInt(time)",
"this.time",
"this",
"this.time",
"Integer.parseInt(time)",
"Integer.parseInt",
"Integer",
"time",
"String name",
"name",
"String time",
"time",
"public int doTask(int quantum) {\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }",
"doTask",
"{\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }",
"int spend = quantum - Math.max(quantum - time, 0);",
"spend",
"quantum - Math.max(quantum - time, 0)",
"quantum",
"Math.max(quantum - time, 0)",
"Math.max",
"Math",
"quantum - time",
"quantum",
"time",
"0",
"time = Math.max(time - quantum, 0)",
"time",
"Math.max(time - quantum, 0)",
"Math.max",
"Math",
"time - quantum",
"time",
"quantum",
"0",
"return spend;",
"spend",
"int quantum",
"quantum",
"public String getName() {\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public boolean hasDone() {\n return time <= 0;\n }",
"hasDone",
"{\n return time <= 0;\n }",
"return time <= 0;",
"time <= 0",
"time",
"0",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] processInfo = scanner.nextLine().split(\" \");\n \n int processCount = Integer.parseInt(processInfo[0]);\n int quantum = Integer.parseInt(processInfo[1]);\n \n Queue queue = new Queue(processCount);\n \n for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }\n int totalTime = 0;\n \n while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }\n \n }\n \n private static class Queue {\n \n private Process[] data;\n private int top = 0;\n private int last = 0;\n \n public Queue(int size) {\n data = new Process[size + 1];\n }\n \n public void push(Process p) {\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }\n \n public Process poll() {\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }\n \n public boolean isEmpty() {\n return top == last;\n }\n \n }\n \n private static class Process {\n private String name = null;\n private int time = 0;\n public Process(String name, String time) {\n this.name = name;\n this.time = Integer.parseInt(time);\n }\n \n public int doTask(int quantum) {\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }\n \n public String getName() {\n return name;\n }\n \n public boolean hasDone() {\n return time <= 0;\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] processInfo = scanner.nextLine().split(\" \");\n \n int processCount = Integer.parseInt(processInfo[0]);\n int quantum = Integer.parseInt(processInfo[1]);\n \n Queue queue = new Queue(processCount);\n \n for (int i = 0; i < processCount; i++) {\n String[] p = scanner.nextLine().split(\" \");\n queue.push(new Process(p[0], p[1]));\n }\n int totalTime = 0;\n \n while (!queue.isEmpty()) {\n Process p = queue.poll();\n int spend = p.doTask(quantum);\n \n totalTime += spend;\n if (p.hasDone()) {\n System.out.printf(\"%s %d%n\", p.getName(), totalTime);\n } else {\n queue.push(p);\n }\n\n }\n \n }\n \n private static class Queue {\n \n private Process[] data;\n private int top = 0;\n private int last = 0;\n \n public Queue(int size) {\n data = new Process[size + 1];\n }\n \n public void push(Process p) {\n data[last] = p;\n last++;\n \n if (last >= data.length) {\n last = 0;\n }\n }\n \n public Process poll() {\n Process p = data[top];\n data[top] = null;\n top++;\n if (top >= data.length) {\n top = 0;\n }\n \n return p;\n }\n \n public boolean isEmpty() {\n return top == last;\n }\n \n }\n \n private static class Process {\n private String name = null;\n private int time = 0;\n public Process(String name, String time) {\n this.name = name;\n this.time = Integer.parseInt(time);\n }\n \n public int doTask(int quantum) {\n int spend = quantum - Math.max(quantum - time, 0);\n time = Math.max(time - quantum, 0);\n return spend;\n }\n \n public String getName() {\n return name;\n }\n \n public boolean hasDone() {\n return time <= 0;\n }\n }\n}",
"Main"
] | import java.util.Scanner;
import java.util.Arrays;
import java.util.StringJoiner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] processInfo = scanner.nextLine().split(" ");
int processCount = Integer.parseInt(processInfo[0]);
int quantum = Integer.parseInt(processInfo[1]);
Queue queue = new Queue(processCount);
for (int i = 0; i < processCount; i++) {
String[] p = scanner.nextLine().split(" ");
queue.push(new Process(p[0], p[1]));
}
int totalTime = 0;
while (!queue.isEmpty()) {
Process p = queue.poll();
int spend = p.doTask(quantum);
totalTime += spend;
if (p.hasDone()) {
System.out.printf("%s %d%n", p.getName(), totalTime);
} else {
queue.push(p);
}
}
}
private static class Queue {
private Process[] data;
private int top = 0;
private int last = 0;
public Queue(int size) {
data = new Process[size + 1];
}
public void push(Process p) {
data[last] = p;
last++;
if (last >= data.length) {
last = 0;
}
}
public Process poll() {
Process p = data[top];
data[top] = null;
top++;
if (top >= data.length) {
top = 0;
}
return p;
}
public boolean isEmpty() {
return top == last;
}
}
private static class Process {
private String name = null;
private int time = 0;
public Process(String name, String time) {
this.name = name;
this.time = Integer.parseInt(time);
}
public int doTask(int quantum) {
int spend = quantum - Math.max(quantum - time, 0);
time = Math.max(time - quantum, 0);
return spend;
}
public String getName() {
return name;
}
public boolean hasDone() {
return time <= 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,
20,
41,
13,
20,
41,
13,
17,
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,
42,
2,
4,
18,
13,
17,
30,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
14,
2,
4,
18,
13,
17,
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
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
119,
17
],
[
119,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
20,
30
],
[
30,
31
],
[
30,
32
],
[
20,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
20,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
20,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
43,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
55,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
60,
61
],
[
55,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
65,
66
],
[
66,
67
],
[
20,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
69,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
78,
82
],
[
74,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
87,
88
],
[
74,
89
],
[
89,
90
],
[
89,
91
],
[
74,
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
],
[
110,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
110,
114
],
[
110,
115
],
[
18,
116
],
[
116,
117
],
[
0,
118
],
[
118,
119
],
[
118,
120
]
] | [
"\n\nimport java.util.Deque;\nimport java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport 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\t\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> name = new LinkedList<>();\n\t\t\n\t\tint time = 0;\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{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\n\t\t\n\t}\n}\n",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"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\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> name = new LinkedList<>();\n\t\t\n\t\tint time = 0;\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{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\n\t\t\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> name = new LinkedList<>();\n\t\t\n\t\tint time = 0;\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{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\n\t\t\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> name = new LinkedList<>();\n\t\t\n\t\tint time = 0;\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{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\n\t\t\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Deque<Integer> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"Deque<String> name = new LinkedList<>();",
"name",
"new LinkedList<>()",
"int time = 0;",
"time",
"0",
"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{\n\t\t\tname.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\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}",
"name.add(sc.next())",
"name.add",
"name",
"sc.next()",
"sc.next",
"sc",
"queue.add(sc.nextInt())",
"queue.add",
"queue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}",
"queue.size()>0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}",
"queue.addLast(queue.poll()-q)",
"queue.addLast",
"queue",
"queue.poll()-q",
"queue.poll()",
"queue.poll",
"queue",
"q",
"name.addLast(name.poll())",
"name.addLast",
"name",
"name.poll()",
"name.poll",
"name",
"time += q",
"time",
"q",
"if(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}",
"queue.peekLast()<=0",
"queue.peekLast()",
"queue.peekLast",
"queue",
"0",
"{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}",
"time += queue.pollLast()",
"time",
"queue.pollLast()",
"queue.pollLast",
"queue",
"System.out.println(name.pollLast()+\" \"+time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name.pollLast()+\" \"+time",
"name.pollLast()+\" \"+time",
"name.pollLast()",
"name.pollLast",
"name",
"\" \"",
"time",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\t\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> name = new LinkedList<>();\n\t\t\n\t\tint time = 0;\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{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\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\n\t\t\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> name = new LinkedList<>();\n\t\t\n\t\tint time = 0;\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{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile(queue.size()>0)\n\t\t{\n\t\t\tqueue.addLast(queue.poll()-q);//ๅๅป\n\t\t\tname.addLast(name.poll());\n\t\t\ttime += q; //ๆถ้ด็ดฏๅ \n\t\t\tif(queue.peekLast()<=0)\n\t\t\t{\n\t\t\t\t//ไปฅP2ไธบไพ\n\t\t\t\t//P1 150 - 100 50 p1 50 time =100\n\t\t\t\t//p2 80 -20 -20+200 180\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(name.pollLast()+\" \"+time);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\n\t\t\n\n\t\t\n\t}\n}",
"Main"
] |
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Deque<Integer> queue = new LinkedList<>();
Deque<String> name = new LinkedList<>();
int time = 0;
int n = sc.nextInt();
int q = sc.nextInt();
for(int i=0;i<n;i++)
{
name.add(sc.next());
queue.add(sc.nextInt());
}
while(queue.size()>0)
{
queue.addLast(queue.poll()-q);//ๅๅป
name.addLast(name.poll());
time += q; //ๆถ้ด็ดฏๅ
if(queue.peekLast()<=0)
{
//ไปฅP2ไธบไพ
//P1 150 - 100 50 p1 50 time =100
//p2 80 -20 -20+200 180
time += queue.pollLast();
System.out.println(name.pollLast()+" "+time);
}
}
}
}
|
[
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,
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,
20,
4,
18,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
13,
17,
30,
0,
13,
13,
4,
18,
13,
20,
4,
18,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
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
],
[
168,
11
],
[
168,
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
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
14,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
14,
36
],
[
36,
37
],
[
36,
38
],
[
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
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
51,
57
],
[
57,
58
],
[
57,
59
],
[
51,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
14,
64
],
[
64,
65
],
[
64,
66
],
[
14,
67
],
[
67,
68
],
[
67,
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
],
[
85,
86
],
[
78,
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
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
103,
111
],
[
101,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
99,
116
],
[
87,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
14,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
130,
131
],
[
131,
132
],
[
12,
133
],
[
133,
134
],
[
0,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
135,
139
],
[
139,
140
],
[
135,
141
],
[
141,
142
],
[
141,
143
],
[
135,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
146,
150
],
[
150,
151
],
[
150,
152
],
[
144,
153
],
[
153,
154
],
[
144,
155
],
[
155,
156
],
[
135,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
135,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
0,
167
],
[
167,
168
],
[
167,
169
]
] | [
"import java.util.Scanner;\nimport java.util.Queue;\nimport java.util.ArrayDeque;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString input = in.nextLine();\n\t\tScanner setsinput = new Scanner(input);\n\t\tint n = setsinput.nextInt();\n\t\tint quantum_time = setsinput.nextInt();\n\t\tQueue<Process> q = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}\n\t\t\n\t\tProcess tmp = new Process();\n\t\tStringBuilder ans = new StringBuilder();\n\t\tint total_time = 0;\n\t\t\n\t\twhile (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(ans.toString());\n\t}\n}\n\nclass Process {\n\tString name;\n\tint time;\n\t\n\tProcess(){\n\t\t\n\t}\n\t\n\tProcess(String init_name, int init_time){\n\t\tname = init_name;\n\t\ttime = init_time;\n\t}\n\t\n\tpublic String get_Name() {\n\t\treturn name;\n\t}\n\t\n\tpublic int get_time() {\n\t\treturn time;\n\t}\n\t\n}\n\n\t\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString input = in.nextLine();\n\t\tScanner setsinput = new Scanner(input);\n\t\tint n = setsinput.nextInt();\n\t\tint quantum_time = setsinput.nextInt();\n\t\tQueue<Process> q = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}\n\t\t\n\t\tProcess tmp = new Process();\n\t\tStringBuilder ans = new StringBuilder();\n\t\tint total_time = 0;\n\t\t\n\t\twhile (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(ans.toString());\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString input = in.nextLine();\n\t\tScanner setsinput = new Scanner(input);\n\t\tint n = setsinput.nextInt();\n\t\tint quantum_time = setsinput.nextInt();\n\t\tQueue<Process> q = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}\n\t\t\n\t\tProcess tmp = new Process();\n\t\tStringBuilder ans = new StringBuilder();\n\t\tint total_time = 0;\n\t\t\n\t\twhile (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(ans.toString());\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tString input = in.nextLine();\n\t\tScanner setsinput = new Scanner(input);\n\t\tint n = setsinput.nextInt();\n\t\tint quantum_time = setsinput.nextInt();\n\t\tQueue<Process> q = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}\n\t\t\n\t\tProcess tmp = new Process();\n\t\tStringBuilder ans = new StringBuilder();\n\t\tint total_time = 0;\n\t\t\n\t\twhile (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(ans.toString());\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"String input = in.nextLine();",
"input",
"in.nextLine()",
"in.nextLine",
"in",
"Scanner setsinput = new Scanner(input);",
"setsinput",
"new Scanner(input)",
"int n = setsinput.nextInt();",
"n",
"setsinput.nextInt()",
"setsinput.nextInt",
"setsinput",
"int quantum_time = setsinput.nextInt();",
"quantum_time",
"setsinput.nextInt()",
"setsinput.nextInt",
"setsinput",
"Queue<Process> q = new ArrayDeque<Process>();",
"q",
"new ArrayDeque<Process>()",
"for(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}",
"{\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}",
"String setsStr = in.nextLine();",
"setsStr",
"in.nextLine()",
"in.nextLine",
"in",
"Scanner setsLine = new Scanner(setsStr);",
"setsLine",
"new Scanner(setsStr)",
"q.add(new Process(setsLine.next(),setsLine.nextInt()))",
"q.add",
"q",
"new Process(setsLine.next(),setsLine.nextInt())",
"Process tmp = new Process();",
"tmp",
"new Process()",
"StringBuilder ans = new StringBuilder();",
"ans",
"new StringBuilder()",
"int total_time = 0;",
"total_time",
"0",
"while (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}",
"tmp = q.peek()",
"tmp",
"q.peek()",
"q.peek",
"q",
"q.poll()",
"q.poll",
"q",
"if(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}",
"tmp.get_time() <= quantum_time",
"tmp.get_time()",
"tmp.get_time",
"tmp",
"quantum_time",
"{\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}",
"total_time += tmp.get_time()",
"total_time",
"tmp.get_time()",
"tmp.get_time",
"tmp",
"ans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\")",
"ans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append",
"ans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time))",
"ans.append(tmp.get_Name()).append(\" \").append",
"ans.append(tmp.get_Name()).append(\" \")",
"ans.append(tmp.get_Name()).append",
"ans.append(tmp.get_Name())",
"ans.append",
"ans",
"tmp.get_Name()",
"tmp.get_Name",
"tmp",
"\" \"",
"Integer.toString(total_time)",
"Integer.toString",
"Integer",
"total_time",
"\"\\n\"",
"{\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}",
"total_time += quantum_time",
"total_time",
"quantum_time",
"q.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time))",
"q.add",
"q",
"new Process(tmp.get_Name(), tmp.get_time() - quantum_time)",
"System.out.print(ans.toString())",
"System.out.print",
"System.out",
"System",
"System.out",
"ans.toString()",
"ans.toString",
"ans",
"String[] args",
"args",
"class Process {\n\tString name;\n\tint time;\n\t\n\tProcess(){\n\t\t\n\t}\n\t\n\tProcess(String init_name, int init_time){\n\t\tname = init_name;\n\t\ttime = init_time;\n\t}\n\t\n\tpublic String get_Name() {\n\t\treturn name;\n\t}\n\t\n\tpublic int get_time() {\n\t\treturn time;\n\t}\n\t\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(){\n\t\t\n\t}",
"Process",
"{\n\t\t\n\t}",
"Process(String init_name, int init_time){\n\t\tname = init_name;\n\t\ttime = init_time;\n\t}",
"Process",
"{\n\t\tname = init_name;\n\t\ttime = init_time;\n\t}",
"name = init_name",
"name",
"init_name",
"time = init_time",
"time",
"init_time",
"String init_name",
"init_name",
"int init_time",
"init_time",
"public String get_Name() {\n\t\treturn name;\n\t}",
"get_Name",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public int get_time() {\n\t\treturn time;\n\t}",
"get_time",
"{\n\t\treturn time;\n\t}",
"return time;",
"time",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString input = in.nextLine();\n\t\tScanner setsinput = new Scanner(input);\n\t\tint n = setsinput.nextInt();\n\t\tint quantum_time = setsinput.nextInt();\n\t\tQueue<Process> q = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}\n\t\t\n\t\tProcess tmp = new Process();\n\t\tStringBuilder ans = new StringBuilder();\n\t\tint total_time = 0;\n\t\t\n\t\twhile (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(ans.toString());\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tString input = in.nextLine();\n\t\tScanner setsinput = new Scanner(input);\n\t\tint n = setsinput.nextInt();\n\t\tint quantum_time = setsinput.nextInt();\n\t\tQueue<Process> q = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tString setsStr = in.nextLine();\n\t\t\t//System.out.println(setsStr.charAt(0));\n\t\t\tScanner setsLine = new Scanner(setsStr);\n\t\t\tq.add(new Process(setsLine.next(),setsLine.nextInt()));\n\t\t}\n\t\t\n\t\tProcess tmp = new Process();\n\t\tStringBuilder ans = new StringBuilder();\n\t\tint total_time = 0;\n\t\t\n\t\twhile (!q.isEmpty()) {\n\t\t\ttmp = q.peek();\n\t\t\tq.poll();\n\t\t\tif(tmp.get_time() <= quantum_time) {\n\t\t\t\ttotal_time += tmp.get_time();\n\t\t\t\tans.append(tmp.get_Name()).append(\" \").append(Integer.toString(total_time)).append(\"\\n\");\n\t\t\t}else {\n\t\t\t\ttotal_time += quantum_time;\n\t\t\t\tq.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(ans.toString());\n\t}\n}",
"Main"
] | import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String input = in.nextLine();
Scanner setsinput = new Scanner(input);
int n = setsinput.nextInt();
int quantum_time = setsinput.nextInt();
Queue<Process> q = new ArrayDeque<Process>();
for(int i = 0; i < n; i++) {
String setsStr = in.nextLine();
//System.out.println(setsStr.charAt(0));
Scanner setsLine = new Scanner(setsStr);
q.add(new Process(setsLine.next(),setsLine.nextInt()));
}
Process tmp = new Process();
StringBuilder ans = new StringBuilder();
int total_time = 0;
while (!q.isEmpty()) {
tmp = q.peek();
q.poll();
if(tmp.get_time() <= quantum_time) {
total_time += tmp.get_time();
ans.append(tmp.get_Name()).append(" ").append(Integer.toString(total_time)).append("\n");
}else {
total_time += quantum_time;
q.add(new Process(tmp.get_Name(), tmp.get_time() - quantum_time));
}
}
System.out.print(ans.toString());
}
}
class Process {
String name;
int time;
Process(){
}
Process(String init_name, int init_time){
name = init_name;
time = init_time;
}
public String get_Name() {
return name;
}
public int get_time() {
return time;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
41,
13,
20,
38,
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,
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,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
13,
17,
30,
0,
13,
13,
4,
18,
13,
20,
4,
18,
18,
13,
13,
17,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
12,
13,
30,
0,
13,
13,
0,
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
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
215,
17
],
[
215,
18
],
[
18,
19
],
[
18,
20
],
[
215,
21
],
[
21,
22
],
[
21,
23
],
[
215,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
30,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
40,
45
],
[
37,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
51,
52
],
[
51,
53
],
[
37,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
59,
61
],
[
37,
62
],
[
62,
63
],
[
62,
64
],
[
37,
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
],
[
87,
88
],
[
86,
89
],
[
37,
90
],
[
90,
91
],
[
90,
92
],
[
37,
93
],
[
93,
94
],
[
93,
95
],
[
37,
96
],
[
96,
97
],
[
96,
98
],
[
37,
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
],
[
104,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
114,
118
],
[
113,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
119,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
135,
136
],
[
129,
137
],
[
127,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
125,
142
],
[
113,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
37,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
151,
157
],
[
157,
158
],
[
158,
159
],
[
24,
160
],
[
160,
161
],
[
0,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
162,
166
],
[
166,
167
],
[
162,
168
],
[
168,
169
],
[
168,
170
],
[
162,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
177,
178
],
[
177,
179
],
[
171,
180
],
[
180,
181
],
[
171,
182
],
[
182,
183
],
[
162,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
187,
188
],
[
162,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
189,
197
],
[
197,
198
],
[
162,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
202,
203
],
[
162,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
211
],
[
204,
212
],
[
212,
213
],
[
0,
214
],
[
214,
215
],
[
214,
216
]
] | [
"import 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 final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n\nclass Process{\n\n\tprivate String name;\n\tprivate int time;\n\n\tProcess(){\n\t\t//Do nothing\n\t}\n\n\tProcess(String arg_name,int arg_time){\n\t\tname = arg_name;\n\t\ttime = arg_time;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = 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}",
"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 final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main",
"public static final int BIG_NUM = 2000000000;",
"BIG_NUM",
"2000000000",
"public static final int MOD = 1000000007;",
"MOD",
"1000000007",
"public static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"main",
"{\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"try {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}",
"catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}",
"IOException e",
"{\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}",
"String first_input[] = br.readLine().split(\"\\\\s+\");",
"first_input",
"br.readLine().split(\"\\\\s+\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s+\"",
"int N = Integer.parseInt(first_input[0]);",
"N",
"Integer.parseInt(first_input[0])",
"Integer.parseInt",
"Integer",
"first_input[0]",
"first_input",
"0",
"int quantum = Integer.parseInt(first_input[1]);",
"quantum",
"Integer.parseInt(first_input[1])",
"Integer.parseInt",
"Integer",
"first_input[1]",
"first_input",
"1",
"Queue<Process> Q = new ArrayDeque<Process>();",
"Q",
"new ArrayDeque<Process>()",
"for(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}",
"int loop = 0;",
"int loop = 0;",
"loop",
"0",
"loop < N",
"loop",
"N",
"loop++",
"loop++",
"loop",
"{\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}",
"{\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}",
"String input[] = br.readLine().split(\"\\\\s+\");",
"input",
"br.readLine().split(\"\\\\s+\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s+\"",
"Q.add(new Process(input[0],Integer.parseInt(input[1])))",
"Q.add",
"Q",
"new Process(input[0],Integer.parseInt(input[1]))",
"StringBuilder ans = new StringBuilder();",
"ans",
"new StringBuilder()",
"Process tmp = new Process();",
"tmp",
"new Process()",
"int current_time = 0;",
"current_time",
"0",
"while(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}",
"!Q.isEmpty()",
"Q.isEmpty()",
"Q.isEmpty",
"Q",
"{\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}",
"tmp = Q.peek()",
"tmp",
"Q.peek()",
"Q.peek",
"Q",
"Q.poll()",
"Q.poll",
"Q",
"if(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}",
"tmp.getTime() <= quantum",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"quantum",
"{\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}",
"current_time += tmp.getTime()",
"current_time",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"ans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\")",
"ans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append",
"ans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time))",
"ans.append(tmp.getName()).append(\" \").append",
"ans.append(tmp.getName()).append(\" \")",
"ans.append(tmp.getName()).append",
"ans.append(tmp.getName())",
"ans.append",
"ans",
"tmp.getName()",
"tmp.getName",
"tmp",
"\" \"",
"Integer.toString(current_time)",
"Integer.toString",
"Integer",
"current_time",
"\"\\n\"",
"{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}",
"current_time += quantum",
"current_time",
"quantum",
"Q.add(new Process(tmp.getName(),tmp.getTime()-quantum))",
"Q.add",
"Q",
"new Process(tmp.getName(),tmp.getTime()-quantum)",
"System.out.printf(\"%s\",ans.toString())",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s\"",
"ans.toString()",
"ans.toString",
"ans",
"String[] args",
"args",
"class Process{\n\n\tprivate String name;\n\tprivate int time;\n\n\tProcess(){\n\t\t//Do nothing\n\t}\n\n\tProcess(String arg_name,int arg_time){\n\t\tname = arg_name;\n\t\ttime = arg_time;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = 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}",
"Process",
"private String name;",
"name",
"private int time;",
"time",
"Process(){\n\t\t//Do nothing\n\t}",
"Process",
"{\n\t\t//Do nothing\n\t}",
"Process(String arg_name,int arg_time){\n\t\tname = arg_name;\n\t\ttime = arg_time;\n\t}",
"Process",
"{\n\t\tname = arg_name;\n\t\ttime = arg_time;\n\t}",
"name = arg_name",
"name",
"arg_name",
"time = arg_time",
"time",
"arg_time",
"String arg_name",
"arg_name",
"int arg_time",
"arg_time",
"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 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\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"public class Main {\n\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry {\n\t\t\tString first_input[] = br.readLine().split(\"\\\\s+\");\n\n\t\t\tint N = Integer.parseInt(first_input[0]);\n\t\t\tint quantum = Integer.parseInt(first_input[1]);\n\n\t\t\tQueue<Process> Q = new ArrayDeque<Process>();\n\n\t\t\tfor(int loop = 0; loop < N; loop++){\n\t\t\t\tString input[] = br.readLine().split(\"\\\\s+\");\n\t\t\t\tQ.add(new Process(input[0],Integer.parseInt(input[1])));\n\t\t\t}\n\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\tProcess tmp = new Process();\n\n\t\t\tint current_time = 0;\n\n\t\t\twhile(!Q.isEmpty()){\n\t\t\t\ttmp = Q.peek();\n\t\t\t\tQ.poll();\n\n\t\t\t\tif(tmp.getTime() <= quantum){\n\t\t\t\t\tcurrent_time += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(current_time)).append(\"\\n\");\n\t\t\t\t}else{\n\t\t\t\t\tcurrent_time += quantum;\n\t\t\t\t\tQ.add(new Process(tmp.getName(),tmp.getTime()-quantum));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tSystem.out.printf(\"%s\",ans.toString());\n\n\t\t}catch (IOException e) {\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;
import java.util.Queue;
public class Main {
public static final int BIG_NUM = 2000000000;
public static final int MOD = 1000000007;
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String first_input[] = br.readLine().split("\\s+");
int N = Integer.parseInt(first_input[0]);
int quantum = Integer.parseInt(first_input[1]);
Queue<Process> Q = new ArrayDeque<Process>();
for(int loop = 0; loop < N; loop++){
String input[] = br.readLine().split("\\s+");
Q.add(new Process(input[0],Integer.parseInt(input[1])));
}
StringBuilder ans = new StringBuilder();
Process tmp = new Process();
int current_time = 0;
while(!Q.isEmpty()){
tmp = Q.peek();
Q.poll();
if(tmp.getTime() <= quantum){
current_time += tmp.getTime();
ans.append(tmp.getName()).append(" ").append(Integer.toString(current_time)).append("\n");
}else{
current_time += quantum;
Q.add(new Process(tmp.getName(),tmp.getTime()-quantum));
}
}
System.out.printf("%s",ans.toString());
}catch (IOException e) {
e.printStackTrace();
}
}
}
class Process{
private String name;
private int time;
Process(){
//Do nothing
}
Process(String arg_name,int arg_time){
name = arg_name;
time = arg_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,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
13,
20,
2,
13,
17,
0,
13,
20,
2,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
0,
13,
17,
0,
13,
13,
0,
13,
17,
11,
1,
40,
4,
13,
30,
30,
0,
13,
4,
13,
13,
13,
0,
13,
4,
13,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
13,
4,
13,
13,
13,
13,
4,
13,
13,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
4,
18,
13,
23,
13,
23,
13,
12,
13,
30,
4,
18,
20,
18,
13,
13,
18,
13,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
2,
13,
17,
23,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
0,
13,
2,
2,
13,
17,
2,
13,
17,
29,
18,
13,
2,
2,
13,
13,
2,
13,
17,
23,
13,
23,
13,
12,
13,
30,
29,
18,
13,
2,
2,
13,
13,
2,
13,
17,
23,
13,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
17,
30,
29,
17,
10,
6,
13
] | [
[
0,
1
],
[
256,
2
],
[
256,
3
],
[
3,
4
],
[
256,
5
],
[
5,
6
],
[
256,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
10,
11
],
[
10,
12
],
[
9,
13
],
[
13,
14
],
[
9,
15
],
[
15,
16
],
[
9,
17
],
[
17,
18
],
[
9,
19
],
[
19,
20
],
[
9,
21
],
[
21,
22
],
[
9,
23
],
[
23,
24
],
[
9,
25
],
[
25,
26
],
[
9,
27
],
[
27,
28
],
[
9,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
9,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
9,
39
],
[
39,
40
],
[
39,
41
],
[
42,
43
],
[
42,
44
],
[
9,
45
],
[
45,
46
],
[
45,
47
],
[
48,
49
],
[
48,
50
],
[
9,
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
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
69,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
9,
78
],
[
78,
79
],
[
78,
80
],
[
9,
81
],
[
81,
82
],
[
81,
83
],
[
9,
84
],
[
84,
85
],
[
84,
86
],
[
9,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
87,
92
],
[
93,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
96,
99
],
[
93,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
102,
105
],
[
93,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
114,
116
],
[
110,
117
],
[
117,
118
],
[
117,
119
],
[
117,
120
],
[
117,
121
],
[
110,
122
],
[
122,
123
],
[
122,
124
],
[
122,
125
],
[
122,
126
],
[
106,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
131,
136
],
[
137,
137
],
[
137,
138
],
[
137,
139
],
[
137,
140
],
[
9,
141
],
[
141,
142
],
[
142,
143
],
[
7,
144
],
[
144,
145
],
[
7,
146
],
[
146,
147
],
[
256,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
154,
155
],
[
154,
156
],
[
151,
157
],
[
157,
158
],
[
157,
159
],
[
148,
160
],
[
160,
161
],
[
256,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
164,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
176,
178
],
[
162,
179
],
[
179,
180
],
[
162,
181
],
[
181,
182
],
[
162,
183
],
[
183,
184
],
[
256,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
188,
192
],
[
185,
193
],
[
193,
194
],
[
185,
195
],
[
195,
196
],
[
185,
197
],
[
197,
198
],
[
256,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
204,
208
],
[
208,
209
],
[
208,
210
],
[
201,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
214,
218
],
[
218,
219
],
[
218,
220
],
[
199,
221
],
[
221,
222
],
[
199,
223
],
[
223,
224
],
[
256,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
231,
235
],
[
235,
236
],
[
235,
237
],
[
225,
238
],
[
238,
239
],
[
225,
240
],
[
240,
241
],
[
256,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
245,
249
],
[
249,
250
],
[
250,
251
],
[
245,
252
],
[
252,
253
],
[
253,
254
],
[
0,
255
],
[
255,
256
],
[
255,
257
]
] | [
"public class Main{\n static int head, tail;\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n, q;\n String[] name;\n int[] time;\n int i, t, a;\n String s;\n\n n = sc.nextInt();\n q = sc.nextInt();\n name = new String[n + 1];\n time = new int[n + 1];\n for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n head = 0;\n tail = n;\n t = 0;\n\n for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n\n private static void enqueue(int[] time, int n, int a){\n time[tail] = a;\n tail = (tail + 1) % (n + 1);\n }\n\n private static void strenqueue(String[] name, int n, String s){\n name[tail] = s;\n }\n\n private static int dequeue(int[] time, int n){\n head = (head + 1) % (n + 1);\n return time[(n + head) % (n + 1)];\n }\n\n private static String strdequeue(String[] name, int n){\n return name[(head + n) % (n + 1)];\n }\n\n private static boolean isEmpty(){\n if(head == tail){\n return true;\n }else{\n return false;\n }\n }\n\n}",
"public class Main{\n static int head, tail;\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n, q;\n String[] name;\n int[] time;\n int i, t, a;\n String s;\n\n n = sc.nextInt();\n q = sc.nextInt();\n name = new String[n + 1];\n time = new int[n + 1];\n for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n head = 0;\n tail = n;\n t = 0;\n\n for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n\n private static void enqueue(int[] time, int n, int a){\n time[tail] = a;\n tail = (tail + 1) % (n + 1);\n }\n\n private static void strenqueue(String[] name, int n, String s){\n name[tail] = s;\n }\n\n private static int dequeue(int[] time, int n){\n head = (head + 1) % (n + 1);\n return time[(n + head) % (n + 1)];\n }\n\n private static String strdequeue(String[] name, int n){\n return name[(head + n) % (n + 1)];\n }\n\n private static boolean isEmpty(){\n if(head == tail){\n return true;\n }else{\n return false;\n }\n }\n\n}",
"Main",
"static int head",
"head",
"tail;",
"tail",
"public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n, q;\n String[] name;\n int[] time;\n int i, t, a;\n String s;\n\n n = sc.nextInt();\n q = sc.nextInt();\n name = new String[n + 1];\n time = new int[n + 1];\n for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n head = 0;\n tail = n;\n t = 0;\n\n for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }\n\n sc.close();\n }",
"run",
"{\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n, q;\n String[] name;\n int[] time;\n int i, t, a;\n String s;\n\n n = sc.nextInt();\n q = sc.nextInt();\n name = new String[n + 1];\n time = new int[n + 1];\n for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n head = 0;\n tail = n;\n t = 0;\n\n for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }\n\n sc.close();\n }",
"java.util.Scanner sc = new java.util.Scanner(in);",
"sc",
"new java.util.Scanner(in)",
"int n",
"n",
"q;",
"q",
"String[] name;",
"name",
"int[] time;",
"time",
"int i",
"i",
"t",
"t",
"a;",
"a",
"String s;",
"s",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = sc.nextInt()",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"name = new String[n + 1]",
"name",
"new String[n + 1]",
"n + 1",
"n",
"1",
"time = new int[n + 1]",
"time",
"new int[n + 1]",
"n + 1",
"n",
"1",
"for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }",
"i = 0;",
"i = 0",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\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",
"head = 0",
"head",
"0",
"tail = n",
"tail",
"n",
"t = 0",
"t",
"0",
"for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }",
";",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }",
"{\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }",
"a = dequeue(time, n)",
"a",
"dequeue(time, n)",
"dequeue",
"time",
"n",
"s = strdequeue(name, n)",
"s",
"strdequeue(name, n)",
"strdequeue",
"name",
"n",
"if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }",
"a > q",
"a",
"q",
"{\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }",
"t += q",
"t",
"q",
"a -= q",
"a",
"q",
"strenqueue(name, n, s)",
"strenqueue",
"name",
"n",
"s",
"enqueue(time, n, a)",
"enqueue",
"time",
"n",
"a",
"{\n t += a;\n System.out.println(s + \" \" + t);\n }",
"t += a",
"t",
"a",
"System.out.println(s + \" \" + t)",
"System.out.println",
"System.out",
"System",
"System.out",
"s + \" \" + t",
"s + \" \" + t",
"s",
"\" \"",
"t",
"sc.close()",
"sc.close",
"sc",
"java.io.InputStream in",
"in",
"java.io.PrintStream out",
"out",
"public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }",
"main",
"{\n (new Main()).run(System.in, System.out);\n }",
"(new Main()).run(System.in, System.out)",
"(new Main()).run",
"(new Main())",
"System.in",
"System",
"System.in",
"System.out",
"System",
"System.out",
"String[] args",
"args",
"private static void enqueue(int[] time, int n, int a){\n time[tail] = a;\n tail = (tail + 1) % (n + 1);\n }",
"enqueue",
"{\n time[tail] = a;\n tail = (tail + 1) % (n + 1);\n }",
"time[tail] = a",
"time[tail]",
"time",
"tail",
"a",
"tail = (tail + 1) % (n + 1)",
"tail",
"(tail + 1) % (n + 1)",
"(tail + 1)",
"tail",
"1",
"(n + 1)",
"n",
"1",
"int[] time",
"time",
"int n",
"n",
"int a",
"a",
"private static void strenqueue(String[] name, int n, String s){\n name[tail] = s;\n }",
"strenqueue",
"{\n name[tail] = s;\n }",
"name[tail] = s",
"name[tail]",
"name",
"tail",
"s",
"String[] name",
"name",
"int n",
"n",
"String s",
"s",
"private static int dequeue(int[] time, int n){\n head = (head + 1) % (n + 1);\n return time[(n + head) % (n + 1)];\n }",
"dequeue",
"{\n head = (head + 1) % (n + 1);\n return time[(n + head) % (n + 1)];\n }",
"head = (head + 1) % (n + 1)",
"head",
"(head + 1) % (n + 1)",
"(head + 1)",
"head",
"1",
"(n + 1)",
"n",
"1",
"return time[(n + head) % (n + 1)];",
"time[(n + head) % (n + 1)]",
"time",
"(n + head) % (n + 1)",
"(n + head)",
"n",
"head",
"(n + 1)",
"n",
"1",
"int[] time",
"time",
"int n",
"n",
"private static String strdequeue(String[] name, int n){\n return name[(head + n) % (n + 1)];\n }",
"strdequeue",
"{\n return name[(head + n) % (n + 1)];\n }",
"return name[(head + n) % (n + 1)];",
"name[(head + n) % (n + 1)]",
"name",
"(head + n) % (n + 1)",
"(head + n)",
"head",
"n",
"(n + 1)",
"n",
"1",
"String[] name",
"name",
"int n",
"n",
"private static boolean isEmpty(){\n if(head == tail){\n return true;\n }else{\n return false;\n }\n }",
"isEmpty",
"{\n if(head == tail){\n return true;\n }else{\n return false;\n }\n }",
"if(head == tail){\n return true;\n }else{\n return false;\n }",
"head == tail",
"head",
"tail",
"{\n return true;\n }",
"return true;",
"true",
"{\n return false;\n }",
"return false;",
"false",
"public class Main{\n static int head, tail;\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n, q;\n String[] name;\n int[] time;\n int i, t, a;\n String s;\n\n n = sc.nextInt();\n q = sc.nextInt();\n name = new String[n + 1];\n time = new int[n + 1];\n for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n head = 0;\n tail = n;\n t = 0;\n\n for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n\n private static void enqueue(int[] time, int n, int a){\n time[tail] = a;\n tail = (tail + 1) % (n + 1);\n }\n\n private static void strenqueue(String[] name, int n, String s){\n name[tail] = s;\n }\n\n private static int dequeue(int[] time, int n){\n head = (head + 1) % (n + 1);\n return time[(n + head) % (n + 1)];\n }\n\n private static String strdequeue(String[] name, int n){\n return name[(head + n) % (n + 1)];\n }\n\n private static boolean isEmpty(){\n if(head == tail){\n return true;\n }else{\n return false;\n }\n }\n\n}",
"public class Main{\n static int head, tail;\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n/*answer*/\n int n, q;\n String[] name;\n int[] time;\n int i, t, a;\n String s;\n\n n = sc.nextInt();\n q = sc.nextInt();\n name = new String[n + 1];\n time = new int[n + 1];\n for(i = 0;i < n;i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n head = 0;\n tail = n;\n t = 0;\n\n for(;!isEmpty();){\n a = dequeue(time, n);\n s = strdequeue(name, n);\n if(a > q){\n t += q;\n a -= q;\n strenqueue(name, n, s);\n enqueue(time, n, a);\n }else{\n t += a;\n System.out.println(s + \" \" + t);\n }\n }\n\n sc.close();\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n\n private static void enqueue(int[] time, int n, int a){\n time[tail] = a;\n tail = (tail + 1) % (n + 1);\n }\n\n private static void strenqueue(String[] name, int n, String s){\n name[tail] = s;\n }\n\n private static int dequeue(int[] time, int n){\n head = (head + 1) % (n + 1);\n return time[(n + head) % (n + 1)];\n }\n\n private static String strdequeue(String[] name, int n){\n return name[(head + n) % (n + 1)];\n }\n\n private static boolean isEmpty(){\n if(head == tail){\n return true;\n }else{\n return false;\n }\n }\n\n}",
"Main"
] | public class Main{
static int head, tail;
public void run(java.io.InputStream in, java.io.PrintStream out){
java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
int n, q;
String[] name;
int[] time;
int i, t, a;
String s;
n = sc.nextInt();
q = sc.nextInt();
name = new String[n + 1];
time = new int[n + 1];
for(i = 0;i < n;i++){
name[i] = sc.next();
time[i] = sc.nextInt();
}
head = 0;
tail = n;
t = 0;
for(;!isEmpty();){
a = dequeue(time, n);
s = strdequeue(name, n);
if(a > q){
t += q;
a -= q;
strenqueue(name, n, s);
enqueue(time, n, a);
}else{
t += a;
System.out.println(s + " " + t);
}
}
sc.close();
}
public static void main(String[] args){
(new Main()).run(System.in, System.out);
}
private static void enqueue(int[] time, int n, int a){
time[tail] = a;
tail = (tail + 1) % (n + 1);
}
private static void strenqueue(String[] name, int n, String s){
name[tail] = s;
}
private static int dequeue(int[] time, int n){
head = (head + 1) % (n + 1);
return time[(n + head) % (n + 1)];
}
private static String strdequeue(String[] name, int n){
return name[(head + n) % (n + 1)];
}
private static boolean isEmpty(){
if(head == tail){
return true;
}else{
return false;
}
}
} |
[
7,
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,
29,
13,
6,
13,
41,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
13,
20,
2,
13,
17,
23,
13,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
18,
13,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
0,
18,
13,
13,
20,
14,
2,
2,
13,
17,
18,
13,
13,
30,
0,
13,
17,
30,
40,
13,
23,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
18,
13,
13,
30,
0,
13,
17,
30,
40,
13,
29,
13,
12,
13,
30,
29,
8,
2,
13,
13,
13,
13,
23,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
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,
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,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
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
],
[
9,
10
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
15,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
13,
26
],
[
26,
27
],
[
13,
28
],
[
28,
29
],
[
7,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
7,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
0,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
40,
44
],
[
44,
45
],
[
44,
46
],
[
40,
47
],
[
47,
48
],
[
47,
49
],
[
40,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
56,
57
],
[
56,
58
],
[
50,
59
],
[
59,
60
],
[
40,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
40,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
78,
80
],
[
40,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
88,
89
],
[
83,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
83,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
100,
102
],
[
95,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
95,
107
],
[
107,
108
],
[
108,
109
],
[
81,
110
],
[
110,
111
],
[
81,
112
],
[
112,
113
],
[
40,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
120,
121
],
[
121,
122
],
[
116,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
116,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
128,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
128,
140
],
[
140,
141
],
[
141,
142
],
[
116,
143
],
[
143,
144
],
[
40,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
149,
154
],
[
145,
155
],
[
155,
156
],
[
145,
157
],
[
157,
158
],
[
0,
159
],
[
268,
160
],
[
268,
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
],
[
163,
182
],
[
182,
183
],
[
163,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
184,
189
],
[
189,
190
],
[
189,
191
],
[
184,
192
],
[
192,
193
],
[
193,
194
],
[
184,
195
],
[
196,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
199,
200
],
[
200,
201
],
[
196,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
205,
206
],
[
196,
207
],
[
207,
208
],
[
208,
209
],
[
207,
210
],
[
207,
211
],
[
163,
212
],
[
212,
213
],
[
212,
214
],
[
163,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
215,
220
],
[
220,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
224,
225
],
[
220,
226
],
[
226,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
227,
231
],
[
226,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
232,
236
],
[
236,
237
],
[
237,
238
],
[
236,
239
],
[
239,
240
],
[
240,
241
],
[
236,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
242,
246
],
[
226,
247
],
[
247,
248
],
[
248,
249
],
[
248,
250
],
[
250,
251
],
[
251,
252
],
[
247,
253
],
[
253,
254
],
[
254,
255
],
[
255,
256
],
[
255,
257
],
[
253,
258
],
[
259,
259
],
[
259,
260
],
[
260,
261
],
[
261,
262
],
[
259,
263
],
[
259,
264
],
[
161,
265
],
[
265,
266
],
[
0,
267
],
[
267,
268
],
[
267,
269
]
] | [
"import java.util.Scanner;\nimport java.nio.*;\n\nclass Queue{\n private String name;\n private int time;\n\n public Queue(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 int getTime(){\n return time;\n }\n}\n\nclass MyQueue{\n private Queue[] queue;\n private int head = 0;\n private int tail = 0;\n \n public MyQueue(int size){\n queue = new Queue[size + 1];\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n public boolean isFull(){\n return head == (tail + 1) % queue.length;\n }\n\n public void enqueue(String name, int time) throws Exception{\n if(isFull()){\n throw new Exception();\n }\n\n queue[tail] = new Queue(name, time);\n\n if(tail + 1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }\n\n public Queue dequeue() throws Exception{\n if(isEmpty()){\n throw new Exception();\n }\n Queue x = queue[head];\n if(head + 1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }\n\n public int min(int a, int b){\n return a < b ? a : b;\n }\n}\n\npublic class Main{\n public static void main(String[] args) throws Exception{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n MyQueue queue = new MyQueue(n);\n\n String name;\n int time;\n for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }\n \n int sum = 0;\n while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }\n }\n}\n\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.nio.*;",
"nio.*",
"java",
"class Queue{\n private String name;\n private int time;\n\n public Queue(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 int getTime(){\n return time;\n }\n}",
"Queue",
"private String name;",
"name",
"private int time;",
"time",
"public Queue(String name, int time){\n this.name = name;\n this.time = time;\n }",
"Queue",
"{\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 int getTime(){\n return time;\n }",
"getTime",
"{\n return time;\n }",
"return time;",
"time",
"class MyQueue{\n private Queue[] queue;\n private int head = 0;\n private int tail = 0;\n \n public MyQueue(int size){\n queue = new Queue[size + 1];\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n public boolean isFull(){\n return head == (tail + 1) % queue.length;\n }\n\n public void enqueue(String name, int time) throws Exception{\n if(isFull()){\n throw new Exception();\n }\n\n queue[tail] = new Queue(name, time);\n\n if(tail + 1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }\n\n public Queue dequeue() throws Exception{\n if(isEmpty()){\n throw new Exception();\n }\n Queue x = queue[head];\n if(head + 1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }\n\n public int min(int a, int b){\n return a < b ? a : b;\n }\n}",
"MyQueue",
"private Queue[] queue;",
"queue",
"private int head = 0;",
"head",
"0",
"private int tail = 0;",
"tail",
"0",
"public MyQueue(int size){\n queue = new Queue[size + 1];\n }",
"MyQueue",
"{\n queue = new Queue[size + 1];\n }",
"queue = new Queue[size + 1]",
"queue",
"new Queue[size + 1]",
"size + 1",
"size",
"1",
"int size",
"size",
"public boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"public boolean isFull(){\n return head == (tail + 1) % queue.length;\n }",
"isFull",
"{\n return head == (tail + 1) % queue.length;\n }",
"return head == (tail + 1) % queue.length;",
"head == (tail + 1) % queue.length",
"head",
"(tail + 1) % queue.length",
"(tail + 1)",
"tail",
"1",
"queue.length",
"queue",
"queue.length",
"public void enqueue(String name, int time) throws Exception{\n if(isFull()){\n throw new Exception();\n }\n\n queue[tail] = new Queue(name, time);\n\n if(tail + 1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }",
"enqueue",
"{\n if(isFull()){\n throw new Exception();\n }\n\n queue[tail] = new Queue(name, time);\n\n if(tail + 1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }\n }",
"if(isFull()){\n throw new Exception();\n }",
"isFull()",
"isFull",
"{\n throw new Exception();\n }",
"throw new Exception();",
"new Exception()",
"queue[tail] = new Queue(name, time)",
"queue[tail]",
"queue",
"tail",
"new Queue(name, time)",
"if(tail + 1 == queue.length){\n tail = 0;\n }else{\n tail++;\n }",
"tail + 1 == queue.length",
"tail + 1",
"tail",
"1",
"queue.length",
"queue",
"queue.length",
"{\n tail = 0;\n }",
"tail = 0",
"tail",
"0",
"{\n tail++;\n }",
"tail++",
"tail",
"String name",
"name",
"int time",
"time",
"public Queue dequeue() throws Exception{\n if(isEmpty()){\n throw new Exception();\n }\n Queue x = queue[head];\n if(head + 1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }",
"dequeue",
"{\n if(isEmpty()){\n throw new Exception();\n }\n Queue x = queue[head];\n if(head + 1 == queue.length){\n head = 0;\n }else{\n head++;\n }\n return x;\n }",
"if(isEmpty()){\n throw new Exception();\n }",
"isEmpty()",
"isEmpty",
"{\n throw new Exception();\n }",
"throw new Exception();",
"new Exception()",
"Queue x = queue[head];",
"x",
"queue[head]",
"queue",
"head",
"if(head + 1 == queue.length){\n head = 0;\n }else{\n head++;\n }",
"head + 1 == queue.length",
"head + 1",
"head",
"1",
"queue.length",
"queue",
"queue.length",
"{\n head = 0;\n }",
"head = 0",
"head",
"0",
"{\n head++;\n }",
"head++",
"head",
"return x;",
"x",
"public int min(int a, int b){\n return a < b ? a : b;\n }",
"min",
"{\n return a < b ? a : b;\n }",
"return a < b ? a : b;",
"a < b ? a : b",
"a < b",
"a",
"b",
"a",
"b",
"int a",
"a",
"int b",
"b",
"public class Main{\n public static void main(String[] args) throws Exception{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n MyQueue queue = new MyQueue(n);\n\n String name;\n int time;\n for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }\n \n int sum = 0;\n while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) throws Exception{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n MyQueue queue = new MyQueue(n);\n\n String name;\n int time;\n for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }\n \n int sum = 0;\n while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n MyQueue queue = new MyQueue(n);\n\n String name;\n int time;\n for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }\n \n int sum = 0;\n while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\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",
"MyQueue queue = new MyQueue(n);",
"queue",
"new MyQueue(n)",
"String name;",
"name",
"int time;",
"time",
"for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }",
"{\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }",
"name = sc.next()",
"name",
"sc.next()",
"sc.next",
"sc",
"time = sc.nextInt()",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"queue.enqueue(name, time)",
"queue.enqueue",
"queue",
"name",
"time",
"int sum = 0;",
"sum",
"0",
"while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }",
"Queue q1 = queue.dequeue();",
"q1",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }",
"q1.getTime() > q",
"q1.getTime()",
"q1.getTime",
"q1",
"q",
"{\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }",
"sum += q",
"sum",
"q",
"queue.enqueue(q1.getName(), q1.getTime() - q)",
"queue.enqueue",
"queue",
"q1.getName()",
"q1.getName",
"q1",
"q1.getTime() - q",
"q1.getTime()",
"q1.getTime",
"q1",
"q",
"{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }",
"sum += q1.getTime()",
"sum",
"q1.getTime()",
"q1.getTime",
"q1",
"System.out.println(q1.getName() + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"q1.getName() + \" \" + sum",
"q1.getName() + \" \" + sum",
"q1.getName()",
"q1.getName",
"q1",
"\" \"",
"sum",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args) throws Exception{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n MyQueue queue = new MyQueue(n);\n\n String name;\n int time;\n for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }\n \n int sum = 0;\n while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }\n }\n}",
"public class Main{\n public static void main(String[] args) throws Exception{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n MyQueue queue = new MyQueue(n);\n\n String name;\n int time;\n for(int i = 0; i < n; i++){\n name = sc.next();\n time = sc.nextInt();\n queue.enqueue(name, time);\n }\n \n int sum = 0;\n while(!queue.isEmpty()){\n Queue q1 = queue.dequeue();\n if(q1.getTime() > q){\n sum += q;\n queue.enqueue(q1.getName(), q1.getTime() - q);\n }else{\n sum += q1.getTime();\n System.out.println(q1.getName() + \" \" + sum);\n }\n }\n }\n}",
"Main"
] | import java.util.Scanner;
import java.nio.*;
class Queue{
private String name;
private int time;
public Queue(String name, int time){
this.name = name;
this.time = time;
}
public String getName(){
return name;
}
public int getTime(){
return time;
}
}
class MyQueue{
private Queue[] queue;
private int head = 0;
private int tail = 0;
public MyQueue(int size){
queue = new Queue[size + 1];
}
public boolean isEmpty(){
return head == tail;
}
public boolean isFull(){
return head == (tail + 1) % queue.length;
}
public void enqueue(String name, int time) throws Exception{
if(isFull()){
throw new Exception();
}
queue[tail] = new Queue(name, time);
if(tail + 1 == queue.length){
tail = 0;
}else{
tail++;
}
}
public Queue dequeue() throws Exception{
if(isEmpty()){
throw new Exception();
}
Queue x = queue[head];
if(head + 1 == queue.length){
head = 0;
}else{
head++;
}
return x;
}
public int min(int a, int b){
return a < b ? a : b;
}
}
public class Main{
public static void main(String[] args) throws Exception{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
MyQueue queue = new MyQueue(n);
String name;
int time;
for(int i = 0; i < n; i++){
name = sc.next();
time = sc.nextInt();
queue.enqueue(name, time);
}
int sum = 0;
while(!queue.isEmpty()){
Queue q1 = queue.dequeue();
if(q1.getTime() > q){
sum += q;
queue.enqueue(q1.getName(), q1.getTime() - q);
}else{
sum += q1.getTime();
System.out.println(q1.getName() + " " + sum);
}
}
}
}
|
[
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,
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,
13,
41,
13,
17,
41,
13,
17,
42,
2,
13,
17,
30,
14,
2,
18,
13,
13,
17,
30,
0,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
30,
40,
13,
0,
13,
2,
18,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
0,
13,
2,
13,
13,
14,
2,
13,
13,
0,
13,
2,
13,
17,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
17,
40,
13,
14,
2,
13,
13,
0,
13,
2,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
169,
5
],
[
169,
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
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
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
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
46,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
59,
60
],
[
8,
61
],
[
61,
62
],
[
61,
63
],
[
8,
64
],
[
64,
65
],
[
64,
66
],
[
8,
67
],
[
67,
68
],
[
67,
69
],
[
8,
70
],
[
70,
71
],
[
70,
72
],
[
8,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
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
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
96,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
112,
117
],
[
90,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
118,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
118,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
140,
142
],
[
118,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
84,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
77,
155
],
[
155,
156
],
[
77,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
6,
166
],
[
166,
167
],
[
0,
168
],
[
168,
169
],
[
168,
170
]
] | [
"import java.util.Scanner;\npublic class Main{\n public static void main(String[] args){\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n int q=s.nextInt();\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }\n int total=0,cnt=n,now=0,next=0;\n while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String[] args){\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n int q=s.nextInt();\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }\n int total=0,cnt=n,now=0,next=0;\n while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n int q=s.nextInt();\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }\n int total=0,cnt=n,now=0,next=0;\n while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }\n }",
"main",
"{\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n int q=s.nextInt();\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }\n int total=0,cnt=n,now=0,next=0;\n while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }\n }",
"Scanner s=new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int n=s.nextInt();",
"n",
"s.nextInt()",
"s.nextInt",
"s",
"int q=s.nextInt();",
"q",
"s.nextInt()",
"s.nextInt",
"s",
"String name[]=new String[n+1];",
"name",
"new String[n+1]",
"n+1",
"n",
"1",
"int time[]=new int[n+1];",
"time",
"new int[n+1]",
"n+1",
"n",
"1",
"for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name[i]=s.next();\n time[i]=s.nextInt();\n }",
"{\n name[i]=s.next();\n time[i]=s.nextInt();\n }",
"name[i]=s.next()",
"name[i]",
"name",
"i",
"s.next()",
"s.next",
"s",
"time[i]=s.nextInt()",
"time[i]",
"time",
"i",
"s.nextInt()",
"s.nextInt",
"s",
"int total=0",
"total",
"0",
"cnt=n",
"cnt",
"n",
"now=0",
"now",
"0",
"next=0;",
"next",
"0",
"while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }",
"cnt!=0",
"cnt",
"0",
"{\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }",
"if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }",
"time[now]>0",
"time[now]",
"time",
"now",
"0",
"{\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }",
"time[now]-=q",
"time[now]",
"time",
"now",
"q",
"if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }",
"time[now]<=0",
"time[now]",
"time",
"now",
"0",
"{\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }",
"cnt--",
"cnt",
"total+=time[now]+q",
"total",
"time[now]+q",
"time[now]",
"time",
"now",
"q",
"System.out.println(name[now]+\" \"+total)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[now]+\" \"+total",
"name[now]+\" \"+total",
"name[now]",
"name",
"now",
"\" \"",
"total",
"{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }",
"total+=q",
"total",
"q",
"next=now+cnt",
"next",
"now+cnt",
"now",
"cnt",
"if(next>n) next-=(n+1);",
"next>n",
"next",
"n",
"next-=(n+1)",
"next",
"(n+1)",
"n",
"1",
"name[next]=name[now]",
"name[next]",
"name",
"next",
"name[now]",
"name",
"now",
"time[next]=time[now]",
"time[next]",
"time",
"next",
"time[now]",
"time",
"now",
"time[now]=0",
"time[now]",
"time",
"now",
"0",
"now++",
"now",
"if(now>n) now-=(n+1);",
"now>n",
"now",
"n",
"now-=(n+1)",
"now",
"(n+1)",
"n",
"1",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n int q=s.nextInt();\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }\n int total=0,cnt=n,now=0,next=0;\n while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }\n }\n}",
"public class Main{\n public static void main(String[] args){\n Scanner s=new Scanner(System.in);\n int n=s.nextInt();\n int q=s.nextInt();\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(int i=0;i<n;i++){\n name[i]=s.next();\n time[i]=s.nextInt();\n }\n int total=0,cnt=n,now=0,next=0;\n while(cnt!=0){\n if(time[now]>0){\n time[now]-=q;\n if(time[now]<=0){\n cnt--;\n total+=time[now]+q;\n System.out.println(name[now]+\" \"+total);\n }else{\n total+=q;\n next=now+cnt;\n if(next>n) next-=(n+1);\n name[next]=name[now];\n time[next]=time[now];\n }\n time[now]=0;\n }\n now++;\n if(now>n) now-=(n+1);\n }\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int q=s.nextInt();
String name[]=new String[n+1];
int time[]=new int[n+1];
for(int i=0;i<n;i++){
name[i]=s.next();
time[i]=s.nextInt();
}
int total=0,cnt=n,now=0,next=0;
while(cnt!=0){
if(time[now]>0){
time[now]-=q;
if(time[now]<=0){
cnt--;
total+=time[now]+q;
System.out.println(name[now]+" "+total);
}else{
total+=q;
next=now+cnt;
if(next>n) next-=(n+1);
name[next]=name[now];
time[next]=time[now];
}
time[now]=0;
}
now++;
if(now>n) now-=(n+1);
}
}
}
|
[
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,
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,
18,
0,
13,
4,
18,
13,
13,
13,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
13,
20,
4,
18,
13,
13,
40,
13,
30,
0,
13,
13,
0,
18,
13,
13,
2,
18,
13,
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,
18,
13,
13,
17,
4,
18,
13,
18,
13,
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
],
[
0,
27
],
[
163,
28
],
[
163,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
31,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
31,
45
],
[
45,
46
],
[
45,
47
],
[
31,
48
],
[
48,
49
],
[
48,
50
],
[
31,
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
],
[
65,
66
],
[
64,
67
],
[
31,
68
],
[
68,
69
],
[
68,
70
],
[
31,
71
],
[
71,
72
],
[
71,
73
],
[
31,
74
],
[
74,
75
],
[
31,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
87,
94
],
[
86,
95
],
[
85,
96
],
[
84,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
97,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
97,
111
],
[
111,
112
],
[
84,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
113,
126
],
[
126,
127
],
[
79,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
78,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
136,
137
],
[
31,
138
],
[
138,
139
],
[
138,
140
],
[
138,
141
],
[
142,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
149,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
149,
154
],
[
154,
155
],
[
155,
156
],
[
154,
157
],
[
157,
158
],
[
157,
159
],
[
29,
160
],
[
160,
161
],
[
0,
162
],
[
162,
163
],
[
162,
164
]
] | [
"import java.util.*;\n \nclass process {\n public String name;\n public int time;\n \n public process(String name,int time){\n this.name = name;\n this.time = 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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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.name + \" \" + String.valueOf(r.time));\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class process {\n public String name;\n public int time;\n \n public process(String name,int time){\n this.name = name;\n this.time = time;\n }\n}",
"process",
"public String name;",
"name",
"public 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 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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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.name + \" \" + String.valueOf(r.time));\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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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.name + \" \" + String.valueOf(r.time));\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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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.name + \" \" + String.valueOf(r.time));\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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - q;\n i++;\n }\n } else {\n i = 0;\n }",
"i < n",
"i",
"n",
"{\n if((p = ar.get(i)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - q;\n i++;\n }\n }",
"if((p = ar.get(i)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - q;\n i++;\n }",
"(p = ar.get(i)).time - q <= 0",
"(p = ar.get(i)).time - q",
"(p = ar.get(i)).time",
"(p = ar.get(i))",
"p",
"ar.get(i)",
"ar.get",
"ar",
"i",
"(p = ar.get(i)).time",
"q",
"0",
"{\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n }",
"LapsedTime += p.time",
"LapsedTime",
"p.time",
"p",
"p.time",
"result.add(new process(p.name,LapsedTime))",
"result.add",
"result",
"new process(p.name,LapsedTime)",
"ar.remove(i)",
"ar.remove",
"ar",
"i",
"n--",
"n",
"{\n LapsedTime += q;\n p.time = p.time - q;\n i++;\n }",
"LapsedTime += q",
"LapsedTime",
"q",
"p.time = p.time - q",
"p.time",
"p",
"p.time",
"p.time - q",
"p.time",
"p",
"p.time",
"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.name + \" \" + String.valueOf(r.time));\n }",
"process r",
"result",
"{\n System.out.println(r.name + \" \" + String.valueOf(r.time));\n }",
"{\n System.out.println(r.name + \" \" + String.valueOf(r.time));\n }",
"System.out.println(r.name + \" \" + String.valueOf(r.time))",
"System.out.println",
"System.out",
"System",
"System.out",
"r.name + \" \" + String.valueOf(r.time)",
"r.name + \" \" + String.valueOf(r.time)",
"r.name",
"r",
"r.name",
"\" \"",
"String.valueOf(r.time)",
"String.valueOf",
"String",
"r.time",
"r",
"r.time",
"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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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.name + \" \" + String.valueOf(r.time));\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)).time - q <= 0){\n LapsedTime += p.time;\n result.add(new process(p.name,LapsedTime));\n ar.remove(i);\n n--;\n } else {\n LapsedTime += q;\n p.time = p.time - 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.name + \" \" + String.valueOf(r.time));\n }\n }\n}",
"Main"
] | import java.util.*;
class process {
public String name;
public int time;
public process(String name,int time){
this.name = name;
this.time = 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)).time - q <= 0){
LapsedTime += p.time;
result.add(new process(p.name,LapsedTime));
ar.remove(i);
n--;
} else {
LapsedTime += q;
p.time = p.time - q;
i++;
}
} else {
i = 0;
}
if (n == 0){
break;
}
}
for(process r:result) {
System.out.println(r.name + " " + String.valueOf(r.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,
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,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
14,
2,
4,
18,
13,
17,
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,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
17,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
163,
8
],
[
163,
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
],
[
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
],
[
60,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
60,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
60,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
84,
86
],
[
11,
87
],
[
87,
88
],
[
87,
89
],
[
11,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
91,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
98,
103
],
[
97,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
104,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
117,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
117,
122
],
[
117,
123
],
[
104,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
104,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
97,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
139,
144
],
[
132,
145
],
[
145,
146
],
[
146,
147
],
[
145,
148
],
[
148,
149
],
[
149,
150
],
[
148,
151
],
[
132,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
132,
156
],
[
156,
157
],
[
157,
158
],
[
156,
159
],
[
9,
160
],
[
160,
161
],
[
0,
162
],
[
162,
163
],
[
162,
164
]
] | [
"import java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line1 = sc.nextLine();\n\t\tString[] li1 = line1.split(\" \");\n\t\tint n = Integer.parseInt(li1[0]);\n\t\tint q = Integer.parseInt(li1[1]);\n\n\t\tArrayList<String> st = new ArrayList<String>();\n\t\tArrayList<Integer> in = new ArrayList<Integer>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\t\n\t\twhile (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}\n\n\t}\n\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\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line1 = sc.nextLine();\n\t\tString[] li1 = line1.split(\" \");\n\t\tint n = Integer.parseInt(li1[0]);\n\t\tint q = Integer.parseInt(li1[1]);\n\n\t\tArrayList<String> st = new ArrayList<String>();\n\t\tArrayList<Integer> in = new ArrayList<Integer>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\t\n\t\twhile (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line1 = sc.nextLine();\n\t\tString[] li1 = line1.split(\" \");\n\t\tint n = Integer.parseInt(li1[0]);\n\t\tint q = Integer.parseInt(li1[1]);\n\n\t\tArrayList<String> st = new ArrayList<String>();\n\t\tArrayList<Integer> in = new ArrayList<Integer>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\t\n\t\twhile (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line1 = sc.nextLine();\n\t\tString[] li1 = line1.split(\" \");\n\t\tint n = Integer.parseInt(li1[0]);\n\t\tint q = Integer.parseInt(li1[1]);\n\n\t\tArrayList<String> st = new ArrayList<String>();\n\t\tArrayList<Integer> in = new ArrayList<Integer>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\t\n\t\twhile (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String line1 = sc.nextLine();",
"line1",
"sc.nextLine()",
"sc.nextLine",
"sc",
"String[] li1 = line1.split(\" \");",
"li1",
"line1.split(\" \")",
"line1.split",
"line1",
"\" \"",
"int n = Integer.parseInt(li1[0]);",
"n",
"Integer.parseInt(li1[0])",
"Integer.parseInt",
"Integer",
"li1[0]",
"li1",
"0",
"int q = Integer.parseInt(li1[1]);",
"q",
"Integer.parseInt(li1[1])",
"Integer.parseInt",
"Integer",
"li1[1]",
"li1",
"1",
"ArrayList<String> st = new ArrayList<String>();",
"st",
"new ArrayList<String>()",
"ArrayList<Integer> in = new ArrayList<Integer>();",
"in",
"new ArrayList<Integer>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}",
"{\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}",
"String kari1 = sc.nextLine();",
"kari1",
"sc.nextLine()",
"sc.nextLine",
"sc",
"String[] kari2 = kari1.split(\" \");",
"kari2",
"kari1.split(\" \")",
"kari1.split",
"kari1",
"\" \"",
"st.add(kari2[0])",
"st.add",
"st",
"kari2[0]",
"kari2",
"0",
"in.add(Integer.parseInt(kari2[1]))",
"in.add",
"in",
"Integer.parseInt(kari2[1])",
"Integer.parseInt",
"Integer",
"kari2[1]",
"kari2",
"1",
"int time = 0;",
"time",
"0",
"while (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}",
"in.size() > 0",
"in.size()",
"in.size",
"in",
"0",
"{\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}",
"if (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}",
"in.get(0) <= q",
"in.get(0)",
"in.get",
"in",
"0",
"q",
"{\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t}",
"time += in.get(0)",
"time",
"in.get(0)",
"in.get",
"in",
"0",
"System.out.println(st.get(0) + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"st.get(0) + \" \" + time",
"st.get(0) + \" \" + time",
"st.get(0)",
"st.get",
"st",
"0",
"\" \"",
"time",
"in.remove(0)",
"in.remove",
"in",
"0",
"st.remove(0)",
"st.remove",
"st",
"0",
"{\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}",
"time += q",
"time",
"q",
"in.add(in.get(0) - q)",
"in.add",
"in",
"in.get(0) - q",
"in.get(0)",
"in.get",
"in",
"0",
"q",
"st.add(st.get(0))",
"st.add",
"st",
"st.get(0)",
"st.get",
"st",
"0",
"in.remove(0)",
"in.remove",
"in",
"0",
"st.remove(0)",
"st.remove",
"st",
"0",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line1 = sc.nextLine();\n\t\tString[] li1 = line1.split(\" \");\n\t\tint n = Integer.parseInt(li1[0]);\n\t\tint q = Integer.parseInt(li1[1]);\n\n\t\tArrayList<String> st = new ArrayList<String>();\n\t\tArrayList<Integer> in = new ArrayList<Integer>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\t\n\t\twhile (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\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\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\t\tString line1 = sc.nextLine();\n\t\tString[] li1 = line1.split(\" \");\n\t\tint n = Integer.parseInt(li1[0]);\n\t\tint q = Integer.parseInt(li1[1]);\n\n\t\tArrayList<String> st = new ArrayList<String>();\n\t\tArrayList<Integer> in = new ArrayList<Integer>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString kari1 = sc.nextLine();\n\t\t\tString[] kari2 = kari1.split(\" \");\n\t\t\t\n\t\t\tst.add(kari2[0]);\n\t\t\tin.add(Integer.parseInt(kari2[1]));\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\t\n\t\twhile (in.size() > 0) {\n\t\t\tif (in.get(0) <= q) {\n\t\t\t\ttime += in.get(0);\n\t\t\t\tSystem.out.println(st.get(0) + \" \" + time);\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\tin.add(in.get(0) - q);\n\t\t\t\tst.add(st.get(0));\n\t\t\t\tin.remove(0);\n\t\t\t\tst.remove(0);\n\n\t\t\t}\n\t\t}\n\n\t}\n\n}",
"Main"
] | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO ?????????????????????????????????????????????
Scanner sc = new Scanner(System.in);
String line1 = sc.nextLine();
String[] li1 = line1.split(" ");
int n = Integer.parseInt(li1[0]);
int q = Integer.parseInt(li1[1]);
ArrayList<String> st = new ArrayList<String>();
ArrayList<Integer> in = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
String kari1 = sc.nextLine();
String[] kari2 = kari1.split(" ");
st.add(kari2[0]);
in.add(Integer.parseInt(kari2[1]));
}
int time = 0;
while (in.size() > 0) {
if (in.get(0) <= q) {
time += in.get(0);
System.out.println(st.get(0) + " " + time);
in.remove(0);
st.remove(0);
} else {
time += q;
in.add(in.get(0) - q);
st.add(st.get(0));
in.remove(0);
st.remove(0);
}
}
}
} |
[
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,
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,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
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
],
[
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
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
56,
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
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
80,
82
],
[
76,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
76,
87
],
[
87,
88
],
[
87,
89
],
[
72,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
94,
99
],
[
100,
100
],
[
100,
101
],
[
100,
102
],
[
100,
103
],
[
6,
104
],
[
104,
105
]
] | [
"\nimport java.util.*;\n\nclass Main{\n\n\tpublic static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n= sc.nextInt(), q= sc.nextInt();\n\n\t\tDeque<String> P = new ArrayDeque<String>();\n\t\tDeque<Integer> T = new ArrayDeque<Integer>();\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}\n\n\t\tint total=0;\n\t\twhile ( !P.isEmpty() ) {\n\t\t\tString p= P.pop();\n\t\t\tint t= T.pop();\n\n\t\t\tif(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); } \n\t\t}\n\t}\t\n}",
"import java.util.*;",
"util.*",
"java",
"class Main{\n\n\tpublic static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n= sc.nextInt(), q= sc.nextInt();\n\n\t\tDeque<String> P = new ArrayDeque<String>();\n\t\tDeque<Integer> T = new ArrayDeque<Integer>();\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}\n\n\t\tint total=0;\n\t\twhile ( !P.isEmpty() ) {\n\t\t\tString p= P.pop();\n\t\t\tint t= T.pop();\n\n\t\t\tif(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); } \n\t\t}\n\t}\t\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n= sc.nextInt(), q= sc.nextInt();\n\n\t\tDeque<String> P = new ArrayDeque<String>();\n\t\tDeque<Integer> T = new ArrayDeque<Integer>();\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}\n\n\t\tint total=0;\n\t\twhile ( !P.isEmpty() ) {\n\t\t\tString p= P.pop();\n\t\t\tint t= T.pop();\n\n\t\t\tif(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); } \n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc= new Scanner(System.in);\n\t\tint n= sc.nextInt(), q= sc.nextInt();\n\n\t\tDeque<String> P = new ArrayDeque<String>();\n\t\tDeque<Integer> T = new ArrayDeque<Integer>();\n\n\t\tfor(int i=0; i<n; i++){\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}\n\n\t\tint total=0;\n\t\twhile ( !P.isEmpty() ) {\n\t\t\tString p= P.pop();\n\t\t\tint t= T.pop();\n\n\t\t\tif(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); } \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",
"q= sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Deque<String> P = new ArrayDeque<String>();",
"P",
"new ArrayDeque<String>()",
"Deque<Integer> T = new ArrayDeque<Integer>();",
"T",
"new ArrayDeque<Integer>()",
"for(int i=0; i<n; i++){\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}",
"{\n\t\t\tP.add( sc.next() ); \n\t\t\tT.add( sc.nextInt() );\n\t\t}",
"P.add( sc.next() )",
"P.add",
"P",
"sc.next()",
"sc.next",
"sc",
"T.add( sc.nextInt() )",
"T.add",
"T",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int total=0;",
"total",
"0",
"while ( !P.isEmpty() ) {\n\t\t\tString p= P.pop();\n\t\t\tint t= T.pop();\n\n\t\t\tif(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); } \n\t\t}",
"!P.isEmpty()",
"P.isEmpty()",
"P.isEmpty",
"P",
"{\n\t\t\tString p= P.pop();\n\t\t\tint t= T.pop();\n\n\t\t\tif(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); } \n\t\t}",
"String p= P.pop();",
"p",
"P.pop()",
"P.pop",
"P",
"int t= T.pop();",
"t",
"T.pop()",
"T.pop",
"T",
"if(q<t) { T.add(t-q); P.add(p); total+= q; }\n\t\t\telse { total+= t; System.out.println(p +\" \"+ total); }",
"q<t",
"q",
"t",
"{ T.add(t-q); P.add(p); total+= q; }",
"T.add(t-q)",
"T.add",
"T",
"t-q",
"t",
"q",
"P.add(p)",
"P.add",
"P",
"p",
"total+= q",
"total",
"q",
"{ total+= t; System.out.println(p +\" \"+ total); }",
"total+= t",
"total",
"t",
"System.out.println(p +\" \"+ total)",
"System.out.println",
"System.out",
"System",
"System.out",
"p +\" \"+ total",
"p +\" \"+ total",
"p",
"\" \"",
"total",
"String[] args",
"args"
] |
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
int n= sc.nextInt(), q= sc.nextInt();
Deque<String> P = new ArrayDeque<String>();
Deque<Integer> T = new ArrayDeque<Integer>();
for(int i=0; i<n; i++){
P.add( sc.next() );
T.add( sc.nextInt() );
}
int total=0;
while ( !P.isEmpty() ) {
String p= P.pop();
int t= T.pop();
if(q<t) { T.add(t-q); P.add(p); total+= q; }
else { total+= t; System.out.println(p +" "+ total); }
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
17,
41,
13,
12,
13,
30,
0,
13,
17,
12,
13,
30,
0,
18,
13,
40,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
40,
13,
29,
13,
12,
13,
30,
14,
2,
13,
17,
29,
17,
29,
17,
12,
13,
30,
14,
2,
13,
17,
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,
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,
10
],
[
10,
11
],
[
4,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
4,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
21,
26
],
[
18,
27
],
[
27,
28
],
[
4,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
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
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
54,
56
],
[
31,
57
],
[
57,
58
],
[
31,
59
],
[
59,
60
],
[
4,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
64,
70
],
[
70,
71
],
[
4,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
75,
81
],
[
81,
82
],
[
0,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
83,
87
],
[
87,
88
],
[
83,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
89,
102
],
[
102,
103
],
[
89,
104
],
[
104,
105
],
[
83,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
108,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
120,
121
],
[
120,
122
],
[
106,
123
],
[
123,
124
],
[
0,
125
],
[
229,
126
],
[
229,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
129,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
141,
142
],
[
129,
143
],
[
143,
144
],
[
143,
145
],
[
129,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
151,
152
],
[
151,
153
],
[
146,
154
],
[
154,
155
],
[
155,
156
],
[
146,
157
],
[
158,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
162,
163
],
[
158,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
158,
169
],
[
169,
170
],
[
170,
171
],
[
169,
172
],
[
129,
173
],
[
173,
174
],
[
173,
175
],
[
129,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
176,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
181,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
181,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
192,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
203,
205
],
[
198,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
206,
211
],
[
212,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
212,
217
],
[
192,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
219,
222
],
[
218,
223
],
[
223,
224
],
[
223,
225
],
[
127,
226
],
[
226,
227
],
[
0,
228
],
[
228,
229
],
[
228,
230
]
] | [
"import java.util.Scanner;\n\nclass Queue{\n Process[] a = new Process[100001];\n int top;\n\n Queue(){\n top = 0;\n }\n\n void enqueue(Process p){\n a[++top] = p;\n }\n\n Process dequeue(){\n Process p = new Process(a[1]);\n for(int i = 1; i < top; i++){\n a[i] = a[i+1];\n }\n top--;\n return p;\n }\n\n boolean isFull(){\n if(top == 100000)\n return true;\n else\n return false;\n }\n\n boolean isEmpty(){\n if(top == 0)\n return true;\n else\n return false;\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 Process[] a = new Process[100001];\n int top;\n\n Queue(){\n top = 0;\n }\n\n void enqueue(Process p){\n a[++top] = p;\n }\n\n Process dequeue(){\n Process p = new Process(a[1]);\n for(int i = 1; i < top; i++){\n a[i] = a[i+1];\n }\n top--;\n return p;\n }\n\n boolean isFull(){\n if(top == 100000)\n return true;\n else\n return false;\n }\n\n boolean isEmpty(){\n if(top == 0)\n return true;\n else\n return false;\n }\n\n}",
"Queue",
"Process[] a = new Process[100001];",
"a",
"new Process[100001]",
"100001",
"int top;",
"top",
"Queue(){\n top = 0;\n }",
"Queue",
"{\n top = 0;\n }",
"top = 0",
"top",
"0",
"void enqueue(Process p){\n a[++top] = p;\n }",
"enqueue",
"{\n a[++top] = p;\n }",
"a[++top] = p",
"a[++top]",
"a",
"++top",
"top",
"p",
"Process p",
"p",
"Process dequeue(){\n Process p = new Process(a[1]);\n for(int i = 1; i < top; i++){\n a[i] = a[i+1];\n }\n top--;\n return p;\n }",
"dequeue",
"{\n Process p = new Process(a[1]);\n for(int i = 1; i < top; i++){\n a[i] = a[i+1];\n }\n top--;\n return p;\n }",
"Process p = new Process(a[1]);",
"p",
"new Process(a[1])",
"for(int i = 1; i < top; i++){\n a[i] = a[i+1];\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i < top",
"i",
"top",
"i++",
"i++",
"i",
"{\n a[i] = a[i+1];\n }",
"{\n a[i] = a[i+1];\n }",
"a[i] = a[i+1]",
"a[i]",
"a",
"i",
"a[i+1]",
"a",
"i+1",
"i",
"1",
"top--",
"top",
"return p;",
"p",
"boolean isFull(){\n if(top == 100000)\n return true;\n else\n return false;\n }",
"isFull",
"{\n if(top == 100000)\n return true;\n else\n return false;\n }",
"if(top == 100000)\n return true;\n else\n return false;",
"top == 100000",
"top",
"100000",
"return true;",
"true",
"return false;",
"false",
"boolean isEmpty(){\n if(top == 0)\n return true;\n else\n return false;\n }",
"isEmpty",
"{\n if(top == 0)\n return true;\n else\n return false;\n }",
"if(top == 0)\n return true;\n else\n return false;",
"top == 0",
"top",
"0",
"return true;",
"true",
"return false;",
"false",
"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{
Process[] a = new Process[100001];
int top;
Queue(){
top = 0;
}
void enqueue(Process p){
a[++top] = p;
}
Process dequeue(){
Process p = new Process(a[1]);
for(int i = 1; i < top; i++){
a[i] = a[i+1];
}
top--;
return p;
}
boolean isFull(){
if(top == 100000)
return true;
else
return false;
}
boolean isEmpty(){
if(top == 0)
return true;
else
return false;
}
}
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,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
17,
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,
2,
2,
4,
18,
13,
17,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
42,
17,
30,
38,
5,
13,
30,
3,
30,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
18,
13,
17,
2,
17,
4,
18,
13,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
17,
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
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
8,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
8,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
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
],
[
42,
45
],
[
46,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
46,
50
],
[
46,
51
],
[
51,
52
],
[
52,
53
],
[
8,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
8,
59
],
[
59,
60
],
[
59,
61
],
[
8,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
65,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
73,
78
],
[
64,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
84,
86
],
[
64,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
91,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
91,
102
],
[
102,
103
],
[
103,
104
],
[
91,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
87,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
123,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
138,
143
],
[
6,
144
],
[
144,
145
]
] | [
"\nimport java.util.*;\n\n\nclass Main\n{\n public static void main(String[] args)throws Exception\n {\n Scanner sc = new Scanner(System.in);\n Deque <String> que = new ArrayDeque <>(); \n String []s = new String [2]; \n int n = sc.nextInt();\n int quan = sc.nextInt();\n for(int i = 0; i<n;i++) \n {\n que.add(sc.next()+\" \"+sc.next());\n }\n Iterator itr = que.iterator();\n int time = 0;\n while(true)\n {\n try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }\n int num = Integer.parseInt(s[1]);\n if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }\n }\n }\n}\n \n\n\n",
"import java.util.*;",
"util.*",
"java",
"class Main\n{\n public static void main(String[] args)throws Exception\n {\n Scanner sc = new Scanner(System.in);\n Deque <String> que = new ArrayDeque <>(); \n String []s = new String [2]; \n int n = sc.nextInt();\n int quan = sc.nextInt();\n for(int i = 0; i<n;i++) \n {\n que.add(sc.next()+\" \"+sc.next());\n }\n Iterator itr = que.iterator();\n int time = 0;\n while(true)\n {\n try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }\n int num = Integer.parseInt(s[1]);\n if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args)throws Exception\n {\n Scanner sc = new Scanner(System.in);\n Deque <String> que = new ArrayDeque <>(); \n String []s = new String [2]; \n int n = sc.nextInt();\n int quan = sc.nextInt();\n for(int i = 0; i<n;i++) \n {\n que.add(sc.next()+\" \"+sc.next());\n }\n Iterator itr = que.iterator();\n int time = 0;\n while(true)\n {\n try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }\n int num = Integer.parseInt(s[1]);\n if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n Deque <String> que = new ArrayDeque <>(); \n String []s = new String [2]; \n int n = sc.nextInt();\n int quan = sc.nextInt();\n for(int i = 0; i<n;i++) \n {\n que.add(sc.next()+\" \"+sc.next());\n }\n Iterator itr = que.iterator();\n int time = 0;\n while(true)\n {\n try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }\n int num = Integer.parseInt(s[1]);\n if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Deque <String> que = new ArrayDeque <>();",
"que",
"new ArrayDeque <>()",
"String []s = new String [2];",
"s",
"new String [2]",
"2",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int quan = sc.nextInt();",
"quan",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i = 0; i<n;i++) \n {\n que.add(sc.next()+\" \"+sc.next());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n que.add(sc.next()+\" \"+sc.next());\n }",
"{\n que.add(sc.next()+\" \"+sc.next());\n }",
"que.add(sc.next()+\" \"+sc.next())",
"que.add",
"que",
"sc.next()+\" \"+sc.next()",
"sc.next()+\" \"+sc.next()",
"sc.next()",
"sc.next",
"sc",
"\" \"",
"sc.next()",
"sc.next",
"sc",
"Iterator itr = que.iterator();",
"itr",
"que.iterator()",
"que.iterator",
"que",
"int time = 0;",
"time",
"0",
"while(true)\n {\n try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }\n int num = Integer.parseInt(s[1]);\n if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }\n }",
"true",
"{\n try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }\n int num = Integer.parseInt(s[1]);\n if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }\n }",
"try\n {\n s= que.getFirst().split(\" \");\n }\n catch(NoSuchElementException e) \n {\n break;\n }",
"catch(NoSuchElementException e) \n {\n break;\n }",
"NoSuchElementException e",
"{\n break;\n }",
"break;",
"{\n s= que.getFirst().split(\" \");\n }",
"s= que.getFirst().split(\" \")",
"s",
"que.getFirst().split(\" \")",
"que.getFirst().split",
"que.getFirst()",
"que.getFirst",
"que",
"\" \"",
"int num = Integer.parseInt(s[1]);",
"num",
"Integer.parseInt(s[1])",
"Integer.parseInt",
"Integer",
"s[1]",
"s",
"1",
"if(num>quan) \n {\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }\n else if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }",
"num>quan",
"num",
"quan",
"{\n time = quan + time;\n num = num-quan;\n que.removeFirst();\n que.add(s[0].concat(\" \"+ String.valueOf(num)));\n }",
"time = quan + time",
"time",
"quan + time",
"quan",
"time",
"num = num-quan",
"num",
"num-quan",
"num",
"quan",
"que.removeFirst()",
"que.removeFirst",
"que",
"que.add(s[0].concat(\" \"+ String.valueOf(num)))",
"que.add",
"que",
"s[0].concat(\" \"+ String.valueOf(num))",
"s[0].concat",
"s[0]",
"s",
"0",
"\" \"+ String.valueOf(num)",
"\" \"",
"String.valueOf(num)",
"String.valueOf",
"String",
"num",
"if (num<=quan)\n {\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }",
"num<=quan",
"num",
"quan",
"{\n time = num + time;\n que.removeFirst();\n System.out.println(s[0]+\" \"+ time);\n }",
"time = num + time",
"time",
"num + time",
"num",
"time",
"que.removeFirst()",
"que.removeFirst",
"que",
"System.out.println(s[0]+\" \"+ time)",
"System.out.println",
"System.out",
"System",
"System.out",
"s[0]+\" \"+ time",
"s[0]+\" \"+ time",
"s[0]",
"s",
"0",
"\" \"",
"time",
"String[] args",
"args"
] |
import java.util.*;
class Main
{
public static void main(String[] args)throws Exception
{
Scanner sc = new Scanner(System.in);
Deque <String> que = new ArrayDeque <>();
String []s = new String [2];
int n = sc.nextInt();
int quan = sc.nextInt();
for(int i = 0; i<n;i++)
{
que.add(sc.next()+" "+sc.next());
}
Iterator itr = que.iterator();
int time = 0;
while(true)
{
try
{
s= que.getFirst().split(" ");
}
catch(NoSuchElementException e)
{
break;
}
int num = Integer.parseInt(s[1]);
if(num>quan)
{
time = quan + time;
num = num-quan;
que.removeFirst();
que.add(s[0].concat(" "+ String.valueOf(num)));
}
else if (num<=quan)
{
time = num + time;
que.removeFirst();
System.out.println(s[0]+" "+ time);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
41,
13,
0,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
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,
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,
30,
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,
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
],
[
0,
12
],
[
198,
13
],
[
198,
14
],
[
14,
15
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
16,
23
],
[
23,
24
],
[
16,
25
],
[
25,
26
],
[
16,
27
],
[
27,
28
],
[
27,
29
],
[
16,
30
],
[
30,
31
],
[
30,
32
],
[
16,
33
],
[
33,
34
],
[
16,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
16,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
16,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
51,
52
],
[
51,
53
],
[
16,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
59,
61
],
[
16,
62
],
[
62,
63
],
[
62,
64
],
[
16,
66
],
[
66,
67
],
[
66,
68
],
[
16,
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
],
[
89,
92
],
[
81,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
81,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
98,
104
],
[
104,
105
],
[
104,
106
],
[
81,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
107,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
116,
117
],
[
116,
118
],
[
81,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
122,
123
],
[
122,
124
],
[
16,
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
],
[
138,
140
],
[
137,
141
],
[
136,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
145,
147
],
[
142,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
142,
153
],
[
153,
154
],
[
154,
155
],
[
153,
156
],
[
136,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
157,
166
],
[
166,
167
],
[
167,
168
],
[
166,
169
],
[
16,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
170,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
175,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
181,
186
],
[
187,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
187,
192
],
[
192,
193
],
[
192,
194
],
[
14,
195
],
[
195,
196
],
[
0,
197
],
[
197,
198
],
[
197,
199
]
] | [
"import java.util.*;\nclass Processe{\n\tString processesName;\n\tint Times;\n\tint endtime;\n}\npublic class Main{\n\tpublic static void main(String[] args){\n\t\tQueue<Processe> queue = new LinkedList<Processe>();\n\t\tQueue<Processe> queue2 = new LinkedList<Processe>();\n\t\tint n;\n\t\tint q;\n\t\tint endtime = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString string;\n\t\tstring = scanner.nextLine();\n\t\t\n\t\tString [] strings = string.split(\" \");\n\t\tn = Integer.parseInt(strings[0]);\n\t\tq= Integer.parseInt(strings[1]);\n\t\t\n\t\tProcesse[] processes = new Processe [n];\n\t\t\n\t\tProcesse processe = new Processe();\n\t\t\n\t\tfor(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\t\twhile(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}\n\t\twhile(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"class Processe{\n\tString processesName;\n\tint Times;\n\tint endtime;\n}",
"Processe",
"String processesName;",
"processesName",
"int Times;",
"Times",
"int endtime;",
"endtime",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tQueue<Processe> queue = new LinkedList<Processe>();\n\t\tQueue<Processe> queue2 = new LinkedList<Processe>();\n\t\tint n;\n\t\tint q;\n\t\tint endtime = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString string;\n\t\tstring = scanner.nextLine();\n\t\t\n\t\tString [] strings = string.split(\" \");\n\t\tn = Integer.parseInt(strings[0]);\n\t\tq= Integer.parseInt(strings[1]);\n\t\t\n\t\tProcesse[] processes = new Processe [n];\n\t\t\n\t\tProcesse processe = new Processe();\n\t\t\n\t\tfor(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\t\twhile(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}\n\t\twhile(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tQueue<Processe> queue = new LinkedList<Processe>();\n\t\tQueue<Processe> queue2 = new LinkedList<Processe>();\n\t\tint n;\n\t\tint q;\n\t\tint endtime = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString string;\n\t\tstring = scanner.nextLine();\n\t\t\n\t\tString [] strings = string.split(\" \");\n\t\tn = Integer.parseInt(strings[0]);\n\t\tq= Integer.parseInt(strings[1]);\n\t\t\n\t\tProcesse[] processes = new Processe [n];\n\t\t\n\t\tProcesse processe = new Processe();\n\t\t\n\t\tfor(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\t\twhile(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}\n\t\twhile(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}\n\t}",
"main",
"{\n\t\tQueue<Processe> queue = new LinkedList<Processe>();\n\t\tQueue<Processe> queue2 = new LinkedList<Processe>();\n\t\tint n;\n\t\tint q;\n\t\tint endtime = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString string;\n\t\tstring = scanner.nextLine();\n\t\t\n\t\tString [] strings = string.split(\" \");\n\t\tn = Integer.parseInt(strings[0]);\n\t\tq= Integer.parseInt(strings[1]);\n\t\t\n\t\tProcesse[] processes = new Processe [n];\n\t\t\n\t\tProcesse processe = new Processe();\n\t\t\n\t\tfor(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\t\twhile(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}\n\t\twhile(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}\n\t}",
"Queue<Processe> queue = new LinkedList<Processe>();",
"queue",
"new LinkedList<Processe>()",
"Queue<Processe> queue2 = new LinkedList<Processe>();",
"queue2",
"new LinkedList<Processe>()",
"int n;",
"n",
"int q;",
"q",
"int endtime = 0;",
"endtime",
"0",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"String string;",
"string",
"string = scanner.nextLine()",
"string",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"String [] strings = string.split(\" \");",
"strings",
"string.split(\" \")",
"string.split",
"string",
"\" \"",
"n = Integer.parseInt(strings[0])",
"n",
"Integer.parseInt(strings[0])",
"Integer.parseInt",
"Integer",
"strings[0]",
"strings",
"0",
"q= Integer.parseInt(strings[1])",
"q",
"Integer.parseInt(strings[1])",
"Integer.parseInt",
"Integer",
"strings[1]",
"strings",
"1",
"Processe[] processes = new Processe [n];",
"processes",
"new Processe [n]",
"n",
"Processe processe = new Processe();",
"processe",
"new Processe()",
"for(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}",
"{\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}",
"string = scanner.nextLine()",
"string",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"strings = string.split(\" \")",
"strings",
"string.split(\" \")",
"string.split",
"string",
"\" \"",
"processes[i] = new Processe()",
"processes[i]",
"processes",
"i",
"new Processe()",
"processes[i].processesName = strings[0]",
"processes[i].processesName",
"processes[i]",
"processes",
"i",
"processes[i].processesName",
"strings[0]",
"strings",
"0",
"processes[i].Times = Integer.parseInt(strings[1])",
"processes[i].Times",
"processes[i]",
"processes",
"i",
"processes[i].Times",
"Integer.parseInt(strings[1])",
"Integer.parseInt",
"Integer",
"strings[1]",
"strings",
"1",
"queue.add(processes[i])",
"queue.add",
"queue",
"processes[i]",
"processes",
"i",
"while(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}",
"processe = queue.poll()",
"processe",
"queue.poll()",
"queue.poll",
"queue",
"if(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}",
"processe.Times <= q",
"processe.Times",
"processe",
"processe.Times",
"q",
"{\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}",
"endtime += processe.Times",
"endtime",
"processe.Times",
"processe",
"processe.Times",
"processe.endtime = endtime",
"processe.endtime",
"processe",
"processe.endtime",
"endtime",
"queue2.add(processe)",
"queue2.add",
"queue2",
"processe",
"{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}",
"endtime += q",
"endtime",
"q",
"processe.Times -= q",
"processe.Times",
"processe",
"processe.Times",
"q",
"queue.add(processe)",
"queue.add",
"queue",
"processe",
"while(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}",
"!queue2.isEmpty()",
"queue2.isEmpty()",
"queue2.isEmpty",
"queue2",
"{\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}",
"processe = queue2.poll()",
"processe",
"queue2.poll()",
"queue2.poll",
"queue2",
"System.out.println(processe.processesName + \" \" + processe.endtime)",
"System.out.println",
"System.out",
"System",
"System.out",
"processe.processesName + \" \" + processe.endtime",
"processe.processesName + \" \" + processe.endtime",
"processe.processesName",
"processe",
"processe.processesName",
"\" \"",
"processe.endtime",
"processe",
"processe.endtime",
"String[] args",
"args",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tQueue<Processe> queue = new LinkedList<Processe>();\n\t\tQueue<Processe> queue2 = new LinkedList<Processe>();\n\t\tint n;\n\t\tint q;\n\t\tint endtime = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString string;\n\t\tstring = scanner.nextLine();\n\t\t\n\t\tString [] strings = string.split(\" \");\n\t\tn = Integer.parseInt(strings[0]);\n\t\tq= Integer.parseInt(strings[1]);\n\t\t\n\t\tProcesse[] processes = new Processe [n];\n\t\t\n\t\tProcesse processe = new Processe();\n\t\t\n\t\tfor(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\t\twhile(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}\n\t\twhile(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}\n\t}\n}",
"public class Main{\n\tpublic static void main(String[] args){\n\t\tQueue<Processe> queue = new LinkedList<Processe>();\n\t\tQueue<Processe> queue2 = new LinkedList<Processe>();\n\t\tint n;\n\t\tint q;\n\t\tint endtime = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\tString string;\n\t\tstring = scanner.nextLine();\n\t\t\n\t\tString [] strings = string.split(\" \");\n\t\tn = Integer.parseInt(strings[0]);\n\t\tq= Integer.parseInt(strings[1]);\n\t\t\n\t\tProcesse[] processes = new Processe [n];\n\t\t\n\t\tProcesse processe = new Processe();\n\t\t\n\t\tfor(int i=0; i<n; i++){\n\t\t\tstring = scanner.nextLine();\n\t\t\tstrings = string.split(\" \");\n\t\t\tprocesses[i] = new Processe();\n\t\t\tprocesses[i].processesName = strings[0];\n\t\t\tprocesses[i].Times = Integer.parseInt(strings[1]);\n\t\t\tqueue.add(processes[i]);\n\t\t}\n\t\twhile(!queue.isEmpty()){\n\t\t\tprocesse = queue.poll();\n\t\t\tif(processe.Times <= q){\n\t\t\t\tendtime += processe.Times;\n\t\t\t\tprocesse.endtime = endtime;\n\t\t\t\tqueue2.add(processe);\n\t\t\t}else{\n\t\t\t\tendtime += q;\n\t\t\t\tprocesse.Times -= q;\n\t\t\t\tqueue.add(processe);\n\t\t\t}\n\t\t}\n\t\twhile(!queue2.isEmpty()){\n\t\t\tprocesse = queue2.poll();\n\t\t\tSystem.out.println(processe.processesName + \" \" + processe.endtime);\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
class Processe{
String processesName;
int Times;
int endtime;
}
public class Main{
public static void main(String[] args){
Queue<Processe> queue = new LinkedList<Processe>();
Queue<Processe> queue2 = new LinkedList<Processe>();
int n;
int q;
int endtime = 0;
Scanner scanner = new Scanner(System.in);
String string;
string = scanner.nextLine();
String [] strings = string.split(" ");
n = Integer.parseInt(strings[0]);
q= Integer.parseInt(strings[1]);
Processe[] processes = new Processe [n];
Processe processe = new Processe();
for(int i=0; i<n; i++){
string = scanner.nextLine();
strings = string.split(" ");
processes[i] = new Processe();
processes[i].processesName = strings[0];
processes[i].Times = Integer.parseInt(strings[1]);
queue.add(processes[i]);
}
while(!queue.isEmpty()){
processe = queue.poll();
if(processe.Times <= q){
endtime += processe.Times;
processe.endtime = endtime;
queue2.add(processe);
}else{
endtime += q;
processe.Times -= q;
queue.add(processe);
}
}
while(!queue2.isEmpty()){
processe = queue2.poll();
System.out.println(processe.processesName + " " + processe.endtime);
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
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,
0,
18,
36,
13,
13,
23,
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,
4,
18,
13,
20,
41,
13,
17,
41,
13,
42,
2,
4,
18,
13,
17,
30,
14,
2,
4,
18,
4,
18,
13,
13,
30,
0,
13,
4,
18,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
4,
18,
13,
17,
13,
4,
18,
13,
30,
0,
13,
2,
4,
18,
4,
18,
13,
13,
4,
18,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
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
],
[
12,
13
],
[
10,
14
],
[
14,
15
],
[
10,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
10,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
10,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
29,
33
],
[
26,
34
],
[
34,
35
],
[
10,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
38,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
36,
49
],
[
49,
50
],
[
36,
51
],
[
51,
52
],
[
0,
53
],
[
167,
54
],
[
167,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
57,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
57,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
57,
71
],
[
71,
72
],
[
71,
73
],
[
57,
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
],
[
88,
89
],
[
87,
90
],
[
57,
91
],
[
91,
92
],
[
91,
93
],
[
57,
94
],
[
94,
95
],
[
57,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
97,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
103,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
125,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
125,
131
],
[
125,
132
],
[
111,
133
],
[
133,
134
],
[
134,
135
],
[
103,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
139,
145
],
[
136,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
146,
151
],
[
136,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
155,
156
],
[
156,
157
],
[
136,
158
],
[
158,
159
],
[
159,
160
],
[
136,
161
],
[
161,
162
],
[
161,
163
],
[
55,
164
],
[
164,
165
],
[
0,
166
],
[
166,
167
],
[
166,
168
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\nclass Processees {\n\tprivate String name;\n\tprivate int time;\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getTime() {\n\t\treturn time;\n\t};\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\n\tpublic Processees(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n}\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint p = scanner.nextInt();\n\n\t\tDeque<Processees> Processeeses = new ArrayDeque<Processees>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}\n\t\tint totalTime =0;\n\t\tint tempTime;\n\t\twhile(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}\n\n\t}\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Processees {\n\tprivate String name;\n\tprivate int time;\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getTime() {\n\t\treturn time;\n\t};\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\n\tpublic Processees(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n}",
"Processees",
"private String name;",
"name",
"private 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 Processees(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Processees",
"{\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) {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint p = scanner.nextInt();\n\n\t\tDeque<Processees> Processeeses = new ArrayDeque<Processees>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}\n\t\tint totalTime =0;\n\t\tint tempTime;\n\t\twhile(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint p = scanner.nextInt();\n\n\t\tDeque<Processees> Processeeses = new ArrayDeque<Processees>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}\n\t\tint totalTime =0;\n\t\tint tempTime;\n\t\twhile(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint p = scanner.nextInt();\n\n\t\tDeque<Processees> Processeeses = new ArrayDeque<Processees>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}\n\t\tint totalTime =0;\n\t\tint tempTime;\n\t\twhile(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int p = scanner.nextInt();",
"p",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"Deque<Processees> Processeeses = new ArrayDeque<Processees>(n);",
"Processeeses",
"new ArrayDeque<Processees>(n)",
"for (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}",
"{\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}",
"Processeeses.add(new Processees(scanner.next(), scanner.nextInt()))",
"Processeeses.add",
"Processeeses",
"new Processees(scanner.next(), scanner.nextInt())",
"int totalTime =0;",
"totalTime",
"0",
"int tempTime;",
"tempTime",
"while(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}",
"Processeeses.size()!=0",
"Processeeses.size()",
"Processeeses.size",
"Processeeses",
"0",
"{\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}",
"if(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}",
"Processeeses.element().getTime()<=p",
"Processeeses.element().getTime()",
"Processeeses.element().getTime",
"Processeeses.element()",
"Processeeses.element",
"Processeeses",
"p",
"{\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}",
"totalTime+=Processeeses.element().getTime()",
"totalTime",
"Processeeses.element().getTime()",
"Processeeses.element().getTime",
"Processeeses.element()",
"Processeeses.element",
"Processeeses",
"System.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime",
"Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime",
"Processeeses.element().getName()",
"Processeeses.element().getName",
"Processeeses.element()",
"Processeeses.element",
"Processeeses",
"\" \"",
"totalTime",
"Processeeses.poll()",
"Processeeses.poll",
"Processeeses",
"{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}",
"tempTime = Processeeses.element().getTime()-p",
"tempTime",
"Processeeses.element().getTime()-p",
"Processeeses.element().getTime()",
"Processeeses.element().getTime",
"Processeeses.element()",
"Processeeses.element",
"Processeeses",
"p",
"Processeeses.element().setTime(tempTime)",
"Processeeses.element().setTime",
"Processeeses.element()",
"Processeeses.element",
"Processeeses",
"tempTime",
"Processeeses.add(Processeeses.element())",
"Processeeses.add",
"Processeeses",
"Processeeses.element()",
"Processeeses.element",
"Processeeses",
"Processeeses.poll()",
"Processeeses.poll",
"Processeeses",
"totalTime+=p",
"totalTime",
"p",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint p = scanner.nextInt();\n\n\t\tDeque<Processees> Processeeses = new ArrayDeque<Processees>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}\n\t\tint totalTime =0;\n\t\tint tempTime;\n\t\twhile(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}\n\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint p = scanner.nextInt();\n\n\t\tDeque<Processees> Processeeses = new ArrayDeque<Processees>(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tProcesseeses.add(new Processees(scanner.next(), scanner.nextInt()));\n\t\t}\n\t\tint totalTime =0;\n\t\tint tempTime;\n\t\twhile(Processeeses.size()!=0){\n\t\t\tif(Processeeses.element().getTime()<=p){\n\t\t\t\ttotalTime+=Processeeses.element().getTime();\n\t\t\t\tSystem.out.println(Processeeses.element().getName()\n\t\t\t\t\t\t+ \" \"+totalTime);\n\t\t\t\tProcesseeses.poll();\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttempTime = Processeeses.element().getTime()-p;\n\t\t\t\tProcesseeses.element().setTime(tempTime);\n\t\t\t\tProcesseeses.add(Processeeses.element());\n\t\t\t\tProcesseeses.poll();\n\t\t\t\ttotalTime+=p;\n\t\t\t}\n\t\t}\n\n\t}\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
class Processees {
private String name;
private int time;
public String getName() {
return name;
}
public int getTime() {
return time;
};
public void setTime(int time) {
this.time = time;
}
public Processees(String name, int time) {
this.name = name;
this.time = time;
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int p = scanner.nextInt();
Deque<Processees> Processeeses = new ArrayDeque<Processees>(n);
for (int i = 0; i < n; i++) {
Processeeses.add(new Processees(scanner.next(), scanner.nextInt()));
}
int totalTime =0;
int tempTime;
while(Processeeses.size()!=0){
if(Processeeses.element().getTime()<=p){
totalTime+=Processeeses.element().getTime();
System.out.println(Processeeses.element().getName()
+ " "+totalTime);
Processeeses.poll();
}
else{
tempTime = Processeeses.element().getTime()-p;
Processeeses.element().setTime(tempTime);
Processeeses.add(Processeeses.element());
Processeeses.poll();
totalTime+=p;
}
}
}
} |
[
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,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
13,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
17,
42,
17,
30,
38,
5,
13,
30,
3,
30,
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,
9,
0,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
23,
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
],
[
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
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
51,
52
],
[
46,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
57,
58
],
[
14,
59
],
[
59,
60
],
[
59,
61
],
[
59,
62
],
[
59,
63
],
[
12,
64
],
[
64,
65
],
[
10,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
71,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
68,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
79,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
84,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
84,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
111,
111
],
[
111,
112
],
[
111,
113
],
[
111,
114
],
[
101,
115
],
[
84,
116
],
[
116,
117
],
[
116,
118
],
[
84,
119
],
[
119,
120
],
[
119,
121
],
[
84,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
84,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
66,
130
],
[
130,
131
],
[
66,
132
],
[
132,
133
],
[
66,
134
],
[
134,
135
]
] | [
"import java.util.Scanner;\nimport java.util.Deque;\nimport java.util.ArrayDeque;\n\nclass Main {\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 Deque<String> names = new ArrayDeque<String>(50000);\n Deque<Integer> times = new ArrayDeque<Integer>(50000);\n\n for (int i = 0; i < n; i++) {\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }\n\n execution(q, names, times);\n }\n\n public static void execution(int q, Deque<String> names, Deque<Integer> times) {\n int time;\n String name;\n int currentTime = 0;\n\n while(true) {\n try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\n }\n }\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"class Main {\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 Deque<String> names = new ArrayDeque<String>(50000);\n Deque<Integer> times = new ArrayDeque<Integer>(50000);\n\n for (int i = 0; i < n; i++) {\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }\n\n execution(q, names, times);\n }\n\n public static void execution(int q, Deque<String> names, Deque<Integer> times) {\n int time;\n String name;\n int currentTime = 0;\n\n while(true) {\n try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\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 Deque<String> names = new ArrayDeque<String>(50000);\n Deque<Integer> times = new ArrayDeque<Integer>(50000);\n\n for (int i = 0; i < n; i++) {\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }\n\n execution(q, names, times);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<String> names = new ArrayDeque<String>(50000);\n Deque<Integer> times = new ArrayDeque<Integer>(50000);\n\n for (int i = 0; i < n; i++) {\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }\n\n execution(q, names, times);\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",
"Deque<String> names = new ArrayDeque<String>(50000);",
"names",
"new ArrayDeque<String>(50000)",
"Deque<Integer> times = new ArrayDeque<Integer>(50000);",
"times",
"new ArrayDeque<Integer>(50000)",
"for (int i = 0; i < n; i++) {\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }",
"{\n names.offerLast(sc.next());\n times.offerLast(sc.nextInt());\n }",
"names.offerLast(sc.next())",
"names.offerLast",
"names",
"sc.next()",
"sc.next",
"sc",
"times.offerLast(sc.nextInt())",
"times.offerLast",
"times",
"sc.nextInt()",
"sc.nextInt",
"sc",
"execution(q, names, times)",
"execution",
"q",
"names",
"times",
"String... args",
"args",
"public static void execution(int q, Deque<String> names, Deque<Integer> times) {\n int time;\n String name;\n int currentTime = 0;\n\n while(true) {\n try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\n }\n }\n }",
"execution",
"{\n int time;\n String name;\n int currentTime = 0;\n\n while(true) {\n try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\n }\n }\n }",
"int time;",
"time",
"String name;",
"name",
"int currentTime = 0;",
"currentTime",
"0",
"while(true) {\n try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\n }\n }",
"true",
"{\n try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\n }\n }",
"try {\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n } catch (Exception e) {\n break;\n }",
"catch (Exception e) {\n break;\n }",
"Exception e",
"{\n break;\n }",
"break;",
"{\n name = names.removeFirst();\n time = times.removeFirst();\n\n if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }\n\n time -= q;\n currentTime += q;\n\n names.offerLast(name);\n times.offerLast(time);\n\n }",
"name = names.removeFirst()",
"name",
"names.removeFirst()",
"names.removeFirst",
"names",
"time = times.removeFirst()",
"time",
"times.removeFirst()",
"times.removeFirst",
"times",
"if (time - q <= 0) {\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }",
"time - q <= 0",
"time - q",
"time",
"q",
"0",
"{\n currentTime += time;\n System.out.println(name + \" \" + currentTime);\n continue;\n }",
"currentTime += time",
"currentTime",
"time",
"System.out.println(name + \" \" + currentTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + currentTime",
"name + \" \" + currentTime",
"name",
"\" \"",
"currentTime",
"continue;",
"time -= q",
"time",
"q",
"currentTime += q",
"currentTime",
"q",
"names.offerLast(name)",
"names.offerLast",
"names",
"name",
"times.offerLast(time)",
"times.offerLast",
"times",
"time",
"int q",
"q",
"Deque<String> names",
"names",
"Deque<Integer> times",
"times"
] | import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;
class Main {
public static void main(String... args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Deque<String> names = new ArrayDeque<String>(50000);
Deque<Integer> times = new ArrayDeque<Integer>(50000);
for (int i = 0; i < n; i++) {
names.offerLast(sc.next());
times.offerLast(sc.nextInt());
}
execution(q, names, times);
}
public static void execution(int q, Deque<String> names, Deque<Integer> times) {
int time;
String name;
int currentTime = 0;
while(true) {
try {
name = names.removeFirst();
time = times.removeFirst();
if (time - q <= 0) {
currentTime += time;
System.out.println(name + " " + currentTime);
continue;
}
time -= q;
currentTime += q;
names.offerLast(name);
times.offerLast(time);
} catch (Exception e) {
break;
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
41,
13,
20,
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,
13,
0,
13,
4,
18,
13,
17,
4,
18,
13,
20,
4,
18,
13,
42,
40,
4,
18,
13,
30,
14,
2,
18,
4,
18,
13,
13,
17,
30,
14,
2,
18,
4,
18,
13,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
13,
17,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
202,
11
],
[
202,
12
],
[
12,
13
],
[
202,
14
],
[
14,
15
],
[
202,
16
],
[
16,
17
],
[
16,
18
],
[
202,
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
],
[
32,
35
],
[
21,
36
],
[
36,
37
],
[
21,
38
],
[
38,
39
],
[
38,
40
],
[
21,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
43,
46
],
[
46,
47
],
[
46,
48
],
[
21,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
54,
55
],
[
54,
56
],
[
21,
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
],
[
72,
73
],
[
73,
74
],
[
69,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
69,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
21,
85
],
[
85,
86
],
[
86,
87
],
[
21,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
88,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
96,
100
],
[
95,
101
],
[
94,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
105,
109
],
[
104,
110
],
[
103,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
111,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
111,
125
],
[
125,
126
],
[
125,
127
],
[
111,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
103,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
132,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
143,
145
],
[
132,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
146,
151
],
[
152,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
152,
157
],
[
94,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
165,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
166,
170
],
[
165,
171
],
[
165,
172
],
[
158,
173
],
[
173,
174
],
[
174,
175
],
[
19,
176
],
[
176,
177
],
[
0,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
178,
182
],
[
182,
183
],
[
178,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
186,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
184,
197
],
[
197,
198
],
[
184,
199
],
[
199,
200
],
[
0,
201
],
[
201,
202
],
[
201,
203
]
] | [
"import java.util.Scanner;\nimport java.util.LinkedList;\nimport java.util.Queue;\n\npublic class Main{\n\tString name;\n\tint time;\n\tstatic int totalTime = 0;\n\n\n\t\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner in = new Scanner(System.in);\n\t\tString line = in.nextLine(); \n\t\tString[] words = line.split(\" \");\n\t\tProblem currentItem;\n\t\tQueue<Problem> myQueue = new LinkedList<Problem>();\n\t\tint pro = Integer.parseInt(words[0]);\n\t\tint Required = Integer.parseInt(words[1]);\n\n\t\tfor(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}\n\t\tin.close();\n\n\n\t\t//System.out.println(\"StartQueue\");\n\t\twhile(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}\n\n\n\t}\n}\n\tclass Problem {\n\tString name;\n\tint time;\n\tpublic Problem(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t}",
"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\tString name;\n\tint time;\n\tstatic int totalTime = 0;\n\n\n\t\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner in = new Scanner(System.in);\n\t\tString line = in.nextLine(); \n\t\tString[] words = line.split(\" \");\n\t\tProblem currentItem;\n\t\tQueue<Problem> myQueue = new LinkedList<Problem>();\n\t\tint pro = Integer.parseInt(words[0]);\n\t\tint Required = Integer.parseInt(words[1]);\n\n\t\tfor(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}\n\t\tin.close();\n\n\n\t\t//System.out.println(\"StartQueue\");\n\t\twhile(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}\n\n\n\t}\n}",
"Main",
"String name;",
"name",
"int time;",
"time",
"static int totalTime = 0;",
"totalTime",
"0",
"public static void main(String[] args) {\n\n\t\tScanner in = new Scanner(System.in);\n\t\tString line = in.nextLine(); \n\t\tString[] words = line.split(\" \");\n\t\tProblem currentItem;\n\t\tQueue<Problem> myQueue = new LinkedList<Problem>();\n\t\tint pro = Integer.parseInt(words[0]);\n\t\tint Required = Integer.parseInt(words[1]);\n\n\t\tfor(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}\n\t\tin.close();\n\n\n\t\t//System.out.println(\"StartQueue\");\n\t\twhile(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}\n\n\n\t}",
"main",
"{\n\n\t\tScanner in = new Scanner(System.in);\n\t\tString line = in.nextLine(); \n\t\tString[] words = line.split(\" \");\n\t\tProblem currentItem;\n\t\tQueue<Problem> myQueue = new LinkedList<Problem>();\n\t\tint pro = Integer.parseInt(words[0]);\n\t\tint Required = Integer.parseInt(words[1]);\n\n\t\tfor(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}\n\t\tin.close();\n\n\n\t\t//System.out.println(\"StartQueue\");\n\t\twhile(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}\n\n\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"String line = in.nextLine();",
"line",
"in.nextLine()",
"in.nextLine",
"in",
"String[] words = line.split(\" \");",
"words",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"Problem currentItem;",
"currentItem",
"Queue<Problem> myQueue = new LinkedList<Problem>();",
"myQueue",
"new LinkedList<Problem>()",
"int pro = Integer.parseInt(words[0]);",
"pro",
"Integer.parseInt(words[0])",
"Integer.parseInt",
"Integer",
"words[0]",
"words",
"0",
"int Required = Integer.parseInt(words[1]);",
"Required",
"Integer.parseInt(words[1])",
"Integer.parseInt",
"Integer",
"words[1]",
"words",
"1",
"for(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < pro",
"i",
"pro",
"i++",
"i++",
"i",
"{\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}",
"{\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}",
"line = in.nextLine()",
"line",
"in.nextLine()",
"in.nextLine",
"in",
"words = line.split(\" \")",
"words",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"myQueue.offer(new Problem(words[0], Integer.parseInt(words[1])))",
"myQueue.offer",
"myQueue",
"new Problem(words[0], Integer.parseInt(words[1]))",
"in.close()",
"in.close",
"in",
"while(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}",
"!myQueue.isEmpty()",
"myQueue.isEmpty()",
"myQueue.isEmpty",
"myQueue",
"{\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}",
"if(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}",
"((Problem) myQueue.peek()).time > 0",
"((Problem) myQueue.peek()).time",
"((Problem) myQueue.peek())",
"myQueue.peek",
"myQueue",
"((Problem) myQueue.peek()).time",
"0",
"{\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}",
"if(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}",
"((Problem) myQueue.peek()).time > Required",
"((Problem) myQueue.peek()).time",
"((Problem) myQueue.peek())",
"myQueue.peek",
"myQueue",
"((Problem) myQueue.peek()).time",
"Required",
"{\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}",
"currentItem = ((Problem) myQueue.peek())",
"currentItem",
"((Problem) myQueue.peek())",
"myQueue.peek",
"myQueue",
"myQueue.remove()",
"myQueue.remove",
"myQueue",
"currentItem.time -= Required",
"currentItem.time",
"currentItem",
"currentItem.time",
"Required",
"totalTime += Required",
"totalTime",
"Required",
"myQueue.offer(currentItem)",
"myQueue.offer",
"myQueue",
"currentItem",
"{\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}",
"currentItem = ((Problem) myQueue.peek())",
"currentItem",
"((Problem) myQueue.peek())",
"myQueue.peek",
"myQueue",
"myQueue.remove()",
"myQueue.remove",
"myQueue",
"totalTime += currentItem.time",
"totalTime",
"currentItem.time",
"currentItem",
"currentItem.time",
"System.out.println(currentItem.name + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"currentItem.name + \" \" + totalTime",
"currentItem.name + \" \" + totalTime",
"currentItem.name",
"currentItem",
"currentItem.name",
"\" \"",
"totalTime",
"{\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}",
"System.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"((Problem) myQueue.peek()).name + \" \" + totalTime",
"((Problem) myQueue.peek()).name + \" \" + totalTime",
"((Problem) myQueue.peek()).name",
"((Problem) myQueue.peek())",
"myQueue.peek",
"myQueue",
"((Problem) myQueue.peek()).name",
"\" \"",
"totalTime",
"myQueue.remove()",
"myQueue.remove",
"myQueue",
"String[] args",
"args",
"class Problem {\n\tString name;\n\tint time;\n\tpublic Problem(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t}",
"Problem",
"String name;",
"name",
"int time;",
"time",
"public Problem(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Problem",
"{\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\tString name;\n\tint time;\n\tstatic int totalTime = 0;\n\n\n\t\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner in = new Scanner(System.in);\n\t\tString line = in.nextLine(); \n\t\tString[] words = line.split(\" \");\n\t\tProblem currentItem;\n\t\tQueue<Problem> myQueue = new LinkedList<Problem>();\n\t\tint pro = Integer.parseInt(words[0]);\n\t\tint Required = Integer.parseInt(words[1]);\n\n\t\tfor(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}\n\t\tin.close();\n\n\n\t\t//System.out.println(\"StartQueue\");\n\t\twhile(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}\n\n\n\t}\n}",
"public class Main{\n\tString name;\n\tint time;\n\tstatic int totalTime = 0;\n\n\n\t\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner in = new Scanner(System.in);\n\t\tString line = in.nextLine(); \n\t\tString[] words = line.split(\" \");\n\t\tProblem currentItem;\n\t\tQueue<Problem> myQueue = new LinkedList<Problem>();\n\t\tint pro = Integer.parseInt(words[0]);\n\t\tint Required = Integer.parseInt(words[1]);\n\n\t\tfor(int i = 0; i < pro; i++) {\n\t\t\tline = in.nextLine(); \n\t\t\twords = line.split(\" \");\n\t\t\tmyQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));\n\t\t\t//System.out.println(\"added to queue: \" + words[0]);\n\t\t}\n\t\tin.close();\n\n\n\t\t//System.out.println(\"StartQueue\");\n\t\twhile(!myQueue.isEmpty()) {\n\t\t\t//System.out.println(\"Queue Not Empty\");\n\t\t\tif(((Problem) myQueue.peek()).time > 0){\n\t\t\t\t//System.out.println(\"IF1\");\n\t\t\t\tif(((Problem) myQueue.peek()).time > Required){\n\t\t\t\t\t//System.out.println(\"IF2\");\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\tcurrentItem.time -= Required;\n\t\t\t\t\ttotalTime += Required;\n\t\t\t\t\tmyQueue.offer(currentItem);\n\t\t\t\t}else {\n\t\t\t\t\tcurrentItem = ((Problem) myQueue.peek()); \n\t\t\t\t\tmyQueue.remove();\n\t\t\t\t\ttotalTime += currentItem.time;\n\t\t\t\t\tSystem.out.println(currentItem.name + \" \" + totalTime);\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tSystem.out.println(((Problem) myQueue.peek()).name + \" \" + totalTime);\n\t\t\t\tmyQueue.remove();\n\n\t\t\t}\n\t\t}\n\n\n\t}\n}",
"Main"
] | import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;
public class Main{
String name;
int time;
static int totalTime = 0;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String line = in.nextLine();
String[] words = line.split(" ");
Problem currentItem;
Queue<Problem> myQueue = new LinkedList<Problem>();
int pro = Integer.parseInt(words[0]);
int Required = Integer.parseInt(words[1]);
for(int i = 0; i < pro; i++) {
line = in.nextLine();
words = line.split(" ");
myQueue.offer(new Problem(words[0], Integer.parseInt(words[1])));
//System.out.println("added to queue: " + words[0]);
}
in.close();
//System.out.println("StartQueue");
while(!myQueue.isEmpty()) {
//System.out.println("Queue Not Empty");
if(((Problem) myQueue.peek()).time > 0){
//System.out.println("IF1");
if(((Problem) myQueue.peek()).time > Required){
//System.out.println("IF2");
currentItem = ((Problem) myQueue.peek());
myQueue.remove();
currentItem.time -= Required;
totalTime += Required;
myQueue.offer(currentItem);
}else {
currentItem = ((Problem) myQueue.peek());
myQueue.remove();
totalTime += currentItem.time;
System.out.println(currentItem.name + " " + totalTime);
}
}else {
System.out.println(((Problem) myQueue.peek()).name + " " + totalTime);
myQueue.remove();
}
}
}
}
class Problem {
String name;
int time;
public Problem(String name, int time){
this.name = name;
this.time = time;
}
}
|
[
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,
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,
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
] | [
[
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
],
[
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
],
[
77,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
82,
88
],
[
88,
89
],
[
88,
90
],
[
82,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
92,
102
],
[
91,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
91,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
108,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
120,
125
],
[
12,
126
],
[
126,
127
],
[
0,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
128,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
138,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
136,
149
],
[
149,
150
],
[
136,
151
],
[
151,
152
]
] | [
"import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Queue;\nclass Main {\n public static void main(String[] args){\n\t\tScanner scan = new Scanner(System.in);\n\t\tString[] t = scan.nextLine().split(\"\\\\s\");\n\t\tint num = Integer.parseInt(t[0]);\n\t\tint Dectime = Integer.parseInt(t[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < num; i++){\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}\n\t\t\n\t\tint result = 0;\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tProcess pro = queue.poll();\n\t\t\t\t\n\t\t\tresult += Dectime;\n\t\t\t\n\t\t\tif((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}\n\nclass Process{\n\tString name = null;\n\tint time = 0;\n\t\n\tProcess(String n, int t){\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"class Main {\n public static void main(String[] args){\n\t\tScanner scan = new Scanner(System.in);\n\t\tString[] t = scan.nextLine().split(\"\\\\s\");\n\t\tint num = Integer.parseInt(t[0]);\n\t\tint Dectime = Integer.parseInt(t[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < num; i++){\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}\n\t\t\n\t\tint result = 0;\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tProcess pro = queue.poll();\n\t\t\t\t\n\t\t\tresult += Dectime;\n\t\t\t\n\t\t\tif((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner scan = new Scanner(System.in);\n\t\tString[] t = scan.nextLine().split(\"\\\\s\");\n\t\tint num = Integer.parseInt(t[0]);\n\t\tint Dectime = Integer.parseInt(t[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < num; i++){\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}\n\t\t\n\t\tint result = 0;\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tProcess pro = queue.poll();\n\t\t\t\t\n\t\t\tresult += Dectime;\n\t\t\t\n\t\t\tif((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tString[] t = scan.nextLine().split(\"\\\\s\");\n\t\tint num = Integer.parseInt(t[0]);\n\t\tint Dectime = Integer.parseInt(t[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < num; i++){\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}\n\t\t\n\t\tint result = 0;\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tProcess pro = queue.poll();\n\t\t\t\t\n\t\t\tresult += Dectime;\n\t\t\t\n\t\t\tif((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"String[] t = scan.nextLine().split(\"\\\\s\");",
"t",
"scan.nextLine().split(\"\\\\s\")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\"\\\\s\"",
"int num = Integer.parseInt(t[0]);",
"num",
"Integer.parseInt(t[0])",
"Integer.parseInt",
"Integer",
"t[0]",
"t",
"0",
"int Dectime = Integer.parseInt(t[1]);",
"Dectime",
"Integer.parseInt(t[1])",
"Integer.parseInt",
"Integer",
"t[1]",
"t",
"1",
"Queue<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for(int i = 0; i < num; i++){\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}",
"{\n\t\t\tString[] str = scan.nextLine().split(\"\\\\s\");\n\t\t\t\n\t\t\tProcess pro = new Process(str[0], Integer.parseInt(str[1]));\n\t\t\tqueue.offer(pro);\n\t\t}",
"String[] str = scan.nextLine().split(\"\\\\s\");",
"str",
"scan.nextLine().split(\"\\\\s\")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\"\\\\s\"",
"Process pro = new Process(str[0], Integer.parseInt(str[1]));",
"pro",
"new Process(str[0], Integer.parseInt(str[1]))",
"queue.offer(pro)",
"queue.offer",
"queue",
"pro",
"int result = 0;",
"result",
"0",
"while(queue.size() > 0){\n\t\t\tProcess pro = queue.poll();\n\t\t\t\t\n\t\t\tresult += Dectime;\n\t\t\t\n\t\t\tif((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}\n\t\t\t\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tProcess pro = queue.poll();\n\t\t\t\t\n\t\t\tresult += Dectime;\n\t\t\t\n\t\t\tif((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}\n\t\t\t\n\t\t}",
"Process pro = queue.poll();",
"pro",
"queue.poll()",
"queue.poll",
"queue",
"result += Dectime",
"result",
"Dectime",
"if((pro.time = pro.time - Dectime) > 0){\n\t\t\t\tqueue.offer(pro);\n\t\t\t}else{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}",
"(pro.time = pro.time - Dectime) > 0",
"(pro.time = pro.time - Dectime)",
"pro.time",
"pro",
"pro.time",
"pro.time - Dectime",
"pro.time",
"pro",
"pro.time",
"Dectime",
"0",
"{\n\t\t\t\tqueue.offer(pro);\n\t\t\t}",
"queue.offer(pro)",
"queue.offer",
"queue",
"pro",
"{\n\t\t\t\tresult += pro.time;\n\t\t\t\tSystem.out.println(pro.name + \" \" + result);\n\t\t\t}",
"result += pro.time",
"result",
"pro.time",
"pro",
"pro.time",
"System.out.println(pro.name + \" \" + result)",
"System.out.println",
"System.out",
"System",
"System.out",
"pro.name + \" \" + result",
"pro.name + \" \" + result",
"pro.name",
"pro",
"pro.name",
"\" \"",
"result",
"String[] args",
"args",
"class Process{\n\tString name = null;\n\tint time = 0;\n\t\n\tProcess(String n, int t){\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}\n}",
"Process",
"String name = null;",
"name",
"null",
"int time = 0;",
"time",
"0",
"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"
] | import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;
class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String[] t = scan.nextLine().split("\\s");
int num = Integer.parseInt(t[0]);
int Dectime = Integer.parseInt(t[1]);
Queue<Process> queue = new ArrayDeque<Process>();
for(int i = 0; i < num; i++){
String[] str = scan.nextLine().split("\\s");
Process pro = new Process(str[0], Integer.parseInt(str[1]));
queue.offer(pro);
}
int result = 0;
while(queue.size() > 0){
Process pro = queue.poll();
result += Dectime;
if((pro.time = pro.time - Dectime) > 0){
queue.offer(pro);
}else{
result += pro.time;
System.out.println(pro.name + " " + result);
}
}
}
}
class Process{
String name = null;
int time = 0;
Process(String n, int t){
this.name = n;
this.time = t;
}
} |
[
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,
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,
4,
18,
13,
18,
13,
13,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
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,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
12,
13,
30,
0,
18,
36,
13,
20,
2,
13,
17,
23,
13,
12,
13,
30,
29,
2,
18,
36,
13,
18,
36,
13,
12,
13,
30,
29,
2,
18,
36,
13,
2,
2,
18,
36,
13,
17,
18,
18,
36,
13,
13,
12,
13,
30,
14,
4,
18,
36,
30,
37,
20,
0,
18,
18,
36,
13,
18,
36,
13,
20,
14,
2,
2,
18,
36,
13,
17,
18,
18,
36,
13,
13,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
23,
13,
23,
13,
12,
13,
30,
14,
4,
18,
36,
30,
37,
20,
41,
13,
18,
18,
36,
13,
18,
36,
13,
14,
2,
2,
18,
36,
13,
17,
18,
18,
36,
13,
13,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
285,
8
],
[
285,
9
],
[
9,
10
],
[
9,
11
],
[
285,
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
],
[
55,
59
],
[
14,
60
],
[
60,
61
],
[
60,
62
],
[
14,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
63,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
74,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
87,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
74,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
107,
112
],
[
14,
113
],
[
113,
114
],
[
114,
115
],
[
12,
116
],
[
116,
117
],
[
0,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
118,
122
],
[
122,
123
],
[
118,
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
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
146,
148
],
[
141,
149
],
[
149,
150
],
[
141,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
159,
160
],
[
159,
161
],
[
151,
162
],
[
162,
163
],
[
141,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
172,
173
],
[
172,
174
],
[
141,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
183,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
189,
193
],
[
141,
194
],
[
194,
195
],
[
194,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
197,
201
],
[
201,
202
],
[
202,
203
],
[
196,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
205,
209
],
[
209,
210
],
[
209,
211
],
[
204,
212
],
[
196,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
215,
219
],
[
214,
220
],
[
220,
221
],
[
221,
222
],
[
221,
223
],
[
220,
224
],
[
213,
225
],
[
225,
226
],
[
226,
227
],
[
227,
228
],
[
227,
229
],
[
226,
230
],
[
213,
231
],
[
231,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
194,
236
],
[
236,
237
],
[
194,
238
],
[
238,
239
],
[
141,
240
],
[
240,
241
],
[
240,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
245,
246
],
[
243,
247
],
[
247,
248
],
[
248,
249
],
[
242,
250
],
[
250,
251
],
[
250,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
252,
256
],
[
256,
257
],
[
256,
258
],
[
242,
259
],
[
259,
260
],
[
260,
261
],
[
261,
262
],
[
262,
263
],
[
262,
264
],
[
261,
265
],
[
260,
266
],
[
266,
267
],
[
267,
268
],
[
267,
269
],
[
266,
270
],
[
259,
271
],
[
271,
272
],
[
272,
273
],
[
273,
274
],
[
273,
275
],
[
272,
276
],
[
259,
277
],
[
277,
278
],
[
278,
279
],
[
279,
280
],
[
279,
281
],
[
242,
282
],
[
282,
283
],
[
0,
284
],
[
284,
285
],
[
284,
286
]
] | [
"import java.nio.*;\nimport java.util.*;\n\npublic class Main {\n static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) throws Exception {\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n\n String s;\n int t;\n for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }\n\n sc.close();\n }\n}\n\nclass P {\n public String s;\n public int t;\n\n public P(String s, int t) {\n this.s = s;\n this.t = t;\n }\n}\n\nclass Queue {\n private int head = 0;\n private int tail = 0;\n private P[] p;\n\n public Queue(int n) {\n this.p = new P[n + 1];\n }\n\n public boolean isEmpty() {\n return this.head == this.tail;\n }\n\n public boolean isFull() {\n return this.head == (this.tail + 1) % this.p.length;\n }\n\n public void enQueue(String s, int t) throws Exception {\n if (this.isFull()) {\n throw new Exception();\n }\n\n this.p[this.tail] = new P(s, t);\n\n if (this.tail + 1 == this.p.length) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public P deQueue() throws Exception {\n if (this.isEmpty()) {\n throw new Exception();\n }\n\n P p = this.p[this.head];\n\n if (this.head + 1 == this.p.length) {\n this.head = 0;\n } else {\n this.head++;\n }\n\n return p;\n }\n}",
"import java.nio.*;",
"nio.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) throws Exception {\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n\n String s;\n int t;\n for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }\n\n sc.close();\n }\n}",
"Main",
"static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args) throws Exception {\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n\n String s;\n int t;\n for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }\n\n sc.close();\n }",
"main",
"{\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n\n String s;\n int t;\n for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }\n\n sc.close();\n }",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue queue = new Queue(n);",
"queue",
"new Queue(n)",
"String s;",
"s",
"int t;",
"t",
"for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }",
"{\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }",
"s = sc.next()",
"s",
"sc.next()",
"sc.next",
"sc",
"t = sc.nextInt()",
"t",
"sc.nextInt()",
"sc.nextInt",
"sc",
"queue.enQueue(s, t)",
"queue.enQueue",
"queue",
"s",
"t",
"int sum = 0;",
"sum",
"0",
"while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }",
"P p = queue.deQueue();",
"p",
"queue.deQueue()",
"queue.deQueue",
"queue",
"if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }",
"p.t > q",
"p.t",
"p",
"p.t",
"q",
"{\n sum += q;\n queue.enQueue(p.s, p.t - q);\n }",
"sum += q",
"sum",
"q",
"queue.enQueue(p.s, p.t - q)",
"queue.enQueue",
"queue",
"p.s",
"p",
"p.s",
"p.t - q",
"p.t",
"p",
"p.t",
"q",
"{\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }",
"sum += p.t",
"sum",
"p.t",
"p",
"p.t",
"System.out.println(p.s + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.s + \" \" + sum",
"p.s + \" \" + sum",
"p.s",
"p",
"p.s",
"\" \"",
"sum",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"class P {\n public String s;\n public int t;\n\n public P(String s, int t) {\n this.s = s;\n this.t = t;\n }\n}",
"P",
"public String s;",
"s",
"public int t;",
"t",
"public P(String s, int t) {\n this.s = s;\n this.t = t;\n }",
"P",
"{\n this.s = s;\n this.t = t;\n }",
"this.s = s",
"this.s",
"this",
"this.s",
"s",
"this.t = t",
"this.t",
"this",
"this.t",
"t",
"String s",
"s",
"int t",
"t",
"class Queue {\n private int head = 0;\n private int tail = 0;\n private P[] p;\n\n public Queue(int n) {\n this.p = new P[n + 1];\n }\n\n public boolean isEmpty() {\n return this.head == this.tail;\n }\n\n public boolean isFull() {\n return this.head == (this.tail + 1) % this.p.length;\n }\n\n public void enQueue(String s, int t) throws Exception {\n if (this.isFull()) {\n throw new Exception();\n }\n\n this.p[this.tail] = new P(s, t);\n\n if (this.tail + 1 == this.p.length) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public P deQueue() throws Exception {\n if (this.isEmpty()) {\n throw new Exception();\n }\n\n P p = this.p[this.head];\n\n if (this.head + 1 == this.p.length) {\n this.head = 0;\n } else {\n this.head++;\n }\n\n return p;\n }\n}",
"Queue",
"private int head = 0;",
"head",
"0",
"private int tail = 0;",
"tail",
"0",
"private P[] p;",
"p",
"public Queue(int n) {\n this.p = new P[n + 1];\n }",
"Queue",
"{\n this.p = new P[n + 1];\n }",
"this.p = new P[n + 1]",
"this.p",
"this",
"this.p",
"new P[n + 1]",
"n + 1",
"n",
"1",
"int n",
"n",
"public boolean isEmpty() {\n return this.head == this.tail;\n }",
"isEmpty",
"{\n return this.head == this.tail;\n }",
"return this.head == this.tail;",
"this.head == this.tail",
"this.head",
"this",
"this.head",
"this.tail",
"this",
"this.tail",
"public boolean isFull() {\n return this.head == (this.tail + 1) % this.p.length;\n }",
"isFull",
"{\n return this.head == (this.tail + 1) % this.p.length;\n }",
"return this.head == (this.tail + 1) % this.p.length;",
"this.head == (this.tail + 1) % this.p.length",
"this.head",
"this",
"this.head",
"(this.tail + 1) % this.p.length",
"(this.tail + 1)",
"this.tail",
"this",
"this.tail",
"1",
"this.p.length",
"this.p",
"this",
"this.p",
"this.p.length",
"public void enQueue(String s, int t) throws Exception {\n if (this.isFull()) {\n throw new Exception();\n }\n\n this.p[this.tail] = new P(s, t);\n\n if (this.tail + 1 == this.p.length) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }",
"enQueue",
"{\n if (this.isFull()) {\n throw new Exception();\n }\n\n this.p[this.tail] = new P(s, t);\n\n if (this.tail + 1 == this.p.length) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }",
"if (this.isFull()) {\n throw new Exception();\n }",
"this.isFull()",
"this.isFull",
"this",
"{\n throw new Exception();\n }",
"throw new Exception();",
"new Exception()",
"this.p[this.tail] = new P(s, t)",
"this.p[this.tail]",
"this.p",
"this",
"this.p",
"this.tail",
"this",
"this.tail",
"new P(s, t)",
"if (this.tail + 1 == this.p.length) {\n this.tail = 0;\n } else {\n this.tail++;\n }",
"this.tail + 1 == this.p.length",
"this.tail + 1",
"this.tail",
"this",
"this.tail",
"1",
"this.p.length",
"this.p",
"this",
"this.p",
"this.p.length",
"{\n this.tail = 0;\n }",
"this.tail = 0",
"this.tail",
"this",
"this.tail",
"0",
"{\n this.tail++;\n }",
"this.tail++",
"this.tail",
"this",
"this.tail",
"String s",
"s",
"int t",
"t",
"public P deQueue() throws Exception {\n if (this.isEmpty()) {\n throw new Exception();\n }\n\n P p = this.p[this.head];\n\n if (this.head + 1 == this.p.length) {\n this.head = 0;\n } else {\n this.head++;\n }\n\n return p;\n }",
"deQueue",
"{\n if (this.isEmpty()) {\n throw new Exception();\n }\n\n P p = this.p[this.head];\n\n if (this.head + 1 == this.p.length) {\n this.head = 0;\n } else {\n this.head++;\n }\n\n return p;\n }",
"if (this.isEmpty()) {\n throw new Exception();\n }",
"this.isEmpty()",
"this.isEmpty",
"this",
"{\n throw new Exception();\n }",
"throw new Exception();",
"new Exception()",
"P p = this.p[this.head];",
"p",
"this.p[this.head]",
"this.p",
"this",
"this.p",
"this.head",
"this",
"this.head",
"if (this.head + 1 == this.p.length) {\n this.head = 0;\n } else {\n this.head++;\n }",
"this.head + 1 == this.p.length",
"this.head + 1",
"this.head",
"this",
"this.head",
"1",
"this.p.length",
"this.p",
"this",
"this.p",
"this.p.length",
"{\n this.head = 0;\n }",
"this.head = 0",
"this.head",
"this",
"this.head",
"0",
"{\n this.head++;\n }",
"this.head++",
"this.head",
"this",
"this.head",
"return p;",
"p",
"public class Main {\n static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) throws Exception {\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n\n String s;\n int t;\n for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }\n\n sc.close();\n }\n}",
"public class Main {\n static Scanner sc = new Scanner(System.in);\n\n public static void main(String[] args) throws Exception {\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n\n String s;\n int t;\n for (int i = 0; i < n; i++) {\n s = sc.next();\n t = sc.nextInt();\n\n queue.enQueue(s, t);\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n P p = queue.deQueue();\n if (p.t > q) {\n sum += q;\n queue.enQueue(p.s, p.t - q);\n } else {\n sum += p.t;\n System.out.println(p.s + \" \" + sum);\n }\n }\n\n sc.close();\n }\n}",
"Main"
] | import java.nio.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) throws Exception {
int n = sc.nextInt();
int q = sc.nextInt();
Queue queue = new Queue(n);
String s;
int t;
for (int i = 0; i < n; i++) {
s = sc.next();
t = sc.nextInt();
queue.enQueue(s, t);
}
int sum = 0;
while (!queue.isEmpty()) {
P p = queue.deQueue();
if (p.t > q) {
sum += q;
queue.enQueue(p.s, p.t - q);
} else {
sum += p.t;
System.out.println(p.s + " " + sum);
}
}
sc.close();
}
}
class P {
public String s;
public int t;
public P(String s, int t) {
this.s = s;
this.t = t;
}
}
class Queue {
private int head = 0;
private int tail = 0;
private P[] p;
public Queue(int n) {
this.p = new P[n + 1];
}
public boolean isEmpty() {
return this.head == this.tail;
}
public boolean isFull() {
return this.head == (this.tail + 1) % this.p.length;
}
public void enQueue(String s, int t) throws Exception {
if (this.isFull()) {
throw new Exception();
}
this.p[this.tail] = new P(s, t);
if (this.tail + 1 == this.p.length) {
this.tail = 0;
} else {
this.tail++;
}
}
public P deQueue() throws Exception {
if (this.isEmpty()) {
throw new Exception();
}
P p = this.p[this.head];
if (this.head + 1 == this.p.length) {
this.head = 0;
} else {
this.head++;
}
return p;
}
}
|
[
7,
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,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
116,
11
],
[
116,
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
],
[
28,
29
],
[
29,
30
],
[
14,
31
],
[
31,
32
],
[
31,
33
],
[
14,
34
],
[
34,
35
],
[
34,
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
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
49,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
60,
61
],
[
14,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
71,
75
],
[
70,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
77,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
87,
91
],
[
77,
92
],
[
92,
93
],
[
92,
94
],
[
69,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
107,
111
],
[
107,
112
],
[
12,
113
],
[
113,
114
],
[
0,
115
],
[
115,
116
],
[
115,
117
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\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\t\tint timecount =0;\n\t\tint count = sc.nextInt();\n\t\tint max = sc.nextInt();\n\n\t\tQueue<String> queName = new LinkedList<String>();\n\t\tQueue<Integer> queTime = new LinkedList<Integer>();\n\n\t\tfor(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}\n\n\t\twhile(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}\n\n\n\n\n\t}\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\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint timecount =0;\n\t\tint count = sc.nextInt();\n\t\tint max = sc.nextInt();\n\n\t\tQueue<String> queName = new LinkedList<String>();\n\t\tQueue<Integer> queTime = new LinkedList<Integer>();\n\n\t\tfor(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}\n\n\t\twhile(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}\n\n\n\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint timecount =0;\n\t\tint count = sc.nextInt();\n\t\tint max = sc.nextInt();\n\n\t\tQueue<String> queName = new LinkedList<String>();\n\t\tQueue<Integer> queTime = new LinkedList<Integer>();\n\n\t\tfor(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}\n\n\t\twhile(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}\n\n\n\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint timecount =0;\n\t\tint count = sc.nextInt();\n\t\tint max = sc.nextInt();\n\n\t\tQueue<String> queName = new LinkedList<String>();\n\t\tQueue<Integer> queTime = new LinkedList<Integer>();\n\n\t\tfor(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}\n\n\t\twhile(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}\n\n\n\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int timecount =0;",
"timecount",
"0",
"int count = sc.nextInt();",
"count",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int max = sc.nextInt();",
"max",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<String> queName = new LinkedList<String>();",
"queName",
"new LinkedList<String>()",
"Queue<Integer> queTime = new LinkedList<Integer>();",
"queTime",
"new LinkedList<Integer>()",
"for(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<count",
"i",
"count",
"i++",
"i++",
"i",
"{\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}",
"queName.add(sc.next())",
"queName.add",
"queName",
"sc.next()",
"sc.next",
"sc",
"queTime.add(sc.nextInt())",
"queTime.add",
"queTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}",
"queName.size() !=0",
"queName.size()",
"queName.size",
"queName",
"0",
"{\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}",
"if(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}",
"queTime.peek()-max>0",
"queTime.peek()-max",
"queTime.peek()",
"queTime.peek",
"queTime",
"max",
"0",
"{\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}",
"queName.add(queName.poll())",
"queName.add",
"queName",
"queName.poll()",
"queName.poll",
"queName",
"queTime.add(queTime.poll()-max)",
"queTime.add",
"queTime",
"queTime.poll()-max",
"queTime.poll()",
"queTime.poll",
"queTime",
"max",
"timecount +=max",
"timecount",
"max",
"{\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}",
"timecount += queTime.poll()",
"timecount",
"queTime.poll()",
"queTime.poll",
"queTime",
"System.out.println(queName.poll()+\" \"+timecount)",
"System.out.println",
"System.out",
"System",
"System.out",
"queName.poll()+\" \"+timecount",
"queName.poll()+\" \"+timecount",
"queName.poll()",
"queName.poll",
"queName",
"\" \"",
"timecount",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint timecount =0;\n\t\tint count = sc.nextInt();\n\t\tint max = sc.nextInt();\n\n\t\tQueue<String> queName = new LinkedList<String>();\n\t\tQueue<Integer> queTime = new LinkedList<Integer>();\n\n\t\tfor(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}\n\n\t\twhile(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}\n\n\n\n\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint timecount =0;\n\t\tint count = sc.nextInt();\n\t\tint max = sc.nextInt();\n\n\t\tQueue<String> queName = new LinkedList<String>();\n\t\tQueue<Integer> queTime = new LinkedList<Integer>();\n\n\t\tfor(int i=0; i<count; i++) {\n\t\t\tqueName.add(sc.next());\n\t\t\tqueTime.add(sc.nextInt());\n\t\t}\n\n\t\twhile(queName.size() !=0) {\n\t\t\tif(queTime.peek()-max>0) {\n\t\t\t\tqueName.add(queName.poll());\n\t\t\t\tqueTime.add(queTime.poll()-max);\n\t\t\t\ttimecount +=max;\n\t\t\t}else {\n\t\t\t\ttimecount += queTime.poll();\n\t\t\t\tSystem.out.println(queName.poll()+\" \"+timecount);\n\t\t\t}\n\n\t\t}\n\n\n\n\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) {
Scanner sc = new Scanner(System.in);
int timecount =0;
int count = sc.nextInt();
int max = sc.nextInt();
Queue<String> queName = new LinkedList<String>();
Queue<Integer> queTime = new LinkedList<Integer>();
for(int i=0; i<count; i++) {
queName.add(sc.next());
queTime.add(sc.nextInt());
}
while(queName.size() !=0) {
if(queTime.peek()-max>0) {
queName.add(queName.poll());
queTime.add(queTime.poll()-max);
timecount +=max;
}else {
timecount += queTime.poll();
System.out.println(queName.poll()+" "+timecount);
}
}
}
}
|
[
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,
11,
1,
41,
13,
17,
40,
4,
18,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
2,
18,
13,
13,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
139,
5
],
[
139,
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
],
[
54,
55
],
[
54,
56
],
[
52,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
52,
61
],
[
62,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
69,
75
],
[
68,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
88,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
88,
93
],
[
68,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
94,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
94,
104
],
[
104,
105
],
[
104,
106
],
[
139,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
107,
113
],
[
113,
114
],
[
139,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
115,
119
],
[
119,
120
],
[
115,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
121,
134
],
[
134,
135
],
[
121,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
]
] | [
"import java.util.*;\n\npublic class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main",
"void run() {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}",
"run",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int q = scanner.nextInt();",
"q",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"Queue<Process> que = new LinkedList<Process>();",
"que",
"new LinkedList<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.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 = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"{\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"String name = scanner.next();",
"name",
"scanner.next()",
"scanner.next",
"scanner",
"int time = scanner.nextInt();",
"time",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"que.add(new Process(name, time))",
"que.add",
"que",
"new Process(name, time)",
"for (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"int time = 0;",
"int time = 0;",
"time",
"0",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"{\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"Process p = que.poll();",
"p",
"que.poll()",
"que.poll",
"que",
"if (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}",
"p.time - q <= 0",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"0",
"{\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t}",
"time += p.time",
"time",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + time",
"p.name + \" \" + time",
"p.name",
"p",
"p.name",
"\" \"",
"time",
"{\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"que.add(p)",
"que.add",
"que",
"p",
"time += q",
"time",
"q",
"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",
"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",
"public class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"public class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scanner.next();\n\t\t\tint time = scanner.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
class Process {
String name;
int time;
Process(String name, int time) {
this.name = name;
this.time = time;
}
}
void run() {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int q = scanner.nextInt();
Queue<Process> que = new LinkedList<Process>();
for (int i = 0; i < n; i++) {
String name = scanner.next();
int time = scanner.nextInt();
que.add(new Process(name, time));
}
for (int time = 0; !que.isEmpty();) {
Process p = que.poll();
if (p.time - q <= 0) {
time += p.time;
System.out.println(p.name + " " + time);
} else {
p.time -= q;
que.add(p);
time += q;
}
}
}
public static void main(String[] args) {
new Main().run();
}
}
|
[
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,
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,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
2,
13,
13,
0,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
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
],
[
118,
11
],
[
118,
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
],
[
34,
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
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
49,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
59,
60
],
[
60,
61
],
[
14,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
62,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
67,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
67,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
83,
88
],
[
89,
89
],
[
89,
90
],
[
89,
91
],
[
89,
92
],
[
92,
93
],
[
92,
94
],
[
82,
95
],
[
95,
96
],
[
95,
97
],
[
78,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
98,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
106,
107
],
[
106,
108
],
[
98,
109
],
[
109,
110
],
[
109,
111
],
[
14,
112
],
[
112,
113
],
[
113,
114
],
[
12,
115
],
[
115,
116
],
[
0,
117
],
[
117,
118
],
[
117,
119
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tfinal int t = scan.nextInt();\n\t\tint totalTime = 0;\n\n\t\tDeque<String> queueName = new ArrayDeque<String>();\n\t\tDeque<Integer> queueTime = new ArrayDeque<Integer>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}\n\n\t\twhile(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tfinal int t = scan.nextInt();\n\t\tint totalTime = 0;\n\n\t\tDeque<String> queueName = new ArrayDeque<String>();\n\t\tDeque<Integer> queueTime = new ArrayDeque<Integer>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}\n\n\t\twhile(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\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\tint n = scan.nextInt();\n\t\tfinal int t = scan.nextInt();\n\t\tint totalTime = 0;\n\n\t\tDeque<String> queueName = new ArrayDeque<String>();\n\t\tDeque<Integer> queueTime = new ArrayDeque<Integer>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}\n\n\t\twhile(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tfinal int t = scan.nextInt();\n\t\tint totalTime = 0;\n\n\t\tDeque<String> queueName = new ArrayDeque<String>();\n\t\tDeque<Integer> queueTime = new ArrayDeque<Integer>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}\n\n\t\twhile(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"final int t = scan.nextInt();",
"t",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int totalTime = 0;",
"totalTime",
"0",
"Deque<String> queueName = new ArrayDeque<String>();",
"queueName",
"new ArrayDeque<String>()",
"Deque<Integer> queueTime = new ArrayDeque<Integer>();",
"queueTime",
"new ArrayDeque<Integer>()",
"for(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}",
"{\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}",
"queueName.addLast(scan.next())",
"queueName.addLast",
"queueName",
"scan.next()",
"scan.next",
"scan",
"queueTime.addLast(scan.nextInt())",
"queueTime.addLast",
"queueTime",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}",
"!queueName.isEmpty()",
"queueName.isEmpty()",
"queueName.isEmpty",
"queueName",
"{\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}",
"String procName = queueName.pollFirst();",
"procName",
"queueName.pollFirst()",
"queueName.pollFirst",
"queueName",
"int procTime = queueTime.pollFirst();",
"procTime",
"queueTime.pollFirst()",
"queueTime.pollFirst",
"queueTime",
"if(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}",
"procTime <= t",
"procTime",
"t",
"{\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t}",
"System.out.println(procName + \" \" + (procTime + totalTime))",
"System.out.println",
"System.out",
"System",
"System.out",
"procName + \" \" + (procTime + totalTime)",
"procName + \" \" + (procTime + totalTime)",
"procName",
"\" \"",
"(procTime + totalTime)",
"procTime",
"totalTime",
"totalTime += procTime",
"totalTime",
"procTime",
"{\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}",
"queueName.addLast(procName)",
"queueName.addLast",
"queueName",
"procName",
"queueTime.addLast(procTime - t)",
"queueTime.addLast",
"queueTime",
"procTime - t",
"procTime",
"t",
"totalTime += t",
"totalTime",
"t",
"scan.close()",
"scan.close",
"scan",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tfinal int t = scan.nextInt();\n\t\tint totalTime = 0;\n\n\t\tDeque<String> queueName = new ArrayDeque<String>();\n\t\tDeque<Integer> queueTime = new ArrayDeque<Integer>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}\n\n\t\twhile(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tfinal int t = scan.nextInt();\n\t\tint totalTime = 0;\n\n\t\tDeque<String> queueName = new ArrayDeque<String>();\n\t\tDeque<Integer> queueTime = new ArrayDeque<Integer>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tqueueName.addLast(scan.next());\n\t\t\tqueueTime.addLast(scan.nextInt());\n\t\t}\n\n\t\twhile(!queueName.isEmpty()) {\n\t\t\tString procName = queueName.pollFirst();\n\t\t\tint procTime = queueTime.pollFirst();\n\t\t\tif(procTime <= t) {\n\t\t\t\tSystem.out.println(procName + \" \" + (procTime + totalTime));\n\t\t\t\ttotalTime += procTime;\n\t\t\t} else {\n\t\t\t\tqueueName.addLast(procName);\n\t\t\t\tqueueTime.addLast(procTime - t);\n\t\t\t\ttotalTime += t;\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
final int t = scan.nextInt();
int totalTime = 0;
Deque<String> queueName = new ArrayDeque<String>();
Deque<Integer> queueTime = new ArrayDeque<Integer>();
for(int i = 0; i < n; i++) {
queueName.addLast(scan.next());
queueTime.addLast(scan.nextInt());
}
while(!queueName.isEmpty()) {
String procName = queueName.pollFirst();
int procTime = queueTime.pollFirst();
if(procTime <= t) {
System.out.println(procName + " " + (procTime + totalTime));
totalTime += procTime;
} else {
queueName.addLast(procName);
queueTime.addLast(procTime - t);
totalTime += t;
}
}
scan.close();
}
}
|
[
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,
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,
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,
13,
13,
30,
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
],
[
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
],
[
133,
24
],
[
133,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
27,
31
],
[
31,
32
],
[
27,
33
],
[
33,
34
],
[
27,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
27,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
27,
45
],
[
45,
46
],
[
45,
47
],
[
27,
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
],
[
60,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
60,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
27,
75
],
[
75,
76
],
[
75,
77
],
[
27,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
78,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
83,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
94,
96
],
[
91,
97
],
[
83,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
83,
103
],
[
103,
104
],
[
103,
105
],
[
83,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
106,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
106,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
118,
123
],
[
124,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
124,
129
],
[
25,
130
],
[
130,
131
],
[
0,
132
],
[
132,
133
],
[
132,
134
]
] | [
"import java.util.*;\nclass Pair{\n\tint t;\n\tString name;\n\tpublic Pair(int val,String str){\n\t\tt = val;\n\t\tname = str; \n\t}\n}\npublic class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n,quantum;\n\t\tn = sc.nextInt();\n\t\tquantum = sc.nextInt();\n\t\tQueue<Pair> queue = new LinkedList<Pair>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}\n\t\tint elapse =0;\n\t\twhile(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"class Pair{\n\tint t;\n\tString name;\n\tpublic Pair(int val,String str){\n\t\tt = val;\n\t\tname = str; \n\t}\n}",
"Pair",
"int t;",
"t",
"String name;",
"name",
"public Pair(int val,String str){\n\t\tt = val;\n\t\tname = str; \n\t}",
"Pair",
"{\n\t\tt = val;\n\t\tname = str; \n\t}",
"t = val",
"t",
"val",
"name = str",
"name",
"str",
"int val",
"val",
"String str",
"str",
"public class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n,quantum;\n\t\tn = sc.nextInt();\n\t\tquantum = sc.nextInt();\n\t\tQueue<Pair> queue = new LinkedList<Pair>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}\n\t\tint elapse =0;\n\t\twhile(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\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 n,quantum;\n\t\tn = sc.nextInt();\n\t\tquantum = sc.nextInt();\n\t\tQueue<Pair> queue = new LinkedList<Pair>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}\n\t\tint elapse =0;\n\t\twhile(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n,quantum;\n\t\tn = sc.nextInt();\n\t\tquantum = sc.nextInt();\n\t\tQueue<Pair> queue = new LinkedList<Pair>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}\n\t\tint elapse =0;\n\t\twhile(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"Scanner sc =new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n",
"n",
"quantum;",
"quantum",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"quantum = sc.nextInt()",
"quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Pair> queue = new LinkedList<Pair>();",
"queue",
"new LinkedList<Pair>()",
"for(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\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 t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int t = sc.nextInt();",
"t",
"sc.nextInt()",
"sc.nextInt",
"sc",
"queue.offer(new Pair(t,name))",
"queue.offer",
"queue",
"new Pair(t,name)",
"int elapse =0;",
"elapse",
"0",
"while(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}\n\t\t}",
"Pair p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"int c= Math.min(p.t, quantum);",
"c",
"Math.min(p.t, quantum)",
"Math.min",
"Math",
"p.t",
"p",
"p.t",
"quantum",
"p.t -=c",
"p.t",
"p",
"p.t",
"c",
"elapse+=c",
"elapse",
"c",
"if(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}",
"p.t>0",
"p.t",
"p",
"p.t",
"0",
"{\n\t\t\t\tqueue.offer(p);\n\t\t\t}",
"queue.offer(p)",
"queue.offer",
"queue",
"p",
"{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}",
"System.out.println(p.name+\" \"+elapse)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name+\" \"+elapse",
"p.name+\" \"+elapse",
"p.name",
"p",
"p.name",
"\" \"",
"elapse",
"String args[]",
"args",
"public class Main {\n\tpublic static void main(String args[]){\n\t\tScanner sc =new Scanner(System.in);\n\t\tint n,quantum;\n\t\tn = sc.nextInt();\n\t\tquantum = sc.nextInt();\n\t\tQueue<Pair> queue = new LinkedList<Pair>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}\n\t\tint elapse =0;\n\t\twhile(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\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 n,quantum;\n\t\tn = sc.nextInt();\n\t\tquantum = sc.nextInt();\n\t\tQueue<Pair> queue = new LinkedList<Pair>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString name = sc.next();\n\t\t\tint t = sc.nextInt();\n\t\t\tqueue.offer(new Pair(t,name));\n\t\t}\n\t\tint elapse =0;\n\t\twhile(!queue.isEmpty()){\n\t\t\tPair p = queue.poll();\n\t\t\tint c= Math.min(p.t, quantum);\n\t\t\tp.t -=c;\n\t\t\telapse+=c;\n\t\t\tif(p.t>0){\n\t\t\t\tqueue.offer(p);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(p.name+\" \"+elapse);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main"
] | import java.util.*;
class Pair{
int t;
String name;
public Pair(int val,String str){
t = val;
name = str;
}
}
public class Main {
public static void main(String args[]){
Scanner sc =new Scanner(System.in);
int n,quantum;
n = sc.nextInt();
quantum = sc.nextInt();
Queue<Pair> queue = new LinkedList<Pair>();
for(int i=0;i<n;i++){
String name = sc.next();
int t = sc.nextInt();
queue.offer(new Pair(t,name));
}
int elapse =0;
while(!queue.isEmpty()){
Pair p = queue.poll();
int c= Math.min(p.t, quantum);
p.t -=c;
elapse+=c;
if(p.t>0){
queue.offer(p);
}else{
System.out.println(p.name+" "+elapse);
}
}
}
} |
[
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,
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,
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,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
4,
18,
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
],
[
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
],
[
16,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
16,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
44,
52
],
[
52,
53
],
[
16,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
0,
59
],
[
167,
60
],
[
167,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
63,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
63,
77
],
[
77,
78
],
[
77,
79
],
[
63,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
85,
86
],
[
85,
87
],
[
80,
88
],
[
88,
89
],
[
89,
90
],
[
80,
91
],
[
92,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
92,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
92,
103
],
[
103,
104
],
[
103,
105
],
[
92,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
63,
110
],
[
110,
111
],
[
110,
112
],
[
63,
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
],
[
127,
128
],
[
125,
129
],
[
124,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
134,
138
],
[
130,
139
],
[
139,
140
],
[
139,
141
],
[
130,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
124,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
146,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
152,
157
],
[
158,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
158,
162
],
[
158,
163
],
[
61,
164
],
[
164,
165
],
[
0,
166
],
[
166,
167
],
[
166,
168
]
] | [
"import java.io.IOException;\nimport java.io.InputStream;\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\nclass Process {\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 int getTime() {\n return time;\n }\n\n public void setTime(int time) {\n this.time = time;\n }\n\n public String getName() {\n return name;\n }\n \n \n}\npublic class Main {\n\n public static void main(String[] args) {\n \n // scanner for input.\n Scanner s = new Scanner(System.in);\n // accept number of processes.\n int numberOfProcesses = s.nextInt();\n // accept time quantum.\n int timeQuantum = s.nextInt();\n \n // declare queue for processes.\n Queue<Process> processes = new LinkedList<Process>();\n \n // fill the queue form the input.\n for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }\n \n // intialize current ongoing time.\n int currTime = 0;\n // check if process(Queue) is empty\n while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }\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.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Process {\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 int getTime() {\n return time;\n }\n\n public void setTime(int time) {\n this.time = time;\n }\n\n public String getName() {\n return name;\n }\n \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 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 String getName() {\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public class Main {\n\n public static void main(String[] args) {\n \n // scanner for input.\n Scanner s = new Scanner(System.in);\n // accept number of processes.\n int numberOfProcesses = s.nextInt();\n // accept time quantum.\n int timeQuantum = s.nextInt();\n \n // declare queue for processes.\n Queue<Process> processes = new LinkedList<Process>();\n \n // fill the queue form the input.\n for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }\n \n // intialize current ongoing time.\n int currTime = 0;\n // check if process(Queue) is empty\n while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n \n // scanner for input.\n Scanner s = new Scanner(System.in);\n // accept number of processes.\n int numberOfProcesses = s.nextInt();\n // accept time quantum.\n int timeQuantum = s.nextInt();\n \n // declare queue for processes.\n Queue<Process> processes = new LinkedList<Process>();\n \n // fill the queue form the input.\n for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }\n \n // intialize current ongoing time.\n int currTime = 0;\n // check if process(Queue) is empty\n while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }\n }",
"main",
"{\n \n // scanner for input.\n Scanner s = new Scanner(System.in);\n // accept number of processes.\n int numberOfProcesses = s.nextInt();\n // accept time quantum.\n int timeQuantum = s.nextInt();\n \n // declare queue for processes.\n Queue<Process> processes = new LinkedList<Process>();\n \n // fill the queue form the input.\n for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }\n \n // intialize current ongoing time.\n int currTime = 0;\n // check if process(Queue) is empty\n while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }\n }",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int numberOfProcesses = s.nextInt();",
"numberOfProcesses",
"s.nextInt()",
"s.nextInt",
"s",
"int timeQuantum = s.nextInt();",
"timeQuantum",
"s.nextInt()",
"s.nextInt",
"s",
"Queue<Process> processes = new LinkedList<Process>();",
"processes",
"new LinkedList<Process>()",
"for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<numberOfProcesses",
"i",
"numberOfProcesses",
"i++",
"i++",
"i",
"{\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }",
"{\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }",
"String namei = s.next();",
"namei",
"s.next()",
"s.next",
"s",
"int timei = s.nextInt();",
"timei",
"s.nextInt()",
"s.nextInt",
"s",
"Process processi = new Process(namei, timei);",
"processi",
"new Process(namei, timei)",
"processes.add(processi)",
"processes.add",
"processes",
"processi",
"int currTime = 0;",
"currTime",
"0",
"while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }",
"!processes.isEmpty()",
"processes.isEmpty()",
"processes.isEmpty",
"processes",
"{\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }",
"Process p = processes.poll();",
"p",
"processes.poll()",
"processes.poll",
"processes",
"if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }",
"p.getTime() > timeQuantum",
"p.getTime()",
"p.getTime",
"p",
"timeQuantum",
"{\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }",
"p.setTime(p.getTime() - timeQuantum)",
"p.setTime",
"p",
"p.getTime() - timeQuantum",
"p.getTime()",
"p.getTime",
"p",
"timeQuantum",
"currTime += timeQuantum",
"currTime",
"timeQuantum",
"processes.add(p)",
"processes.add",
"processes",
"p",
"{\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }",
"currTime += p.getTime()",
"currTime",
"p.getTime()",
"p.getTime",
"p",
"System.out.println(p.getName() + \" \" + currTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getName() + \" \" + currTime",
"p.getName() + \" \" + currTime",
"p.getName()",
"p.getName",
"p",
"\" \"",
"currTime",
"String[] args",
"args",
"public class Main {\n\n public static void main(String[] args) {\n \n // scanner for input.\n Scanner s = new Scanner(System.in);\n // accept number of processes.\n int numberOfProcesses = s.nextInt();\n // accept time quantum.\n int timeQuantum = s.nextInt();\n \n // declare queue for processes.\n Queue<Process> processes = new LinkedList<Process>();\n \n // fill the queue form the input.\n for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }\n \n // intialize current ongoing time.\n int currTime = 0;\n // check if process(Queue) is empty\n while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n \n // scanner for input.\n Scanner s = new Scanner(System.in);\n // accept number of processes.\n int numberOfProcesses = s.nextInt();\n // accept time quantum.\n int timeQuantum = s.nextInt();\n \n // declare queue for processes.\n Queue<Process> processes = new LinkedList<Process>();\n \n // fill the queue form the input.\n for (int i = 0; i<numberOfProcesses; i++) {\n String namei = s.next();\n int timei = s.nextInt();\n \n Process processi = new Process(namei, timei);\n processes.add(processi);\n }\n \n // intialize current ongoing time.\n int currTime = 0;\n // check if process(Queue) is empty\n while(!processes.isEmpty()) {\n // get the head of queue and remove from queue.\n Process p = processes.poll();\n // if the current process is greater than time quantum\n // subtract its remaining time. and add the current time.\n // add the process back to queue.\n if (p.getTime() > timeQuantum) {\n p.setTime(p.getTime() - timeQuantum);\n currTime += timeQuantum;\n processes.add(p);\n }\n // Else add the current time and display the output.\n else {\n currTime += p.getTime();\n System.out.println(p.getName() + \" \" + currTime);\n }\n }\n }\n}",
"Main"
] | import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
class Process {
private String name;
private int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public String getName() {
return name;
}
}
public class Main {
public static void main(String[] args) {
// scanner for input.
Scanner s = new Scanner(System.in);
// accept number of processes.
int numberOfProcesses = s.nextInt();
// accept time quantum.
int timeQuantum = s.nextInt();
// declare queue for processes.
Queue<Process> processes = new LinkedList<Process>();
// fill the queue form the input.
for (int i = 0; i<numberOfProcesses; i++) {
String namei = s.next();
int timei = s.nextInt();
Process processi = new Process(namei, timei);
processes.add(processi);
}
// intialize current ongoing time.
int currTime = 0;
// check if process(Queue) is empty
while(!processes.isEmpty()) {
// get the head of queue and remove from queue.
Process p = processes.poll();
// if the current process is greater than time quantum
// subtract its remaining time. and add the current time.
// add the process back to queue.
if (p.getTime() > timeQuantum) {
p.setTime(p.getTime() - timeQuantum);
currTime += timeQuantum;
processes.add(p);
}
// Else add the current time and display the output.
else {
currTime += p.getTime();
System.out.println(p.getName() + " " + currTime);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
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,
20,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
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,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
41,
13,
4,
18,
13,
17,
18,
13,
13,
13,
4,
18,
18,
13,
13,
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
],
[
0,
10
],
[
127,
11
],
[
127,
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
],
[
48,
50
],
[
47,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
59,
60
],
[
43,
61
],
[
61,
62
],
[
62,
63
],
[
61,
64
],
[
14,
65
],
[
65,
66
],
[
65,
67
],
[
14,
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
],
[
82,
84
],
[
81,
85
],
[
80,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
86,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
80,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
107,
111
],
[
111,
112
],
[
111,
113
],
[
107,
114
],
[
99,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
14,
121
],
[
121,
122
],
[
122,
123
],
[
12,
124
],
[
124,
125
],
[
0,
126
],
[
126,
127
],
[
126,
128
]
] | [
"import java.util.*;\n\nclass Task {\n String name;\n int time;\n}\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 quantum = sc.nextInt();\n\n Queue<Task> que = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }\n\n int time = 0;\n\n while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }\n \n sc.close();\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"class Task {\n String name;\n int time;\n}",
"Task",
"String name;",
"name",
"int time;",
"time",
"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 quantum = sc.nextInt();\n\n Queue<Task> que = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }\n\n int time = 0;\n\n while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }\n \n sc.close();\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<Task> que = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }\n\n int time = 0;\n\n while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }\n \n sc.close();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int quantum = sc.nextInt();\n\n Queue<Task> que = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }\n\n int time = 0;\n\n while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }\n \n sc.close();\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<Task> que = new ArrayDeque<>();",
"que",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }",
"{\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }",
"Task task = new Task();",
"task",
"new Task()",
"task.name = sc.next()",
"task.name",
"task",
"task.name",
"sc.next()",
"sc.next",
"sc",
"task.time = sc.nextInt()",
"task.time",
"task",
"task.time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"que.offer(task)",
"que.offer",
"que",
"task",
"int time = 0;",
"time",
"0",
"while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }",
"que.peek() != null",
"que.peek()",
"que.peek",
"que",
"null",
"{\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }",
"Task task = que.poll();",
"task",
"que.poll()",
"que.poll",
"que",
"if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }",
"task.time > quantum",
"task.time",
"task",
"task.time",
"quantum",
"{\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n }",
"time += quantum",
"time",
"quantum",
"task.time -= quantum",
"task.time",
"task",
"task.time",
"quantum",
"que.offer(task)",
"que.offer",
"que",
"task",
"{\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }",
"time += task.time",
"time",
"task.time",
"task",
"task.time",
"String output = String.format(\"%s %d\", task.name, time);",
"output",
"String.format(\"%s %d\", task.name, time)",
"String.format",
"String",
"\"%s %d\"",
"task.name",
"task",
"task.name",
"time",
"System.out.println(output)",
"System.out.println",
"System.out",
"System",
"System.out",
"output",
"sc.close()",
"sc.close",
"sc",
"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 quantum = sc.nextInt();\n\n Queue<Task> que = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }\n\n int time = 0;\n\n while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }\n \n sc.close();\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 quantum = sc.nextInt();\n\n Queue<Task> que = new ArrayDeque<>();\n\n for (int i = 0; i < n; i++) {\n Task task = new Task();\n task.name = sc.next();\n task.time = sc.nextInt();\n que.offer(task);\n }\n\n int time = 0;\n\n while(que.peek() != null) {\n Task task = que.poll();\n if (task.time > quantum) {\n time += quantum;\n task.time -= quantum;\n que.offer(task);\n } else {\n time += task.time;\n String output = String.format(\"%s %d\", task.name, time);\n System.out.println(output);\n }\n }\n \n sc.close();\n }\n}",
"Main"
] | import java.util.*;
class Task {
String name;
int time;
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int quantum = sc.nextInt();
Queue<Task> que = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
Task task = new Task();
task.name = sc.next();
task.time = sc.nextInt();
que.offer(task);
}
int time = 0;
while(que.peek() != null) {
Task task = que.poll();
if (task.time > quantum) {
time += quantum;
task.time -= quantum;
que.offer(task);
} else {
time += task.time;
String output = String.format("%s %d", task.name, time);
System.out.println(output);
}
}
sc.close();
}
}
|
[
7,
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,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
13,
41,
13,
17,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
20,
0,
13,
4,
18,
13,
14,
2,
2,
18,
13,
13,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
13,
17,
13,
17,
14,
2,
2,
18,
13,
13,
13,
17,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
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
],
[
184,
14
],
[
184,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
17,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
17,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
17,
45
],
[
45,
46
],
[
45,
47
],
[
17,
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
],
[
69,
71
],
[
60,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
60,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
86,
88
],
[
60,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
17,
93
],
[
93,
94
],
[
93,
95
],
[
17,
96
],
[
96,
97
],
[
96,
98
],
[
17,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
99,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
104,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
114,
120
],
[
113,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
136,
137
],
[
136,
138
],
[
131,
139
],
[
129,
140
],
[
127,
141
],
[
113,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
143,
149
],
[
142,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
150,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
150,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
166,
168
],
[
17,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
15,
175
],
[
175,
176
],
[
0,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
177,
181
],
[
181,
182
],
[
0,
183
],
[
183,
184
],
[
183,
185
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.io.IOException;\nimport java.util.ArrayDeque;\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[] t = br.readLine().split(\" \");\n int n = Integer.parseInt(t[0]);\n int q = Integer.parseInt(t[1]);\n ArrayDeque<P> Q = new ArrayDeque<P>();\n for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }\n int sumTime = 0;\n StringBuilder sb = new StringBuilder();\n while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }\n System.out.print(sb);\n }\n\n}\n\nclass P{\n String name;\n int time;\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"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[] t = br.readLine().split(\" \");\n int n = Integer.parseInt(t[0]);\n int q = Integer.parseInt(t[1]);\n ArrayDeque<P> Q = new ArrayDeque<P>();\n for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }\n int sumTime = 0;\n StringBuilder sb = new StringBuilder();\n while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }\n System.out.print(sb);\n }\n\n}",
"Main",
"public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] t = br.readLine().split(\" \");\n int n = Integer.parseInt(t[0]);\n int q = Integer.parseInt(t[1]);\n ArrayDeque<P> Q = new ArrayDeque<P>();\n for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }\n int sumTime = 0;\n StringBuilder sb = new StringBuilder();\n while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }\n System.out.print(sb);\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] t = br.readLine().split(\" \");\n int n = Integer.parseInt(t[0]);\n int q = Integer.parseInt(t[1]);\n ArrayDeque<P> Q = new ArrayDeque<P>();\n for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }\n int sumTime = 0;\n StringBuilder sb = new StringBuilder();\n while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }\n System.out.print(sb);\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] t = br.readLine().split(\" \");",
"t",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(t[0]);",
"n",
"Integer.parseInt(t[0])",
"Integer.parseInt",
"Integer",
"t[0]",
"t",
"0",
"int q = Integer.parseInt(t[1]);",
"q",
"Integer.parseInt(t[1])",
"Integer.parseInt",
"Integer",
"t[1]",
"t",
"1",
"ArrayDeque<P> Q = new ArrayDeque<P>();",
"Q",
"new ArrayDeque<P>()",
"for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }",
"{\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }",
"t = br.readLine().split(\" \")",
"t",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"P p = new P();",
"p",
"new P()",
"p.name = t[0]",
"p.name",
"p",
"p.name",
"t[0]",
"t",
"0",
"p.time = Integer.parseInt(t[1])",
"p.time",
"p",
"p.time",
"Integer.parseInt(t[1])",
"Integer.parseInt",
"Integer",
"t[1]",
"t",
"1",
"Q.addLast(p)",
"Q.addLast",
"Q",
"p",
"int sumTime = 0;",
"sumTime",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }",
"!Q.isEmpty()",
"Q.isEmpty()",
"Q.isEmpty",
"Q",
"{\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }",
"P p = new P();",
"p",
"new P()",
"p = Q.pollFirst()",
"p",
"Q.pollFirst()",
"Q.pollFirst",
"Q",
"if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }",
"p.time - q <= 0",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"0",
"{\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }",
"sumTime += p.time",
"sumTime",
"p.time",
"p",
"p.time",
"sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\")",
"sb.append(p.name).append(\" \").append(sumTime).append",
"sb.append(p.name).append(\" \").append(sumTime)",
"sb.append(p.name).append(\" \").append",
"sb.append(p.name).append(\" \")",
"sb.append(p.name).append",
"sb.append(p.name)",
"sb.append",
"sb",
"p.name",
"p",
"p.name",
"\" \"",
"sumTime",
"\"\\n\"",
"if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }",
"p.time - q > 0",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"0",
"{\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }",
"p.time = p.time - q",
"p.time",
"p",
"p.time",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"Q.addLast(p)",
"Q.addLast",
"Q",
"p",
"sumTime = sumTime + q",
"sumTime",
"sumTime + q",
"sumTime",
"q",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"String[] args",
"args",
"class P{\n String name;\n int time;\n}",
"P",
"String name;",
"name",
"int time;",
"time",
"public class Main{\n\n public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] t = br.readLine().split(\" \");\n int n = Integer.parseInt(t[0]);\n int q = Integer.parseInt(t[1]);\n ArrayDeque<P> Q = new ArrayDeque<P>();\n for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }\n int sumTime = 0;\n StringBuilder sb = new StringBuilder();\n while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }\n System.out.print(sb);\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[] t = br.readLine().split(\" \");\n int n = Integer.parseInt(t[0]);\n int q = Integer.parseInt(t[1]);\n ArrayDeque<P> Q = new ArrayDeque<P>();\n for(int i = 0; i < n; i++){\n t = br.readLine().split(\" \");\n P p = new P();\n p.name = t[0];\n p.time = Integer.parseInt(t[1]);\n Q.addLast(p);\n }\n int sumTime = 0;\n StringBuilder sb = new StringBuilder();\n while(!Q.isEmpty()){\n P p = new P();\n p = Q.pollFirst();\n //p.time = p.time - q; \n if(p.time - q <= 0){\n sumTime += p.time;\n sb.append(p.name).append(\" \").append(sumTime).append(\"\\n\");\n }else if(p.time - q > 0){\n p.time = p.time - q;\n Q.addLast(p);\n sumTime = sumTime + q;\n }\n }\n System.out.print(sb);\n }\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayDeque;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] t = br.readLine().split(" ");
int n = Integer.parseInt(t[0]);
int q = Integer.parseInt(t[1]);
ArrayDeque<P> Q = new ArrayDeque<P>();
for(int i = 0; i < n; i++){
t = br.readLine().split(" ");
P p = new P();
p.name = t[0];
p.time = Integer.parseInt(t[1]);
Q.addLast(p);
}
int sumTime = 0;
StringBuilder sb = new StringBuilder();
while(!Q.isEmpty()){
P p = new P();
p = Q.pollFirst();
//p.time = p.time - q;
if(p.time - q <= 0){
sumTime += p.time;
sb.append(p.name).append(" ").append(sumTime).append("\n");
}else if(p.time - q > 0){
p.time = p.time - q;
Q.addLast(p);
sumTime = sumTime + q;
}
}
System.out.print(sb);
}
}
class P{
String name;
int time;
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
38,
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,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
41,
13,
17,
41,
13,
41,
13,
20,
42,
40,
4,
18,
13,
30,
0,
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,
4,
18,
4,
18,
4,
18,
13,
18,
13,
13,
17,
13,
17,
30,
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,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
13,
0,
13,
0,
13,
17,
0,
13,
18,
13,
13,
23,
13,
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,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
4,
18,
18,
13,
13,
17,
37,
20,
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
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
275,
11
],
[
275,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
22,
27
],
[
16,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
33,
34
],
[
33,
35
],
[
16,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
41,
42
],
[
41,
43
],
[
16,
44
],
[
44,
45
],
[
44,
46
],
[
16,
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
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
62,
67
],
[
59,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
16,
72
],
[
72,
73
],
[
72,
74
],
[
16,
75
],
[
75,
76
],
[
16,
77
],
[
77,
78
],
[
77,
79
],
[
16,
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
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
85,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
96,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
102,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
119,
120
],
[
119,
121
],
[
114,
122
],
[
112,
123
],
[
110,
124
],
[
96,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
16,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
133,
138
],
[
12,
139
],
[
139,
140
],
[
0,
141
],
[
141,
142
],
[
141,
143
],
[
143,
144
],
[
141,
145
],
[
145,
146
],
[
141,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
149,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
147,
160
],
[
160,
161
],
[
147,
162
],
[
162,
163
],
[
0,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
164,
168
],
[
168,
169
],
[
164,
170
],
[
170,
171
],
[
164,
172
],
[
172,
173
],
[
164,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
181
],
[
181,
182
],
[
181,
183
],
[
183,
184
],
[
183,
185
],
[
176,
186
],
[
186,
187
],
[
186,
188
],
[
188,
189
],
[
188,
190
],
[
174,
191
],
[
191,
192
],
[
164,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
164,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
206,
210
],
[
164,
211
],
[
211,
212
],
[
211,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
214,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
217,
222
],
[
213,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
223,
227
],
[
213,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
229,
233
],
[
228,
234
],
[
234,
235
],
[
234,
236
],
[
228,
237
],
[
237,
238
],
[
211,
239
],
[
239,
240
],
[
164,
241
],
[
241,
242
],
[
241,
243
],
[
243,
244
],
[
244,
245
],
[
245,
246
],
[
244,
247
],
[
247,
248
],
[
248,
249
],
[
249,
250
],
[
250,
251
],
[
250,
252
],
[
248,
253
],
[
247,
254
],
[
254,
255
],
[
243,
256
],
[
256,
257
],
[
256,
258
],
[
258,
259
],
[
258,
260
],
[
243,
261
],
[
261,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
266
],
[
261,
267
],
[
267,
268
],
[
267,
269
],
[
261,
270
],
[
270,
271
],
[
243,
272
],
[
272,
273
],
[
0,
274
],
[
274,
275
],
[
274,
276
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }\n }\n}\n\nclass Process {\n final String name;\n int pTime;\n\n public Process(String name, int time) {\n this.name = name;\n this.pTime = time;\n }\n}\n\nclass Queue<E> {\n\n private Object[] queue;\n private int head;\n private int tail;\n private int max;\n\n public Queue(int capacity) {\n queue = new Object[capacity];\n head = tail = 0;\n max = queue.length;\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n boolean isFull() {\n return head == (tail + 1) % max;\n }\n\n void enQueue(E x) {\n if(isFull()) System.out.println(\"queue is full!\");\n\n queue[tail] = x;\n if(tail+1 == max) tail = 0;\n else tail++;\n }\n @SuppressWarnings(\"unchecked\")\n E deQueue() {\n if(isEmpty()) {\n System.out.println(\"queue is empty!\");\n throw new IllegalStateException(\"queue is empty!\");\n }\n\n E ret = (E)queue[head];\n\n if(head+1 == max) head = 0;\n else head++;\n\n return ret;\n }\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 public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }\n }",
"main",
"{\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }\n }",
"try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }",
"{\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\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 = br.readLine().split(\" \");",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(line[0]);",
"n",
"Integer.parseInt(line[0])",
"Integer.parseInt",
"Integer",
"line[0]",
"line",
"0",
"int qTime = Integer.parseInt(line[1]);",
"qTime",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"Queue<Process> queue = new Queue<>(n*2);",
"queue",
"new Queue<>(n*2)",
"for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i!=n",
"i",
"n",
"i++",
"i++",
"i",
"{\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }",
"{\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }",
"line = br.readLine().split(\" \")",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) )",
"queue.enQueue",
"queue",
"new Process(line[0], Integer.parseInt(line[1]))",
"int usingTime = 0;",
"usingTime",
"0",
"Process proc;",
"proc",
"StringBuilder result = new StringBuilder(n*5);",
"result",
"new StringBuilder(n*5)",
"while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }",
"proc = queue.deQueue()",
"proc",
"queue.deQueue()",
"queue.deQueue",
"queue",
"proc.pTime -= qTime",
"proc.pTime",
"proc",
"proc.pTime",
"qTime",
"if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }",
"proc.pTime < 1",
"proc.pTime",
"proc",
"proc.pTime",
"1",
"{\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n }",
"usingTime += qTime + proc.pTime",
"usingTime",
"qTime + proc.pTime",
"qTime",
"proc.pTime",
"proc",
"proc.pTime",
"result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\")",
"result.append(proc.name).append(\" \").append(usingTime).append",
"result.append(proc.name).append(\" \").append(usingTime)",
"result.append(proc.name).append(\" \").append",
"result.append(proc.name).append(\" \")",
"result.append(proc.name).append",
"result.append(proc.name)",
"result.append",
"result",
"proc.name",
"proc",
"proc.name",
"\" \"",
"usingTime",
"\"\\n\"",
"{\n usingTime += qTime;\n queue.enQueue(proc);\n }",
"usingTime += qTime",
"usingTime",
"qTime",
"queue.enQueue(proc)",
"queue.enQueue",
"queue",
"proc",
"System.out.print(result)",
"System.out.print",
"System.out",
"System",
"System.out",
"result",
"String[] args",
"args",
"class Process {\n final String name;\n int pTime;\n\n public Process(String name, int time) {\n this.name = name;\n this.pTime = time;\n }\n}",
"Process",
"final String name;",
"name",
"int pTime;",
"pTime",
"public Process(String name, int time) {\n this.name = name;\n this.pTime = time;\n }",
"Process",
"{\n this.name = name;\n this.pTime = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.pTime = time",
"this.pTime",
"this",
"this.pTime",
"time",
"String name",
"name",
"int time",
"time",
"class Queue<E> {\n\n private Object[] queue;\n private int head;\n private int tail;\n private int max;\n\n public Queue(int capacity) {\n queue = new Object[capacity];\n head = tail = 0;\n max = queue.length;\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n boolean isFull() {\n return head == (tail + 1) % max;\n }\n\n void enQueue(E x) {\n if(isFull()) System.out.println(\"queue is full!\");\n\n queue[tail] = x;\n if(tail+1 == max) tail = 0;\n else tail++;\n }\n @SuppressWarnings(\"unchecked\")\n E deQueue() {\n if(isEmpty()) {\n System.out.println(\"queue is empty!\");\n throw new IllegalStateException(\"queue is empty!\");\n }\n\n E ret = (E)queue[head];\n\n if(head+1 == max) head = 0;\n else head++;\n\n return ret;\n }\n}",
"Queue",
"private Object[] queue;",
"queue",
"private int head;",
"head",
"private int tail;",
"tail",
"private int max;",
"max",
"public Queue(int capacity) {\n queue = new Object[capacity];\n head = tail = 0;\n max = queue.length;\n }",
"Queue",
"{\n queue = new Object[capacity];\n head = tail = 0;\n max = queue.length;\n }",
"queue = new Object[capacity]",
"queue",
"new Object[capacity]",
"capacity",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"max = queue.length",
"max",
"queue.length",
"queue",
"queue.length",
"int capacity",
"capacity",
"boolean isEmpty() {\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"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",
"void enQueue(E x) {\n if(isFull()) System.out.println(\"queue is full!\");\n\n queue[tail] = x;\n if(tail+1 == max) tail = 0;\n else tail++;\n }",
"enQueue",
"{\n if(isFull()) System.out.println(\"queue is full!\");\n\n queue[tail] = x;\n if(tail+1 == max) tail = 0;\n else tail++;\n }",
"if(isFull()) System.out.println(\"queue is full!\");",
"isFull()",
"isFull",
"System.out.println(\"queue is full!\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"queue is full!\"",
"queue[tail] = x",
"queue[tail]",
"queue",
"tail",
"x",
"if(tail+1 == max) tail = 0;\n else tail++;",
"tail+1 == max",
"tail+1",
"tail",
"1",
"max",
"tail = 0",
"tail",
"0",
"tail++",
"tail",
"E x",
"x",
"@SuppressWarnings(\"unchecked\")\n E deQueue() {\n if(isEmpty()) {\n System.out.println(\"queue is empty!\");\n throw new IllegalStateException(\"queue is empty!\");\n }\n\n E ret = (E)queue[head];\n\n if(head+1 == max) head = 0;\n else head++;\n\n return ret;\n }",
"deQueue",
"{\n if(isEmpty()) {\n System.out.println(\"queue is empty!\");\n throw new IllegalStateException(\"queue is empty!\");\n }\n\n E ret = (E)queue[head];\n\n if(head+1 == max) head = 0;\n else head++;\n\n return ret;\n }",
"if(isEmpty()) {\n System.out.println(\"queue is empty!\");\n throw new IllegalStateException(\"queue is empty!\");\n }",
"isEmpty()",
"isEmpty",
"{\n System.out.println(\"queue is empty!\");\n throw new IllegalStateException(\"queue is empty!\");\n }",
"System.out.println(\"queue is empty!\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"queue is empty!\"",
"throw new IllegalStateException(\"queue is empty!\");",
"new IllegalStateException(\"queue is empty!\")",
"E ret = (E)queue[head];",
"ret",
"(E)queue[head]",
"queue",
"head",
"if(head+1 == max) head = 0;\n else head++;",
"head+1 == max",
"head+1",
"head",
"1",
"max",
"head = 0",
"head",
"0",
"head++",
"head",
"return ret;",
"ret",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n \n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int qTime = Integer.parseInt(line[1]);\n Queue<Process> queue = new Queue<>(n*2);\n\n for(int i=0; i!=n; i++) {\n line = br.readLine().split(\" \");\n queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );\n }\n\n int usingTime = 0;\n Process proc;\n StringBuilder result = new StringBuilder(n*5);\n\n while(!queue.isEmpty()) {\n proc = queue.deQueue();\n proc.pTime -= qTime;\n\n if(proc.pTime < 1) {\n usingTime += qTime + proc.pTime;\n result.append(proc.name).append(\" \").append(usingTime).append(\"\\n\"); \n } else {\n usingTime += qTime;\n queue.enQueue(proc);\n }\n }\n\n System.out.print(result);\n }\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String[] line = br.readLine().split(" ");
int n = Integer.parseInt(line[0]);
int qTime = Integer.parseInt(line[1]);
Queue<Process> queue = new Queue<>(n*2);
for(int i=0; i!=n; i++) {
line = br.readLine().split(" ");
queue.enQueue( new Process(line[0], Integer.parseInt(line[1])) );
}
int usingTime = 0;
Process proc;
StringBuilder result = new StringBuilder(n*5);
while(!queue.isEmpty()) {
proc = queue.deQueue();
proc.pTime -= qTime;
if(proc.pTime < 1) {
usingTime += qTime + proc.pTime;
result.append(proc.name).append(" ").append(usingTime).append("\n");
} else {
usingTime += qTime;
queue.enQueue(proc);
}
}
System.out.print(result);
}
}
}
class Process {
final String name;
int pTime;
public Process(String name, int time) {
this.name = name;
this.pTime = time;
}
}
class Queue<E> {
private Object[] queue;
private int head;
private int tail;
private int max;
public Queue(int capacity) {
queue = new Object[capacity];
head = tail = 0;
max = queue.length;
}
boolean isEmpty() {
return head == tail;
}
boolean isFull() {
return head == (tail + 1) % max;
}
void enQueue(E x) {
if(isFull()) System.out.println("queue is full!");
queue[tail] = x;
if(tail+1 == max) tail = 0;
else tail++;
}
@SuppressWarnings("unchecked")
E deQueue() {
if(isEmpty()) {
System.out.println("queue is empty!");
throw new IllegalStateException("queue is empty!");
}
E ret = (E)queue[head];
if(head+1 == max) head = 0;
else head++;
return ret;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
20,
41,
13,
17,
41,
13,
20,
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,
41,
13,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
14,
2,
13,
17,
30,
0,
13,
13,
14,
2,
4,
18,
13,
17,
13,
30,
0,
13,
4,
18,
13,
17,
0,
13,
2,
13,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
17,
0,
13,
13,
30,
0,
13,
13,
4,
18,
13,
17,
2,
4,
18,
13,
17,
13,
0,
13,
17,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
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
] | [
[
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
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
14,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
14,
38
],
[
38,
39
],
[
38,
40
],
[
14,
41
],
[
41,
42
],
[
41,
43
],
[
14,
44
],
[
44,
45
],
[
44,
46
],
[
14,
47
],
[
47,
48
],
[
47,
49
],
[
14,
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
],
[
63,
66
],
[
66,
67
],
[
67,
68
],
[
62,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
72,
73
],
[
73,
74
],
[
14,
75
],
[
75,
76
],
[
75,
77
],
[
14,
78
],
[
78,
79
],
[
78,
80
],
[
14,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
82,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
87,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
97,
102
],
[
96,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
103,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
103,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
103,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
103,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
103,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
103,
137
],
[
137,
138
],
[
137,
139
],
[
96,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
144,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
148,
153
],
[
140,
154
],
[
154,
155
],
[
154,
156
],
[
140,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
159,
162
],
[
140,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
140,
169
],
[
169,
170
],
[
170,
171
],
[
169,
172
],
[
140,
173
],
[
173,
174
],
[
174,
175
],
[
173,
176
],
[
140,
177
],
[
177,
178
],
[
178,
179
],
[
177,
180
],
[
140,
181
],
[
181,
182
],
[
182,
183
],
[
181,
184
],
[
14,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
185,
190
],
[
190,
191
],
[
190,
192
],
[
185,
193
],
[
193,
194
],
[
194,
195
],
[
185,
196
],
[
197,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
198,
203
],
[
204,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
205,
208
],
[
204,
209
],
[
204,
210
],
[
210,
211
],
[
211,
212
],
[
210,
213
],
[
12,
214
],
[
214,
215
]
] | [
"import java.util.List;\nimport java.util.ArrayList;\n\nimport java.util.Scanner;\nclass Main{\n static public void main(String[] av){\n int sum=0;\n\n Scanner sc =new Scanner(System.in);\n // int n =sc.nextInt();\nint ch =1;\nint[] a= new int[100];\n\n //String s= sc.next();\n int n = sc.nextInt();\n int q =sc.nextInt();\n List<String> list = new ArrayList<String>();\n List<Integer> intlist = new ArrayList<Integer>();\n List<String> sl = new ArrayList<String>();\n List<Integer> il = new ArrayList<Integer>();\nfor(int k=0;k<n;k++){\n list.add(sc.next());\n intlist.add(sc.nextInt());\n} \nint q2= q;\nint t=0;\n while ( list.size() !=0){\n if (q2==0){\n q2=q;\n }\n if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }\n\n }\n for (int i=0;i<n;i++){\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }\n}\n }\n",
"import java.util.List;",
"List",
"java.util",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main{\n static public void main(String[] av){\n int sum=0;\n\n Scanner sc =new Scanner(System.in);\n // int n =sc.nextInt();\nint ch =1;\nint[] a= new int[100];\n\n //String s= sc.next();\n int n = sc.nextInt();\n int q =sc.nextInt();\n List<String> list = new ArrayList<String>();\n List<Integer> intlist = new ArrayList<Integer>();\n List<String> sl = new ArrayList<String>();\n List<Integer> il = new ArrayList<Integer>();\nfor(int k=0;k<n;k++){\n list.add(sc.next());\n intlist.add(sc.nextInt());\n} \nint q2= q;\nint t=0;\n while ( list.size() !=0){\n if (q2==0){\n q2=q;\n }\n if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }\n\n }\n for (int i=0;i<n;i++){\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }\n}\n }",
"Main",
"static public void main(String[] av){\n int sum=0;\n\n Scanner sc =new Scanner(System.in);\n // int n =sc.nextInt();\nint ch =1;\nint[] a= new int[100];\n\n //String s= sc.next();\n int n = sc.nextInt();\n int q =sc.nextInt();\n List<String> list = new ArrayList<String>();\n List<Integer> intlist = new ArrayList<Integer>();\n List<String> sl = new ArrayList<String>();\n List<Integer> il = new ArrayList<Integer>();\nfor(int k=0;k<n;k++){\n list.add(sc.next());\n intlist.add(sc.nextInt());\n} \nint q2= q;\nint t=0;\n while ( list.size() !=0){\n if (q2==0){\n q2=q;\n }\n if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }\n\n }\n for (int i=0;i<n;i++){\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }\n}",
"main",
"{\n int sum=0;\n\n Scanner sc =new Scanner(System.in);\n // int n =sc.nextInt();\nint ch =1;\nint[] a= new int[100];\n\n //String s= sc.next();\n int n = sc.nextInt();\n int q =sc.nextInt();\n List<String> list = new ArrayList<String>();\n List<Integer> intlist = new ArrayList<Integer>();\n List<String> sl = new ArrayList<String>();\n List<Integer> il = new ArrayList<Integer>();\nfor(int k=0;k<n;k++){\n list.add(sc.next());\n intlist.add(sc.nextInt());\n} \nint q2= q;\nint t=0;\n while ( list.size() !=0){\n if (q2==0){\n q2=q;\n }\n if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }\n\n }\n for (int i=0;i<n;i++){\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }\n}",
"int sum=0;",
"sum",
"0",
"Scanner sc =new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int ch =1;",
"ch",
"1",
"int[] a= new int[100];",
"a",
"new int[100]",
"100",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q =sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"List<String> list = new ArrayList<String>();",
"list",
"new ArrayList<String>()",
"List<Integer> intlist = new ArrayList<Integer>();",
"intlist",
"new ArrayList<Integer>()",
"List<String> sl = new ArrayList<String>();",
"sl",
"new ArrayList<String>()",
"List<Integer> il = new ArrayList<Integer>();",
"il",
"new ArrayList<Integer>()",
"for(int k=0;k<n;k++){\n list.add(sc.next());\n intlist.add(sc.nextInt());\n}",
"int k=0;",
"int k=0;",
"k",
"0",
"k<n",
"k",
"n",
"k++",
"k++",
"k",
"{\n list.add(sc.next());\n intlist.add(sc.nextInt());\n}",
"{\n list.add(sc.next());\n intlist.add(sc.nextInt());\n}",
"list.add(sc.next())",
"list.add",
"list",
"sc.next()",
"sc.next",
"sc",
"intlist.add(sc.nextInt())",
"intlist.add",
"intlist",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q2= q;",
"q2",
"q",
"int t=0;",
"t",
"0",
"while ( list.size() !=0){\n if (q2==0){\n q2=q;\n }\n if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }\n\n }",
"list.size() !=0",
"list.size()",
"list.size",
"list",
"0",
"{\n if (q2==0){\n q2=q;\n }\n if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }\n\n }",
"if (q2==0){\n q2=q;\n }",
"q2==0",
"q2",
"0",
"{\n q2=q;\n }",
"q2=q",
"q2",
"q",
"if ( intlist.get(0) <=q2){\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }\n else{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }",
"intlist.get(0) <=q2",
"intlist.get(0)",
"intlist.get",
"intlist",
"0",
"q2",
"{\n t+=intlist.get(0);\nq2=q2-intlist.get(0);\nsl.add(list.get(0));\nil.add(t);\n\nintlist.remove(0);\nlist.remove(0);\nq2=q;\n }",
"t+=intlist.get(0)",
"t",
"intlist.get(0)",
"intlist.get",
"intlist",
"0",
"q2=q2-intlist.get(0)",
"q2",
"q2-intlist.get(0)",
"q2",
"intlist.get(0)",
"intlist.get",
"intlist",
"0",
"sl.add(list.get(0))",
"sl.add",
"sl",
"list.get(0)",
"list.get",
"list",
"0",
"il.add(t)",
"il.add",
"il",
"t",
"intlist.remove(0)",
"intlist.remove",
"intlist",
"0",
"list.remove(0)",
"list.remove",
"list",
"0",
"q2=q",
"q2",
"q",
"{\n t+=q2; \nintlist.set(0,intlist.get(0)-q2);\nq2=0;\nint x=intlist.get(0);\nString y=list.get(0);\nintlist.remove(0);\nlist.remove(0);\nintlist.add(x);\nlist.add(y);\n }",
"t+=q2",
"t",
"q2",
"intlist.set(0,intlist.get(0)-q2)",
"intlist.set",
"intlist",
"0",
"intlist.get(0)-q2",
"intlist.get(0)",
"intlist.get",
"intlist",
"0",
"q2",
"q2=0",
"q2",
"0",
"int x=intlist.get(0);",
"x",
"intlist.get(0)",
"intlist.get",
"intlist",
"0",
"String y=list.get(0);",
"y",
"list.get(0)",
"list.get",
"list",
"0",
"intlist.remove(0)",
"intlist.remove",
"intlist",
"0",
"list.remove(0)",
"list.remove",
"list",
"0",
"intlist.add(x)",
"intlist.add",
"intlist",
"x",
"list.add(y)",
"list.add",
"list",
"y",
"for (int i=0;i<n;i++){\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }",
"{\n System.out.println(sl.get(i)+ \" \"+ il.get(i));\n }",
"System.out.println(sl.get(i)+ \" \"+ il.get(i))",
"System.out.println",
"System.out",
"System",
"System.out",
"sl.get(i)+ \" \"+ il.get(i)",
"sl.get(i)+ \" \"+ il.get(i)",
"sl.get(i)",
"sl.get",
"sl",
"i",
"\" \"",
"il.get(i)",
"il.get",
"il",
"i",
"String[] av",
"av"
] | import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
static public void main(String[] av){
int sum=0;
Scanner sc =new Scanner(System.in);
// int n =sc.nextInt();
int ch =1;
int[] a= new int[100];
//String s= sc.next();
int n = sc.nextInt();
int q =sc.nextInt();
List<String> list = new ArrayList<String>();
List<Integer> intlist = new ArrayList<Integer>();
List<String> sl = new ArrayList<String>();
List<Integer> il = new ArrayList<Integer>();
for(int k=0;k<n;k++){
list.add(sc.next());
intlist.add(sc.nextInt());
}
int q2= q;
int t=0;
while ( list.size() !=0){
if (q2==0){
q2=q;
}
if ( intlist.get(0) <=q2){
t+=intlist.get(0);
q2=q2-intlist.get(0);
sl.add(list.get(0));
il.add(t);
intlist.remove(0);
list.remove(0);
q2=q;
}
else{
t+=q2;
intlist.set(0,intlist.get(0)-q2);
q2=0;
int x=intlist.get(0);
String y=list.get(0);
intlist.remove(0);
list.remove(0);
intlist.add(x);
list.add(y);
}
}
for (int i=0;i<n;i++){
System.out.println(sl.get(i)+ " "+ il.get(i));
}
}
}
|
[
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,
20,
41,
13,
20,
41,
13,
17,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
17,
5,
13,
30,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
0,
13,
20,
0,
13,
4,
18,
13,
4,
18,
13,
0,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
0,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
42,
17,
30,
0,
13,
4,
18,
13,
17,
0,
13,
4,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
2,
13,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
14,
2,
4,
18,
13,
17,
30,
4,
18,
13,
17,
30,
0,
13,
17,
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
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
23,
33
],
[
33,
34
],
[
33,
35
],
[
23,
36
],
[
36,
37
],
[
23,
38
],
[
38,
39
],
[
38,
40
],
[
23,
41
],
[
41,
42
],
[
41,
43
],
[
23,
44
],
[
44,
45
],
[
44,
46
],
[
23,
47
],
[
47,
48
],
[
47,
49
],
[
23,
50
],
[
50,
51
],
[
50,
52
],
[
23,
53
],
[
53,
54
],
[
53,
55
],
[
23,
56
],
[
56,
57
],
[
56,
58
],
[
23,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
59,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
59,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
74,
80
],
[
80,
81
],
[
80,
82
],
[
74,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
88,
89
],
[
89,
90
],
[
74,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
96,
97
],
[
97,
98
],
[
74,
99
],
[
99,
100
],
[
99,
101
],
[
74,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
107,
108
],
[
107,
109
],
[
102,
110
],
[
110,
111
],
[
111,
112
],
[
102,
113
],
[
114,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
118,
119
],
[
114,
120
],
[
120,
121
],
[
120,
122
],
[
114,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
114,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
133,
134
],
[
134,
135
],
[
114,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
141,
144
],
[
144,
145
],
[
144,
146
],
[
140,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
140,
151
],
[
151,
152
],
[
151,
153
],
[
136,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
164,
164
],
[
164,
165
],
[
164,
166
],
[
164,
167
],
[
74,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
173,
176
],
[
170,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
180,
181
],
[
179,
182
],
[
170,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
191,
192
],
[
191,
193
],
[
193,
194
],
[
193,
195
],
[
187,
196
],
[
196,
197
],
[
197,
198
],
[
196,
199
],
[
187,
200
],
[
200,
201
],
[
201,
202
],
[
200,
203
],
[
187,
204
],
[
204,
205
],
[
205,
206
],
[
204,
207
],
[
187,
208
],
[
208,
209
],
[
209,
210
],
[
208,
211
],
[
183,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
216,
217
],
[
217,
218
],
[
216,
219
],
[
212,
220
],
[
220,
221
],
[
221,
222
],
[
220,
223
],
[
212,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
224,
229
],
[
230,
230
],
[
230,
231
],
[
230,
232
],
[
230,
233
],
[
170,
234
],
[
234,
235
],
[
235,
236
],
[
236,
237
],
[
237,
238
],
[
235,
239
],
[
234,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
241,
244
],
[
234,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
21,
249
],
[
249,
250
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.StringTokenizer;\n\nclass Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tList<Integer> time=new ArrayList<Integer>();\t\t//ใญใฅใผใฎๅฆ็ใซใใใๆ้\n\t\tList<String> cue_nm=new ArrayList<String>();\n\t\tBufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));\n\t\tString moto=\"\";\n\t\tStringTokenizer stk;\n\t\tint cue_su=0;\t\t//ใใจใใจไธใใใใใญใฅใผๆฐ\n\t\tint jikan=0;\t\t//็พๅจใฎ็ต้ๆ้\n\t\tint quantum=0;\t\t//ใญใฅใผใฎๅฆ็ๆ้ๅถ้\n\t\tint que_zanryo=0;\t//ใญใฅใผใฎๆฎๆฐ\n\n\t\tString name=\"\";\t\t\t\t//ๅคๆฐไฟ็ฎก็จ\n\t\tint suuji=0;\n\t\tboolean end=false;\n\n\t\ttry {\n\t\t\tmoto=bfr.readLine();\n\t\t\tstk=new StringTokenizer(moto, \" \");\n\t\t\tcue_su=Integer.parseInt(stk.nextToken());\n\t\t\tquantum=Integer.parseInt(stk.nextToken());\n\n\t\t\tque_zanryo=cue_su;\n\n\t\t\tfor(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}catch(IOException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(IndexOutOfBoundsException e) {\n\t\t\tSystem.exit(0);\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.ArrayList;",
"ArrayList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.StringTokenizer;",
"StringTokenizer",
"java.util",
"class Main{\n\n\tpublic static void main(String[] args) {\n\n\t\tList<Integer> time=new ArrayList<Integer>();\t\t//ใญใฅใผใฎๅฆ็ใซใใใๆ้\n\t\tList<String> cue_nm=new ArrayList<String>();\n\t\tBufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));\n\t\tString moto=\"\";\n\t\tStringTokenizer stk;\n\t\tint cue_su=0;\t\t//ใใจใใจไธใใใใใญใฅใผๆฐ\n\t\tint jikan=0;\t\t//็พๅจใฎ็ต้ๆ้\n\t\tint quantum=0;\t\t//ใญใฅใผใฎๅฆ็ๆ้ๅถ้\n\t\tint que_zanryo=0;\t//ใญใฅใผใฎๆฎๆฐ\n\n\t\tString name=\"\";\t\t\t\t//ๅคๆฐไฟ็ฎก็จ\n\t\tint suuji=0;\n\t\tboolean end=false;\n\n\t\ttry {\n\t\t\tmoto=bfr.readLine();\n\t\t\tstk=new StringTokenizer(moto, \" \");\n\t\t\tcue_su=Integer.parseInt(stk.nextToken());\n\t\t\tquantum=Integer.parseInt(stk.nextToken());\n\n\t\t\tque_zanryo=cue_su;\n\n\t\t\tfor(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}catch(IOException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(IndexOutOfBoundsException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tList<Integer> time=new ArrayList<Integer>();\t\t//ใญใฅใผใฎๅฆ็ใซใใใๆ้\n\t\tList<String> cue_nm=new ArrayList<String>();\n\t\tBufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));\n\t\tString moto=\"\";\n\t\tStringTokenizer stk;\n\t\tint cue_su=0;\t\t//ใใจใใจไธใใใใใญใฅใผๆฐ\n\t\tint jikan=0;\t\t//็พๅจใฎ็ต้ๆ้\n\t\tint quantum=0;\t\t//ใญใฅใผใฎๅฆ็ๆ้ๅถ้\n\t\tint que_zanryo=0;\t//ใญใฅใผใฎๆฎๆฐ\n\n\t\tString name=\"\";\t\t\t\t//ๅคๆฐไฟ็ฎก็จ\n\t\tint suuji=0;\n\t\tboolean end=false;\n\n\t\ttry {\n\t\t\tmoto=bfr.readLine();\n\t\t\tstk=new StringTokenizer(moto, \" \");\n\t\t\tcue_su=Integer.parseInt(stk.nextToken());\n\t\t\tquantum=Integer.parseInt(stk.nextToken());\n\n\t\t\tque_zanryo=cue_su;\n\n\t\t\tfor(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}catch(IOException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(IndexOutOfBoundsException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t}",
"main",
"{\n\n\t\tList<Integer> time=new ArrayList<Integer>();\t\t//ใญใฅใผใฎๅฆ็ใซใใใๆ้\n\t\tList<String> cue_nm=new ArrayList<String>();\n\t\tBufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));\n\t\tString moto=\"\";\n\t\tStringTokenizer stk;\n\t\tint cue_su=0;\t\t//ใใจใใจไธใใใใใญใฅใผๆฐ\n\t\tint jikan=0;\t\t//็พๅจใฎ็ต้ๆ้\n\t\tint quantum=0;\t\t//ใญใฅใผใฎๅฆ็ๆ้ๅถ้\n\t\tint que_zanryo=0;\t//ใญใฅใผใฎๆฎๆฐ\n\n\t\tString name=\"\";\t\t\t\t//ๅคๆฐไฟ็ฎก็จ\n\t\tint suuji=0;\n\t\tboolean end=false;\n\n\t\ttry {\n\t\t\tmoto=bfr.readLine();\n\t\t\tstk=new StringTokenizer(moto, \" \");\n\t\t\tcue_su=Integer.parseInt(stk.nextToken());\n\t\t\tquantum=Integer.parseInt(stk.nextToken());\n\n\t\t\tque_zanryo=cue_su;\n\n\t\t\tfor(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}catch(IOException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(IndexOutOfBoundsException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t}",
"List<Integer> time=new ArrayList<Integer>();",
"time",
"new ArrayList<Integer>()",
"List<String> cue_nm=new ArrayList<String>();",
"cue_nm",
"new ArrayList<String>()",
"BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));",
"bfr",
"new BufferedReader(new InputStreamReader(System.in))",
"String moto=\"\";",
"moto",
"\"\"",
"StringTokenizer stk;",
"stk",
"int cue_su=0;",
"cue_su",
"0",
"int jikan=0;",
"jikan",
"0",
"int quantum=0;",
"quantum",
"0",
"int que_zanryo=0;",
"que_zanryo",
"0",
"String name=\"\";",
"name",
"\"\"",
"int suuji=0;",
"suuji",
"0",
"boolean end=false;",
"end",
"false",
"try {\n\t\t\tmoto=bfr.readLine();\n\t\t\tstk=new StringTokenizer(moto, \" \");\n\t\t\tcue_su=Integer.parseInt(stk.nextToken());\n\t\t\tquantum=Integer.parseInt(stk.nextToken());\n\n\t\t\tque_zanryo=cue_su;\n\n\t\t\tfor(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}catch(IOException e) {\n\t\t\tSystem.exit(0);\n\t\t}\n\t\tcatch(IndexOutOfBoundsException e) {\n\t\t\tSystem.exit(0);\n\t\t}",
"catch(IOException e) {\n\t\t\tSystem.exit(0);\n\t\t}",
"IOException e",
"{\n\t\t\tSystem.exit(0);\n\t\t}",
"System.exit(0)",
"System.exit",
"System",
"0",
"catch(IndexOutOfBoundsException e) {\n\t\t\tSystem.exit(0);\n\t\t}",
"IndexOutOfBoundsException e",
"{\n\t\t\tSystem.exit(0);\n\t\t}",
"System.exit(0)",
"System.exit",
"System",
"0",
"{\n\t\t\tmoto=bfr.readLine();\n\t\t\tstk=new StringTokenizer(moto, \" \");\n\t\t\tcue_su=Integer.parseInt(stk.nextToken());\n\t\t\tquantum=Integer.parseInt(stk.nextToken());\n\n\t\t\tque_zanryo=cue_su;\n\n\t\t\tfor(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\twhile(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}",
"moto=bfr.readLine()",
"moto",
"bfr.readLine()",
"bfr.readLine",
"bfr",
"stk=new StringTokenizer(moto, \" \")",
"stk",
"new StringTokenizer(moto, \" \")",
"cue_su=Integer.parseInt(stk.nextToken())",
"cue_su",
"Integer.parseInt(stk.nextToken())",
"Integer.parseInt",
"Integer",
"stk.nextToken()",
"stk.nextToken",
"stk",
"quantum=Integer.parseInt(stk.nextToken())",
"quantum",
"Integer.parseInt(stk.nextToken())",
"Integer.parseInt",
"Integer",
"stk.nextToken()",
"stk.nextToken",
"stk",
"que_zanryo=cue_su",
"que_zanryo",
"cue_su",
"for(int i=0; i<cue_su; i++) {\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<cue_su",
"i",
"cue_su",
"i++",
"i++",
"i",
"{\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}",
"{\n\t\t\t\tmoto=bfr.readLine();\n\t\t\t\tstk=new StringTokenizer(moto,\" \");\n\t\t\t\tname=stk.nextToken();\n\t\t\t\tsuuji=Integer.parseInt(stk.nextToken());\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\t\t\t}",
"moto=bfr.readLine()",
"moto",
"bfr.readLine()",
"bfr.readLine",
"bfr",
"stk=new StringTokenizer(moto,\" \")",
"stk",
"new StringTokenizer(moto,\" \")",
"name=stk.nextToken()",
"name",
"stk.nextToken()",
"stk.nextToken",
"stk",
"suuji=Integer.parseInt(stk.nextToken())",
"suuji",
"Integer.parseInt(stk.nextToken())",
"Integer.parseInt",
"Integer",
"stk.nextToken()",
"stk.nextToken",
"stk",
"if(suuji>quantum) {\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}",
"suuji>quantum",
"suuji",
"quantum",
"{\n\t\t\t\t\ttime.add(suuji-quantum);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t}",
"time.add(suuji-quantum)",
"time.add",
"time",
"suuji-quantum",
"suuji",
"quantum",
"cue_nm.add(name)",
"cue_nm.add",
"cue_nm",
"name",
"jikan+=quantum",
"jikan",
"quantum",
"{\n\t\t\t\t\t//ใชในใใซใฏใคใใใใชใ\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}",
"jikan+=suuji",
"jikan",
"suuji",
"System.out.println(name+\" \"+jikan)",
"System.out.println",
"System.out",
"System",
"System.out",
"name+\" \"+jikan",
"name+\" \"+jikan",
"name",
"\" \"",
"jikan",
"while(true) {\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}",
"true",
"{\n\t\t\t\tname=cue_nm.get(0);\n\t\t\t\tsuuji=time.get(0);\n\n\t\t\t\tif(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}\n\n\t\t\t\tif(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}\n\t\t\t}",
"name=cue_nm.get(0)",
"name",
"cue_nm.get(0)",
"cue_nm.get",
"cue_nm",
"0",
"suuji=time.get(0)",
"suuji",
"time.get(0)",
"time.get",
"time",
"0",
"if(suuji>quantum) {\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}",
"suuji>quantum",
"suuji",
"quantum",
"{\n\t\t\t\t\tjikan+=quantum;\n\t\t\t\t\tsuuji=suuji-quantum;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tcue_nm.add(name);\n\t\t\t\t\ttime.add(suuji);\n\t\t\t\t}",
"jikan+=quantum",
"jikan",
"quantum",
"suuji=suuji-quantum",
"suuji",
"suuji-quantum",
"suuji",
"quantum",
"cue_nm.remove(0)",
"cue_nm.remove",
"cue_nm",
"0",
"time.remove(0)",
"time.remove",
"time",
"0",
"cue_nm.add(name)",
"cue_nm.add",
"cue_nm",
"name",
"time.add(suuji)",
"time.add",
"time",
"suuji",
"{\n\t\t\t\t\tjikan+=suuji;\n\t\t\t\t\tcue_nm.remove(0);\n\t\t\t\t\ttime.remove(0);\n\t\t\t\t\tSystem.out.println(name+\" \"+jikan);\n\t\t\t\t}",
"jikan+=suuji",
"jikan",
"suuji",
"cue_nm.remove(0)",
"cue_nm.remove",
"cue_nm",
"0",
"time.remove(0)",
"time.remove",
"time",
"0",
"System.out.println(name+\" \"+jikan)",
"System.out.println",
"System.out",
"System",
"System.out",
"name+\" \"+jikan",
"name+\" \"+jikan",
"name",
"\" \"",
"jikan",
"if(cue_nm.size()<=0) {\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}\n\n\t\t\t\telse {\n\t\t\t\t\tend=false;\n\t\t\t\t}",
"cue_nm.size()<=0",
"cue_nm.size()",
"cue_nm.size",
"cue_nm",
"0",
"{\n\t\t\t\t\tSystem.exit(0);\n\t\t\t\t}",
"System.exit(0)",
"System.exit",
"System",
"0",
"{\n\t\t\t\t\tend=false;\n\t\t\t\t}",
"end=false",
"end",
"false",
"String[] args",
"args"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
class Main{
public static void main(String[] args) {
List<Integer> time=new ArrayList<Integer>(); //ใญใฅใผใฎๅฆ็ใซใใใๆ้
List<String> cue_nm=new ArrayList<String>();
BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
String moto="";
StringTokenizer stk;
int cue_su=0; //ใใจใใจไธใใใใใญใฅใผๆฐ
int jikan=0; //็พๅจใฎ็ต้ๆ้
int quantum=0; //ใญใฅใผใฎๅฆ็ๆ้ๅถ้
int que_zanryo=0; //ใญใฅใผใฎๆฎๆฐ
String name=""; //ๅคๆฐไฟ็ฎก็จ
int suuji=0;
boolean end=false;
try {
moto=bfr.readLine();
stk=new StringTokenizer(moto, " ");
cue_su=Integer.parseInt(stk.nextToken());
quantum=Integer.parseInt(stk.nextToken());
que_zanryo=cue_su;
for(int i=0; i<cue_su; i++) {
moto=bfr.readLine();
stk=new StringTokenizer(moto," ");
name=stk.nextToken();
suuji=Integer.parseInt(stk.nextToken());
if(suuji>quantum) {
time.add(suuji-quantum);
cue_nm.add(name);
jikan+=quantum;
}
else {
//ใชในใใซใฏใคใใใใชใ
jikan+=suuji;
System.out.println(name+" "+jikan);
}
}
while(true) {
name=cue_nm.get(0);
suuji=time.get(0);
if(suuji>quantum) {
jikan+=quantum;
suuji=suuji-quantum;
cue_nm.remove(0);
time.remove(0);
cue_nm.add(name);
time.add(suuji);
}
else {
jikan+=suuji;
cue_nm.remove(0);
time.remove(0);
System.out.println(name+" "+jikan);
}
if(cue_nm.size()<=0) {
System.exit(0);
}
else {
end=false;
}
}
}catch(IOException e) {
System.exit(0);
}
catch(IndexOutOfBoundsException e) {
System.exit(0);
}
}
}
|
[
7,
15,
13,
17,
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,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
13,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
4,
18,
13,
30,
14,
2,
13,
17,
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,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
13,
20,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
18,
13,
17,
4,
13,
13,
40,
13,
14,
2,
13,
13,
30,
3,
41,
13,
17,
41,
13,
17,
42,
2,
13,
13,
30,
0,
13,
4,
13,
41,
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,
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
],
[
255,
5
],
[
255,
6
],
[
6,
7
],
[
6,
8
],
[
255,
9
],
[
9,
10
],
[
9,
11
],
[
255,
13
],
[
13,
14
],
[
13,
15
],
[
255,
16
],
[
16,
17
],
[
16,
18
],
[
255,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
255,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
32,
36
],
[
255,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
43,
44
],
[
44,
45
],
[
39,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
39,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
37,
58
],
[
58,
59
],
[
255,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
66,
67
],
[
67,
68
],
[
62,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
62,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
62,
81
],
[
81,
82
],
[
255,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
89,
91
],
[
85,
92
],
[
92,
93
],
[
92,
94
],
[
85,
95
],
[
95,
96
],
[
95,
97
],
[
85,
98
],
[
98,
99
],
[
98,
100
],
[
85,
101
],
[
101,
102
],
[
101,
103
],
[
85,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
104,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
116,
121
],
[
113,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
127,
128
],
[
127,
129
],
[
113,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
135,
136
],
[
135,
137
],
[
109,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
141,
146
],
[
138,
147
],
[
147,
148
],
[
147,
149
],
[
138,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
150,
154
],
[
154,
155
],
[
154,
156
],
[
138,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
162,
163
],
[
161,
164
],
[
164,
165
],
[
164,
166
],
[
138,
167
],
[
167,
168
],
[
167,
169
],
[
138,
170
],
[
170,
171
],
[
138,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
85,
178
],
[
178,
179
],
[
178,
180
],
[
85,
181
],
[
181,
182
],
[
181,
183
],
[
85,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
188,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
195,
197
],
[
195,
198
],
[
198,
199
],
[
198,
200
],
[
188,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
201,
205
],
[
188,
206
],
[
206,
207
],
[
206,
208
],
[
188,
209
],
[
209,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
210,
214
],
[
209,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
209,
219
],
[
219,
220
],
[
220,
221
],
[
221,
222
],
[
222,
223
],
[
222,
224
],
[
220,
225
],
[
226,
226
],
[
226,
227
],
[
227,
228
],
[
227,
229
],
[
226,
230
],
[
226,
231
],
[
83,
232
],
[
232,
233
],
[
255,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
237,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
238,
242
],
[
238,
243
],
[
234,
244
],
[
244,
245
],
[
234,
246
],
[
246,
247
],
[
255,
248
],
[
248,
249
],
[
248,
250
],
[
250,
251
],
[
248,
252
],
[
252,
253
],
[
0,
254
],
[
254,
255
],
[
254,
256
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\n static class P{\n String name;\n int time;\n }\n\n static int len = 100001;\n static P[] Q = new P[len];\n\n static int head = 0;\n static int tail = 0;\n\n static boolean isEmpty(){\n return head == tail;\n }\n\n static boolean isFull(){\n return head == (tail + 1) % len;\n }\n\n static void enqueue(P p){\n if(isFull()){\n throw new IndexOutOfBoundsException();\n }\n Q[tail] = p;\n\n tail = (tail + 1) % len;\n }\n\n static P dequeue(){\n if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }\n P temp = Q[head];\n\n head = (head + 1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n P p = null;\n int n = 0;\n int q = 0;\n int index = 0;\n String[] temp = null;\n while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }\n\n int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด\n\n P curr = null;\n while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }\n }\n\n\n static int min(int a,int b){\n return a > b ? b : a;\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n static class P{\n String name;\n int time;\n }\n\n static int len = 100001;\n static P[] Q = new P[len];\n\n static int head = 0;\n static int tail = 0;\n\n static boolean isEmpty(){\n return head == tail;\n }\n\n static boolean isFull(){\n return head == (tail + 1) % len;\n }\n\n static void enqueue(P p){\n if(isFull()){\n throw new IndexOutOfBoundsException();\n }\n Q[tail] = p;\n\n tail = (tail + 1) % len;\n }\n\n static P dequeue(){\n if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }\n P temp = Q[head];\n\n head = (head + 1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n P p = null;\n int n = 0;\n int q = 0;\n int index = 0;\n String[] temp = null;\n while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }\n\n int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด\n\n P curr = null;\n while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }\n }\n\n\n static int min(int a,int b){\n return a > b ? b : a;\n }\n}",
"Main",
"static int len = 100001;",
"len",
"100001",
"static P[] Q = new P[len];",
"Q",
"new P[len]",
"len",
"static int head = 0;",
"head",
"0",
"static int tail = 0;",
"tail",
"0",
"static boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"static boolean isFull(){\n return head == (tail + 1) % len;\n }",
"isFull",
"{\n return head == (tail + 1) % len;\n }",
"return head == (tail + 1) % len;",
"head == (tail + 1) % len",
"head",
"(tail + 1) % len",
"(tail + 1)",
"tail",
"1",
"len",
"static void enqueue(P p){\n if(isFull()){\n throw new IndexOutOfBoundsException();\n }\n Q[tail] = p;\n\n tail = (tail + 1) % len;\n }",
"enqueue",
"{\n if(isFull()){\n throw new IndexOutOfBoundsException();\n }\n Q[tail] = p;\n\n tail = (tail + 1) % len;\n }",
"if(isFull()){\n throw new IndexOutOfBoundsException();\n }",
"isFull()",
"isFull",
"{\n throw new IndexOutOfBoundsException();\n }",
"throw new IndexOutOfBoundsException();",
"new IndexOutOfBoundsException()",
"Q[tail] = p",
"Q[tail]",
"Q",
"tail",
"p",
"tail = (tail + 1) % len",
"tail",
"(tail + 1) % len",
"(tail + 1)",
"tail",
"1",
"len",
"P p",
"p",
"static P dequeue(){\n if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }\n P temp = Q[head];\n\n head = (head + 1) % len;\n return temp;\n }",
"dequeue",
"{\n if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }\n P temp = Q[head];\n\n head = (head + 1) % len;\n return temp;\n }",
"if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }",
"isEmpty()",
"isEmpty",
"{\n throw new IndexOutOfBoundsException();\n }",
"throw new IndexOutOfBoundsException();",
"new IndexOutOfBoundsException()",
"P temp = Q[head];",
"temp",
"Q[head]",
"Q",
"head",
"head = (head + 1) % len",
"head",
"(head + 1) % len",
"(head + 1)",
"head",
"1",
"len",
"return temp;",
"temp",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n P p = null;\n int n = 0;\n int q = 0;\n int index = 0;\n String[] temp = null;\n while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }\n\n int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด\n\n P curr = null;\n while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n P p = null;\n int n = 0;\n int q = 0;\n int index = 0;\n String[] temp = null;\n while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }\n\n int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด\n\n P curr = null;\n while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"P p = null;",
"p",
"null",
"int n = 0;",
"n",
"0",
"int q = 0;",
"q",
"0",
"int index = 0;",
"index",
"0",
"String[] temp = null;",
"temp",
"null",
"while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }",
"sc.hasNextLine()",
"sc.hasNextLine",
"sc",
"{\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }",
"if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }",
"n == 0",
"n",
"0",
"{\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }",
"temp = sc.nextLine().split(\" \")",
"temp",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"n = Integer.valueOf(temp[0])",
"n",
"Integer.valueOf(temp[0])",
"Integer.valueOf",
"Integer",
"temp[0]",
"temp",
"0",
"q = Integer.valueOf(temp[1])",
"q",
"Integer.valueOf(temp[1])",
"Integer.valueOf",
"Integer",
"temp[1]",
"temp",
"1",
"{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }",
"temp = sc.nextLine().split(\" \")",
"temp",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"p = new P()",
"p",
"new P()",
"p.name = temp[0]",
"p.name",
"p",
"p.name",
"temp[0]",
"temp",
"0",
"p.time = Integer.valueOf(temp[1])",
"p.time",
"p",
"p.time",
"Integer.valueOf(temp[1])",
"Integer.valueOf",
"Integer",
"temp[1]",
"temp",
"1",
"enqueue(p)",
"enqueue",
"p",
"index ++",
"index",
"if(index == n){\n break;\n }",
"index == n",
"index",
"n",
"{\n break;\n }",
"break;",
"int sumTime = 0;",
"sumTime",
"0",
"P curr = null;",
"curr",
"null",
"while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }",
"head != tail",
"head",
"tail",
"{\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }",
"curr = dequeue()",
"curr",
"dequeue()",
"dequeue",
"int c = min(q,curr.time);",
"c",
"min(q,curr.time)",
"min",
"q",
"curr.time",
"curr",
"curr.time",
"curr.time -= c",
"curr.time",
"curr",
"curr.time",
"c",
"sumTime += c",
"sumTime",
"c",
"if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }",
"curr.time > 0",
"curr.time",
"curr",
"curr.time",
"0",
"{\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }",
"enqueue(curr)",
"enqueue",
"curr",
"{\n System.out.println(curr.name + \" \" + sumTime);\n }",
"System.out.println(curr.name + \" \" + sumTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"curr.name + \" \" + sumTime",
"curr.name + \" \" + sumTime",
"curr.name",
"curr",
"curr.name",
"\" \"",
"sumTime",
"String[] args",
"args",
"static int min(int a,int b){\n return a > b ? b : a;\n }",
"min",
"{\n return a > b ? b : a;\n }",
"return a > b ? b : a;",
"a > b ? b : a",
"a > b",
"a",
"b",
"b",
"a",
"int a",
"a",
"int b",
"b",
"static class P{\n String name;\n int time;\n }",
"P",
"String name;",
"name",
"int time;",
"time",
"public class Main {\n\n static class P{\n String name;\n int time;\n }\n\n static int len = 100001;\n static P[] Q = new P[len];\n\n static int head = 0;\n static int tail = 0;\n\n static boolean isEmpty(){\n return head == tail;\n }\n\n static boolean isFull(){\n return head == (tail + 1) % len;\n }\n\n static void enqueue(P p){\n if(isFull()){\n throw new IndexOutOfBoundsException();\n }\n Q[tail] = p;\n\n tail = (tail + 1) % len;\n }\n\n static P dequeue(){\n if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }\n P temp = Q[head];\n\n head = (head + 1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n P p = null;\n int n = 0;\n int q = 0;\n int index = 0;\n String[] temp = null;\n while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }\n\n int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด\n\n P curr = null;\n while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }\n }\n\n\n static int min(int a,int b){\n return a > b ? b : a;\n }\n}",
"public class Main {\n\n static class P{\n String name;\n int time;\n }\n\n static int len = 100001;\n static P[] Q = new P[len];\n\n static int head = 0;\n static int tail = 0;\n\n static boolean isEmpty(){\n return head == tail;\n }\n\n static boolean isFull(){\n return head == (tail + 1) % len;\n }\n\n static void enqueue(P p){\n if(isFull()){\n throw new IndexOutOfBoundsException();\n }\n Q[tail] = p;\n\n tail = (tail + 1) % len;\n }\n\n static P dequeue(){\n if(isEmpty()){\n throw new IndexOutOfBoundsException();\n }\n P temp = Q[head];\n\n head = (head + 1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n P p = null;\n int n = 0;\n int q = 0;\n int index = 0;\n String[] temp = null;\n while (sc.hasNextLine()){\n if(n == 0){\n temp = sc.nextLine().split(\" \");\n n = Integer.valueOf(temp[0]);\n q = Integer.valueOf(temp[1]);\n }else{\n temp = sc.nextLine().split(\" \");\n p = new P();\n p.name = temp[0];\n p.time = Integer.valueOf(temp[1]);\n enqueue(p);\n index ++;\n if(index == n){\n break;\n }\n }\n }\n\n int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด\n\n P curr = null;\n while (head != tail){\n curr = dequeue();\n int c = min(q,curr.time);\n curr.time -= c;\n sumTime += c;\n if(curr.time > 0){\n //ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ\n enqueue(curr);\n }else{\n System.out.println(curr.name + \" \" + sumTime);\n }\n }\n }\n\n\n static int min(int a,int b){\n return a > b ? b : a;\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
static class P{
String name;
int time;
}
static int len = 100001;
static P[] Q = new P[len];
static int head = 0;
static int tail = 0;
static boolean isEmpty(){
return head == tail;
}
static boolean isFull(){
return head == (tail + 1) % len;
}
static void enqueue(P p){
if(isFull()){
throw new IndexOutOfBoundsException();
}
Q[tail] = p;
tail = (tail + 1) % len;
}
static P dequeue(){
if(isEmpty()){
throw new IndexOutOfBoundsException();
}
P temp = Q[head];
head = (head + 1) % len;
return temp;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
P p = null;
int n = 0;
int q = 0;
int index = 0;
String[] temp = null;
while (sc.hasNextLine()){
if(n == 0){
temp = sc.nextLine().split(" ");
n = Integer.valueOf(temp[0]);
q = Integer.valueOf(temp[1]);
}else{
temp = sc.nextLine().split(" ");
p = new P();
p.name = temp[0];
p.time = Integer.valueOf(temp[1]);
enqueue(p);
index ++;
if(index == n){
break;
}
}
}
int sumTime = 0;//ๅฝๅๆป่ฟ่กๆถ้ด
P curr = null;
while (head != tail){
curr = dequeue();
int c = min(q,curr.time);
curr.time -= c;
sumTime += c;
if(curr.time > 0){
//ๅฆๆๅฝๅไปปๅกๆๅฉไฝๆถ้ด ๅๅ ๅ
ฅ้ๅ
enqueue(curr);
}else{
System.out.println(curr.name + " " + sumTime);
}
}
}
static int min(int a,int b){
return a > b ? b : a;
}
}
|
[
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,
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,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
2,
13,
13,
17,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
14,
2,
2,
13,
13,
17,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
115,
5
],
[
115,
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
],
[
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
],
[
42,
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
],
[
56,
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
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
88,
88
],
[
88,
89
],
[
88,
90
],
[
88,
91
],
[
61,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
98,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
106,
107
],
[
106,
108
],
[
98,
109
],
[
109,
110
],
[
109,
111
],
[
6,
112
],
[
112,
113
],
[
0,
114
],
[
114,
115
],
[
114,
116
]
] | [
"import java.util.*;\npublic class Main{\n\tpublic static void main(String args[]){\n\t Scanner input = new Scanner(System.in);\n\t \n\t Queue<Integer>num = new LinkedList<Integer>();\n\t Queue<String> p = new LinkedList<String>();\n\t int number = input.nextInt();\n\t int time = input.nextInt();\n\t int timer = 0;\n\t for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for\n\t \n\t while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while\n\t \n}//main\n}//main",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tpublic static void main(String args[]){\n\t Scanner input = new Scanner(System.in);\n\t \n\t Queue<Integer>num = new LinkedList<Integer>();\n\t Queue<String> p = new LinkedList<String>();\n\t int number = input.nextInt();\n\t int time = input.nextInt();\n\t int timer = 0;\n\t for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for\n\t \n\t while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while\n\t \n}//main\n}//main",
"Main",
"public static void main(String args[]){\n\t Scanner input = new Scanner(System.in);\n\t \n\t Queue<Integer>num = new LinkedList<Integer>();\n\t Queue<String> p = new LinkedList<String>();\n\t int number = input.nextInt();\n\t int time = input.nextInt();\n\t int timer = 0;\n\t for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for\n\t \n\t while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while\n\t \n}//main",
"main",
"{\n\t Scanner input = new Scanner(System.in);\n\t \n\t Queue<Integer>num = new LinkedList<Integer>();\n\t Queue<String> p = new LinkedList<String>();\n\t int number = input.nextInt();\n\t int time = input.nextInt();\n\t int timer = 0;\n\t for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for\n\t \n\t while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while\n\t \n}",
"Scanner input = new Scanner(System.in);",
"input",
"new Scanner(System.in)",
"Queue<Integer>num = new LinkedList<Integer>();",
"num",
"new LinkedList<Integer>()",
"Queue<String> p = new LinkedList<String>();",
"p",
"new LinkedList<String>()",
"int number = input.nextInt();",
"number",
"input.nextInt()",
"input.nextInt",
"input",
"int time = input.nextInt();",
"time",
"input.nextInt()",
"input.nextInt",
"input",
"int timer = 0;",
"timer",
"0",
"for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < number",
"i",
"number",
"i++",
"i++",
"i",
"{\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for",
"{\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }",
"p.add(input.next())",
"p.add",
"p",
"input.next()",
"input.next",
"input",
"num.add(input.nextInt())",
"num.add",
"num",
"input.nextInt()",
"input.nextInt",
"input",
"while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while",
"!num.isEmpty()",
"num.isEmpty()",
"num.isEmpty",
"num",
"{\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }",
"String test2 = p.remove();",
"test2",
"p.remove()",
"p.remove",
"p",
"int test = num.remove();",
"test",
"num.remove()",
"num.remove",
"num",
"if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if",
"test - time <= 0",
"test - time",
"test",
"time",
"0",
"{\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }",
"timer += test",
"timer",
"test",
"System.out.println(test2 + \" \" +(timer))",
"System.out.println",
"System.out",
"System",
"System.out",
"test2 + \" \" +(timer)",
"test2 + \" \" +(timer)",
"test2",
"\" \"",
"(timer)",
"if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if",
"test - time > 0",
"test - time",
"test",
"time",
"0",
"{\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }",
"p.add(test2)",
"p.add",
"p",
"test2",
"num.add(test - time)",
"num.add",
"num",
"test - time",
"test",
"time",
"timer += time",
"timer",
"time",
"String args[]",
"args",
"public class Main{\n\tpublic static void main(String args[]){\n\t Scanner input = new Scanner(System.in);\n\t \n\t Queue<Integer>num = new LinkedList<Integer>();\n\t Queue<String> p = new LinkedList<String>();\n\t int number = input.nextInt();\n\t int time = input.nextInt();\n\t int timer = 0;\n\t for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for\n\t \n\t while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while\n\t \n}//main\n}//main",
"public class Main{\n\tpublic static void main(String args[]){\n\t Scanner input = new Scanner(System.in);\n\t \n\t Queue<Integer>num = new LinkedList<Integer>();\n\t Queue<String> p = new LinkedList<String>();\n\t int number = input.nextInt();\n\t int time = input.nextInt();\n\t int timer = 0;\n\t for(int i = 0; i < number; i++ ){\n\t \tp.add(input.next());\n\t num.add(input.nextInt());\n\t }//for\n\t \n\t while(!num.isEmpty()){\n\t \tString test2 = p.remove();\n\t int test = num.remove();\n\t if(test - time <= 0 ){\n\t timer += test;\n\t System.out.println(test2 + \" \" +(timer));\n\t }//if\n\t if(test - time > 0){\n\t \tp.add(test2);\n\t num.add(test - time);\n\t timer += time;\n\t }//if\n\t \n\t }//while\n\t \n}//main\n}//main",
"Main"
] | import java.util.*;
public class Main{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
Queue<Integer>num = new LinkedList<Integer>();
Queue<String> p = new LinkedList<String>();
int number = input.nextInt();
int time = input.nextInt();
int timer = 0;
for(int i = 0; i < number; i++ ){
p.add(input.next());
num.add(input.nextInt());
}//for
while(!num.isEmpty()){
String test2 = p.remove();
int test = num.remove();
if(test - time <= 0 ){
timer += test;
System.out.println(test2 + " " +(timer));
}//if
if(test - time > 0){
p.add(test2);
num.add(test - time);
timer += time;
}//if
}//while
}//main
}//main
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
6,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
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,
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,
13,
13,
0,
13,
13,
41,
13,
17,
42,
2,
13,
13,
30,
41,
13,
4,
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,
4,
13,
13,
0,
13,
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
],
[
162,
11
],
[
162,
12
],
[
12,
13
],
[
12,
14
],
[
162,
15
],
[
15,
16
],
[
15,
17
],
[
162,
19
],
[
19,
20
],
[
19,
21
],
[
162,
22
],
[
22,
23
],
[
22,
24
],
[
162,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
28,
32
],
[
27,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
25,
40
],
[
40,
41
],
[
162,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
47,
49
],
[
44,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
44,
57
],
[
57,
58
],
[
162,
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
],
[
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
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
87,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
103,
104
],
[
87,
105
],
[
105,
106
],
[
105,
107
],
[
61,
108
],
[
108,
109
],
[
108,
110
],
[
61,
111
],
[
111,
112
],
[
111,
113
],
[
61,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
118,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
132,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
141,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
141,
146
],
[
123,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
147,
153
],
[
153,
154
],
[
153,
155
],
[
147,
156
],
[
156,
157
],
[
156,
158
],
[
59,
159
],
[
159,
160
],
[
0,
161
],
[
161,
162
],
[
161,
163
]
] | [
"import java.util.Scanner;\n\nclass Task{\n String name;\n int time;\n}\n\npublic class Main {\n\n static final int len = 100005;\n static Task[] num = new Task[len];\n\n static int head = 0;\n static int tail = 0;\n\n // ??????????????????????????????\n public static void enqueue(Task task){\n num[tail] = task;\n tail = (tail+1) % len;\n }\n\n // ??????????????????????????????\n public static Task dequeue(){\n Task temp = num[head];\n head = (head+1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }\n\n tail = n;\n\n int sum = 0;\n\n //????????????????????ยถ????????ยฌ??????????????????\n while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }\n }\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Task{\n String name;\n int time;\n}",
"Task",
"String name;",
"name",
"int time;",
"time",
"public class Main {\n\n static final int len = 100005;\n static Task[] num = new Task[len];\n\n static int head = 0;\n static int tail = 0;\n\n // ??????????????????????????????\n public static void enqueue(Task task){\n num[tail] = task;\n tail = (tail+1) % len;\n }\n\n // ??????????????????????????????\n public static Task dequeue(){\n Task temp = num[head];\n head = (head+1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }\n\n tail = n;\n\n int sum = 0;\n\n //????????????????????ยถ????????ยฌ??????????????????\n while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }\n }\n\n}",
"Main",
"static final int len = 100005;",
"len",
"100005",
"static Task[] num = new Task[len];",
"num",
"new Task[len]",
"len",
"static int head = 0;",
"head",
"0",
"static int tail = 0;",
"tail",
"0",
"// ??????????????????????????????\n public static void enqueue(Task task){\n num[tail] = task;\n tail = (tail+1) % len;\n }",
"enqueue",
"{\n num[tail] = task;\n tail = (tail+1) % len;\n }",
"num[tail] = task",
"num[tail]",
"num",
"tail",
"task",
"tail = (tail+1) % len",
"tail",
"(tail+1) % len",
"(tail+1)",
"tail",
"1",
"len",
"Task task",
"task",
"// ??????????????????????????????\n public static Task dequeue(){\n Task temp = num[head];\n head = (head+1) % len;\n return temp;\n }",
"dequeue",
"{\n Task temp = num[head];\n head = (head+1) % len;\n return temp;\n }",
"Task temp = num[head];",
"temp",
"num[head]",
"num",
"head",
"head = (head+1) % len",
"head",
"(head+1) % len",
"(head+1)",
"head",
"1",
"len",
"return temp;",
"temp",
"public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }\n\n tail = n;\n\n int sum = 0;\n\n //????????????????????ยถ????????ยฌ??????????????????\n while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }\n }",
"main",
"{\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }\n\n tail = n;\n\n int sum = 0;\n\n //????????????????????ยถ????????ยฌ??????????????????\n while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\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",
"for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }",
"{\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }",
"Task temp = new Task();",
"temp",
"new Task()",
"temp.name = sc.next()",
"temp.name",
"temp",
"temp.name",
"sc.next()",
"sc.next",
"sc",
"temp.time = sc.nextInt()",
"temp.time",
"temp",
"temp.time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"enqueue(temp)",
"enqueue",
"temp",
"tail = n",
"tail",
"n",
"int sum = 0;",
"sum",
"0",
"while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }",
"head != tail",
"head",
"tail",
"{\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }",
"Task temp = dequeue();",
"temp",
"dequeue()",
"dequeue",
"if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }",
"temp.time <= q",
"temp.time",
"temp",
"temp.time",
"q",
"{\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }",
"sum += temp.time",
"sum",
"temp.time",
"temp",
"temp.time",
"System.out.println(temp.name + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.name + \" \" + sum",
"temp.name + \" \" + sum",
"temp.name",
"temp",
"temp.name",
"\" \"",
"sum",
"{\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }",
"temp.time -= q",
"temp.time",
"temp",
"temp.time",
"q",
"enqueue(temp)",
"enqueue",
"temp",
"sum += q",
"sum",
"q",
"String[] args",
"args",
"public class Main {\n\n static final int len = 100005;\n static Task[] num = new Task[len];\n\n static int head = 0;\n static int tail = 0;\n\n // ??????????????????????????????\n public static void enqueue(Task task){\n num[tail] = task;\n tail = (tail+1) % len;\n }\n\n // ??????????????????????????????\n public static Task dequeue(){\n Task temp = num[head];\n head = (head+1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }\n\n tail = n;\n\n int sum = 0;\n\n //????????????????????ยถ????????ยฌ??????????????????\n while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }\n }\n\n}",
"public class Main {\n\n static final int len = 100005;\n static Task[] num = new Task[len];\n\n static int head = 0;\n static int tail = 0;\n\n // ??????????????????????????????\n public static void enqueue(Task task){\n num[tail] = task;\n tail = (tail+1) % len;\n }\n\n // ??????????????????????????????\n public static Task dequeue(){\n Task temp = num[head];\n head = (head+1) % len;\n return temp;\n }\n\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n for (int i=0; i<n; i++){\n Task temp = new Task();\n temp.name = sc.next();\n temp.time = sc.nextInt();\n enqueue(temp);\n }\n\n tail = n;\n\n int sum = 0;\n\n //????????????????????ยถ????????ยฌ??????????????????\n while (head != tail){\n Task temp = dequeue();\n if (temp.time <= q){\n sum += temp.time;\n System.out.println(temp.name + \" \" + sum);\n }\n else {\n temp.time -= q;\n enqueue(temp);\n sum += q;\n }\n }\n }\n\n}",
"Main"
] | import java.util.Scanner;
class Task{
String name;
int time;
}
public class Main {
static final int len = 100005;
static Task[] num = new Task[len];
static int head = 0;
static int tail = 0;
// ??????????????????????????????
public static void enqueue(Task task){
num[tail] = task;
tail = (tail+1) % len;
}
// ??????????????????????????????
public static Task dequeue(){
Task temp = num[head];
head = (head+1) % len;
return temp;
}
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++){
Task temp = new Task();
temp.name = sc.next();
temp.time = sc.nextInt();
enqueue(temp);
}
tail = n;
int sum = 0;
//????????????????????ยถ????????ยฌ??????????????????
while (head != tail){
Task temp = dequeue();
if (temp.time <= q){
sum += temp.time;
System.out.println(temp.name + " " + sum);
}
else {
temp.time -= q;
enqueue(temp);
sum += q;
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
12,
13,
30,
29,
8,
2,
2,
13,
13,
13,
17,
17,
12,
13,
30,
29,
8,
2,
2,
13,
13,
17,
17,
17,
12,
13,
30,
14,
4,
13,
37,
20,
0,
18,
13,
2,
13,
13,
13,
40,
13,
23,
13,
23,
13,
12,
13,
30,
14,
4,
13,
37,
20,
41,
13,
18,
13,
2,
13,
13,
0,
18,
13,
2,
13,
13,
17,
40,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
13,
17,
29,
13,
30,
4,
18,
13,
2,
13,
13,
29,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
13,
13,
20,
4,
18,
13,
42,
40,
4,
13,
30,
41,
13,
4,
13,
13,
0,
13,
4,
13,
13,
13,
14,
2,
4,
18,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
4,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
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,
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
],
[
272,
5
],
[
272,
6
],
[
6,
7
],
[
6,
8
],
[
272,
9
],
[
9,
10
],
[
9,
11
],
[
272,
12
],
[
12,
13
],
[
12,
14
],
[
272,
15
],
[
15,
16
],
[
15,
17
],
[
272,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
22,
28
],
[
22,
29
],
[
272,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
34,
40
],
[
34,
41
],
[
272,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
44,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
50,
56
],
[
44,
57
],
[
57,
58
],
[
42,
59
],
[
59,
60
],
[
42,
61
],
[
61,
62
],
[
272,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
69,
70
],
[
65,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
65,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
81,
83
],
[
78,
84
],
[
65,
85
],
[
85,
86
],
[
65,
87
],
[
87,
88
],
[
63,
89
],
[
89,
90
],
[
272,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
103,
108
],
[
108,
109
],
[
99,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
114,
115
],
[
114,
116
],
[
110,
117
],
[
117,
118
],
[
91,
119
],
[
119,
120
],
[
91,
121
],
[
121,
122
],
[
272,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
125,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
125,
139
],
[
139,
140
],
[
139,
141
],
[
125,
143
],
[
143,
144
],
[
143,
145
],
[
125,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
146,
153
],
[
153,
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
],
[
167,
170
],
[
153,
171
],
[
171,
172
],
[
172,
173
],
[
153,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
174,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
181,
183
],
[
178,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
186,
188
],
[
186,
189
],
[
178,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
191,
195
],
[
190,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
197,
202
],
[
203,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
203,
207
],
[
203,
208
],
[
190,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
210,
213
],
[
123,
214
],
[
214,
215
],
[
0,
216
],
[
216,
217
],
[
216,
218
],
[
218,
219
],
[
216,
220
],
[
220,
221
],
[
216,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
225,
226
],
[
216,
227
],
[
227,
228
],
[
227,
229
],
[
229,
230
],
[
230,
231
],
[
216,
232
],
[
232,
233
],
[
232,
234
],
[
234,
235
],
[
235,
236
],
[
236,
237
],
[
236,
238
],
[
235,
239
],
[
232,
240
],
[
240,
241
],
[
216,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
245,
249
],
[
242,
250
],
[
250,
251
],
[
216,
252
],
[
252,
253
],
[
252,
254
],
[
254,
255
],
[
255,
256
],
[
254,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
257,
261
],
[
254,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
266
],
[
252,
267
],
[
267,
268
],
[
252,
269
],
[
269,
270
],
[
0,
271
],
[
271,
272
],
[
271,
273
]
] | [
"\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static int size = 5;\n\tpublic static int interval = 100;\n\t\n\tpublic static int head=0, tail=0;\n\t\n\tpublic static boolean isFull() {\n\t\treturn (tail-head >= size) ? true : false;\n\t}\n\t\n\tpublic static boolean isEmpty() {\n\t\treturn (tail-head <=0 ) ? true : false;\n\t}\n\n\tpublic static void enqueue(Item[] queue, Item x) throws Exception {\n\t\tif (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");\n\t\tqueue[tail%size] = x;\n\t\ttail ++;\n\t}\n\t\n\tpublic static Item dequeue(Item[] queue) throws Exception {\n\t\tif (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");\n\t\tItem headItem = queue[head%size];\n\t\tqueue[head%size] = null;\n\t\thead ++;\n\t\treturn headItem;\n\t}\n\t\n\tpublic static int process(Item i, int interval) {\n\t\tint time = i.getTime();\n\t\tif (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsize = sc.nextInt();\n\t\tinterval = sc.nextInt();\n\t\tItem[] queue = new Item[size];\n\t\t\n\t\tint atime = 0;\n\t\t\n\t\ttry {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n}\n\nclass Item {\n\tprivate String name;\n\tprivate int time;\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\tpublic Item(String name, int time) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static int size = 5;\n\tpublic static int interval = 100;\n\t\n\tpublic static int head=0, tail=0;\n\t\n\tpublic static boolean isFull() {\n\t\treturn (tail-head >= size) ? true : false;\n\t}\n\t\n\tpublic static boolean isEmpty() {\n\t\treturn (tail-head <=0 ) ? true : false;\n\t}\n\n\tpublic static void enqueue(Item[] queue, Item x) throws Exception {\n\t\tif (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");\n\t\tqueue[tail%size] = x;\n\t\ttail ++;\n\t}\n\t\n\tpublic static Item dequeue(Item[] queue) throws Exception {\n\t\tif (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");\n\t\tItem headItem = queue[head%size];\n\t\tqueue[head%size] = null;\n\t\thead ++;\n\t\treturn headItem;\n\t}\n\t\n\tpublic static int process(Item i, int interval) {\n\t\tint time = i.getTime();\n\t\tif (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsize = sc.nextInt();\n\t\tinterval = sc.nextInt();\n\t\tItem[] queue = new Item[size];\n\t\t\n\t\tint atime = 0;\n\t\t\n\t\ttry {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n}",
"Main",
"public static int size = 5;",
"size",
"5",
"public static int interval = 100;",
"interval",
"100",
"public static int head=0",
"head",
"0",
"tail=0;",
"tail",
"0",
"public static boolean isFull() {\n\t\treturn (tail-head >= size) ? true : false;\n\t}",
"isFull",
"{\n\t\treturn (tail-head >= size) ? true : false;\n\t}",
"return (tail-head >= size) ? true : false;",
"(tail-head >= size) ? true : false",
"(tail-head >= size)",
"tail-head",
"tail",
"head",
"size",
"true",
"false",
"public static boolean isEmpty() {\n\t\treturn (tail-head <=0 ) ? true : false;\n\t}",
"isEmpty",
"{\n\t\treturn (tail-head <=0 ) ? true : false;\n\t}",
"return (tail-head <=0 ) ? true : false;",
"(tail-head <=0 ) ? true : false",
"(tail-head <=0 )",
"tail-head",
"tail",
"head",
"0",
"true",
"false",
"public static void enqueue(Item[] queue, Item x) throws Exception {\n\t\tif (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");\n\t\tqueue[tail%size] = x;\n\t\ttail ++;\n\t}",
"enqueue",
"{\n\t\tif (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");\n\t\tqueue[tail%size] = x;\n\t\ttail ++;\n\t}",
"if (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");",
"isFull()",
"isFull",
"throw new Exception(\"Error: The queue is full!\");",
"new Exception(\"Error: The queue is full!\")",
"queue[tail%size] = x",
"queue[tail%size]",
"queue",
"tail%size",
"tail",
"size",
"x",
"tail ++",
"tail",
"Item[] queue",
"queue",
"Item x",
"x",
"public static Item dequeue(Item[] queue) throws Exception {\n\t\tif (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");\n\t\tItem headItem = queue[head%size];\n\t\tqueue[head%size] = null;\n\t\thead ++;\n\t\treturn headItem;\n\t}",
"dequeue",
"{\n\t\tif (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");\n\t\tItem headItem = queue[head%size];\n\t\tqueue[head%size] = null;\n\t\thead ++;\n\t\treturn headItem;\n\t}",
"if (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");",
"isEmpty()",
"isEmpty",
"throw new Exception(\"Error: The queue is empty\");",
"new Exception(\"Error: The queue is empty\")",
"Item headItem = queue[head%size];",
"headItem",
"queue[head%size]",
"queue",
"head%size",
"head",
"size",
"queue[head%size] = null",
"queue[head%size]",
"queue",
"head%size",
"head",
"size",
"null",
"head ++",
"head",
"return headItem;",
"headItem",
"Item[] queue",
"queue",
"public static int process(Item i, int interval) {\n\t\tint time = i.getTime();\n\t\tif (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}\n\t}",
"process",
"{\n\t\tint time = i.getTime();\n\t\tif (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}\n\t}",
"int time = i.getTime();",
"time",
"i.getTime()",
"i.getTime",
"i",
"if (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}",
"time<=interval",
"time",
"interval",
"{\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t}",
"i.setTime(0)",
"i.setTime",
"i",
"0",
"return time;",
"time",
"{\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}",
"i.setTime(time-interval)",
"i.setTime",
"i",
"time-interval",
"time",
"interval",
"return interval;",
"interval",
"Item i",
"i",
"int interval",
"interval",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsize = sc.nextInt();\n\t\tinterval = sc.nextInt();\n\t\tItem[] queue = new Item[size];\n\t\t\n\t\tint atime = 0;\n\t\t\n\t\ttry {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tsize = sc.nextInt();\n\t\tinterval = sc.nextInt();\n\t\tItem[] queue = new Item[size];\n\t\t\n\t\tint atime = 0;\n\t\t\n\t\ttry {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"size = sc.nextInt()",
"size",
"sc.nextInt()",
"sc.nextInt",
"sc",
"interval = sc.nextInt()",
"interval",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Item[] queue = new Item[size];",
"queue",
"new Item[size]",
"size",
"int atime = 0;",
"atime",
"0",
"try {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}",
"catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}",
"Exception e",
"{\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t}",
"for (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<size",
"i",
"size",
"i++",
"i++",
"i",
"{\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}",
"{\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}",
"enqueue(queue, new Item(sc.next(), sc.nextInt()))",
"enqueue",
"queue",
"new Item(sc.next(), sc.nextInt())",
"sc.close()",
"sc.close",
"sc",
"while (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}",
"Item item = dequeue(queue);",
"item",
"dequeue(queue)",
"dequeue",
"queue",
"atime += process(item, interval)",
"atime",
"process(item, interval)",
"process",
"item",
"interval",
"if (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}",
"item.getTime() == 0",
"item.getTime()",
"item.getTime",
"item",
"0",
"{\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t}",
"System.out.println(item.getName() + \" \" + atime)",
"System.out.println",
"System.out",
"System",
"System.out",
"item.getName() + \" \" + atime",
"item.getName() + \" \" + atime",
"item.getName()",
"item.getName",
"item",
"\" \"",
"atime",
"{\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}",
"enqueue(queue, item)",
"enqueue",
"queue",
"item",
"String[] args",
"args",
"class Item {\n\tprivate String name;\n\tprivate int time;\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\tpublic Item(String name, int time) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t\n}",
"Item",
"private String name;",
"name",
"private 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 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 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 Item(String name, int time) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Item",
"{\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"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\t\n\tpublic static int size = 5;\n\tpublic static int interval = 100;\n\t\n\tpublic static int head=0, tail=0;\n\t\n\tpublic static boolean isFull() {\n\t\treturn (tail-head >= size) ? true : false;\n\t}\n\t\n\tpublic static boolean isEmpty() {\n\t\treturn (tail-head <=0 ) ? true : false;\n\t}\n\n\tpublic static void enqueue(Item[] queue, Item x) throws Exception {\n\t\tif (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");\n\t\tqueue[tail%size] = x;\n\t\ttail ++;\n\t}\n\t\n\tpublic static Item dequeue(Item[] queue) throws Exception {\n\t\tif (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");\n\t\tItem headItem = queue[head%size];\n\t\tqueue[head%size] = null;\n\t\thead ++;\n\t\treturn headItem;\n\t}\n\t\n\tpublic static int process(Item i, int interval) {\n\t\tint time = i.getTime();\n\t\tif (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsize = sc.nextInt();\n\t\tinterval = sc.nextInt();\n\t\tItem[] queue = new Item[size];\n\t\t\n\t\tint atime = 0;\n\t\t\n\t\ttry {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n}",
"public class Main {\n\t\n\tpublic static int size = 5;\n\tpublic static int interval = 100;\n\t\n\tpublic static int head=0, tail=0;\n\t\n\tpublic static boolean isFull() {\n\t\treturn (tail-head >= size) ? true : false;\n\t}\n\t\n\tpublic static boolean isEmpty() {\n\t\treturn (tail-head <=0 ) ? true : false;\n\t}\n\n\tpublic static void enqueue(Item[] queue, Item x) throws Exception {\n\t\tif (isFull()) \n\t\t\tthrow new Exception(\"Error: The queue is full!\");\n\t\tqueue[tail%size] = x;\n\t\ttail ++;\n\t}\n\t\n\tpublic static Item dequeue(Item[] queue) throws Exception {\n\t\tif (isEmpty())\n\t\t\tthrow new Exception(\"Error: The queue is empty\");\n\t\tItem headItem = queue[head%size];\n\t\tqueue[head%size] = null;\n\t\thead ++;\n\t\treturn headItem;\n\t}\n\t\n\tpublic static int process(Item i, int interval) {\n\t\tint time = i.getTime();\n\t\tif (time<=interval) {\n\t\t\ti.setTime(0);\n\t\t\treturn time;\n\t\t} else {\n\t\t\ti.setTime(time-interval);\n\t\t\treturn interval;\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tsize = sc.nextInt();\n\t\tinterval = sc.nextInt();\n\t\tItem[] queue = new Item[size];\n\t\t\n\t\tint atime = 0;\n\t\t\n\t\ttry {\n\t\t\tfor (int i=0; i<size; i++) {\n\t\t\t\tenqueue(queue, new Item(sc.next(), sc.nextInt()));\n\t\t\t}\n\t\t\tsc.close();\n\t\t\t\n\t\t\twhile (!isEmpty()) {\n\t\t\t\tItem item = dequeue(queue);\n\t\t\t\tatime += process(item, interval);\n\t\t\t\tif (item.getTime() == 0) {\n\t\t\t\t\tSystem.out.println(item.getName() + \" \" + atime);\n\t\t\t\t} else {\n\t\t\t\t\tenqueue(queue, item);\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n\n}",
"Main"
] |
import java.util.Scanner;
public class Main {
public static int size = 5;
public static int interval = 100;
public static int head=0, tail=0;
public static boolean isFull() {
return (tail-head >= size) ? true : false;
}
public static boolean isEmpty() {
return (tail-head <=0 ) ? true : false;
}
public static void enqueue(Item[] queue, Item x) throws Exception {
if (isFull())
throw new Exception("Error: The queue is full!");
queue[tail%size] = x;
tail ++;
}
public static Item dequeue(Item[] queue) throws Exception {
if (isEmpty())
throw new Exception("Error: The queue is empty");
Item headItem = queue[head%size];
queue[head%size] = null;
head ++;
return headItem;
}
public static int process(Item i, int interval) {
int time = i.getTime();
if (time<=interval) {
i.setTime(0);
return time;
} else {
i.setTime(time-interval);
return interval;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
size = sc.nextInt();
interval = sc.nextInt();
Item[] queue = new Item[size];
int atime = 0;
try {
for (int i=0; i<size; i++) {
enqueue(queue, new Item(sc.next(), sc.nextInt()));
}
sc.close();
while (!isEmpty()) {
Item item = dequeue(queue);
atime += process(item, interval);
if (item.getTime() == 0) {
System.out.println(item.getName() + " " + atime);
} else {
enqueue(queue, item);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
class Item {
private String name;
private int time;
public String getName() {
return name;
}
public int getTime() {
return time;
}
public void setName(String name) {
this.name = name;
}
public void setTime(int time) {
this.time = time;
}
public Item(String name, int time) {
super();
this.name = name;
this.time = time;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
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,
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,
2,
13,
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,
23,
13,
6,
13,
41,
13,
12,
13,
30,
0,
13,
20,
12,
13,
30,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
2,
4,
18,
13,
17,
4,
18,
13,
2,
4,
18,
13,
17,
29,
13,
12,
13,
30,
29,
4,
18,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
14,
2,
13,
17,
0,
13,
13,
14,
2,
13,
17,
30,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
13,
17,
30,
0,
18,
13,
13,
17,
30,
0,
13,
17,
29,
13,
12,
13,
30,
29,
2,
2,
13,
17,
2,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
23,
13,
6,
13,
41,
13,
41,
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,
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
],
[
306,
14
],
[
306,
15
],
[
15,
16
],
[
15,
17
],
[
306,
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
],
[
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
],
[
48,
49
],
[
47,
50
],
[
20,
51
],
[
51,
52
],
[
51,
53
],
[
20,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
54,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
59,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
67,
71
],
[
59,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
82,
87
],
[
88,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
88,
92
],
[
88,
93
],
[
72,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
94,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
18,
106
],
[
106,
107
],
[
0,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
108,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
108,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
118,
125
],
[
125,
126
],
[
108,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
135,
139
],
[
129,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
143,
147
],
[
129,
148
],
[
148,
149
],
[
108,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
0,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
157,
161
],
[
161,
162
],
[
157,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
173,
174
],
[
173,
175
],
[
165,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
180,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
165,
191
],
[
191,
192
],
[
191,
193
],
[
163,
194
],
[
194,
195
],
[
157,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
201,
203
],
[
198,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
206,
208
],
[
198,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
209,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
214,
218
],
[
209,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
198,
223
],
[
223,
224
],
[
157,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
229,
233
],
[
233,
234
],
[
233,
235
],
[
0,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
236,
240
],
[
240,
241
],
[
236,
242
],
[
242,
243
],
[
236,
244
],
[
244,
245
],
[
244,
246
],
[
246,
247
],
[
247,
248
],
[
247,
249
],
[
244,
250
],
[
250,
251
],
[
0,
252
],
[
252,
253
],
[
252,
254
],
[
254,
255
],
[
252,
256
],
[
256,
257
],
[
252,
258
],
[
258,
259
],
[
258,
260
],
[
260,
261
],
[
261,
262
],
[
252,
263
],
[
263,
264
],
[
263,
265
],
[
265,
266
],
[
266,
267
],
[
267,
268
],
[
267,
269
],
[
266,
270
],
[
263,
271
],
[
271,
272
],
[
252,
273
],
[
273,
274
],
[
273,
275
],
[
275,
276
],
[
276,
277
],
[
252,
278
],
[
278,
279
],
[
278,
280
],
[
280,
281
],
[
281,
282
],
[
282,
283
],
[
282,
284
],
[
281,
285
],
[
278,
286
],
[
286,
287
],
[
252,
288
],
[
288,
289
],
[
288,
290
],
[
290,
291
],
[
291,
292
],
[
292,
293
],
[
292,
294
],
[
291,
295
],
[
290,
296
],
[
296,
297
],
[
297,
298
],
[
297,
299
],
[
296,
300
],
[
288,
301
],
[
301,
302
],
[
288,
303
],
[
303,
304
],
[
0,
305
],
[
305,
306
],
[
305,
307
]
] | [
"import java.util.List;\nimport java.util.ArrayList;\nimport java.util.HashMap;\n\nimport java.util.Scanner;\n\npublic class Main {\n private static Scanner sc = new Scanner(System.in);\n public static void main(String[] args) {\n Queue<Pair<String, Integer>> queue = new Queue<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n for (int i = 0; i < n; i++) {\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }\n \n long pass = 0;\n \n while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }\n }\n}\n\nclass Stack<T> {\n private List<T> list;\n \n public Stack() {\n list = new ArrayList<>();\n }\n \n public void push(T t) {\n list.add(t);\n }\n \n public T pop() {\n T t = list.get(list.size()-1);\n list.remove(list.size()-1);\n return t;\n }\n \n public boolean isEmpty() {\n return list.isEmpty();\n }\n}\n\nclass Queue<T> {\n Node<T> head;\n Node<T> tail;\n \n public void enqueue(T t) {\n Node<T> n = new Node<>(t);\n if (head == null) head = n;\n if (tail != null) {\n tail.next = n;\n n.prev = tail;\n }\n tail = n;\n }\n \n public T dequeue() {\n T t = head.elem;\n head = head.next;\n if (head != null) {\n head.prev = null;\n } else {\n tail = null;\n }\n return t;\n }\n \n public boolean isEmpty() {\n return head == null && tail == null;\n }\n}\n\nclass Node<T> {\n T elem;\n Node<T> prev;\n Node<T> next;\n public Node(T t) { elem = t; }\n}\n\nclass Pair<K, V> {\n K k;\n V v;\n public K getKey() { return k; }\n public void setKey(K k) { this.k = k; }\n public V getValue() { return v; }\n public void setValue(V v) { this.v = v; }\n public Pair(K k, V v) {\n this.k = k;\n this.v = v;\n }\n}",
"import java.util.List;",
"List",
"java.util",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n private static Scanner sc = new Scanner(System.in);\n public static void main(String[] args) {\n Queue<Pair<String, Integer>> queue = new Queue<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n for (int i = 0; i < n; i++) {\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }\n \n long pass = 0;\n \n while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }\n }\n}",
"Main",
"private static Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args) {\n Queue<Pair<String, Integer>> queue = new Queue<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n for (int i = 0; i < n; i++) {\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }\n \n long pass = 0;\n \n while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }\n }",
"main",
"{\n Queue<Pair<String, Integer>> queue = new Queue<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n for (int i = 0; i < n; i++) {\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }\n \n long pass = 0;\n \n while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }\n }",
"Queue<Pair<String, Integer>> queue = new Queue<>();",
"queue",
"new Queue<>()",
"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.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }",
"{\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }",
"queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()))",
"queue.enqueue",
"queue",
"new Pair<String, Integer>(sc.next(), sc.nextInt())",
"long pass = 0;",
"pass",
"0",
"while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }",
"Pair<String, Integer> p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"int i = p.getValue() - q;",
"i",
"p.getValue() - q",
"p.getValue()",
"p.getValue",
"p",
"q",
"if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }",
"i <= 0",
"i",
"0",
"{\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n }",
"pass += (q + i)",
"pass",
"(q + i)",
"q",
"i",
"System.out.println(p.getKey() + \" \" + pass)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getKey() + \" \" + pass",
"p.getKey() + \" \" + pass",
"p.getKey()",
"p.getKey",
"p",
"\" \"",
"pass",
"{\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }",
"pass += q",
"pass",
"q",
"p.setValue(i)",
"p.setValue",
"p",
"i",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"String[] args",
"args",
"class Stack<T> {\n private List<T> list;\n \n public Stack() {\n list = new ArrayList<>();\n }\n \n public void push(T t) {\n list.add(t);\n }\n \n public T pop() {\n T t = list.get(list.size()-1);\n list.remove(list.size()-1);\n return t;\n }\n \n public boolean isEmpty() {\n return list.isEmpty();\n }\n}",
"Stack",
"private List<T> list;",
"list",
"public Stack() {\n list = new ArrayList<>();\n }",
"Stack",
"{\n list = new ArrayList<>();\n }",
"list = new ArrayList<>()",
"list",
"new ArrayList<>()",
"public void push(T t) {\n list.add(t);\n }",
"push",
"{\n list.add(t);\n }",
"list.add(t)",
"list.add",
"list",
"t",
"T t",
"t",
"public T pop() {\n T t = list.get(list.size()-1);\n list.remove(list.size()-1);\n return t;\n }",
"pop",
"{\n T t = list.get(list.size()-1);\n list.remove(list.size()-1);\n return t;\n }",
"T t = list.get(list.size()-1);",
"t",
"list.get(list.size()-1)",
"list.get",
"list",
"list.size()-1",
"list.size()",
"list.size",
"list",
"1",
"list.remove(list.size()-1)",
"list.remove",
"list",
"list.size()-1",
"list.size()",
"list.size",
"list",
"1",
"return t;",
"t",
"public boolean isEmpty() {\n return list.isEmpty();\n }",
"isEmpty",
"{\n return list.isEmpty();\n }",
"return list.isEmpty();",
"list.isEmpty()",
"list.isEmpty",
"list",
"class Queue<T> {\n Node<T> head;\n Node<T> tail;\n \n public void enqueue(T t) {\n Node<T> n = new Node<>(t);\n if (head == null) head = n;\n if (tail != null) {\n tail.next = n;\n n.prev = tail;\n }\n tail = n;\n }\n \n public T dequeue() {\n T t = head.elem;\n head = head.next;\n if (head != null) {\n head.prev = null;\n } else {\n tail = null;\n }\n return t;\n }\n \n public boolean isEmpty() {\n return head == null && tail == null;\n }\n}",
"Queue",
"Node<T> head;",
"head",
"Node<T> tail;",
"tail",
"public void enqueue(T t) {\n Node<T> n = new Node<>(t);\n if (head == null) head = n;\n if (tail != null) {\n tail.next = n;\n n.prev = tail;\n }\n tail = n;\n }",
"enqueue",
"{\n Node<T> n = new Node<>(t);\n if (head == null) head = n;\n if (tail != null) {\n tail.next = n;\n n.prev = tail;\n }\n tail = n;\n }",
"Node<T> n = new Node<>(t);",
"n",
"new Node<>(t)",
"if (head == null) head = n;",
"head == null",
"head",
"null",
"head = n",
"head",
"n",
"if (tail != null) {\n tail.next = n;\n n.prev = tail;\n }",
"tail != null",
"tail",
"null",
"{\n tail.next = n;\n n.prev = tail;\n }",
"tail.next = n",
"tail.next",
"tail",
"tail.next",
"n",
"n.prev = tail",
"n.prev",
"n",
"n.prev",
"tail",
"tail = n",
"tail",
"n",
"T t",
"t",
"public T dequeue() {\n T t = head.elem;\n head = head.next;\n if (head != null) {\n head.prev = null;\n } else {\n tail = null;\n }\n return t;\n }",
"dequeue",
"{\n T t = head.elem;\n head = head.next;\n if (head != null) {\n head.prev = null;\n } else {\n tail = null;\n }\n return t;\n }",
"T t = head.elem;",
"t",
"head.elem",
"head",
"head.elem",
"head = head.next",
"head",
"head.next",
"head",
"head.next",
"if (head != null) {\n head.prev = null;\n } else {\n tail = null;\n }",
"head != null",
"head",
"null",
"{\n head.prev = null;\n }",
"head.prev = null",
"head.prev",
"head",
"head.prev",
"null",
"{\n tail = null;\n }",
"tail = null",
"tail",
"null",
"return t;",
"t",
"public boolean isEmpty() {\n return head == null && tail == null;\n }",
"isEmpty",
"{\n return head == null && tail == null;\n }",
"return head == null && tail == null;",
"head == null && tail == null",
"head == null",
"head",
"null",
"tail == null",
"tail",
"null",
"class Node<T> {\n T elem;\n Node<T> prev;\n Node<T> next;\n public Node(T t) { elem = t; }\n}",
"Node",
"T elem;",
"elem",
"Node<T> prev;",
"prev",
"Node<T> next;",
"next",
"public Node(T t) { elem = t; }",
"Node",
"{ elem = t; }",
"elem = t",
"elem",
"t",
"T t",
"t",
"class Pair<K, V> {\n K k;\n V v;\n public K getKey() { return k; }\n public void setKey(K k) { this.k = k; }\n public V getValue() { return v; }\n public void setValue(V v) { this.v = v; }\n public Pair(K k, V v) {\n this.k = k;\n this.v = v;\n }\n}",
"Pair",
"K k;",
"k",
"V v;",
"v",
"public K getKey() { return k; }",
"getKey",
"{ return k; }",
"return k;",
"k",
"public void setKey(K k) { this.k = k; }",
"setKey",
"{ this.k = k; }",
"this.k = k",
"this.k",
"this",
"this.k",
"k",
"K k",
"k",
"public V getValue() { return v; }",
"getValue",
"{ return v; }",
"return v;",
"v",
"public void setValue(V v) { this.v = v; }",
"setValue",
"{ this.v = v; }",
"this.v = v",
"this.v",
"this",
"this.v",
"v",
"V v",
"v",
"public Pair(K k, V v) {\n this.k = k;\n this.v = v;\n }",
"Pair",
"{\n this.k = k;\n this.v = v;\n }",
"this.k = k",
"this.k",
"this",
"this.k",
"k",
"this.v = v",
"this.v",
"this",
"this.v",
"v",
"K k",
"k",
"V v",
"v",
"public class Main {\n private static Scanner sc = new Scanner(System.in);\n public static void main(String[] args) {\n Queue<Pair<String, Integer>> queue = new Queue<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n for (int i = 0; i < n; i++) {\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }\n \n long pass = 0;\n \n while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }\n }\n}",
"public class Main {\n private static Scanner sc = new Scanner(System.in);\n public static void main(String[] args) {\n Queue<Pair<String, Integer>> queue = new Queue<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n \n for (int i = 0; i < n; i++) {\n queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));\n }\n \n long pass = 0;\n \n while (!queue.isEmpty()) {\n Pair<String, Integer> p = queue.dequeue();\n int i = p.getValue() - q;\n if (i <= 0) {\n pass += (q + i);\n System.out.println(p.getKey() + \" \" + pass);\n } else {\n pass += q;\n p.setValue(i);\n queue.enqueue(p);\n }\n }\n }\n}",
"Main"
] | import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
Queue<Pair<String, Integer>> queue = new Queue<>();
int n = sc.nextInt();
int q = sc.nextInt();
for (int i = 0; i < n; i++) {
queue.enqueue(new Pair<String, Integer>(sc.next(), sc.nextInt()));
}
long pass = 0;
while (!queue.isEmpty()) {
Pair<String, Integer> p = queue.dequeue();
int i = p.getValue() - q;
if (i <= 0) {
pass += (q + i);
System.out.println(p.getKey() + " " + pass);
} else {
pass += q;
p.setValue(i);
queue.enqueue(p);
}
}
}
}
class Stack<T> {
private List<T> list;
public Stack() {
list = new ArrayList<>();
}
public void push(T t) {
list.add(t);
}
public T pop() {
T t = list.get(list.size()-1);
list.remove(list.size()-1);
return t;
}
public boolean isEmpty() {
return list.isEmpty();
}
}
class Queue<T> {
Node<T> head;
Node<T> tail;
public void enqueue(T t) {
Node<T> n = new Node<>(t);
if (head == null) head = n;
if (tail != null) {
tail.next = n;
n.prev = tail;
}
tail = n;
}
public T dequeue() {
T t = head.elem;
head = head.next;
if (head != null) {
head.prev = null;
} else {
tail = null;
}
return t;
}
public boolean isEmpty() {
return head == null && tail == null;
}
}
class Node<T> {
T elem;
Node<T> prev;
Node<T> next;
public Node(T t) { elem = t; }
}
class Pair<K, V> {
K k;
V v;
public K getKey() { return k; }
public void setKey(K k) { this.k = k; }
public V getValue() { return v; }
public void setValue(V v) { this.v = v; }
public Pair(K k, V v) {
this.k = k;
this.v = v;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
4,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
17,
4,
18,
13,
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,
20,
4,
18,
13,
13,
41,
13,
42,
2,
0,
13,
4,
18,
13,
17,
30,
14,
2,
2,
4,
18,
13,
13,
17,
30,
41,
13,
20,
4,
18,
13,
13,
0,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
2,
4,
18,
13,
13,
0,
13,
4,
18,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
139,
5
],
[
139,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
6,
11
],
[
11,
12
],
[
139,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
19,
20
],
[
19,
21
],
[
15,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
15,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
15,
32
],
[
32,
33
],
[
32,
34
],
[
15,
36
],
[
36,
37
],
[
36,
38
],
[
15,
40
],
[
40,
41
],
[
40,
42
],
[
15,
44
],
[
44,
45
],
[
44,
46
],
[
15,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
47,
51
],
[
15,
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
],
[
64,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
77,
78
],
[
64,
79
],
[
79,
80
],
[
79,
81
],
[
64,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
15,
86
],
[
86,
87
],
[
15,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
88,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
99,
103
],
[
98,
104
],
[
97,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
105,
113
],
[
113,
114
],
[
113,
115
],
[
97,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
123,
127
],
[
123,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
128,
132
],
[
116,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tALDS1_3_B();\n\t}\n\n\tpublic static void ALDS1_3_B() {\n\n\t\tclass Pair{\n\t\t\tprivate String name;\n\t\t\tprivate int time;\n\t\t\t\n\t\t\tpublic Pair(String name, int time) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tString getName(){\n\t\t\t\treturn this.name;\n\t\t\t}\n\n\t\t\tint getTime(){\n\t\t\t\treturn this.time;\n\t\t\t}\n\t\t}\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Pair> que = new LinkedList<Pair>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\tint[] timeAns = new int[n];\n\t\tint ans = 0;\n\t\tArrays.fill(timeAns, 0);\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}\n\n\t\tPair pair;\n\t\twhile((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}\n\t}\n\t\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tALDS1_3_B();\n\t}\n\n\tpublic static void ALDS1_3_B() {\n\n\t\tclass Pair{\n\t\t\tprivate String name;\n\t\t\tprivate int time;\n\t\t\t\n\t\t\tpublic Pair(String name, int time) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tString getName(){\n\t\t\t\treturn this.name;\n\t\t\t}\n\n\t\t\tint getTime(){\n\t\t\t\treturn this.time;\n\t\t\t}\n\t\t}\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Pair> que = new LinkedList<Pair>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\tint[] timeAns = new int[n];\n\t\tint ans = 0;\n\t\tArrays.fill(timeAns, 0);\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}\n\n\t\tPair pair;\n\t\twhile((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}\n\t}\n\t\n}",
"Main",
"public static void main(String[] args) {\n\t\tALDS1_3_B();\n\t}",
"main",
"{\n\t\tALDS1_3_B();\n\t}",
"ALDS1_3_B()",
"ALDS1_3_B",
"String[] args",
"args",
"public static void ALDS1_3_B() {\n\n\t\tclass Pair{\n\t\t\tprivate String name;\n\t\t\tprivate int time;\n\t\t\t\n\t\t\tpublic Pair(String name, int time) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tString getName(){\n\t\t\t\treturn this.name;\n\t\t\t}\n\n\t\t\tint getTime(){\n\t\t\t\treturn this.time;\n\t\t\t}\n\t\t}\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Pair> que = new LinkedList<Pair>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\tint[] timeAns = new int[n];\n\t\tint ans = 0;\n\t\tArrays.fill(timeAns, 0);\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}\n\n\t\tPair pair;\n\t\twhile((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}\n\t}",
"ALDS1_3_B",
"{\n\n\t\tclass Pair{\n\t\t\tprivate String name;\n\t\t\tprivate int time;\n\t\t\t\n\t\t\tpublic Pair(String name, int time) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tString getName(){\n\t\t\t\treturn this.name;\n\t\t\t}\n\n\t\t\tint getTime(){\n\t\t\t\treturn this.time;\n\t\t\t}\n\t\t}\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Pair> que = new LinkedList<Pair>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\tint[] timeAns = new int[n];\n\t\tint ans = 0;\n\t\tArrays.fill(timeAns, 0);\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}\n\n\t\tPair pair;\n\t\twhile((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<Pair> que = new LinkedList<Pair>();",
"que",
"new LinkedList<Pair>()",
"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",
"int[] time = new int[n];",
"time",
"new int[n]",
"n",
"int[] timeAns = new int[n];",
"timeAns",
"new int[n]",
"n",
"int ans = 0;",
"ans",
"0",
"Arrays.fill(timeAns, 0)",
"Arrays.fill",
"Arrays",
"timeAns",
"0",
"for(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\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[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}",
"{\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}",
"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",
"Pair pair = new Pair(name[i], time[i]);",
"pair",
"new Pair(name[i], time[i])",
"que.add(pair)",
"que.add",
"que",
"pair",
"Pair pair;",
"pair",
"while((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}",
"(pair = que.poll()) != null",
"(pair = que.poll())",
"pair",
"que.poll()",
"que.poll",
"que",
"null",
"{\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}",
"if(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}",
"pair.getTime() - q > 0",
"pair.getTime() - q",
"pair.getTime()",
"pair.getTime",
"pair",
"q",
"0",
"{\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}",
"Pair tmp = new Pair(pair.getName(), pair.getTime() - q);",
"tmp",
"new Pair(pair.getName(), pair.getTime() - q)",
"que.add(tmp)",
"que.add",
"que",
"tmp",
"ans += q",
"ans",
"q",
"{\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}",
"System.out.println(pair.getName() + \" \" + (pair.getTime() + ans))",
"System.out.println",
"System.out",
"System",
"System.out",
"pair.getName() + \" \" + (pair.getTime() + ans)",
"pair.getName() + \" \" + (pair.getTime() + ans)",
"pair.getName()",
"pair.getName",
"pair",
"\" \"",
"(pair.getTime() + ans)",
"pair.getTime()",
"pair.getTime",
"pair",
"ans",
"ans += pair.getTime()",
"ans",
"pair.getTime()",
"pair.getTime",
"pair",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tALDS1_3_B();\n\t}\n\n\tpublic static void ALDS1_3_B() {\n\n\t\tclass Pair{\n\t\t\tprivate String name;\n\t\t\tprivate int time;\n\t\t\t\n\t\t\tpublic Pair(String name, int time) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tString getName(){\n\t\t\t\treturn this.name;\n\t\t\t}\n\n\t\t\tint getTime(){\n\t\t\t\treturn this.time;\n\t\t\t}\n\t\t}\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Pair> que = new LinkedList<Pair>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\tint[] timeAns = new int[n];\n\t\tint ans = 0;\n\t\tArrays.fill(timeAns, 0);\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}\n\n\t\tPair pair;\n\t\twhile((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}\n\t}\n\t\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tALDS1_3_B();\n\t}\n\n\tpublic static void ALDS1_3_B() {\n\n\t\tclass Pair{\n\t\t\tprivate String name;\n\t\t\tprivate int time;\n\t\t\t\n\t\t\tpublic Pair(String name, int time) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.time = time;\n\t\t\t}\n\n\t\t\tString getName(){\n\t\t\t\treturn this.name;\n\t\t\t}\n\n\t\t\tint getTime(){\n\t\t\t\treturn this.time;\n\t\t\t}\n\t\t}\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Pair> que = new LinkedList<Pair>();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\tint[] timeAns = new int[n];\n\t\tint ans = 0;\n\t\tArrays.fill(timeAns, 0);\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tname[i] = sc.next();\n\t\t\ttime[i] = sc.nextInt();\n\t\t\tPair pair = new Pair(name[i], time[i]);\n\t\t\tque.add(pair);\n\t\t}\n\n\t\tPair pair;\n\t\twhile((pair = que.poll()) != null) {\n\t\t\tif(pair.getTime() - q > 0) {\n\t\t\t\tPair tmp = new Pair(pair.getName(), pair.getTime() - q);\n\t\t\t\tque.add(tmp);\n\t\t\t\tans += q;\n\t\t\t}else {\n\t\t\t\tSystem.out.println(pair.getName() + \" \" + (pair.getTime() + ans));\n\t\t\t\tans += pair.getTime();\n\t\t\t}\n\t\t}\n\t}\n\t\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
ALDS1_3_B();
}
public static void ALDS1_3_B() {
class Pair{
private String name;
private int time;
public Pair(String name, int time) {
this.name = name;
this.time = time;
}
String getName(){
return this.name;
}
int getTime(){
return this.time;
}
}
Scanner sc = new Scanner(System.in);
Queue<Pair> que = new LinkedList<Pair>();
int n = sc.nextInt();
int q = sc.nextInt();
String[] name = new String[n];
int[] time = new int[n];
int[] timeAns = new int[n];
int ans = 0;
Arrays.fill(timeAns, 0);
for(int i = 0; i < n; i++) {
name[i] = sc.next();
time[i] = sc.nextInt();
Pair pair = new Pair(name[i], time[i]);
que.add(pair);
}
Pair pair;
while((pair = que.poll()) != null) {
if(pair.getTime() - q > 0) {
Pair tmp = new Pair(pair.getName(), pair.getTime() - q);
que.add(tmp);
ans += q;
}else {
System.out.println(pair.getName() + " " + (pair.getTime() + ans));
ans += pair.getTime();
}
}
}
}
|
[
7,
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,
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,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
17,
41,
13,
20,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
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,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
14,
2,
13,
17,
30,
4,
18,
13,
0,
13,
17,
23,
13,
6,
13,
41,
13,
41,
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
],
[
171,
14
],
[
171,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
17,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
17,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
37,
39
],
[
17,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
17,
48
],
[
48,
49
],
[
48,
50
],
[
17,
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
],
[
63,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
63,
75
],
[
75,
76
],
[
75,
77
],
[
63,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
82,
84
],
[
63,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
92,
94
],
[
63,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
17,
99
],
[
99,
100
],
[
99,
101
],
[
17,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
108,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
114,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
123,
125
],
[
120,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
132,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
132,
137
],
[
114,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
138,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
17,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
155,
159
],
[
159,
160
],
[
159,
161
],
[
15,
162
],
[
162,
163
],
[
171,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
164,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.LinkedList;\nimport java.util.Queue;\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString line = br.readLine();\n\t\tString[] arr = line.split(\" \");\n\t\tint n = Integer.parseInt(arr[0]);\n\t\tint q = Integer.parseInt(arr[1]);\n\n\t\tQueue<Process> queue = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}\n\n\t\tint passed = 0;\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\n\t\tif (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}\n\t}\n\n\tprivate static class Process {\n\t\tpublic String name;\n\t\tpublic int time;\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"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\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString line = br.readLine();\n\t\tString[] arr = line.split(\" \");\n\t\tint n = Integer.parseInt(arr[0]);\n\t\tint q = Integer.parseInt(arr[1]);\n\n\t\tQueue<Process> queue = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}\n\n\t\tint passed = 0;\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\n\t\tif (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}\n\t}\n\n\tprivate static class Process {\n\t\tpublic String name;\n\t\tpublic int time;\n\t}\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString line = br.readLine();\n\t\tString[] arr = line.split(\" \");\n\t\tint n = Integer.parseInt(arr[0]);\n\t\tint q = Integer.parseInt(arr[1]);\n\n\t\tQueue<Process> queue = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}\n\n\t\tint passed = 0;\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\n\t\tif (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString line = br.readLine();\n\t\tString[] arr = line.split(\" \");\n\t\tint n = Integer.parseInt(arr[0]);\n\t\tint q = Integer.parseInt(arr[1]);\n\n\t\tQueue<Process> queue = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}\n\n\t\tint passed = 0;\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\n\t\tif (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String line = br.readLine();",
"line",
"br.readLine()",
"br.readLine",
"br",
"String[] arr = line.split(\" \");",
"arr",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"int n = Integer.parseInt(arr[0]);",
"n",
"Integer.parseInt(arr[0])",
"Integer.parseInt",
"Integer",
"arr[0]",
"arr",
"0",
"int q = Integer.parseInt(arr[1]);",
"q",
"Integer.parseInt(arr[1])",
"Integer.parseInt",
"Integer",
"arr[1]",
"arr",
"1",
"Queue<Process> queue = new LinkedList<Process>();",
"queue",
"new LinkedList<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\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\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}",
"{\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}",
"line = br.readLine()",
"line",
"br.readLine()",
"br.readLine",
"br",
"arr = line.split(\" \")",
"arr",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"Process p = new Process();",
"p",
"new Process()",
"p.name = arr[0]",
"p.name",
"p",
"p.name",
"arr[0]",
"arr",
"0",
"p.time = Integer.parseInt(arr[1])",
"p.time",
"p",
"p.time",
"Integer.parseInt(arr[1])",
"Integer.parseInt",
"Integer",
"arr[1]",
"arr",
"1",
"queue.offer(p)",
"queue.offer",
"queue",
"p",
"int passed = 0;",
"passed",
"0",
"while (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= 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\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= 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\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t}",
"passed += p.time",
"passed",
"p.time",
"p",
"p.time",
"System.out.println(p.name + ' ' + passed)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + ' ' + passed",
"p.name + ' ' + passed",
"p.name",
"p",
"p.name",
"' '",
"passed",
"{\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}",
"passed += q",
"passed",
"q",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"queue.offer(p)",
"queue.offer",
"queue",
"p",
"if (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}",
"br != null",
"br",
"null",
"{\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}",
"br.close()",
"br.close",
"br",
"br = null",
"br",
"null",
"String[] args",
"args",
"private static class Process {\n\t\tpublic String name;\n\t\tpublic int time;\n\t}",
"Process",
"public String name;",
"name",
"public 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\n\t\tString line = br.readLine();\n\t\tString[] arr = line.split(\" \");\n\t\tint n = Integer.parseInt(arr[0]);\n\t\tint q = Integer.parseInt(arr[1]);\n\n\t\tQueue<Process> queue = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}\n\n\t\tint passed = 0;\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\n\t\tif (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}\n\t}\n\n\tprivate static class Process {\n\t\tpublic String name;\n\t\tpublic int time;\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\n\t\tString line = br.readLine();\n\t\tString[] arr = line.split(\" \");\n\t\tint n = Integer.parseInt(arr[0]);\n\t\tint q = Integer.parseInt(arr[1]);\n\n\t\tQueue<Process> queue = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tline = br.readLine();\n\t\t\tarr = line.split(\" \");\n\t\t\tProcess p = new Process();\n\t\t\tp.name = arr[0];\n\t\t\tp.time = Integer.parseInt(arr[1]);\n\t\t\tqueue.offer(p);\n\t\t}\n\n\t\tint passed = 0;\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess p = queue.poll();\n\t\t\tif (p.time <= q) {\n\t\t\t\tpassed += p.time;\n\t\t\t\tSystem.out.println(p.name + ' ' + passed);\n\t\t\t} else {\n\t\t\t\tpassed += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tqueue.offer(p);\n\t\t\t}\n\t\t}\n\n\t\tif (br != null) {\n\t\t\tbr.close();\n\t\t\tbr = null;\n\t\t}\n\t}\n\n\tprivate static class Process {\n\t\tpublic String name;\n\t\tpublic int time;\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
String[] arr = line.split(" ");
int n = Integer.parseInt(arr[0]);
int q = Integer.parseInt(arr[1]);
Queue<Process> queue = new LinkedList<Process>();
for (int i = 0; i < n; i++) {
line = br.readLine();
arr = line.split(" ");
Process p = new Process();
p.name = arr[0];
p.time = Integer.parseInt(arr[1]);
queue.offer(p);
}
int passed = 0;
while (queue.size() > 0) {
Process p = queue.poll();
if (p.time <= q) {
passed += p.time;
System.out.println(p.name + ' ' + passed);
} else {
passed += q;
p.time -= q;
queue.offer(p);
}
}
if (br != null) {
br.close();
br = null;
}
}
private static class Process {
public String name;
public int time;
}
} |
[
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,
20,
11,
1,
41,
13,
17,
2,
13,
4,
18,
13,
18,
13,
17,
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,
17,
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,
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
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
137,
11
],
[
137,
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
],
[
14,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
40,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
50,
52
],
[
40,
53
],
[
53,
54
],
[
54,
55
],
[
40,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
60,
65
],
[
57,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
69,
70
],
[
69,
71
],
[
57,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
78,
79
],
[
78,
80
],
[
14,
81
],
[
81,
82
],
[
81,
83
],
[
14,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
84,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
89,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
100,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
106,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
114,
115
],
[
114,
116
],
[
106,
117
],
[
117,
118
],
[
117,
119
],
[
100,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
124,
129
],
[
130,
130
],
[
130,
131
],
[
130,
132
],
[
130,
133
],
[
12,
134
],
[
134,
135
],
[
0,
136
],
[
136,
137
],
[
136,
138
]
] | [
"\n\nimport java.util.LinkedList;\nimport java.util.Queue;\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\t\tString[] in = sc.nextLine().split(\" \");\n\n\t\tint cut = Integer.parseInt(in[1]);\n\t\tQueue<Integer> qu = new LinkedList<Integer>();\n\t\tQueue<String> quname = new LinkedList<String>();\n\t\tfor (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}\n\t\t}\n\t}\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\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] in = sc.nextLine().split(\" \");\n\n\t\tint cut = Integer.parseInt(in[1]);\n\t\tQueue<Integer> qu = new LinkedList<Integer>();\n\t\tQueue<String> quname = new LinkedList<String>();\n\t\tfor (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] in = sc.nextLine().split(\" \");\n\n\t\tint cut = Integer.parseInt(in[1]);\n\t\tQueue<Integer> qu = new LinkedList<Integer>();\n\t\tQueue<String> quname = new LinkedList<String>();\n\t\tfor (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] in = sc.nextLine().split(\" \");\n\n\t\tint cut = Integer.parseInt(in[1]);\n\t\tQueue<Integer> qu = new LinkedList<Integer>();\n\t\tQueue<String> quname = new LinkedList<String>();\n\t\tfor (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String[] in = sc.nextLine().split(\" \");",
"in",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"int cut = Integer.parseInt(in[1]);",
"cut",
"Integer.parseInt(in[1])",
"Integer.parseInt",
"Integer",
"in[1]",
"in",
"1",
"Queue<Integer> qu = new LinkedList<Integer>();",
"qu",
"new LinkedList<Integer>()",
"Queue<String> quname = new LinkedList<String>();",
"quname",
"new LinkedList<String>()",
"for (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}",
"int n = 0;",
"int n = 0;",
"n",
"0",
"n <Integer.parseInt(in[0])",
"n",
"Integer.parseInt(in[0])",
"Integer.parseInt",
"Integer",
"in[0]",
"in",
"0",
"n++",
"n++",
"n",
"{\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}",
"{\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}",
"String[] in2 = sc.nextLine().split(\" \");",
"in2",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"quname.offer(in2[0])",
"quname.offer",
"quname",
"in2[0]",
"in2",
"0",
"qu.offer(Integer.parseInt(in2[1]))",
"qu.offer",
"qu",
"Integer.parseInt(in2[1])",
"Integer.parseInt",
"Integer",
"in2[1]",
"in2",
"1",
"int time = 0;",
"time",
"0",
"while (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}\n\t\t}",
"!qu.isEmpty()",
"qu.isEmpty()",
"qu.isEmpty",
"qu",
"{\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}\n\t\t}",
"String name=quname.poll();",
"name",
"quname.poll()",
"quname.poll",
"quname",
"int n = qu.poll();",
"n",
"qu.poll()",
"qu.poll",
"qu",
"if (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}",
"n-cut > 0",
"n-cut",
"n",
"cut",
"0",
"{\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t}",
"quname.offer(name)",
"quname.offer",
"quname",
"name",
"qu.offer(n-cut)",
"qu.offer",
"qu",
"n-cut",
"n",
"cut",
"time += cut",
"time",
"cut",
"{\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\t\t}",
"time += n",
"time",
"n",
"System.out.println(name+\" \"+time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name+\" \"+time",
"name+\" \"+time",
"name",
"\" \"",
"time",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] in = sc.nextLine().split(\" \");\n\n\t\tint cut = Integer.parseInt(in[1]);\n\t\tQueue<Integer> qu = new LinkedList<Integer>();\n\t\tQueue<String> quname = new LinkedList<String>();\n\t\tfor (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\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 sc = new Scanner(System.in);\n\t\tString[] in = sc.nextLine().split(\" \");\n\n\t\tint cut = Integer.parseInt(in[1]);\n\t\tQueue<Integer> qu = new LinkedList<Integer>();\n\t\tQueue<String> quname = new LinkedList<String>();\n\t\tfor (int n = 0; n <Integer.parseInt(in[0]); n++) {\n\t\t\tString[] in2 = sc.nextLine().split(\" \");\n\t\t\tquname.offer(in2[0]);\n\t\t\tqu.offer(Integer.parseInt(in2[1]));\n\t\t\t\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (!qu.isEmpty()) {\n\t\t\tString name=quname.poll();\n\t\t\tint n = qu.poll();\n\t\t\tif (n-cut > 0) {\n\t\t\t\tquname.offer(name);\n\t\t\t\tqu.offer(n-cut);\n\t\t\t\t\n\t\t\t\ttime += cut;\n\t\t\t} else {\t\t\t\t\n\t\t\t\ttime += n;\n\t\t\t\tSystem.out.println(name+\" \"+time);\n\t\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) {
Scanner sc = new Scanner(System.in);
String[] in = sc.nextLine().split(" ");
int cut = Integer.parseInt(in[1]);
Queue<Integer> qu = new LinkedList<Integer>();
Queue<String> quname = new LinkedList<String>();
for (int n = 0; n <Integer.parseInt(in[0]); n++) {
String[] in2 = sc.nextLine().split(" ");
quname.offer(in2[0]);
qu.offer(Integer.parseInt(in2[1]));
}
int time = 0;
while (!qu.isEmpty()) {
String name=quname.poll();
int n = qu.poll();
if (n-cut > 0) {
quname.offer(name);
qu.offer(n-cut);
time += cut;
} else {
time += n;
System.out.println(name+" "+time);
}
}
}
}
|
[
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,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
13,
0,
13,
13,
41,
13,
17,
41,
13,
20,
41,
13,
20,
42,
2,
13,
13,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
30,
0,
13,
13,
4,
18,
13,
2,
13,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
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
],
[
151,
11
],
[
151,
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
],
[
34,
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
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
49,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
49,
61
],
[
61,
62
],
[
62,
63
],
[
61,
64
],
[
49,
65
],
[
65,
66
],
[
65,
67
],
[
14,
68
],
[
68,
69
],
[
68,
70
],
[
14,
71
],
[
71,
72
],
[
71,
73
],
[
14,
74
],
[
74,
75
],
[
74,
76
],
[
14,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
91,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
102,
103
],
[
103,
104
],
[
87,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
112,
113
],
[
112,
114
],
[
105,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
118,
119
],
[
119,
120
],
[
14,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
126,
127
],
[
126,
128
],
[
121,
129
],
[
129,
130
],
[
130,
131
],
[
121,
132
],
[
133,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
140,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
140,
144
],
[
140,
145
],
[
145,
146
],
[
146,
147
],
[
12,
148
],
[
148,
149
],
[
0,
150
],
[
150,
151
],
[
150,
152
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\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 Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n int totalTime = 0;\n for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }\n int sumTime = 0;\n Deque<String> finishName = new ArrayDeque<>();\n Deque<Integer> finishTime = new ArrayDeque<>();\n while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }\n for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }\n }\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"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 int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n int totalTime = 0;\n for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }\n int sumTime = 0;\n Deque<String> finishName = new ArrayDeque<>();\n Deque<Integer> finishTime = new ArrayDeque<>();\n while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }\n for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\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 Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n int totalTime = 0;\n for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }\n int sumTime = 0;\n Deque<String> finishName = new ArrayDeque<>();\n Deque<Integer> finishTime = new ArrayDeque<>();\n while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }\n for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n int totalTime = 0;\n for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }\n int sumTime = 0;\n Deque<String> finishName = new ArrayDeque<>();\n Deque<Integer> finishTime = new ArrayDeque<>();\n while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }\n for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\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",
"Deque<String> name = new ArrayDeque<>();",
"name",
"new ArrayDeque<>()",
"Deque<Integer> time = new ArrayDeque<>();",
"time",
"new ArrayDeque<>()",
"int totalTime = 0;",
"totalTime",
"0",
"for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }",
"{\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }",
"name.add(sc.next())",
"name.add",
"name",
"sc.next()",
"sc.next",
"sc",
"int tmp = sc.nextInt();",
"tmp",
"sc.nextInt()",
"sc.nextInt",
"sc",
"time.add(tmp)",
"time.add",
"time",
"tmp",
"totalTime += tmp",
"totalTime",
"tmp",
"int sumTime = 0;",
"sumTime",
"0",
"Deque<String> finishName = new ArrayDeque<>();",
"finishName",
"new ArrayDeque<>()",
"Deque<Integer> finishTime = new ArrayDeque<>();",
"finishTime",
"new ArrayDeque<>()",
"while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }",
"sumTime != totalTime",
"sumTime",
"totalTime",
"{\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }",
"int t = time.poll();",
"t",
"time.poll()",
"time.poll",
"time",
"if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }",
"t <= q",
"t",
"q",
"{\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }",
"sumTime += t",
"sumTime",
"t",
"finishTime.add(sumTime)",
"finishTime.add",
"finishTime",
"sumTime",
"finishName.add(name.poll())",
"finishName.add",
"finishName",
"name.poll()",
"name.poll",
"name",
"{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }",
"sumTime += q",
"sumTime",
"q",
"time.add(t - q)",
"time.add",
"time",
"t - q",
"t",
"q",
"name.add(name.poll())",
"name.add",
"name",
"name.poll()",
"name.poll",
"name",
"for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }",
"{\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }",
"System.out.println(finishName.poll() + \" \" + finishTime.poll())",
"System.out.println",
"System.out",
"System",
"System.out",
"finishName.poll() + \" \" + finishTime.poll()",
"finishName.poll() + \" \" + finishTime.poll()",
"finishName.poll()",
"finishName.poll",
"finishName",
"\" \"",
"finishTime.poll()",
"finishTime.poll",
"finishTime",
"String[] args",
"args",
"public class Main {\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 Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n int totalTime = 0;\n for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }\n int sumTime = 0;\n Deque<String> finishName = new ArrayDeque<>();\n Deque<Integer> finishTime = new ArrayDeque<>();\n while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }\n for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }\n }\n}",
"public class Main {\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 Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n int totalTime = 0;\n for(int i = 0; i < n; i++){\n name.add(sc.next());\n int tmp = sc.nextInt();\n time.add(tmp);\n totalTime += tmp;\n }\n int sumTime = 0;\n Deque<String> finishName = new ArrayDeque<>();\n Deque<Integer> finishTime = new ArrayDeque<>();\n while(sumTime != totalTime){\n int t = time.poll();\n if(t <= q){\n sumTime += t;\n finishTime.add(sumTime);\n finishName.add(name.poll());\n }else{\n sumTime += q;\n time.add(t - q);\n name.add(name.poll());\n }\n }\n for(int i = 0; i < n; i++){\n System.out.println(finishName.poll() + \" \" + finishTime.poll());\n }\n }\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Deque;
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();
Deque<String> name = new ArrayDeque<>();
Deque<Integer> time = new ArrayDeque<>();
int totalTime = 0;
for(int i = 0; i < n; i++){
name.add(sc.next());
int tmp = sc.nextInt();
time.add(tmp);
totalTime += tmp;
}
int sumTime = 0;
Deque<String> finishName = new ArrayDeque<>();
Deque<Integer> finishTime = new ArrayDeque<>();
while(sumTime != totalTime){
int t = time.poll();
if(t <= q){
sumTime += t;
finishTime.add(sumTime);
finishName.add(name.poll());
}else{
sumTime += q;
time.add(t - q);
name.add(name.poll());
}
}
for(int i = 0; i < n; i++){
System.out.println(finishName.poll() + " " + finishTime.poll());
}
}
}
|
[
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,
20,
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,
20,
41,
13,
17,
41,
13,
17,
42,
17,
30,
14,
2,
13,
13,
3,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
40,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
4,
18,
13,
2,
13,
13,
0,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
0,
13,
17,
0,
13,
20,
13,
0,
18,
36,
13,
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,
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
],
[
236,
8
],
[
236,
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
],
[
11,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
11,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
42,
47
],
[
47,
48
],
[
47,
49
],
[
42,
50
],
[
50,
51
],
[
51,
52
],
[
42,
53
],
[
54,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
57,
62
],
[
54,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
11,
67
],
[
67,
68
],
[
67,
69
],
[
11,
70
],
[
70,
71
],
[
70,
72
],
[
11,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
75,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
75,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
75,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
107,
111
],
[
107,
112
],
[
91,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
117,
119
],
[
113,
120
],
[
120,
121
],
[
120,
122
],
[
113,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
9,
127
],
[
127,
128
],
[
0,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
129,
133
],
[
133,
134
],
[
129,
135
],
[
135,
136
],
[
129,
137
],
[
137,
138
],
[
129,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
141,
147
],
[
147,
148
],
[
147,
149
],
[
141,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
139,
156
],
[
156,
157
],
[
129,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
160,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
158,
173
],
[
173,
174
],
[
129,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
180,
182
],
[
177,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
185,
189
],
[
177,
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
],
[
0,
235
],
[
235,
236
],
[
235,
237
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws Exception{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[] = r.readLine().split(\" \");\n\t\tint max = Integer.parseInt(str[0]);\n\t\tQueue q = new Queue(max);\n\t\tint qtime = Integer.parseInt(str[1]);\n\n\t\tfor(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}\n\n\t\tint elapsedTime = 0;\n\n\t\tint count = 0;\n\t\t//?????\\?????ยฌ????????ยง???\n\t\twhile(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}\n\t}\n\n}\n\nclass Queue{\n\n\tProcess[] processAry;\n\tint top;\n\tint tail;\n\tint max;\n\n\tpublic Queue(int max){\n\t\ttop = tail = 0;\n\t\tprocessAry = new Process[max];\n\t\tthis.max = max;\n\t}\n\n\tpublic void enqueue(Process process) throws Exception{\n\t\t\tprocessAry[top] = process;\n\t\t\ttop = (top + 1) % max;\n\t}\n\n\tpublic Process dequeue() throws Exception{\n\n\t\t\tProcess p = processAry[tail];\n\t\t\ttail = (tail + 1) % max;\n\t\t\treturn p;\n\n\t}\n\n}\n\nclass Process{\n\tprivate String name;\n\tprivate int time;\n\n\tpublic Process(String name,int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[] = r.readLine().split(\" \");\n\t\tint max = Integer.parseInt(str[0]);\n\t\tQueue q = new Queue(max);\n\t\tint qtime = Integer.parseInt(str[1]);\n\n\t\tfor(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}\n\n\t\tint elapsedTime = 0;\n\n\t\tint count = 0;\n\t\t//?????\\?????ยฌ????????ยง???\n\t\twhile(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws Exception{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[] = r.readLine().split(\" \");\n\t\tint max = Integer.parseInt(str[0]);\n\t\tQueue q = new Queue(max);\n\t\tint qtime = Integer.parseInt(str[1]);\n\n\t\tfor(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}\n\n\t\tint elapsedTime = 0;\n\n\t\tint count = 0;\n\t\t//?????\\?????ยฌ????????ยง???\n\t\twhile(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[] = r.readLine().split(\" \");\n\t\tint max = Integer.parseInt(str[0]);\n\t\tQueue q = new Queue(max);\n\t\tint qtime = Integer.parseInt(str[1]);\n\n\t\tfor(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}\n\n\t\tint elapsedTime = 0;\n\n\t\tint count = 0;\n\t\t//?????\\?????ยฌ????????ยง???\n\t\twhile(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}\n\t}",
"BufferedReader r = new BufferedReader(new InputStreamReader(System.in));",
"r",
"new BufferedReader(new InputStreamReader(System.in))",
"String str[] = r.readLine().split(\" \");",
"str",
"r.readLine().split(\" \")",
"r.readLine().split",
"r.readLine()",
"r.readLine",
"r",
"\" \"",
"int max = Integer.parseInt(str[0]);",
"max",
"Integer.parseInt(str[0])",
"Integer.parseInt",
"Integer",
"str[0]",
"str",
"0",
"Queue q = new Queue(max);",
"q",
"new Queue(max)",
"int qtime = Integer.parseInt(str[1]);",
"qtime",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"for(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}",
"int i = 0 ;",
"int i = 0 ;",
"i",
"0",
"i < max",
"i",
"max",
"i++",
"i++",
"i",
"{\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}",
"{\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}",
"str = r.readLine().split(\" \")",
"str",
"r.readLine().split(\" \")",
"r.readLine().split",
"r.readLine()",
"r.readLine",
"r",
"\" \"",
"q.enqueue(new Process(str[0], Integer.parseInt(str[1])))",
"q.enqueue",
"q",
"new Process(str[0], Integer.parseInt(str[1]))",
"int elapsedTime = 0;",
"elapsedTime",
"0",
"int count = 0;",
"count",
"0",
"while(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}",
"true",
"{\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}",
"if(max <= count) break;",
"max <= count",
"max",
"count",
"break;",
"Process p = q.dequeue();",
"p",
"q.dequeue()",
"q.dequeue",
"q",
"int time = p.getTime();",
"time",
"p.getTime()",
"p.getTime",
"p",
"if(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}",
"time <= qtime",
"time",
"qtime",
"{\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}",
"elapsedTime+= time",
"elapsedTime",
"time",
"count++",
"count",
"System.out.println(p.getName() +\" \"+elapsedTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getName() +\" \"+elapsedTime",
"p.getName() +\" \"+elapsedTime",
"p.getName()",
"p.getName",
"p",
"\" \"",
"elapsedTime",
"{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}",
"p.setTime(time - qtime)",
"p.setTime",
"p",
"time - qtime",
"time",
"qtime",
"elapsedTime += qtime",
"elapsedTime",
"qtime",
"q.enqueue(p)",
"q.enqueue",
"q",
"p",
"String[] args",
"args",
"class Queue{\n\n\tProcess[] processAry;\n\tint top;\n\tint tail;\n\tint max;\n\n\tpublic Queue(int max){\n\t\ttop = tail = 0;\n\t\tprocessAry = new Process[max];\n\t\tthis.max = max;\n\t}\n\n\tpublic void enqueue(Process process) throws Exception{\n\t\t\tprocessAry[top] = process;\n\t\t\ttop = (top + 1) % max;\n\t}\n\n\tpublic Process dequeue() throws Exception{\n\n\t\t\tProcess p = processAry[tail];\n\t\t\ttail = (tail + 1) % max;\n\t\t\treturn p;\n\n\t}\n\n}",
"Queue",
"Process[] processAry;",
"processAry",
"int top;",
"top",
"int tail;",
"tail",
"int max;",
"max",
"public Queue(int max){\n\t\ttop = tail = 0;\n\t\tprocessAry = new Process[max];\n\t\tthis.max = max;\n\t}",
"Queue",
"{\n\t\ttop = tail = 0;\n\t\tprocessAry = new Process[max];\n\t\tthis.max = max;\n\t}",
"top = tail = 0",
"top",
"tail = 0",
"tail",
"0",
"processAry = new Process[max]",
"processAry",
"new Process[max]",
"max",
"this.max = max",
"this.max",
"this",
"this.max",
"max",
"int max",
"max",
"public void enqueue(Process process) throws Exception{\n\t\t\tprocessAry[top] = process;\n\t\t\ttop = (top + 1) % max;\n\t}",
"enqueue",
"{\n\t\t\tprocessAry[top] = process;\n\t\t\ttop = (top + 1) % max;\n\t}",
"processAry[top] = process",
"processAry[top]",
"processAry",
"top",
"process",
"top = (top + 1) % max",
"top",
"(top + 1) % max",
"(top + 1)",
"top",
"1",
"max",
"Process process",
"process",
"public Process dequeue() throws Exception{\n\n\t\t\tProcess p = processAry[tail];\n\t\t\ttail = (tail + 1) % max;\n\t\t\treturn p;\n\n\t}",
"dequeue",
"{\n\n\t\t\tProcess p = processAry[tail];\n\t\t\ttail = (tail + 1) % max;\n\t\t\treturn p;\n\n\t}",
"Process p = processAry[tail];",
"p",
"processAry[tail]",
"processAry",
"tail",
"tail = (tail + 1) % max",
"tail",
"(tail + 1) % max",
"(tail + 1)",
"tail",
"1",
"max",
"return p;",
"p",
"class Process{\n\tprivate String name;\n\tprivate int time;\n\n\tpublic Process(String name,int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\n}",
"Process",
"private String name;",
"name",
"private 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 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\n\tpublic static void main(String[] args) throws Exception{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[] = r.readLine().split(\" \");\n\t\tint max = Integer.parseInt(str[0]);\n\t\tQueue q = new Queue(max);\n\t\tint qtime = Integer.parseInt(str[1]);\n\n\t\tfor(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}\n\n\t\tint elapsedTime = 0;\n\n\t\tint count = 0;\n\t\t//?????\\?????ยฌ????????ยง???\n\t\twhile(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws Exception{\n\t\tBufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str[] = r.readLine().split(\" \");\n\t\tint max = Integer.parseInt(str[0]);\n\t\tQueue q = new Queue(max);\n\t\tint qtime = Integer.parseInt(str[1]);\n\n\t\tfor(int i = 0 ; i < max ; i++ ){\n\t\t\tstr = r.readLine().split(\" \");\n\t\t\tq.enqueue(new Process(str[0], Integer.parseInt(str[1])));\n\t\t}\n\n\t\tint elapsedTime = 0;\n\n\t\tint count = 0;\n\t\t//?????\\?????ยฌ????????ยง???\n\t\twhile(true){\n\t\t\tif(max <= count) break;\n\t\t\tProcess p = q.dequeue();\n\t\t\tint time = p.getTime();\n\n\t\t\tif(time <= qtime){\n\t\t\t\telapsedTime+= time;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(p.getName() +\" \"+elapsedTime);\n\t\t\t}else{\n\t\t\t\tp.setTime(time - qtime);\n\t\t\t\telapsedTime += qtime;\n\t\t\t\tq.enqueue(p);\n\t\t\t}\n\n\t\t}\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception{
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
String str[] = r.readLine().split(" ");
int max = Integer.parseInt(str[0]);
Queue q = new Queue(max);
int qtime = Integer.parseInt(str[1]);
for(int i = 0 ; i < max ; i++ ){
str = r.readLine().split(" ");
q.enqueue(new Process(str[0], Integer.parseInt(str[1])));
}
int elapsedTime = 0;
int count = 0;
//?????\?????ยฌ????????ยง???
while(true){
if(max <= count) break;
Process p = q.dequeue();
int time = p.getTime();
if(time <= qtime){
elapsedTime+= time;
count++;
System.out.println(p.getName() +" "+elapsedTime);
}else{
p.setTime(time - qtime);
elapsedTime += qtime;
q.enqueue(p);
}
}
}
}
class Queue{
Process[] processAry;
int top;
int tail;
int max;
public Queue(int max){
top = tail = 0;
processAry = new Process[max];
this.max = max;
}
public void enqueue(Process process) throws Exception{
processAry[top] = process;
top = (top + 1) % max;
}
public Process dequeue() throws Exception{
Process p = processAry[tail];
tail = (tail + 1) % max;
return p;
}
}
class Process{
private String name;
private int time;
public Process(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,
15,
13,
17,
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,
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,
41,
13,
13,
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,
18,
13,
17,
4,
18,
13,
18,
13,
17,
42,
17,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
2,
4,
18,
13,
13,
13,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
13,
4,
18,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
4,
18,
13,
13,
40,
13,
14,
2,
13,
17,
3,
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
],
[
25,
26
],
[
25,
27
],
[
0,
28
],
[
28,
29
],
[
28,
30
],
[
0,
31
],
[
31,
32
],
[
31,
33
],
[
0,
34
],
[
34,
35
],
[
34,
36
],
[
0,
37
],
[
188,
38
],
[
188,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
47,
52
],
[
41,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
58,
60
],
[
41,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
66,
67
],
[
66,
68
],
[
41,
69
],
[
69,
70
],
[
69,
71
],
[
41,
72
],
[
72,
73
],
[
72,
74
],
[
41,
75
],
[
75,
76
],
[
75,
77
],
[
41,
78
],
[
78,
79
],
[
78,
80
],
[
41,
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
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
96,
101
],
[
93,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
105,
106
],
[
105,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
108,
111
],
[
111,
112
],
[
111,
113
],
[
93,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
117,
119
],
[
41,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
126,
127
],
[
122,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
129,
134
],
[
128,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
139,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
143,
148
],
[
135,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
128,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
156,
159
],
[
153,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
160,
164
],
[
153,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
165,
170
],
[
171,
171
],
[
171,
172
],
[
171,
173
],
[
171,
174
],
[
174,
175
],
[
175,
176
],
[
174,
177
],
[
153,
178
],
[
178,
179
],
[
122,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
39,
185
],
[
185,
186
],
[
0,
187
],
[
187,
188
],
[
187,
189
]
] | [
"import java.io.*;\nimport java.util.*;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Stack;\nimport java.util.regex.Matcher;\nimport java.util.regex.Pattern;\nimport java.util.Queue;\nimport java.util.ArrayDeque;\nimport java.util.Map;\nimport java.util.LinkedList;\n\npublic class Main{\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n LinkedList<String> queue = new LinkedList<String>();\n int time = 0;\n int cnt = n;\n Map<String, Integer> map = new HashMap<>();\n\n for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }\n\n while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.Stack;",
"Stack",
"java.util",
"import java.util.regex.Matcher;",
"Matcher",
"java.util.regex",
"import java.util.regex.Pattern;",
"Pattern",
"java.util.regex",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Map;",
"Map",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"public class Main{\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n LinkedList<String> queue = new LinkedList<String>();\n int time = 0;\n int cnt = n;\n Map<String, Integer> map = new HashMap<>();\n\n for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }\n\n while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n LinkedList<String> queue = new LinkedList<String>();\n int time = 0;\n int cnt = n;\n Map<String, Integer> map = new HashMap<>();\n\n for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }\n\n while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n LinkedList<String> queue = new LinkedList<String>();\n int time = 0;\n int cnt = n;\n Map<String, Integer> map = new HashMap<>();\n\n for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }\n\n while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] line = br.readLine().split(\" \");",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"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",
"LinkedList<String> queue = new LinkedList<String>();",
"queue",
"new LinkedList<String>()",
"int time = 0;",
"time",
"0",
"int cnt = n;",
"cnt",
"n",
"Map<String, Integer> map = new HashMap<>();",
"map",
"new HashMap<>()",
"for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }",
"{\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }",
"line = br.readLine().split(\" \")",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"map.put(line[0], Integer.parseInt(line[1]))",
"map.put",
"map",
"line[0]",
"line",
"0",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"queue.add(line[0])",
"queue.add",
"queue",
"line[0]",
"line",
"0",
"while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }",
"true",
"{\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }",
"String x = queue.poll();",
"x",
"queue.poll()",
"queue.poll",
"queue",
"if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }",
"map.get(x) > q",
"map.get(x)",
"map.get",
"map",
"x",
"q",
"{\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }",
"time += q",
"time",
"q",
"map.put(x, map.get(x) - q)",
"map.put",
"map",
"x",
"map.get(x) - q",
"map.get(x)",
"map.get",
"map",
"x",
"q",
"queue.add(x)",
"queue.add",
"queue",
"x",
"{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }",
"time += map.get(x)",
"time",
"map.get(x)",
"map.get",
"map",
"x",
"map.put(x, time)",
"map.put",
"map",
"x",
"time",
"System.out.println(x + \" \" + map.get(x))",
"System.out.println",
"System.out",
"System",
"System.out",
"x + \" \" + map.get(x)",
"x + \" \" + map.get(x)",
"x",
"\" \"",
"map.get(x)",
"map.get",
"map",
"x",
"n--",
"n",
"if(n == 0) break;",
"n == 0",
"n",
"0",
"break;",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n LinkedList<String> queue = new LinkedList<String>();\n int time = 0;\n int cnt = n;\n Map<String, Integer> map = new HashMap<>();\n\n for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }\n\n while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }\n }\n}",
"public class Main{\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n LinkedList<String> queue = new LinkedList<String>();\n int time = 0;\n int cnt = n;\n Map<String, Integer> map = new HashMap<>();\n\n for(int i = 0; i < n; i++){\n line = br.readLine().split(\" \");\n map.put(line[0], Integer.parseInt(line[1]));\n queue.add(line[0]);\n }\n\n while(true){\n String x = queue.poll();\n if(map.get(x) > q){\n time += q;\n map.put(x, map.get(x) - q);\n queue.add(x);\n }else{\n time += map.get(x);\n map.put(x, time);\n System.out.println(x + \" \" + map.get(x));\n n--;\n }\n if(n == 0) break;\n }\n }\n}",
"Main"
] | import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Map;
import java.util.LinkedList;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] line = br.readLine().split(" ");
int n = Integer.parseInt(line[0]);
int q = Integer.parseInt(line[1]);
LinkedList<String> queue = new LinkedList<String>();
int time = 0;
int cnt = n;
Map<String, Integer> map = new HashMap<>();
for(int i = 0; i < n; i++){
line = br.readLine().split(" ");
map.put(line[0], Integer.parseInt(line[1]));
queue.add(line[0]);
}
while(true){
String x = queue.poll();
if(map.get(x) > q){
time += q;
map.put(x, map.get(x) - q);
queue.add(x);
}else{
time += map.get(x);
map.put(x, time);
System.out.println(x + " " + map.get(x));
n--;
}
if(n == 0) break;
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
20,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
2,
13,
17,
0,
18,
36,
13,
17,
23,
13,
12,
13,
30,
40,
18,
36,
13,
40,
18,
36,
13,
14,
2,
18,
36,
13,
18,
36,
13,
30,
0,
18,
36,
13,
17,
0,
18,
18,
36,
13,
18,
36,
13,
13,
23,
13,
12,
13,
30,
14,
2,
18,
36,
13,
17,
30,
29,
40,
17,
41,
13,
2,
2,
18,
36,
13,
18,
36,
13,
17,
14,
2,
13,
17,
30,
0,
13,
18,
36,
13,
41,
13,
18,
18,
36,
13,
13,
40,
18,
36,
13,
29,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
17,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
18,
13,
17,
4,
18,
20,
13,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
13,
41,
13,
42,
2,
0,
13,
4,
18,
13,
17,
30,
14,
2,
18,
13,
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,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
23,
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
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
16,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
16,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
28,
32
],
[
32,
33
],
[
32,
34
],
[
16,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
14,
40
],
[
40,
41
],
[
4,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
44,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
44,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
58,
60
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
44,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
72,
74
],
[
67,
75
],
[
42,
76
],
[
76,
77
],
[
4,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
80,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
80,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
80,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
80,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
80,
123
],
[
123,
124
],
[
0,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
135,
140
],
[
135,
141
],
[
129,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
147,
148
],
[
147,
149
],
[
129,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
155,
156
],
[
155,
157
],
[
129,
158
],
[
158,
159
],
[
158,
160
],
[
129,
162
],
[
162,
163
],
[
162,
164
],
[
129,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
166,
171
],
[
171,
172
],
[
171,
173
],
[
166,
174
],
[
174,
175
],
[
175,
176
],
[
166,
177
],
[
178,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
181,
186
],
[
181,
187
],
[
178,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
188,
192
],
[
192,
193
],
[
192,
194
],
[
178,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
199
],
[
199,
200
],
[
200,
201
],
[
199,
202
],
[
202,
203
],
[
202,
204
],
[
129,
205
],
[
205,
206
],
[
206,
207
],
[
205,
208
],
[
205,
209
],
[
205,
210
],
[
205,
211
],
[
127,
212
],
[
212,
213
],
[
125,
214
],
[
214,
215
],
[
214,
216
],
[
216,
217
],
[
217,
218
],
[
217,
219
],
[
216,
220
],
[
220,
221
],
[
220,
222
],
[
216,
223
],
[
223,
224
],
[
224,
225
],
[
225,
226
],
[
225,
227
],
[
223,
228
],
[
228,
229
],
[
228,
230
],
[
223,
231
],
[
231,
232
],
[
232,
233
],
[
223,
234
],
[
235,
235
],
[
235,
236
],
[
236,
237
],
[
237,
238
],
[
236,
239
],
[
216,
240
],
[
240,
241
],
[
216,
242
],
[
242,
243
],
[
243,
244
],
[
244,
245
],
[
244,
246
],
[
246,
247
],
[
247,
248
],
[
243,
249
],
[
242,
250
],
[
250,
251
],
[
251,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
252,
256
],
[
251,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
260,
261
],
[
260,
262
],
[
257,
263
],
[
263,
264
],
[
264,
265
],
[
265,
266
],
[
265,
267
],
[
263,
268
],
[
268,
269
],
[
268,
270
],
[
257,
271
],
[
271,
272
],
[
272,
273
],
[
273,
274
],
[
273,
275
],
[
271,
276
],
[
257,
277
],
[
277,
278
],
[
278,
279
],
[
279,
280
],
[
279,
281
],
[
277,
282
],
[
251,
283
],
[
283,
284
],
[
284,
285
],
[
284,
286
],
[
283,
287
],
[
287,
288
],
[
288,
289
],
[
288,
290
],
[
287,
291
],
[
283,
292
],
[
292,
293
],
[
293,
294
],
[
292,
295
],
[
214,
296
],
[
296,
297
],
[
214,
298
],
[
298,
299
],
[
214,
300
],
[
300,
301
],
[
214,
302
],
[
302,
303
]
] | [
"import java.util.Scanner;\n\nclass Queue {\n int[] data;\n int maxLen;\n int lastEnqueue;\n int queueSize;\n\n public Queue(int maxLen) {\n this.data = new int[maxLen];\n this.maxLen = maxLen;\n this.lastEnqueue = maxLen - 1;\n this.queueSize = 0;\n }\n\n public void enqueue(int num) {\n this.queueSize++;\n this.lastEnqueue++;\n if (this.lastEnqueue >= this.maxLen) {\n this.lastEnqueue = 0;\n }\n this.data[this.lastEnqueue] = num;\n }\n\n public int dequeue() {\n if (this.queueSize == 0) {\n return -1;\n }\n\n int dequeueIndex = this.lastEnqueue - this.queueSize + 1;\n if (dequeueIndex < 0) {\n dequeueIndex += this.maxLen;\n }\n int num = this.data[dequeueIndex];\n this.queueSize--;\n return num;\n }\n}\n\nclass Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] nq = scanner.nextLine().split(\" \", 2);\n int n = Integer.parseInt(nq[0]); // num processes\n int q = Integer.parseInt(nq[1]); // quoantum number\n\n String[] names = new String[n];\n int[] times = new int[n];\n for (int i = 0; i < n; i++) {\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }\n\n new Main().printProcessFinishes(n, q, names, times);\n }\n\n private void printProcessFinishes(int n, int q, String[] names, int[] times) {\n int now = 0;\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n queue.enqueue(i);\n }\n\n int dequeued;\n while ((dequeued = queue.dequeue()) >= 0) {\n if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }\n }\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Queue {\n int[] data;\n int maxLen;\n int lastEnqueue;\n int queueSize;\n\n public Queue(int maxLen) {\n this.data = new int[maxLen];\n this.maxLen = maxLen;\n this.lastEnqueue = maxLen - 1;\n this.queueSize = 0;\n }\n\n public void enqueue(int num) {\n this.queueSize++;\n this.lastEnqueue++;\n if (this.lastEnqueue >= this.maxLen) {\n this.lastEnqueue = 0;\n }\n this.data[this.lastEnqueue] = num;\n }\n\n public int dequeue() {\n if (this.queueSize == 0) {\n return -1;\n }\n\n int dequeueIndex = this.lastEnqueue - this.queueSize + 1;\n if (dequeueIndex < 0) {\n dequeueIndex += this.maxLen;\n }\n int num = this.data[dequeueIndex];\n this.queueSize--;\n return num;\n }\n}",
"Queue",
"int[] data;",
"data",
"int maxLen;",
"maxLen",
"int lastEnqueue;",
"lastEnqueue",
"int queueSize;",
"queueSize",
"public Queue(int maxLen) {\n this.data = new int[maxLen];\n this.maxLen = maxLen;\n this.lastEnqueue = maxLen - 1;\n this.queueSize = 0;\n }",
"Queue",
"{\n this.data = new int[maxLen];\n this.maxLen = maxLen;\n this.lastEnqueue = maxLen - 1;\n this.queueSize = 0;\n }",
"this.data = new int[maxLen]",
"this.data",
"this",
"this.data",
"new int[maxLen]",
"maxLen",
"this.maxLen = maxLen",
"this.maxLen",
"this",
"this.maxLen",
"maxLen",
"this.lastEnqueue = maxLen - 1",
"this.lastEnqueue",
"this",
"this.lastEnqueue",
"maxLen - 1",
"maxLen",
"1",
"this.queueSize = 0",
"this.queueSize",
"this",
"this.queueSize",
"0",
"int maxLen",
"maxLen",
"public void enqueue(int num) {\n this.queueSize++;\n this.lastEnqueue++;\n if (this.lastEnqueue >= this.maxLen) {\n this.lastEnqueue = 0;\n }\n this.data[this.lastEnqueue] = num;\n }",
"enqueue",
"{\n this.queueSize++;\n this.lastEnqueue++;\n if (this.lastEnqueue >= this.maxLen) {\n this.lastEnqueue = 0;\n }\n this.data[this.lastEnqueue] = num;\n }",
"this.queueSize++",
"this.queueSize",
"this",
"this.queueSize",
"this.lastEnqueue++",
"this.lastEnqueue",
"this",
"this.lastEnqueue",
"if (this.lastEnqueue >= this.maxLen) {\n this.lastEnqueue = 0;\n }",
"this.lastEnqueue >= this.maxLen",
"this.lastEnqueue",
"this",
"this.lastEnqueue",
"this.maxLen",
"this",
"this.maxLen",
"{\n this.lastEnqueue = 0;\n }",
"this.lastEnqueue = 0",
"this.lastEnqueue",
"this",
"this.lastEnqueue",
"0",
"this.data[this.lastEnqueue] = num",
"this.data[this.lastEnqueue]",
"this.data",
"this",
"this.data",
"this.lastEnqueue",
"this",
"this.lastEnqueue",
"num",
"int num",
"num",
"public int dequeue() {\n if (this.queueSize == 0) {\n return -1;\n }\n\n int dequeueIndex = this.lastEnqueue - this.queueSize + 1;\n if (dequeueIndex < 0) {\n dequeueIndex += this.maxLen;\n }\n int num = this.data[dequeueIndex];\n this.queueSize--;\n return num;\n }",
"dequeue",
"{\n if (this.queueSize == 0) {\n return -1;\n }\n\n int dequeueIndex = this.lastEnqueue - this.queueSize + 1;\n if (dequeueIndex < 0) {\n dequeueIndex += this.maxLen;\n }\n int num = this.data[dequeueIndex];\n this.queueSize--;\n return num;\n }",
"if (this.queueSize == 0) {\n return -1;\n }",
"this.queueSize == 0",
"this.queueSize",
"this",
"this.queueSize",
"0",
"{\n return -1;\n }",
"return -1;",
"-1",
"1",
"int dequeueIndex = this.lastEnqueue - this.queueSize + 1;",
"dequeueIndex",
"this.lastEnqueue - this.queueSize + 1",
"this.lastEnqueue - this.queueSize",
"this.lastEnqueue",
"this",
"this.lastEnqueue",
"this.queueSize",
"this",
"this.queueSize",
"1",
"if (dequeueIndex < 0) {\n dequeueIndex += this.maxLen;\n }",
"dequeueIndex < 0",
"dequeueIndex",
"0",
"{\n dequeueIndex += this.maxLen;\n }",
"dequeueIndex += this.maxLen",
"dequeueIndex",
"this.maxLen",
"this",
"this.maxLen",
"int num = this.data[dequeueIndex];",
"num",
"this.data[dequeueIndex]",
"this.data",
"this",
"this.data",
"dequeueIndex",
"this.queueSize--",
"this.queueSize",
"this",
"this.queueSize",
"return num;",
"num",
"class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] nq = scanner.nextLine().split(\" \", 2);\n int n = Integer.parseInt(nq[0]); // num processes\n int q = Integer.parseInt(nq[1]); // quoantum number\n\n String[] names = new String[n];\n int[] times = new int[n];\n for (int i = 0; i < n; i++) {\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }\n\n new Main().printProcessFinishes(n, q, names, times);\n }\n\n private void printProcessFinishes(int n, int q, String[] names, int[] times) {\n int now = 0;\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n queue.enqueue(i);\n }\n\n int dequeued;\n while ((dequeued = queue.dequeue()) >= 0) {\n if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n String[] nq = scanner.nextLine().split(\" \", 2);\n int n = Integer.parseInt(nq[0]); // num processes\n int q = Integer.parseInt(nq[1]); // quoantum number\n\n String[] names = new String[n];\n int[] times = new int[n];\n for (int i = 0; i < n; i++) {\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }\n\n new Main().printProcessFinishes(n, q, names, times);\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n String[] nq = scanner.nextLine().split(\" \", 2);\n int n = Integer.parseInt(nq[0]); // num processes\n int q = Integer.parseInt(nq[1]); // quoantum number\n\n String[] names = new String[n];\n int[] times = new int[n];\n for (int i = 0; i < n; i++) {\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }\n\n new Main().printProcessFinishes(n, q, names, times);\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"String[] nq = scanner.nextLine().split(\" \", 2);",
"nq",
"scanner.nextLine().split(\" \", 2)",
"scanner.nextLine().split",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"\" \"",
"2",
"int n = Integer.parseInt(nq[0]);",
"n",
"Integer.parseInt(nq[0])",
"Integer.parseInt",
"Integer",
"nq[0]",
"nq",
"0",
"int q = Integer.parseInt(nq[1]);",
"q",
"Integer.parseInt(nq[1])",
"Integer.parseInt",
"Integer",
"nq[1]",
"nq",
"1",
"String[] names = new String[n];",
"names",
"new String[n]",
"n",
"int[] times = new int[n];",
"times",
"new int[n]",
"n",
"for (int i = 0; i < n; i++) {\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }",
"{\n String[] nameTime = scanner.nextLine().split(\" \", 2);\n names[i] = nameTime[0];\n times[i] = Integer.parseInt(nameTime[1]);\n }",
"String[] nameTime = scanner.nextLine().split(\" \", 2);",
"nameTime",
"scanner.nextLine().split(\" \", 2)",
"scanner.nextLine().split",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"\" \"",
"2",
"names[i] = nameTime[0]",
"names[i]",
"names",
"i",
"nameTime[0]",
"nameTime",
"0",
"times[i] = Integer.parseInt(nameTime[1])",
"times[i]",
"times",
"i",
"Integer.parseInt(nameTime[1])",
"Integer.parseInt",
"Integer",
"nameTime[1]",
"nameTime",
"1",
"new Main().printProcessFinishes(n, q, names, times)",
"new Main().printProcessFinishes",
"new Main()",
"n",
"q",
"names",
"times",
"String[] args",
"args",
"private void printProcessFinishes(int n, int q, String[] names, int[] times) {\n int now = 0;\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n queue.enqueue(i);\n }\n\n int dequeued;\n while ((dequeued = queue.dequeue()) >= 0) {\n if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }\n }\n }",
"printProcessFinishes",
"{\n int now = 0;\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n queue.enqueue(i);\n }\n\n int dequeued;\n while ((dequeued = queue.dequeue()) >= 0) {\n if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }\n }\n }",
"int now = 0;",
"now",
"0",
"Queue queue = new Queue(n);",
"queue",
"new Queue(n)",
"for (int i = 0; i < n; i++) {\n queue.enqueue(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.enqueue(i);\n }",
"{\n queue.enqueue(i);\n }",
"queue.enqueue(i)",
"queue.enqueue",
"queue",
"i",
"int dequeued;",
"dequeued",
"while ((dequeued = queue.dequeue()) >= 0) {\n if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }\n }",
"(dequeued = queue.dequeue()) >= 0",
"(dequeued = queue.dequeue())",
"dequeued",
"queue.dequeue()",
"queue.dequeue",
"queue",
"0",
"{\n if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }\n }",
"if (times[dequeued] <= q) {\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n } else {\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }",
"times[dequeued] <= q",
"times[dequeued]",
"times",
"dequeued",
"q",
"{\n now += times[dequeued];\n System.out.print(names[dequeued]);\n System.out.print(\" \");\n System.out.println(now);\n }",
"now += times[dequeued]",
"now",
"times[dequeued]",
"times",
"dequeued",
"System.out.print(names[dequeued])",
"System.out.print",
"System.out",
"System",
"System.out",
"names[dequeued]",
"names",
"dequeued",
"System.out.print(\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"\" \"",
"System.out.println(now)",
"System.out.println",
"System.out",
"System",
"System.out",
"now",
"{\n now += q;\n times[dequeued] -= q;\n queue.enqueue(dequeued);\n }",
"now += q",
"now",
"q",
"times[dequeued] -= q",
"times[dequeued]",
"times",
"dequeued",
"q",
"queue.enqueue(dequeued)",
"queue.enqueue",
"queue",
"dequeued",
"int n",
"n",
"int q",
"q",
"String[] names",
"names",
"int[] times",
"times"
] | import java.util.Scanner;
class Queue {
int[] data;
int maxLen;
int lastEnqueue;
int queueSize;
public Queue(int maxLen) {
this.data = new int[maxLen];
this.maxLen = maxLen;
this.lastEnqueue = maxLen - 1;
this.queueSize = 0;
}
public void enqueue(int num) {
this.queueSize++;
this.lastEnqueue++;
if (this.lastEnqueue >= this.maxLen) {
this.lastEnqueue = 0;
}
this.data[this.lastEnqueue] = num;
}
public int dequeue() {
if (this.queueSize == 0) {
return -1;
}
int dequeueIndex = this.lastEnqueue - this.queueSize + 1;
if (dequeueIndex < 0) {
dequeueIndex += this.maxLen;
}
int num = this.data[dequeueIndex];
this.queueSize--;
return num;
}
}
class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] nq = scanner.nextLine().split(" ", 2);
int n = Integer.parseInt(nq[0]); // num processes
int q = Integer.parseInt(nq[1]); // quoantum number
String[] names = new String[n];
int[] times = new int[n];
for (int i = 0; i < n; i++) {
String[] nameTime = scanner.nextLine().split(" ", 2);
names[i] = nameTime[0];
times[i] = Integer.parseInt(nameTime[1]);
}
new Main().printProcessFinishes(n, q, names, times);
}
private void printProcessFinishes(int n, int q, String[] names, int[] times) {
int now = 0;
Queue queue = new Queue(n);
for (int i = 0; i < n; i++) {
queue.enqueue(i);
}
int dequeued;
while ((dequeued = queue.dequeue()) >= 0) {
if (times[dequeued] <= q) {
now += times[dequeued];
System.out.print(names[dequeued]);
System.out.print(" ");
System.out.println(now);
} else {
now += q;
times[dequeued] -= q;
queue.enqueue(dequeued);
}
}
}
}
|
[
7,
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,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
4,
18,
13,
13,
42,
17,
30,
41,
13,
4,
18,
13,
14,
2,
13,
17,
30,
3,
41,
13,
4,
18,
13,
41,
13,
2,
13,
13,
14,
2,
13,
17,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
2,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
17,
0,
13,
17,
0,
13,
13,
0,
13,
20,
13,
0,
13,
20,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
40,
13,
0,
13,
13,
23,
13,
12,
13,
30,
14,
4,
18,
18,
13,
13,
17,
30,
29,
17,
41,
13,
20,
0,
18,
13,
13,
17,
40,
13,
0,
13,
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,
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
],
[
252,
5
],
[
252,
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,
29
],
[
29,
30
],
[
29,
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
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
48,
51
],
[
8,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
54,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
54,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
54,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
73,
75
],
[
54,
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
],
[
91,
92
],
[
92,
93
],
[
90,
94
],
[
90,
95
],
[
76,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
103,
104
],
[
103,
105
],
[
96,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
6,
110
],
[
110,
111
],
[
0,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
112,
116
],
[
116,
117
],
[
112,
118
],
[
118,
119
],
[
112,
120
],
[
120,
121
],
[
112,
122
],
[
122,
123
],
[
112,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
130,
131
],
[
130,
132
],
[
126,
133
],
[
133,
134
],
[
133,
135
],
[
126,
136
],
[
136,
137
],
[
136,
138
],
[
126,
140
],
[
140,
141
],
[
140,
142
],
[
124,
144
],
[
144,
145
],
[
112,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
153,
154
],
[
154,
155
],
[
148,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
160,
161
],
[
161,
162
],
[
148,
163
],
[
163,
164
],
[
148,
165
],
[
165,
166
],
[
165,
167
],
[
146,
168
],
[
168,
169
],
[
112,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
173,
180
],
[
180,
181
],
[
181,
182
],
[
172,
183
],
[
183,
184
],
[
183,
185
],
[
172,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
172,
191
],
[
191,
192
],
[
172,
193
],
[
193,
194
],
[
193,
195
],
[
172,
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
],
[
198,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
224,
225
],
[
198,
226
],
[
226,
227
],
[
226,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
229,
233
],
[
226,
234
],
[
234,
235
],
[
198,
236
],
[
236,
237
],
[
236,
238
],
[
238,
239
],
[
239,
240
],
[
198,
241
],
[
241,
242
],
[
241,
243
],
[
243,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
241,
249
],
[
249,
250
],
[
0,
251
],
[
251,
252
],
[
251,
253
]
] | [
"\nimport java.util.Scanner;\n\n/*\n * ??\\?????????\n5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n */\npublic class Main{\n\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int totalTime = 0;\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n \n int[] A = new int[n];\n Queue queue = new Queue(n);\n \n for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }\n while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }\n }\n}\nclass Queue{\n\tint startIndex;\n\tint endIndex;\n\tint size;\n String[] queueName;\n int[] queueTime;\n \n\tQueue(int n){\n \tstartIndex =0;\n \tendIndex = 0;\n \tsize = n;\n queueName = new String[n];\n queueTime = new int[n];\n\t}\n\tvoid enqueue(Process process){\n\t\t//System.out.println(\"??ยจ????????\\???\"+process.getProcessName()+\",\"+process.getProcessTime());\n\n\t\tqueueName[endIndex]=process.getProcessName();\n\t\tqueueTime[endIndex]=process.getProcessTime();\n\t\tendIndex++;\n\t\tendIndex %= size;\n\t}\n\tProcess dequeue(){\n\t\t//System.out.println(\"????????\\???\"+queueName[startIndex]+\",\"+queueTime[startIndex]);\n\t\tif(queueName[startIndex].equals(\"\")){\n\t\t\treturn null;\n\t\t}\n\t\tProcess process = new Process(queueName[startIndex],queueTime[startIndex]);\n\t\tqueueName[startIndex]=\"\";\n\t\tstartIndex++;\n\t\tstartIndex %= size;\n\t\treturn process;\n\t}\n}\n\nclass Process{\n\tprivate String processName;\n\tprivate int processTime;\n\tProcess(String processName,int processTime){\n\t\tthis.processName = processName;\n\t\tthis.processTime = processTime;\n\t}\n\tString getProcessName(){\n\t\treturn processName;\n\t}\n\tvoid setProcessName(String processName){\n\t\tthis.processName = processName;\n\t}\n\tpublic int getProcessTime() {\n\t\treturn processTime;\n\t}\n\tpublic void setProcessTime(int processTime) {\n\t\tthis.processTime = processTime;\n\t}\n\n\t\n}",
"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 int totalTime = 0;\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n \n int[] A = new int[n];\n Queue queue = new Queue(n);\n \n for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }\n while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int totalTime = 0;\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n \n int[] A = new int[n];\n Queue queue = new Queue(n);\n \n for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }\n while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n int totalTime = 0;\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n \n int[] A = new int[n];\n Queue queue = new Queue(n);\n \n for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }\n while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int totalTime = 0;",
"totalTime",
"0",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int q = scanner.nextInt();",
"q",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] A = new int[n];",
"A",
"new int[n]",
"n",
"Queue queue = new Queue(n);",
"queue",
"new Queue(n)",
"for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }",
"int i=1;",
"int i=1;",
"i",
"1",
"i<=n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }",
"{\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }",
"Process process = new Process(scanner.next(),scanner.nextInt());",
"process",
"new Process(scanner.next(),scanner.nextInt())",
"queue.enqueue(process)",
"queue.enqueue",
"queue",
"process",
"while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }",
"true",
"{\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }",
"Process p= queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if(p==null){\n \t\tbreak;\n \t}",
"p==null",
"p",
"null",
"{\n \t\tbreak;\n \t}",
"break;",
"int time =p.getProcessTime();",
"time",
"p.getProcessTime()",
"p.getProcessTime",
"p",
"int remainingTime = time-q;",
"remainingTime",
"time-q",
"time",
"q",
"if(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}",
"remainingTime <=0",
"remainingTime",
"0",
"{\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}",
"totalTime += time",
"totalTime",
"time",
"System.out.println(p.getProcessName()+\" \"+totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getProcessName()+\" \"+totalTime",
"p.getProcessName()+\" \"+totalTime",
"p.getProcessName()",
"p.getProcessName",
"p",
"\" \"",
"totalTime",
"{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}",
"totalTime += q",
"totalTime",
"q",
"p.setProcessTime(time-q)",
"p.setProcessTime",
"p",
"time-q",
"time",
"q",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"String[] args",
"args",
"class Queue{\n\tint startIndex;\n\tint endIndex;\n\tint size;\n String[] queueName;\n int[] queueTime;\n \n\tQueue(int n){\n \tstartIndex =0;\n \tendIndex = 0;\n \tsize = n;\n queueName = new String[n];\n queueTime = new int[n];\n\t}\n\tvoid enqueue(Process process){\n\t\t//System.out.println(\"??ยจ????????\\???\"+process.getProcessName()+\",\"+process.getProcessTime());\n\n\t\tqueueName[endIndex]=process.getProcessName();\n\t\tqueueTime[endIndex]=process.getProcessTime();\n\t\tendIndex++;\n\t\tendIndex %= size;\n\t}\n\tProcess dequeue(){\n\t\t//System.out.println(\"????????\\???\"+queueName[startIndex]+\",\"+queueTime[startIndex]);\n\t\tif(queueName[startIndex].equals(\"\")){\n\t\t\treturn null;\n\t\t}\n\t\tProcess process = new Process(queueName[startIndex],queueTime[startIndex]);\n\t\tqueueName[startIndex]=\"\";\n\t\tstartIndex++;\n\t\tstartIndex %= size;\n\t\treturn process;\n\t}\n}",
"Queue",
"int startIndex;",
"startIndex",
"int endIndex;",
"endIndex",
"int size;",
"size",
"String[] queueName;",
"queueName",
"int[] queueTime;",
"queueTime",
"Queue(int n){\n \tstartIndex =0;\n \tendIndex = 0;\n \tsize = n;\n queueName = new String[n];\n queueTime = new int[n];\n\t}",
"Queue",
"{\n \tstartIndex =0;\n \tendIndex = 0;\n \tsize = n;\n queueName = new String[n];\n queueTime = new int[n];\n\t}",
"startIndex =0",
"startIndex",
"0",
"endIndex = 0",
"endIndex",
"0",
"size = n",
"size",
"n",
"queueName = new String[n]",
"queueName",
"new String[n]",
"n",
"queueTime = new int[n]",
"queueTime",
"new int[n]",
"n",
"int n",
"n",
"void enqueue(Process process){\n\t\t//System.out.println(\"??ยจ????????\\???\"+process.getProcessName()+\",\"+process.getProcessTime());\n\n\t\tqueueName[endIndex]=process.getProcessName();\n\t\tqueueTime[endIndex]=process.getProcessTime();\n\t\tendIndex++;\n\t\tendIndex %= size;\n\t}",
"enqueue",
"{\n\t\t//System.out.println(\"??ยจ????????\\???\"+process.getProcessName()+\",\"+process.getProcessTime());\n\n\t\tqueueName[endIndex]=process.getProcessName();\n\t\tqueueTime[endIndex]=process.getProcessTime();\n\t\tendIndex++;\n\t\tendIndex %= size;\n\t}",
"queueName[endIndex]=process.getProcessName()",
"queueName[endIndex]",
"queueName",
"endIndex",
"process.getProcessName()",
"process.getProcessName",
"process",
"queueTime[endIndex]=process.getProcessTime()",
"queueTime[endIndex]",
"queueTime",
"endIndex",
"process.getProcessTime()",
"process.getProcessTime",
"process",
"endIndex++",
"endIndex",
"endIndex %= size",
"endIndex",
"size",
"Process process",
"process",
"Process dequeue(){\n\t\t//System.out.println(\"????????\\???\"+queueName[startIndex]+\",\"+queueTime[startIndex]);\n\t\tif(queueName[startIndex].equals(\"\")){\n\t\t\treturn null;\n\t\t}\n\t\tProcess process = new Process(queueName[startIndex],queueTime[startIndex]);\n\t\tqueueName[startIndex]=\"\";\n\t\tstartIndex++;\n\t\tstartIndex %= size;\n\t\treturn process;\n\t}",
"dequeue",
"{\n\t\t//System.out.println(\"????????\\???\"+queueName[startIndex]+\",\"+queueTime[startIndex]);\n\t\tif(queueName[startIndex].equals(\"\")){\n\t\t\treturn null;\n\t\t}\n\t\tProcess process = new Process(queueName[startIndex],queueTime[startIndex]);\n\t\tqueueName[startIndex]=\"\";\n\t\tstartIndex++;\n\t\tstartIndex %= size;\n\t\treturn process;\n\t}",
"if(queueName[startIndex].equals(\"\")){\n\t\t\treturn null;\n\t\t}",
"queueName[startIndex].equals(\"\")",
"queueName[startIndex].equals",
"queueName[startIndex]",
"queueName",
"startIndex",
"\"\"",
"{\n\t\t\treturn null;\n\t\t}",
"return null;",
"null",
"Process process = new Process(queueName[startIndex],queueTime[startIndex]);",
"process",
"new Process(queueName[startIndex],queueTime[startIndex])",
"queueName[startIndex]=\"\"",
"queueName[startIndex]",
"queueName",
"startIndex",
"\"\"",
"startIndex++",
"startIndex",
"startIndex %= size",
"startIndex",
"size",
"return process;",
"process",
"class Process{\n\tprivate String processName;\n\tprivate int processTime;\n\tProcess(String processName,int processTime){\n\t\tthis.processName = processName;\n\t\tthis.processTime = processTime;\n\t}\n\tString getProcessName(){\n\t\treturn processName;\n\t}\n\tvoid setProcessName(String processName){\n\t\tthis.processName = processName;\n\t}\n\tpublic int getProcessTime() {\n\t\treturn processTime;\n\t}\n\tpublic void setProcessTime(int processTime) {\n\t\tthis.processTime = processTime;\n\t}\n\n\t\n}",
"Process",
"private String processName;",
"processName",
"private int processTime;",
"processTime",
"Process(String processName,int processTime){\n\t\tthis.processName = processName;\n\t\tthis.processTime = processTime;\n\t}",
"Process",
"{\n\t\tthis.processName = processName;\n\t\tthis.processTime = processTime;\n\t}",
"this.processName = processName",
"this.processName",
"this",
"this.processName",
"processName",
"this.processTime = processTime",
"this.processTime",
"this",
"this.processTime",
"processTime",
"String processName",
"processName",
"int processTime",
"processTime",
"String getProcessName(){\n\t\treturn processName;\n\t}",
"getProcessName",
"{\n\t\treturn processName;\n\t}",
"return processName;",
"processName",
"void setProcessName(String processName){\n\t\tthis.processName = processName;\n\t}",
"setProcessName",
"{\n\t\tthis.processName = processName;\n\t}",
"this.processName = processName",
"this.processName",
"this",
"this.processName",
"processName",
"String processName",
"processName",
"public int getProcessTime() {\n\t\treturn processTime;\n\t}",
"getProcessTime",
"{\n\t\treturn processTime;\n\t}",
"return processTime;",
"processTime",
"public void setProcessTime(int processTime) {\n\t\tthis.processTime = processTime;\n\t}",
"setProcessTime",
"{\n\t\tthis.processTime = processTime;\n\t}",
"this.processTime = processTime",
"this.processTime",
"this",
"this.processTime",
"processTime",
"int processTime",
"processTime",
"public class Main{\n\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int totalTime = 0;\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n \n int[] A = new int[n];\n Queue queue = new Queue(n);\n \n for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }\n while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }\n }\n}",
"public class Main{\n\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int totalTime = 0;\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n \n int[] A = new int[n];\n Queue queue = new Queue(n);\n \n for(int i=1;i<=n;i++){\n Process process = new Process(scanner.next(),scanner.nextInt());\n queue.enqueue(process);\n }\n while(true){\n \tProcess p= queue.dequeue();\n \tif(p==null){\n \t\tbreak;\n \t}\n \tint time =p.getProcessTime();\n \tint remainingTime = time-q;\n \tif(remainingTime <=0){\n \t\ttotalTime += time;\n \t\tSystem.out.println(p.getProcessName()+\" \"+totalTime);\n \t}else{\n \t\ttotalTime += q;\n \t\tp.setProcessTime(time-q);\n \t\tqueue.enqueue(p);\n \t}\n }\n }\n}",
"Main"
] |
import java.util.Scanner;
/*
* ??\?????????
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
*/
public class Main{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int totalTime = 0;
int n = scanner.nextInt();
int q = scanner.nextInt();
int[] A = new int[n];
Queue queue = new Queue(n);
for(int i=1;i<=n;i++){
Process process = new Process(scanner.next(),scanner.nextInt());
queue.enqueue(process);
}
while(true){
Process p= queue.dequeue();
if(p==null){
break;
}
int time =p.getProcessTime();
int remainingTime = time-q;
if(remainingTime <=0){
totalTime += time;
System.out.println(p.getProcessName()+" "+totalTime);
}else{
totalTime += q;
p.setProcessTime(time-q);
queue.enqueue(p);
}
}
}
}
class Queue{
int startIndex;
int endIndex;
int size;
String[] queueName;
int[] queueTime;
Queue(int n){
startIndex =0;
endIndex = 0;
size = n;
queueName = new String[n];
queueTime = new int[n];
}
void enqueue(Process process){
//System.out.println("??ยจ????????\???"+process.getProcessName()+","+process.getProcessTime());
queueName[endIndex]=process.getProcessName();
queueTime[endIndex]=process.getProcessTime();
endIndex++;
endIndex %= size;
}
Process dequeue(){
//System.out.println("????????\???"+queueName[startIndex]+","+queueTime[startIndex]);
if(queueName[startIndex].equals("")){
return null;
}
Process process = new Process(queueName[startIndex],queueTime[startIndex]);
queueName[startIndex]="";
startIndex++;
startIndex %= size;
return process;
}
}
class Process{
private String processName;
private int processTime;
Process(String processName,int processTime){
this.processName = processName;
this.processTime = processTime;
}
String getProcessName(){
return processName;
}
void setProcessName(String processName){
this.processName = processName;
}
public int getProcessTime() {
return processTime;
}
public void setProcessTime(int processTime) {
this.processTime = processTime;
}
} |
[
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,
23,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
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,
13,
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,
41,
13,
17,
11,
1,
30,
30,
41,
13,
4,
18,
13,
14,
2,
13,
17,
3,
41,
13,
4,
18,
13,
18,
13,
13,
13,
0,
13,
13,
0,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
30,
0,
18,
13,
13,
13,
0,
18,
13,
40,
13,
13,
30,
4,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
18,
13,
13,
13,
17,
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
],
[
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
],
[
15,
28
],
[
28,
29
],
[
15,
30
],
[
30,
31
],
[
0,
32
],
[
191,
33
],
[
191,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
37,
39
],
[
36,
40
],
[
40,
41
],
[
36,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
44,
49
],
[
36,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
55,
56
],
[
55,
57
],
[
36,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
63,
65
],
[
36,
66
],
[
66,
67
],
[
66,
68
],
[
36,
69
],
[
69,
70
],
[
69,
71
],
[
36,
73
],
[
73,
74
],
[
73,
75
],
[
36,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
76,
81
],
[
81,
82
],
[
81,
83
],
[
76,
84
],
[
84,
85
],
[
85,
86
],
[
76,
87
],
[
88,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
91,
96
],
[
88,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
36,
101
],
[
101,
102
],
[
101,
103
],
[
36,
104
],
[
104,
105
],
[
104,
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
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
123,
124
],
[
123,
125
],
[
120,
126
],
[
107,
127
],
[
127,
128
],
[
127,
129
],
[
107,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
107,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
135,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
141,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
147,
152
],
[
135,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
154,
157
],
[
36,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
158,
163
],
[
163,
164
],
[
163,
165
],
[
158,
166
],
[
166,
167
],
[
167,
168
],
[
158,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
170,
175
],
[
176,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
176,
182
],
[
176,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
183,
187
],
[
34,
188
],
[
188,
189
],
[
0,
190
],
[
190,
191
],
[
190,
192
]
] | [
"import java.io.*;\nimport java.util.*;\nclass P{\n\tP(String n,int t){\n\t\tthis.n=n;\n\t\tthis.t=t;\n\t}\n\tpublic String n;\n\tpublic int t,e;\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\tString l[];\n\t\tl=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(l[0]);\n\t\tint q=Integer.parseInt(l[1]);\n\t\tLinkedList<P> p=new LinkedList<P>();\n\t\tP[] e=new P[n];\n\t\tint c=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}\n\t\tint s=0;\n\t\tfor(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"class P{\n\tP(String n,int t){\n\t\tthis.n=n;\n\t\tthis.t=t;\n\t}\n\tpublic String n;\n\tpublic int t,e;\n}",
"P",
"public String n;",
"n",
"public int t",
"t",
"e;",
"e",
"P(String n,int t){\n\t\tthis.n=n;\n\t\tthis.t=t;\n\t}",
"P",
"{\n\t\tthis.n=n;\n\t\tthis.t=t;\n\t}",
"this.n=n",
"this.n",
"this",
"this.n",
"n",
"this.t=t",
"this.t",
"this",
"this.t",
"t",
"String n",
"n",
"int t",
"t",
"public class Main{\n\tpublic static void main(String[] args)throws Exception{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tString l[];\n\t\tl=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(l[0]);\n\t\tint q=Integer.parseInt(l[1]);\n\t\tLinkedList<P> p=new LinkedList<P>();\n\t\tP[] e=new P[n];\n\t\tint c=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}\n\t\tint s=0;\n\t\tfor(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);\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 l[];\n\t\tl=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(l[0]);\n\t\tint q=Integer.parseInt(l[1]);\n\t\tLinkedList<P> p=new LinkedList<P>();\n\t\tP[] e=new P[n];\n\t\tint c=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}\n\t\tint s=0;\n\t\tfor(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);\n\t}",
"main",
"{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tString l[];\n\t\tl=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(l[0]);\n\t\tint q=Integer.parseInt(l[1]);\n\t\tLinkedList<P> p=new LinkedList<P>();\n\t\tP[] e=new P[n];\n\t\tint c=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}\n\t\tint s=0;\n\t\tfor(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);\n\t}",
"BufferedReader br=new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String l[];",
"l",
"l=br.readLine().split(\" \")",
"l",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n=Integer.parseInt(l[0]);",
"n",
"Integer.parseInt(l[0])",
"Integer.parseInt",
"Integer",
"l[0]",
"l",
"0",
"int q=Integer.parseInt(l[1]);",
"q",
"Integer.parseInt(l[1])",
"Integer.parseInt",
"Integer",
"l[1]",
"l",
"1",
"LinkedList<P> p=new LinkedList<P>();",
"p",
"new LinkedList<P>()",
"P[] e=new P[n];",
"e",
"new P[n]",
"n",
"int c=0;",
"c",
"0",
"for(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}",
"{\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}",
"l=br.readLine().split(\" \")",
"l",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"p.offer(new P(l[0],Integer.parseInt(l[1])))",
"p.offer",
"p",
"new P(l[0],Integer.parseInt(l[1]))",
"int s=0;",
"s",
"0",
"for(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}",
";",
"{\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}",
"{\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}",
"P t=p.poll();",
"t",
"p.poll()",
"p.poll",
"p",
"if(t==null)break;",
"t==null",
"t",
"null",
"break;",
"int d=Math.min(t.t,q);",
"d",
"Math.min(t.t,q)",
"Math.min",
"Math",
"t.t",
"t",
"t.t",
"q",
"s+=d",
"s",
"d",
"t.t-=d",
"t.t",
"t",
"t.t",
"d",
"if(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}",
"t.t==0",
"t.t",
"t",
"t.t",
"0",
"{\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}",
"t.e=s",
"t.e",
"t",
"t.e",
"s",
"e[c++]=t",
"e[c++]",
"e",
"c++",
"c",
"t",
"{\n\t\t\t\tp.add(t);\n\t\t\t}",
"p.add(t)",
"p.add",
"p",
"t",
"for(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"System.out.println(e[i].n+' '+e[i].e);",
"System.out.println(e[i].n+' '+e[i].e)",
"System.out.println",
"System.out",
"System",
"System.out",
"e[i].n+' '+e[i].e",
"e[i].n+' '+e[i].e",
"e[i].n",
"e[i]",
"e",
"i",
"e[i].n",
"' '",
"e[i].e",
"e[i]",
"e",
"i",
"e[i].e",
"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\tString l[];\n\t\tl=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(l[0]);\n\t\tint q=Integer.parseInt(l[1]);\n\t\tLinkedList<P> p=new LinkedList<P>();\n\t\tP[] e=new P[n];\n\t\tint c=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}\n\t\tint s=0;\n\t\tfor(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);\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\tString l[];\n\t\tl=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(l[0]);\n\t\tint q=Integer.parseInt(l[1]);\n\t\tLinkedList<P> p=new LinkedList<P>();\n\t\tP[] e=new P[n];\n\t\tint c=0;\n\t\tfor(int i=0;i<n;i++){\n\t\t\tl=br.readLine().split(\" \");\n\t\t\tp.offer(new P(l[0],Integer.parseInt(l[1])));\n\t\t}\n\t\tint s=0;\n\t\tfor(;;){\n\t\t\tP t=p.poll();\n\t\t\tif(t==null)break;\n\t\t\tint d=Math.min(t.t,q);\n\t\t\ts+=d;\n\t\t\tt.t-=d;\n\t\t\tif(t.t==0){\n\t\t\t\tt.e=s;\n\t\t\t\te[c++]=t;\n\t\t\t}else{\n\t\t\t\tp.add(t);\n\t\t\t}\n\t\t}\n\t\tfor(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);\n\t}\n}",
"Main"
] | import java.io.*;
import java.util.*;
class P{
P(String n,int t){
this.n=n;
this.t=t;
}
public String n;
public int t,e;
}
public class Main{
public static void main(String[] args)throws Exception{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String l[];
l=br.readLine().split(" ");
int n=Integer.parseInt(l[0]);
int q=Integer.parseInt(l[1]);
LinkedList<P> p=new LinkedList<P>();
P[] e=new P[n];
int c=0;
for(int i=0;i<n;i++){
l=br.readLine().split(" ");
p.offer(new P(l[0],Integer.parseInt(l[1])));
}
int s=0;
for(;;){
P t=p.poll();
if(t==null)break;
int d=Math.min(t.t,q);
s+=d;
t.t-=d;
if(t.t==0){
t.e=s;
e[c++]=t;
}else{
p.add(t);
}
}
for(int i=0;i<n;i++)System.out.println(e[i].n+' '+e[i].e);
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
20,
17,
41,
13,
20,
17,
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,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
0,
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,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
12,
13,
30,
4,
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
],
[
159,
11
],
[
159,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
14,
20
],
[
20,
21
],
[
14,
22
],
[
22,
23
],
[
14,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
30
],
[
30,
31
],
[
30,
32
],
[
14,
34
],
[
34,
35
],
[
34,
36
],
[
14,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
14,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
14,
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
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
64,
65
],
[
65,
66
],
[
59,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
72,
73
],
[
59,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
14,
78
],
[
78,
79
],
[
78,
80
],
[
14,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
81,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
98,
104
],
[
104,
105
],
[
104,
106
],
[
98,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
92,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
121,
126
],
[
127,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
127,
132
],
[
111,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
133,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
145,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
145,
150
],
[
159,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
151,
156
],
[
156,
157
],
[
0,
158
],
[
158,
159
],
[
158,
160
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n public static void solve(){\n Scanner scan = new Scanner(System.in);\n int n, q, i, t;\n String[] names = new String[100001];\n int[] times = new int[100001];\n Queue<Integer> processList = new LinkedList<>();\n n = scan.nextInt();\n q = scan.nextInt();\n \n for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }\n t = 0;\n while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }\n }\n \n public static void main(String[] args) {\n solve();\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 public static void solve(){\n Scanner scan = new Scanner(System.in);\n int n, q, i, t;\n String[] names = new String[100001];\n int[] times = new int[100001];\n Queue<Integer> processList = new LinkedList<>();\n n = scan.nextInt();\n q = scan.nextInt();\n \n for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }\n t = 0;\n while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }\n }\n \n public static void main(String[] args) {\n solve();\n }\n}",
"Main",
"public static void solve(){\n Scanner scan = new Scanner(System.in);\n int n, q, i, t;\n String[] names = new String[100001];\n int[] times = new int[100001];\n Queue<Integer> processList = new LinkedList<>();\n n = scan.nextInt();\n q = scan.nextInt();\n \n for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }\n t = 0;\n while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }\n }",
"solve",
"{\n Scanner scan = new Scanner(System.in);\n int n, q, i, t;\n String[] names = new String[100001];\n int[] times = new int[100001];\n Queue<Integer> processList = new LinkedList<>();\n n = scan.nextInt();\n q = scan.nextInt();\n \n for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }\n t = 0;\n while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }\n }",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n",
"n",
"q",
"q",
"i",
"i",
"t;",
"t",
"String[] names = new String[100001];",
"names",
"new String[100001]",
"100001",
"int[] times = new int[100001];",
"times",
"new int[100001]",
"100001",
"Queue<Integer> processList = new LinkedList<>();",
"processList",
"new LinkedList<>()",
"n = scan.nextInt()",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"q = scan.nextInt()",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }",
"{\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }",
"names[i] = scan.next()",
"names[i]",
"names",
"i",
"scan.next()",
"scan.next",
"scan",
"times[i] = scan.nextInt()",
"times[i]",
"times",
"i",
"scan.nextInt()",
"scan.nextInt",
"scan",
"processList.add(i)",
"processList.add",
"processList",
"i",
"t = 0",
"t",
"0",
"while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }",
"!processList.isEmpty()",
"processList.isEmpty()",
"processList.isEmpty",
"processList",
"{\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }",
"int x = processList.remove();",
"x",
"processList.remove()",
"processList.remove",
"processList",
"if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }",
"times[x]> q",
"times[x]",
"times",
"x",
"q",
"{\n times[x] -= q;\n t+=q;\n processList.add(x);\n }",
"times[x] -= q",
"times[x]",
"times",
"x",
"q",
"t+=q",
"t",
"q",
"processList.add(x)",
"processList.add",
"processList",
"x",
"if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }",
"times[x] == q",
"times[x]",
"times",
"x",
"q",
"{\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }",
"t+=q",
"t",
"q",
"System.out.println(names[x] + \" \" + t)",
"System.out.println",
"System.out",
"System",
"System.out",
"names[x] + \" \" + t",
"names[x] + \" \" + t",
"names[x]",
"names",
"x",
"\" \"",
"t",
"{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }",
"t += times[x]",
"t",
"times[x]",
"times",
"x",
"System.out.println(names[x] + \" \" + t)",
"System.out.println",
"System.out",
"System",
"System.out",
"names[x] + \" \" + t",
"names[x] + \" \" + t",
"names[x]",
"names",
"x",
"\" \"",
"t",
"public static void main(String[] args) {\n solve();\n }",
"main",
"{\n solve();\n }",
"solve()",
"solve",
"String[] args",
"args",
"public class Main {\n public static void solve(){\n Scanner scan = new Scanner(System.in);\n int n, q, i, t;\n String[] names = new String[100001];\n int[] times = new int[100001];\n Queue<Integer> processList = new LinkedList<>();\n n = scan.nextInt();\n q = scan.nextInt();\n \n for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }\n t = 0;\n while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }\n }\n \n public static void main(String[] args) {\n solve();\n }\n}",
"public class Main {\n public static void solve(){\n Scanner scan = new Scanner(System.in);\n int n, q, i, t;\n String[] names = new String[100001];\n int[] times = new int[100001];\n Queue<Integer> processList = new LinkedList<>();\n n = scan.nextInt();\n q = scan.nextInt();\n \n for(i=0;i<n;i++){\n names[i] = scan.next();\n times[i] = scan.nextInt();\n processList.add(i);\n }\n t = 0;\n while(!processList.isEmpty()){\n int x = processList.remove();\n if(times[x]> q){\n times[x] -= q;\n t+=q;\n processList.add(x);\n }else if(times[x] == q){\n t+=q;\n System.out.println(names[x] + \" \" + t);\n }else{\n t += times[x];\n System.out.println(names[x] + \" \" + t);\n }\n }\n }\n \n public static void main(String[] args) {\n solve();\n }\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void solve(){
Scanner scan = new Scanner(System.in);
int n, q, i, t;
String[] names = new String[100001];
int[] times = new int[100001];
Queue<Integer> processList = new LinkedList<>();
n = scan.nextInt();
q = scan.nextInt();
for(i=0;i<n;i++){
names[i] = scan.next();
times[i] = scan.nextInt();
processList.add(i);
}
t = 0;
while(!processList.isEmpty()){
int x = processList.remove();
if(times[x]> q){
times[x] -= q;
t+=q;
processList.add(x);
}else if(times[x] == q){
t+=q;
System.out.println(names[x] + " " + t);
}else{
t += times[x];
System.out.println(names[x] + " " + t);
}
}
}
public static void main(String[] args) {
solve();
}
}
|
[
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,
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,
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
],
[
123,
5
],
[
123,
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
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
8,
34
],
[
34,
35
],
[
34,
36
],
[
8,
37
],
[
37,
38
],
[
37,
39
],
[
8,
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
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
52,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
52,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
52,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
8,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
71,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
76,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
76,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
101,
101
],
[
101,
102
],
[
101,
103
],
[
101,
104
],
[
87,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
105,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
105,
117
],
[
117,
118
],
[
117,
119
],
[
6,
120
],
[
120,
121
],
[
0,
122
],
[
122,
123
],
[
122,
124
]
] | [
"import java.util.*;\n\npublic class Main{\t\n\npublic static void main(String[] args) {\n\tQueue<String> name = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tScanner in = new Scanner(System.in);\n\t\n\tint elems = in.nextInt();\n\tint timer = in.nextInt();\n\tint timePassed = 0;\n\tin.nextLine();\n\t\n\tString eName = \"\";\n\tint eTime = 0;\n\t\n\tfor (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}\n\t\n\twhile(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}\n}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\t\n\npublic static void main(String[] args) {\n\tQueue<String> name = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tScanner in = new Scanner(System.in);\n\t\n\tint elems = in.nextInt();\n\tint timer = in.nextInt();\n\tint timePassed = 0;\n\tin.nextLine();\n\t\n\tString eName = \"\";\n\tint eTime = 0;\n\t\n\tfor (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}\n\t\n\twhile(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}\n}\n}",
"Main",
"public static void main(String[] args) {\n\tQueue<String> name = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tScanner in = new Scanner(System.in);\n\t\n\tint elems = in.nextInt();\n\tint timer = in.nextInt();\n\tint timePassed = 0;\n\tin.nextLine();\n\t\n\tString eName = \"\";\n\tint eTime = 0;\n\t\n\tfor (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}\n\t\n\twhile(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}\n}",
"main",
"{\n\tQueue<String> name = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tScanner in = new Scanner(System.in);\n\t\n\tint elems = in.nextInt();\n\tint timer = in.nextInt();\n\tint timePassed = 0;\n\tin.nextLine();\n\t\n\tString eName = \"\";\n\tint eTime = 0;\n\t\n\tfor (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}\n\t\n\twhile(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}\n}",
"Queue<String> name = new LinkedList<String>();",
"name",
"new LinkedList<String>()",
"Queue<Integer> time = new LinkedList<Integer>();",
"time",
"new LinkedList<Integer>()",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int elems = in.nextInt();",
"elems",
"in.nextInt()",
"in.nextInt",
"in",
"int timer = in.nextInt();",
"timer",
"in.nextInt()",
"in.nextInt",
"in",
"int timePassed = 0;",
"timePassed",
"0",
"in.nextLine()",
"in.nextLine",
"in",
"String eName = \"\";",
"eName",
"\"\"",
"int eTime = 0;",
"eTime",
"0",
"for (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < elems",
"i",
"elems",
"i++",
"i++",
"i",
"{\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}",
"{\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}",
"eName = in.next()",
"eName",
"in.next()",
"in.next",
"in",
"name.add(eName)",
"name.add",
"name",
"eName",
"eTime = in.nextInt()",
"eTime",
"in.nextInt()",
"in.nextInt",
"in",
"time.add(eTime)",
"time.add",
"time",
"eTime",
"while(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}",
"!name.isEmpty()",
"name.isEmpty()",
"name.isEmpty",
"name",
"{\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}",
"String str = name.poll();",
"str",
"name.poll()",
"name.poll",
"name",
"int remainingTime = time.poll();",
"remainingTime",
"time.poll()",
"time.poll",
"time",
"if (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}",
"remainingTime <= timer",
"remainingTime",
"timer",
"{\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}",
"timePassed += remainingTime",
"timePassed",
"remainingTime",
"System.out.println(str + \" \" + timePassed)",
"System.out.println",
"System.out",
"System",
"System.out",
"str + \" \" + timePassed",
"str + \" \" + timePassed",
"str",
"\" \"",
"timePassed",
"{\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}",
"remainingTime -= timer",
"remainingTime",
"timer",
"name.add(str)",
"name.add",
"name",
"str",
"time.add(remainingTime)",
"time.add",
"time",
"remainingTime",
"timePassed += timer",
"timePassed",
"timer",
"String[] args",
"args",
"public class Main{\t\n\npublic static void main(String[] args) {\n\tQueue<String> name = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tScanner in = new Scanner(System.in);\n\t\n\tint elems = in.nextInt();\n\tint timer = in.nextInt();\n\tint timePassed = 0;\n\tin.nextLine();\n\t\n\tString eName = \"\";\n\tint eTime = 0;\n\t\n\tfor (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}\n\t\n\twhile(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}\n}\n}",
"public class Main{\t\n\npublic static void main(String[] args) {\n\tQueue<String> name = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tScanner in = new Scanner(System.in);\n\t\n\tint elems = in.nextInt();\n\tint timer = in.nextInt();\n\tint timePassed = 0;\n\tin.nextLine();\n\t\n\tString eName = \"\";\n\tint eTime = 0;\n\t\n\tfor (int i = 0; i < elems; i++) {\n\t\teName = in.next();\n\t\tname.add(eName);\n\t\teTime = in.nextInt();\n\t\ttime.add(eTime);\n\t}\n\t\n\twhile(!name.isEmpty()) {\n\t\tString str = name.poll();\n\t\tint remainingTime = time.poll();\n\t\tif (remainingTime <= timer) {\n\t\t\ttimePassed += remainingTime;\n\t\t\tSystem.out.println(str + \" \" + timePassed);\n\t\t}\n\t\telse {\n\t\t\tremainingTime -= timer;\n\t\t\tname.add(str);\n\t\t\ttime.add(remainingTime);\n\t\t\ttimePassed += timer;\n\t\t}\n\t}\n}\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String[] args) {
Queue<String> name = new LinkedList<String>();
Queue<Integer> time = new LinkedList<Integer>();
Scanner in = new Scanner(System.in);
int elems = in.nextInt();
int timer = in.nextInt();
int timePassed = 0;
in.nextLine();
String eName = "";
int eTime = 0;
for (int i = 0; i < elems; i++) {
eName = in.next();
name.add(eName);
eTime = in.nextInt();
time.add(eTime);
}
while(!name.isEmpty()) {
String str = name.poll();
int remainingTime = time.poll();
if (remainingTime <= timer) {
timePassed += remainingTime;
System.out.println(str + " " + timePassed);
}
else {
remainingTime -= timer;
name.add(str);
time.add(remainingTime);
timePassed += timer;
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
20,
17,
41,
13,
20,
17,
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,
4,
13,
13,
13,
41,
13,
17,
42,
2,
13,
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,
0,
13,
13,
4,
13,
13,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
40,
13,
23,
13,
23,
13,
12,
13,
30,
29,
18,
13,
40,
13,
12,
13,
30,
29,
18,
13,
40,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
149,
5
],
[
149,
6
],
[
6,
7
],
[
6,
8
],
[
149,
9
],
[
9,
10
],
[
9,
11
],
[
149,
12
],
[
12,
13
],
[
12,
14
],
[
149,
15
],
[
15,
16
],
[
15,
17
],
[
149,
19
],
[
19,
20
],
[
19,
21
],
[
149,
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
],
[
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
],
[
51,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
62,
63
],
[
62,
64
],
[
62,
65
],
[
25,
66
],
[
66,
67
],
[
66,
68
],
[
25,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
73,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
73,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
96,
96
],
[
96,
97
],
[
96,
98
],
[
96,
99
],
[
82,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
104,
106
],
[
100,
107
],
[
107,
108
],
[
107,
109
],
[
107,
110
],
[
23,
111
],
[
111,
112
],
[
149,
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
],
[
115,
126
],
[
126,
127
],
[
113,
128
],
[
128,
129
],
[
113,
130
],
[
130,
131
],
[
149,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
149,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
0,
148
],
[
148,
149
],
[
148,
150
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n\tpublic static int head1 = 0;\n\tpublic static int head2 = 0;\n\tpublic static int tail = 0;\n\tpublic static String[] queue1 = new String[1000000];\n\tpublic static int[] queue2 = new int[1000000];\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void enqueue(String x, int y) {\n\t\tqueue1[tail] = x;\n\t\tqueue2[tail] = y;\n\t\ttail++;\n\t}\n\t\n\tpublic static String strDequeue() {\n\t\treturn queue1[head1++];\n\t}\n\t\n\tpublic static int intDequeue() {\n\t\treturn queue2[head2++];\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static int head1 = 0;\n\tpublic static int head2 = 0;\n\tpublic static int tail = 0;\n\tpublic static String[] queue1 = new String[1000000];\n\tpublic static int[] queue2 = new int[1000000];\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void enqueue(String x, int y) {\n\t\tqueue1[tail] = x;\n\t\tqueue2[tail] = y;\n\t\ttail++;\n\t}\n\t\n\tpublic static String strDequeue() {\n\t\treturn queue1[head1++];\n\t}\n\t\n\tpublic static int intDequeue() {\n\t\treturn queue2[head2++];\n\t}\n}",
"Main",
"public static int head1 = 0;",
"head1",
"0",
"public static int head2 = 0;",
"head2",
"0",
"public static int tail = 0;",
"tail",
"0",
"public static String[] queue1 = new String[1000000];",
"queue1",
"new String[1000000]",
"1000000",
"public static int[] queue2 = new int[1000000];",
"queue2",
"new int[1000000]",
"1000000",
"public static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\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",
"for (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}",
"{\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}",
"String a = stdIn.next();",
"a",
"stdIn.next()",
"stdIn.next",
"stdIn",
"int b = stdIn.nextInt();",
"b",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"enqueue(a, b)",
"enqueue",
"a",
"b",
"int time = 0;",
"time",
"0",
"while (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}",
"head1 != tail",
"head1",
"tail",
"{\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}",
"String a = strDequeue();",
"a",
"strDequeue()",
"strDequeue",
"int b = intDequeue();",
"b",
"intDequeue()",
"intDequeue",
"if (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}",
"b <= q",
"b",
"q",
"{\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}",
"time += b",
"time",
"b",
"System.out.println(a +\" \"+ time)",
"System.out.println",
"System.out",
"System",
"System.out",
"a +\" \"+ time",
"a +\" \"+ time",
"a",
"\" \"",
"time",
"{\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}",
"time += q",
"time",
"q",
"b -= q",
"b",
"q",
"enqueue(a, b)",
"enqueue",
"a",
"b",
"String[] args",
"args",
"public static void enqueue(String x, int y) {\n\t\tqueue1[tail] = x;\n\t\tqueue2[tail] = y;\n\t\ttail++;\n\t}",
"enqueue",
"{\n\t\tqueue1[tail] = x;\n\t\tqueue2[tail] = y;\n\t\ttail++;\n\t}",
"queue1[tail] = x",
"queue1[tail]",
"queue1",
"tail",
"x",
"queue2[tail] = y",
"queue2[tail]",
"queue2",
"tail",
"y",
"tail++",
"tail",
"String x",
"x",
"int y",
"y",
"public static String strDequeue() {\n\t\treturn queue1[head1++];\n\t}",
"strDequeue",
"{\n\t\treturn queue1[head1++];\n\t}",
"return queue1[head1++];",
"queue1[head1++]",
"queue1",
"head1++",
"head1",
"public static int intDequeue() {\n\t\treturn queue2[head2++];\n\t}",
"intDequeue",
"{\n\t\treturn queue2[head2++];\n\t}",
"return queue2[head2++];",
"queue2[head2++]",
"queue2",
"head2++",
"head2",
"public class Main {\n\tpublic static int head1 = 0;\n\tpublic static int head2 = 0;\n\tpublic static int tail = 0;\n\tpublic static String[] queue1 = new String[1000000];\n\tpublic static int[] queue2 = new int[1000000];\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void enqueue(String x, int y) {\n\t\tqueue1[tail] = x;\n\t\tqueue2[tail] = y;\n\t\ttail++;\n\t}\n\t\n\tpublic static String strDequeue() {\n\t\treturn queue1[head1++];\n\t}\n\t\n\tpublic static int intDequeue() {\n\t\treturn queue2[head2++];\n\t}\n}",
"public class Main {\n\tpublic static int head1 = 0;\n\tpublic static int head2 = 0;\n\tpublic static int tail = 0;\n\tpublic static String[] queue1 = new String[1000000];\n\tpublic static int[] queue2 = new int[1000000];\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner stdIn = new Scanner(System.in);\n\t\t\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString a = stdIn.next();\n\t\t\tint b = stdIn.nextInt();\n\t\t\tenqueue(a, b);\n\t\t}\n\t\t\n\t\tint time = 0;\n\t\twhile (head1 != tail) {\n\t\t\tString a = strDequeue();\n\t\t\tint b = intDequeue();\n\t\t\tif (b <= q) {\n\t\t\t\ttime += b;\n\t\t\t\tSystem.out.println(a +\" \"+ time);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tb -= q;\n\t\t\t\tenqueue(a, b);\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void enqueue(String x, int y) {\n\t\tqueue1[tail] = x;\n\t\tqueue2[tail] = y;\n\t\ttail++;\n\t}\n\t\n\tpublic static String strDequeue() {\n\t\treturn queue1[head1++];\n\t}\n\t\n\tpublic static int intDequeue() {\n\t\treturn queue2[head2++];\n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static int head1 = 0;
public static int head2 = 0;
public static int tail = 0;
public static String[] queue1 = new String[1000000];
public static int[] queue2 = new int[1000000];
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int n = stdIn.nextInt();
int q = stdIn.nextInt();
for (int i = 0; i < n; i++) {
String a = stdIn.next();
int b = stdIn.nextInt();
enqueue(a, b);
}
int time = 0;
while (head1 != tail) {
String a = strDequeue();
int b = intDequeue();
if (b <= q) {
time += b;
System.out.println(a +" "+ time);
}
else {
time += q;
b -= q;
enqueue(a, b);
}
}
}
public static void enqueue(String x, int y) {
queue1[tail] = x;
queue2[tail] = y;
tail++;
}
public static String strDequeue() {
return queue1[head1++];
}
public static int intDequeue() {
return queue2[head2++];
}
} |
[
7,
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,
17,
41,
13,
20,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
0,
13,
17,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
0,
13,
17,
30,
30,
41,
13,
4,
18,
13,
18,
4,
18,
18,
13,
13,
17,
17,
41,
13,
18,
4,
18,
18,
13,
13,
17,
17,
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,
2,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
0,
18,
13,
13,
18,
13,
13,
4,
18,
13,
13,
30,
0,
13,
2,
13,
18,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
13,
17,
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
],
[
15,
16
],
[
13,
17
],
[
17,
18
],
[
13,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
22,
26
],
[
21,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
27,
31
],
[
19,
32
],
[
32,
33
],
[
19,
34
],
[
34,
35
],
[
0,
36
],
[
222,
37
],
[
222,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
40,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
46,
51
],
[
40,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
57,
58
],
[
57,
59
],
[
40,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
62,
65
],
[
65,
66
],
[
65,
67
],
[
40,
68
],
[
68,
69
],
[
68,
70
],
[
40,
71
],
[
71,
72
],
[
71,
73
],
[
40,
74
],
[
74,
75
],
[
74,
76
],
[
40,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
83,
84
],
[
83,
85
],
[
78,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
78,
90
],
[
91,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
97,
98
],
[
40,
99
],
[
99,
100
],
[
100,
101
],
[
40,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
107,
108
],
[
107,
109
],
[
102,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
102,
114
],
[
115,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
121,
128
],
[
115,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
131,
138
],
[
115,
139
],
[
139,
140
],
[
139,
141
],
[
115,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
40,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
147,
151
],
[
146,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
155,
159
],
[
154,
160
],
[
153,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
161,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
169,
171
],
[
161,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
161,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
185,
186
],
[
185,
187
],
[
161,
188
],
[
188,
189
],
[
189,
190
],
[
188,
191
],
[
153,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
197,
201
],
[
192,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
202,
207
],
[
208,
208
],
[
208,
209
],
[
209,
210
],
[
210,
211
],
[
211,
212
],
[
209,
213
],
[
208,
214
],
[
208,
215
],
[
192,
216
],
[
216,
217
],
[
217,
218
],
[
38,
219
],
[
219,
220
],
[
0,
221
],
[
221,
222
],
[
221,
223
]
] | [
"import java.util.Scanner;\n\n\nimport java.util.*;\nimport java.util.LinkedList;\nimport java.util.Queue;\n\nclass Pair{\n\tpublic String key;\n\tpublic int value;\n\tpublic Pair(String name, int number) {\n\t\tthis.key = name;\n\t\tthis.value = number;\n\t}\n}\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(info[0]);\n\t\tint limit =Integer.parseInt(info[1]);\n\t\tint time = 0;\n\t\t\n\t\tQueue<Pair> q = new LinkedList<Pair>();\n\t\tString [] inputArrayS = new String[n];\n\t\tfor (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tfor (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}\n\n\t\t\twhile (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.*;",
"util.*",
"java",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"class Pair{\n\tpublic String key;\n\tpublic int value;\n\tpublic Pair(String name, int number) {\n\t\tthis.key = name;\n\t\tthis.value = number;\n\t}\n}",
"Pair",
"public String key;",
"key",
"public int value;",
"value",
"public Pair(String name, int number) {\n\t\tthis.key = name;\n\t\tthis.value = number;\n\t}",
"Pair",
"{\n\t\tthis.key = name;\n\t\tthis.value = number;\n\t}",
"this.key = name",
"this.key",
"this",
"this.key",
"name",
"this.value = number",
"this.value",
"this",
"this.value",
"number",
"String name",
"name",
"int number",
"number",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(info[0]);\n\t\tint limit =Integer.parseInt(info[1]);\n\t\tint time = 0;\n\t\t\n\t\tQueue<Pair> q = new LinkedList<Pair>();\n\t\tString [] inputArrayS = new String[n];\n\t\tfor (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tfor (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}\n\n\t\t\twhile (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(info[0]);\n\t\tint limit =Integer.parseInt(info[1]);\n\t\tint time = 0;\n\t\t\n\t\tQueue<Pair> q = new LinkedList<Pair>();\n\t\tString [] inputArrayS = new String[n];\n\t\tfor (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tfor (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}\n\n\t\t\twhile (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(info[0]);\n\t\tint limit =Integer.parseInt(info[1]);\n\t\tint time = 0;\n\t\t\n\t\tQueue<Pair> q = new LinkedList<Pair>();\n\t\tString [] inputArrayS = new String[n];\n\t\tfor (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tfor (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}\n\n\t\t\twhile (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String[] info = sc.nextLine().split(\" \");",
"info",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"int n = Integer.parseInt(info[0]);",
"n",
"Integer.parseInt(info[0])",
"Integer.parseInt",
"Integer",
"info[0]",
"info",
"0",
"int limit =Integer.parseInt(info[1]);",
"limit",
"Integer.parseInt(info[1])",
"Integer.parseInt",
"Integer",
"info[1]",
"info",
"1",
"int time = 0;",
"time",
"0",
"Queue<Pair> q = new LinkedList<Pair>();",
"q",
"new LinkedList<Pair>()",
"String [] inputArrayS = new String[n];",
"inputArrayS",
"new String[n]",
"n",
"for (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i += 1",
"i += 1",
"i",
"1",
"{\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}",
"{\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}",
"inputArrayS[i] = sc.nextLine()",
"inputArrayS[i]",
"inputArrayS",
"i",
"sc.nextLine()",
"sc.nextLine",
"sc",
"sc.close()",
"sc.close",
"sc",
"for (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}",
"int j = 0;",
"int j = 0;",
"j",
"0",
"j < n",
"j",
"n",
"j += 1",
"j += 1",
"j",
"1",
"{\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}",
"{\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}",
"int quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);",
"quantum",
"Integer.parseInt(inputArrayS[j].split(\" \")[1])",
"Integer.parseInt",
"Integer",
"inputArrayS[j].split(\" \")[1]",
"inputArrayS[j].split(\" \")",
"inputArrayS[j].split",
"inputArrayS[j]",
"inputArrayS",
"j",
"\" \"",
"1",
"String nameS = inputArrayS[j].split(\" \")[0];",
"nameS",
"inputArrayS[j].split(\" \")[0]",
"inputArrayS[j].split(\" \")",
"inputArrayS[j].split",
"inputArrayS[j]",
"inputArrayS",
"j",
"\" \"",
"0",
"Pair p = new Pair(nameS, quantum);",
"p",
"new Pair(nameS, quantum)",
"q.offer(p)",
"q.offer",
"q",
"p",
"while (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}",
"q.size()>0",
"q.size()",
"q.size",
"q",
"0",
"{\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}",
"if(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}",
"q.peek().value > limit",
"q.peek().value",
"q.peek()",
"q.peek",
"q",
"q.peek().value",
"limit",
"{\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}",
"Pair cp = q.remove();",
"cp",
"q.remove()",
"q.remove",
"q",
"time = time + limit",
"time",
"time + limit",
"time",
"limit",
"cp.value = cp.value - limit",
"cp.value",
"cp",
"cp.value",
"cp.value - limit",
"cp.value",
"cp",
"cp.value",
"limit",
"cp.key = cp.key",
"cp.key",
"cp",
"cp.key",
"cp.key",
"cp",
"cp.key",
"q.add(cp)",
"q.add",
"q",
"cp",
"{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}",
"time = time + q.peek().value",
"time",
"time + q.peek().value",
"time",
"q.peek().value",
"q.peek()",
"q.peek",
"q",
"q.peek().value",
"System.out.println(q.peek().key + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"q.peek().key + \" \" + time",
"q.peek().key + \" \" + time",
"q.peek().key",
"q.peek()",
"q.peek",
"q",
"q.peek().key",
"\" \"",
"time",
"q.remove()",
"q.remove",
"q",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(info[0]);\n\t\tint limit =Integer.parseInt(info[1]);\n\t\tint time = 0;\n\t\t\n\t\tQueue<Pair> q = new LinkedList<Pair>();\n\t\tString [] inputArrayS = new String[n];\n\t\tfor (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tfor (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}\n\n\t\t\twhile (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(info[0]);\n\t\tint limit =Integer.parseInt(info[1]);\n\t\tint time = 0;\n\t\t\n\t\tQueue<Pair> q = new LinkedList<Pair>();\n\t\tString [] inputArrayS = new String[n];\n\t\tfor (int i = 0; i < n; i += 1) {\n\t\t\tinputArrayS[i] = sc.nextLine();\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tfor (int j = 0; j < n; j += 1) {\n\t\t\t\n\t\t\tint quantum = Integer.parseInt(inputArrayS[j].split(\" \")[1]);\n\t\t\tString nameS = inputArrayS[j].split(\" \")[0];\n\t\t\tPair p = new Pair(nameS, quantum);\n\t\t\tq.offer(p);\n\t\t\t}\n\n\t\t\twhile (q.size()>0) {\n\t\t\t\t\n\t\t\t\t\tif(q.peek().value > limit) {\n\t\t\t\t\t\tPair cp = q.remove();\n\t\t\t\t\t\ttime = time + limit;\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tcp.value = cp.value - limit;\n\t\t\t\t\tcp.key = cp.key;\t\n\t\t\t\t\tq.add(cp);\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}else{\n\t\t\t\t\t\n\t\t\t\t\ttime = time + q.peek().value;\t\t\t\t\n\t\t\t\t\tSystem.out.println(q.peek().key + \" \" + time);\n\t\t\t\t\tq.remove();\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"Main"
] | import java.util.Scanner;
import java.util.*;
import java.util.LinkedList;
import java.util.Queue;
class Pair{
public String key;
public int value;
public Pair(String name, int number) {
this.key = name;
this.value = number;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] info = sc.nextLine().split(" ");
int n = Integer.parseInt(info[0]);
int limit =Integer.parseInt(info[1]);
int time = 0;
Queue<Pair> q = new LinkedList<Pair>();
String [] inputArrayS = new String[n];
for (int i = 0; i < n; i += 1) {
inputArrayS[i] = sc.nextLine();
}
sc.close();
for (int j = 0; j < n; j += 1) {
int quantum = Integer.parseInt(inputArrayS[j].split(" ")[1]);
String nameS = inputArrayS[j].split(" ")[0];
Pair p = new Pair(nameS, quantum);
q.offer(p);
}
while (q.size()>0) {
if(q.peek().value > limit) {
Pair cp = q.remove();
time = time + limit;
cp.value = cp.value - limit;
cp.key = cp.key;
q.add(cp);
}else{
time = time + q.peek().value;
System.out.println(q.peek().key + " " + time);
q.remove();
}
}
}
}
|
[
7,
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,
41,
13,
20,
12,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
2,
13,
17,
2,
13,
17,
29,
14,
2,
2,
13,
17,
2,
13,
17,
29,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
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,
18,
13,
13,
13,
0,
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
],
[
9,
10
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
15,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
13,
26
],
[
26,
27
],
[
13,
28
],
[
28,
29
],
[
0,
30
],
[
140,
31
],
[
140,
32
],
[
32,
33
],
[
32,
34
],
[
140,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
41,
43
],
[
37,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
37,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
37,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
37,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
68,
70
],
[
63,
71
],
[
37,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
72,
77
],
[
77,
78
],
[
77,
79
],
[
72,
80
],
[
80,
81
],
[
81,
82
],
[
72,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
37,
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
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
100,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
106,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
112,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
118,
123
],
[
100,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
124,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
35,
137
],
[
137,
138
],
[
0,
139
],
[
139,
140
],
[
139,
141
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\n\nclass Task {\n\tpublic String name;\n\tpublic int time;\n\t\n\tTask(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}\npublic class Main{\n\tstatic LinkedList<Task> queue = new LinkedList<>();\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint sumTime = 0;\n\t\t\n\t\tint taskNum = sc.nextInt();\n\t\tint levelTime = sc.nextInt();\n\t\t\n\t\tif(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;\n\t\tif(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;\n\t\t\n\t\tfor (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\t\n\t\twhile(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Task {\n\tpublic String name;\n\tpublic int time;\n\t\n\tTask(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Task",
"public String name;",
"name",
"public int time;",
"time",
"Task(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Task",
"{\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 LinkedList<Task> queue = new LinkedList<>();\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint sumTime = 0;\n\t\t\n\t\tint taskNum = sc.nextInt();\n\t\tint levelTime = sc.nextInt();\n\t\t\n\t\tif(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;\n\t\tif(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;\n\t\t\n\t\tfor (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\t\n\t\twhile(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"static LinkedList<Task> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint sumTime = 0;\n\t\t\n\t\tint taskNum = sc.nextInt();\n\t\tint levelTime = sc.nextInt();\n\t\t\n\t\tif(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;\n\t\tif(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;\n\t\t\n\t\tfor (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\t\n\t\twhile(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint sumTime = 0;\n\t\t\n\t\tint taskNum = sc.nextInt();\n\t\tint levelTime = sc.nextInt();\n\t\t\n\t\tif(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;\n\t\tif(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;\n\t\t\n\t\tfor (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\t\n\t\twhile(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int sumTime = 0;",
"sumTime",
"0",
"int taskNum = sc.nextInt();",
"taskNum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int levelTime = sc.nextInt();",
"levelTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"if(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;",
"taskNum < 1 || taskNum > 100000",
"taskNum < 1",
"taskNum",
"1",
"taskNum > 100000",
"taskNum",
"100000",
"return;",
"if(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;",
"levelTime < 1 || levelTime > 1000",
"levelTime < 1",
"levelTime",
"1",
"levelTime > 1000",
"levelTime",
"1000",
"return;",
"for (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < taskNum",
"i",
"taskNum",
"i++",
"i++",
"i",
"{\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}",
"{\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}",
"queue.offer(new Task(sc.next(), sc.nextInt()))",
"queue.offer",
"queue",
"new Task(sc.next(), sc.nextInt())",
"while(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}",
"Task task = queue.poll();",
"task",
"queue.poll()",
"queue.poll",
"queue",
"if(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}",
"task.time <= levelTime",
"task.time",
"task",
"task.time",
"levelTime",
"{\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t}",
"sumTime += task.time",
"sumTime",
"task.time",
"task",
"task.time",
"System.out.println(task.name + \" \" + sumTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"task.name + \" \" + sumTime",
"task.name + \" \" + sumTime",
"task.name",
"task",
"task.name",
"\" \"",
"sumTime",
"{\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}",
"task.time -= levelTime",
"task.time",
"task",
"task.time",
"levelTime",
"sumTime += levelTime",
"sumTime",
"levelTime",
"queue.offer(task)",
"queue.offer",
"queue",
"task",
"String[] args",
"args",
"public class Main{\n\tstatic LinkedList<Task> queue = new LinkedList<>();\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint sumTime = 0;\n\t\t\n\t\tint taskNum = sc.nextInt();\n\t\tint levelTime = sc.nextInt();\n\t\t\n\t\tif(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;\n\t\tif(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;\n\t\t\n\t\tfor (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\t\n\t\twhile(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main{\n\tstatic LinkedList<Task> queue = new LinkedList<>();\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint sumTime = 0;\n\t\t\n\t\tint taskNum = sc.nextInt();\n\t\tint levelTime = sc.nextInt();\n\t\t\n\t\tif(taskNum < 1 || taskNum > 100000)\n\t\t\treturn;\n\t\tif(levelTime < 1 || levelTime > 1000)\n\t\t\treturn;\n\t\t\n\t\tfor (int i = 0; i < taskNum; i++) {\n\t\t\t queue.offer(new Task(sc.next(), sc.nextInt()));\n\t\t}\n\t\t\n\t\t\n\t\twhile(!queue.isEmpty()) {\n\t\t\tTask task = queue.poll();\n\t\t\t\n\t\t\tif(task.time <= levelTime) {\n\t\t\t\tsumTime += task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + sumTime);\n\t\t\t} else {\n\t\t\t\ttask.time -= levelTime;\n\t\t\t\tsumTime += levelTime;\n\t\t\t\tqueue.offer(task);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
class Task {
public String name;
public int time;
Task(String name, int time) {
this.name = name;
this.time = time;
}
}
public class Main{
static LinkedList<Task> queue = new LinkedList<>();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sumTime = 0;
int taskNum = sc.nextInt();
int levelTime = sc.nextInt();
if(taskNum < 1 || taskNum > 100000)
return;
if(levelTime < 1 || levelTime > 1000)
return;
for (int i = 0; i < taskNum; i++) {
queue.offer(new Task(sc.next(), sc.nextInt()));
}
while(!queue.isEmpty()) {
Task task = queue.poll();
if(task.time <= levelTime) {
sumTime += task.time;
System.out.println(task.name + " " + sumTime);
} else {
task.time -= levelTime;
sumTime += levelTime;
queue.offer(task);
}
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
18,
13,
13,
13,
30,
41,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
17,
42,
2,
0,
13,
4,
18,
13,
17,
30,
14,
4,
18,
13,
13,
17,
30,
3,
0,
13,
4,
18,
13,
17,
14,
2,
13,
17,
30,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
40,
13,
30,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
41,
13,
41,
13,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
2,
13,
13,
0,
13,
13,
12,
13,
30,
4,
18,
20,
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
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
16,
21
],
[
12,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
22,
26
],
[
26,
27
],
[
26,
28
],
[
22,
29
],
[
29,
30
],
[
29,
31
],
[
22,
32
],
[
32,
33
],
[
32,
34
],
[
22,
35
],
[
35,
36
],
[
22,
37
],
[
37,
38
],
[
37,
39
],
[
22,
40
],
[
40,
41
],
[
40,
42
],
[
22,
43
],
[
43,
44
],
[
22,
45
],
[
45,
46
],
[
45,
47
],
[
22,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
49,
55
],
[
48,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
58,
62
],
[
57,
63
],
[
63,
64
],
[
56,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
56,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
75,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
75,
92
],
[
92,
93
],
[
71,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
98,
99
],
[
98,
100
],
[
94,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
107,
108
],
[
107,
109
],
[
22,
110
],
[
110,
111
],
[
22,
112
],
[
112,
113
],
[
22,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
115,
119
],
[
114,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
120,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
120,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
135,
143
],
[
143,
144
],
[
144,
145
],
[
143,
146
],
[
135,
147
],
[
147,
148
],
[
147,
149
],
[
131,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
151,
156
],
[
157,
157
],
[
157,
158
],
[
157,
159
],
[
157,
160
],
[
160,
161
],
[
160,
162
],
[
150,
163
],
[
163,
164
],
[
163,
165
],
[
7,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
166,
172
],
[
172,
173
]
] | [
"import java.io.*;\nimport java.util.*;\n\n\nclass Main{\n public void run(){\n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){\n int count = 0;\n int n = 0,q = 0;\n String line;\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n String[] tmp;\n int spentTime = 0;\n while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }\n\n String temp_name;\n int temp_time;\n while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }\n }catch(Exception e){\n System.out.println(e);\n }\n }\n public static void main(String[] args){\n new Main().run();\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"class Main{\n public void run(){\n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){\n int count = 0;\n int n = 0,q = 0;\n String line;\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n String[] tmp;\n int spentTime = 0;\n while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }\n\n String temp_name;\n int temp_time;\n while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }\n }catch(Exception e){\n System.out.println(e);\n }\n }\n public static void main(String[] args){\n new Main().run();\n }\n}",
"Main",
"public void run(){\n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){\n int count = 0;\n int n = 0,q = 0;\n String line;\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n String[] tmp;\n int spentTime = 0;\n while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }\n\n String temp_name;\n int temp_time;\n while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }\n }catch(Exception e){\n System.out.println(e);\n }\n }",
"run",
"{\n try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){\n int count = 0;\n int n = 0,q = 0;\n String line;\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n String[] tmp;\n int spentTime = 0;\n while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }\n\n String temp_name;\n int temp_time;\n while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }\n }catch(Exception e){\n System.out.println(e);\n }\n }",
"try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){\n int count = 0;\n int n = 0,q = 0;\n String line;\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n String[] tmp;\n int spentTime = 0;\n while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }\n\n String temp_name;\n int temp_time;\n while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }\n }catch(Exception e){\n System.out.println(e);\n }",
"catch(Exception e){\n System.out.println(e);\n }",
"Exception e",
"{\n System.out.println(e);\n }",
"System.out.println(e)",
"System.out.println",
"System.out",
"System",
"System.out",
"e",
"{\n int count = 0;\n int n = 0,q = 0;\n String line;\n Deque<String> name = new ArrayDeque<>();\n Deque<Integer> time = new ArrayDeque<>();\n String[] tmp;\n int spentTime = 0;\n while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }\n\n String temp_name;\n int temp_time;\n while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"int count = 0;",
"count",
"0",
"int n = 0",
"n",
"0",
"q = 0;",
"q",
"0",
"String line;",
"line",
"Deque<String> name = new ArrayDeque<>();",
"name",
"new ArrayDeque<>()",
"Deque<Integer> time = new ArrayDeque<>();",
"time",
"new ArrayDeque<>()",
"String[] tmp;",
"tmp",
"int spentTime = 0;",
"spentTime",
"0",
"while((line = br.readLine()) != null){\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }",
"(line = br.readLine()) != null",
"(line = br.readLine())",
"line",
"br.readLine()",
"br.readLine",
"br",
"null",
"{\n // System.out.println(line);\n if(Objects.equals(line,\"\")){\n break;\n }\n tmp = line.split(\" \");\n if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }\n }",
"if(Objects.equals(line,\"\")){\n break;\n }",
"Objects.equals(line,\"\")",
"Objects.equals",
"Objects",
"line",
"\"\"",
"{\n break;\n }",
"break;",
"tmp = line.split(\" \")",
"tmp",
"line.split(\" \")",
"line.split",
"line",
"\" \"",
"if(count == 0){\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }\n else{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }",
"count == 0",
"count",
"0",
"{\n n = Integer.parseInt(tmp[0]);\n q = Integer.parseInt(tmp[1]);\n count++;\n }",
"n = Integer.parseInt(tmp[0])",
"n",
"Integer.parseInt(tmp[0])",
"Integer.parseInt",
"Integer",
"tmp[0]",
"tmp",
"0",
"q = Integer.parseInt(tmp[1])",
"q",
"Integer.parseInt(tmp[1])",
"Integer.parseInt",
"Integer",
"tmp[1]",
"tmp",
"1",
"count++",
"count",
"{\n name.addLast(tmp[0]);\n time.addLast(Integer.parseInt(tmp[1]));\n }",
"name.addLast(tmp[0])",
"name.addLast",
"name",
"tmp[0]",
"tmp",
"0",
"time.addLast(Integer.parseInt(tmp[1]))",
"time.addLast",
"time",
"Integer.parseInt(tmp[1])",
"Integer.parseInt",
"Integer",
"tmp[1]",
"tmp",
"1",
"String temp_name;",
"temp_name",
"int temp_time;",
"temp_time",
"while(name.size() != 0){\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }",
"name.size() != 0",
"name.size()",
"name.size",
"name",
"0",
"{\n temp_name = name.removeFirst();\n temp_time = time.removeFirst();\n\n if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }\n }",
"temp_name = name.removeFirst()",
"temp_name",
"name.removeFirst()",
"name.removeFirst",
"name",
"temp_time = time.removeFirst()",
"temp_time",
"time.removeFirst()",
"time.removeFirst",
"time",
"if(temp_time > q){\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }else{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }",
"temp_time > q",
"temp_time",
"q",
"{\n temp_time -= q;\n name.addLast(temp_name);\n time.addLast(temp_time);\n spentTime += q;\n }",
"temp_time -= q",
"temp_time",
"q",
"name.addLast(temp_name)",
"name.addLast",
"name",
"temp_name",
"time.addLast(temp_time)",
"time.addLast",
"time",
"temp_time",
"spentTime += q",
"spentTime",
"q",
"{\n System.out.println(temp_name + \" \" + (spentTime + temp_time));\n spentTime += temp_time;\n }",
"System.out.println(temp_name + \" \" + (spentTime + temp_time))",
"System.out.println",
"System.out",
"System",
"System.out",
"temp_name + \" \" + (spentTime + temp_time)",
"temp_name + \" \" + (spentTime + temp_time)",
"temp_name",
"\" \"",
"(spentTime + temp_time)",
"spentTime",
"temp_time",
"spentTime += temp_time",
"spentTime",
"temp_time",
"public static void main(String[] args){\n new Main().run();\n }",
"main",
"{\n new Main().run();\n }",
"new Main().run()",
"new Main().run",
"new Main()",
"String[] args",
"args"
] | import java.io.*;
import java.util.*;
class Main{
public void run(){
try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
int count = 0;
int n = 0,q = 0;
String line;
Deque<String> name = new ArrayDeque<>();
Deque<Integer> time = new ArrayDeque<>();
String[] tmp;
int spentTime = 0;
while((line = br.readLine()) != null){
// System.out.println(line);
if(Objects.equals(line,"")){
break;
}
tmp = line.split(" ");
if(count == 0){
n = Integer.parseInt(tmp[0]);
q = Integer.parseInt(tmp[1]);
count++;
}
else{
name.addLast(tmp[0]);
time.addLast(Integer.parseInt(tmp[1]));
}
}
String temp_name;
int temp_time;
while(name.size() != 0){
temp_name = name.removeFirst();
temp_time = time.removeFirst();
if(temp_time > q){
temp_time -= q;
name.addLast(temp_name);
time.addLast(temp_time);
spentTime += q;
}else{
System.out.println(temp_name + " " + (spentTime + temp_time));
spentTime += temp_time;
}
}
}catch(Exception e){
System.out.println(e);
}
}
public static void main(String[] args){
new Main().run();
}
} |
[
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,
14,
2,
4,
18,
13,
17,
13,
30,
0,
13,
4,
18,
13,
17,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
17,
13,
30,
4,
18,
13,
2,
4,
18,
13,
17,
13,
4,
18,
13,
4,
18,
13,
17,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
113,
5
],
[
113,
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
],
[
65,
68
],
[
64,
69
],
[
63,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
73,
76
],
[
70,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
77,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
83,
88
],
[
83,
89
],
[
63,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
94,
99
],
[
90,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
90,
107
],
[
107,
108
],
[
107,
109
],
[
6,
110
],
[
110,
111
],
[
0,
112
],
[
112,
113
],
[
112,
114
]
] | [
"import java.util.*;\n\npublic class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n=scan.nextInt();\n int quantam=scan.nextInt();\n int erapsedTime=0;\n ArrayList<String> pname=new ArrayList<String>();\n ArrayList<Integer> ptime=new ArrayList<Integer>();\n \n for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }\n //System.out.println(pname+\":\"+ptime);\n \n while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n=scan.nextInt();\n int quantam=scan.nextInt();\n int erapsedTime=0;\n ArrayList<String> pname=new ArrayList<String>();\n ArrayList<Integer> ptime=new ArrayList<Integer>();\n \n for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }\n //System.out.println(pname+\":\"+ptime);\n \n while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }\n }\n}",
"Main",
"public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n=scan.nextInt();\n int quantam=scan.nextInt();\n int erapsedTime=0;\n ArrayList<String> pname=new ArrayList<String>();\n ArrayList<Integer> ptime=new ArrayList<Integer>();\n \n for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }\n //System.out.println(pname+\":\"+ptime);\n \n while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }\n }",
"main",
"{\n Scanner scan=new Scanner(System.in);\n int n=scan.nextInt();\n int quantam=scan.nextInt();\n int erapsedTime=0;\n ArrayList<String> pname=new ArrayList<String>();\n ArrayList<Integer> ptime=new ArrayList<Integer>();\n \n for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }\n //System.out.println(pname+\":\"+ptime);\n \n while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }\n }",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n=scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int quantam=scan.nextInt();",
"quantam",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int erapsedTime=0;",
"erapsedTime",
"0",
"ArrayList<String> pname=new ArrayList<String>();",
"pname",
"new ArrayList<String>()",
"ArrayList<Integer> ptime=new ArrayList<Integer>();",
"ptime",
"new ArrayList<Integer>()",
"for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }",
"{\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }",
"pname.add(scan.next())",
"pname.add",
"pname",
"scan.next()",
"scan.next",
"scan",
"ptime.add(scan.nextInt())",
"ptime.add",
"ptime",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }",
"ptime.size()!=0",
"ptime.size()",
"ptime.size",
"ptime",
"0",
"{\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }",
"if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }",
"ptime.get(0)<=quantam",
"ptime.get(0)",
"ptime.get",
"ptime",
"0",
"quantam",
"{\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }",
"erapsedTime+=ptime.remove(0)",
"erapsedTime",
"ptime.remove(0)",
"ptime.remove",
"ptime",
"0",
"System.out.println(pname.remove(0)+\" \"+erapsedTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"pname.remove(0)+\" \"+erapsedTime",
"pname.remove(0)+\" \"+erapsedTime",
"pname.remove(0)",
"pname.remove",
"pname",
"0",
"\" \"",
"erapsedTime",
"{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }",
"ptime.add(ptime.remove(0)-quantam)",
"ptime.add",
"ptime",
"ptime.remove(0)-quantam",
"ptime.remove(0)",
"ptime.remove",
"ptime",
"0",
"quantam",
"pname.add(pname.remove(0))",
"pname.add",
"pname",
"pname.remove(0)",
"pname.remove",
"pname",
"0",
"erapsedTime+=quantam",
"erapsedTime",
"quantam",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args){\n Scanner scan=new Scanner(System.in);\n int n=scan.nextInt();\n int quantam=scan.nextInt();\n int erapsedTime=0;\n ArrayList<String> pname=new ArrayList<String>();\n ArrayList<Integer> ptime=new ArrayList<Integer>();\n \n for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }\n //System.out.println(pname+\":\"+ptime);\n \n while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\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 quantam=scan.nextInt();\n int erapsedTime=0;\n ArrayList<String> pname=new ArrayList<String>();\n ArrayList<Integer> ptime=new ArrayList<Integer>();\n \n for(int i=0; i<n; i++){\n pname.add(scan.next());\n ptime.add(scan.nextInt());\n }\n //System.out.println(pname+\":\"+ptime);\n \n while(ptime.size()!=0){\n if(ptime.get(0)<=quantam){\n erapsedTime+=ptime.remove(0);\n System.out.println(pname.remove(0)+\" \"+erapsedTime);\n }\n else{\n ptime.add(ptime.remove(0)-quantam);\n pname.add(pname.remove(0));\n erapsedTime+=quantam;\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int quantam=scan.nextInt();
int erapsedTime=0;
ArrayList<String> pname=new ArrayList<String>();
ArrayList<Integer> ptime=new ArrayList<Integer>();
for(int i=0; i<n; i++){
pname.add(scan.next());
ptime.add(scan.nextInt());
}
//System.out.println(pname+":"+ptime);
while(ptime.size()!=0){
if(ptime.get(0)<=quantam){
erapsedTime+=ptime.remove(0);
System.out.println(pname.remove(0)+" "+erapsedTime);
}
else{
ptime.add(ptime.remove(0)-quantam);
pname.add(pname.remove(0));
erapsedTime+=quantam;
}
}
}
}
|
[
7,
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,
41,
13,
20,
41,
13,
42,
2,
0,
13,
4,
18,
13,
17,
30,
41,
13,
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,
17,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
17,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
17,
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,
41,
13,
12,
13,
30,
4,
18,
36,
13,
4,
18,
36,
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,
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
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
231,
14
],
[
231,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
17,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
17,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
17,
45
],
[
45,
46
],
[
45,
47
],
[
17,
48
],
[
48,
49
],
[
48,
50
],
[
17,
51
],
[
51,
52
],
[
17,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
54,
60
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
61,
68
],
[
68,
69
],
[
68,
70
],
[
61,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
17,
75
],
[
75,
76
],
[
75,
77
],
[
17,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
79,
83
],
[
78,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
84,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
92,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
97,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
97,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
91,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
115,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
115,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
17,
131
],
[
131,
132
],
[
131,
133
],
[
131,
134
],
[
135,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
136,
141
],
[
142,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
142,
146
],
[
142,
147
],
[
147,
148
],
[
148,
149
],
[
15,
150
],
[
150,
151
],
[
0,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
152,
156
],
[
156,
157
],
[
152,
158
],
[
158,
159
],
[
152,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
162,
167
],
[
167,
168
],
[
168,
169
],
[
167,
170
],
[
160,
171
],
[
171,
172
],
[
160,
173
],
[
173,
174
],
[
152,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
175,
183
],
[
183,
184
],
[
152,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
152,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
190,
198
],
[
198,
199
],
[
152,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
152,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
208,
212
],
[
205,
213
],
[
213,
214
],
[
152,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
218,
219
],
[
152,
220
],
[
220,
221
],
[
220,
222
],
[
222,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
223,
227
],
[
220,
228
],
[
228,
229
],
[
0,
230
],
[
230,
231
],
[
230,
232
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\n\n\npublic class Main {\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t//????????????????????????\n\t\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\t//?????????\n\t\tString[] arrayString = bf.readLine().split(\" \");\n\t\t\n\t\tint num=Integer.parseInt(arrayString[0]);\n\t\tint q=Integer.parseInt(arrayString[1]);\n\t\t\n\t\tArrayList<Process> que=new ArrayList<Process>();\n\t\tArrayList<Process> finlist=new ArrayList<Process>();\n\t\t\n\t\tString list;\n\t\twhile((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}\n\t\t\n\t\tint time=0;\n\t\twhile(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}\n\t}\n}\n\nclass Process{\n\tprivate String name;\n\tprivate int time;\n\tprivate int finishtime;\n\t\n\tpublic Process(String name,int time){\n\t\tthis.setName(name);\n\t\tthis.setTime(time);\n\t}\n\n\tpublic void reduceTime(int q) {\n\t\tthis.time-=q;\n\n\t\t\n\t}\n\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\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 getFinishtime() {\n\t\treturn finishtime;\n\t}\n\n\tpublic void setFinishtime(int finishtime) {\n\t\tthis.finishtime = finishtime;\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.ArrayList;",
"ArrayList",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t//????????????????????????\n\t\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\t//?????????\n\t\tString[] arrayString = bf.readLine().split(\" \");\n\t\t\n\t\tint num=Integer.parseInt(arrayString[0]);\n\t\tint q=Integer.parseInt(arrayString[1]);\n\t\t\n\t\tArrayList<Process> que=new ArrayList<Process>();\n\t\tArrayList<Process> finlist=new ArrayList<Process>();\n\t\t\n\t\tString list;\n\t\twhile((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}\n\t\t\n\t\tint time=0;\n\t\twhile(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) throws NumberFormatException, IOException {\n\t\t//????????????????????????\n\t\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\t//?????????\n\t\tString[] arrayString = bf.readLine().split(\" \");\n\t\t\n\t\tint num=Integer.parseInt(arrayString[0]);\n\t\tint q=Integer.parseInt(arrayString[1]);\n\t\t\n\t\tArrayList<Process> que=new ArrayList<Process>();\n\t\tArrayList<Process> finlist=new ArrayList<Process>();\n\t\t\n\t\tString list;\n\t\twhile((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}\n\t\t\n\t\tint time=0;\n\t\twhile(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}\n\t}",
"main",
"{\n\t\t//????????????????????????\n\t\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\t//?????????\n\t\tString[] arrayString = bf.readLine().split(\" \");\n\t\t\n\t\tint num=Integer.parseInt(arrayString[0]);\n\t\tint q=Integer.parseInt(arrayString[1]);\n\t\t\n\t\tArrayList<Process> que=new ArrayList<Process>();\n\t\tArrayList<Process> finlist=new ArrayList<Process>();\n\t\t\n\t\tString list;\n\t\twhile((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}\n\t\t\n\t\tint time=0;\n\t\twhile(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}\n\t}",
"BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));",
"bf",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] arrayString = bf.readLine().split(\" \");",
"arrayString",
"bf.readLine().split(\" \")",
"bf.readLine().split",
"bf.readLine()",
"bf.readLine",
"bf",
"\" \"",
"int num=Integer.parseInt(arrayString[0]);",
"num",
"Integer.parseInt(arrayString[0])",
"Integer.parseInt",
"Integer",
"arrayString[0]",
"arrayString",
"0",
"int q=Integer.parseInt(arrayString[1]);",
"q",
"Integer.parseInt(arrayString[1])",
"Integer.parseInt",
"Integer",
"arrayString[1]",
"arrayString",
"1",
"ArrayList<Process> que=new ArrayList<Process>();",
"que",
"new ArrayList<Process>()",
"ArrayList<Process> finlist=new ArrayList<Process>();",
"finlist",
"new ArrayList<Process>()",
"String list;",
"list",
"while((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}",
"(list=bf.readLine())!=null",
"(list=bf.readLine())",
"list",
"bf.readLine()",
"bf.readLine",
"bf",
"null",
"{\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}",
"String[] str=list.split(\" \");",
"str",
"list.split(\" \")",
"list.split",
"list",
"\" \"",
"Process process=new Process(str[0],Integer.parseInt(str[1]));",
"process",
"new Process(str[0],Integer.parseInt(str[1]))",
"que.add(process)",
"que.add",
"que",
"process",
"int time=0;",
"time",
"0",
"while(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}",
"que.size()!=0",
"que.size()",
"que.size",
"que",
"0",
"{\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}",
"Process process = que.get(0);",
"process",
"que.get(0)",
"que.get",
"que",
"0",
"if(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}",
"process.getTime()<=q",
"process.getTime()",
"process.getTime",
"process",
"q",
"{\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}",
"time+=process.getTime()",
"time",
"process.getTime()",
"process.getTime",
"process",
"process.setFinishtime(time)",
"process.setFinishtime",
"process",
"time",
"finlist.add(process)",
"finlist.add",
"finlist",
"process",
"que.remove(0)",
"que.remove",
"que",
"0",
"{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}",
"time+=q",
"time",
"q",
"process.reduceTime(q)",
"process.reduceTime",
"process",
"q",
"que.add(process)",
"que.add",
"que",
"process",
"que.remove(0)",
"que.remove",
"que",
"0",
"for(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}",
"Process pro",
"finlist",
"{\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}",
"{\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}",
"System.out.println(pro.getName() + \" \" + pro.getFinishtime())",
"System.out.println",
"System.out",
"System",
"System.out",
"pro.getName() + \" \" + pro.getFinishtime()",
"pro.getName() + \" \" + pro.getFinishtime()",
"pro.getName()",
"pro.getName",
"pro",
"\" \"",
"pro.getFinishtime()",
"pro.getFinishtime",
"pro",
"String[] args",
"args",
"class Process{\n\tprivate String name;\n\tprivate int time;\n\tprivate int finishtime;\n\t\n\tpublic Process(String name,int time){\n\t\tthis.setName(name);\n\t\tthis.setTime(time);\n\t}\n\n\tpublic void reduceTime(int q) {\n\t\tthis.time-=q;\n\n\t\t\n\t}\n\n\tpublic int getTime() {\n\t\treturn time;\n\t}\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\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 getFinishtime() {\n\t\treturn finishtime;\n\t}\n\n\tpublic void setFinishtime(int finishtime) {\n\t\tthis.finishtime = finishtime;\n\t}\n}",
"Process",
"private String name;",
"name",
"private int time;",
"time",
"private int finishtime;",
"finishtime",
"public Process(String name,int time){\n\t\tthis.setName(name);\n\t\tthis.setTime(time);\n\t}",
"Process",
"{\n\t\tthis.setName(name);\n\t\tthis.setTime(time);\n\t}",
"this.setName(name)",
"this.setName",
"this",
"name",
"this.setTime(time)",
"this.setTime",
"this",
"time",
"String name",
"name",
"int time",
"time",
"public void reduceTime(int q) {\n\t\tthis.time-=q;\n\n\t\t\n\t}",
"reduceTime",
"{\n\t\tthis.time-=q;\n\n\t\t\n\t}",
"this.time-=q",
"this.time",
"this",
"this.time",
"q",
"int q",
"q",
"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 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 getFinishtime() {\n\t\treturn finishtime;\n\t}",
"getFinishtime",
"{\n\t\treturn finishtime;\n\t}",
"return finishtime;",
"finishtime",
"public void setFinishtime(int finishtime) {\n\t\tthis.finishtime = finishtime;\n\t}",
"setFinishtime",
"{\n\t\tthis.finishtime = finishtime;\n\t}",
"this.finishtime = finishtime",
"this.finishtime",
"this",
"this.finishtime",
"finishtime",
"int finishtime",
"finishtime",
"public class Main {\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t//????????????????????????\n\t\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\t//?????????\n\t\tString[] arrayString = bf.readLine().split(\" \");\n\t\t\n\t\tint num=Integer.parseInt(arrayString[0]);\n\t\tint q=Integer.parseInt(arrayString[1]);\n\t\t\n\t\tArrayList<Process> que=new ArrayList<Process>();\n\t\tArrayList<Process> finlist=new ArrayList<Process>();\n\t\t\n\t\tString list;\n\t\twhile((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}\n\t\t\n\t\tint time=0;\n\t\twhile(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) throws NumberFormatException, IOException {\n\t\t//????????????????????????\n\t\tBufferedReader bf = new BufferedReader(new InputStreamReader(System.in));\n\t\t\n\t\t//?????????\n\t\tString[] arrayString = bf.readLine().split(\" \");\n\t\t\n\t\tint num=Integer.parseInt(arrayString[0]);\n\t\tint q=Integer.parseInt(arrayString[1]);\n\t\t\n\t\tArrayList<Process> que=new ArrayList<Process>();\n\t\tArrayList<Process> finlist=new ArrayList<Process>();\n\t\t\n\t\tString list;\n\t\twhile((list=bf.readLine())!=null){\n\t\t\tString[] str=list.split(\" \");\n\t\t\tProcess process=new Process(str[0],Integer.parseInt(str[1]));\n\t\t\tque.add(process);\n\t\t}\n\t\t\n\t\tint time=0;\n\t\twhile(que.size()!=0){\n\t\t\tProcess process = que.get(0);\n\t\t\tif(process.getTime()<=q){\n\t\t\t\ttime+=process.getTime();\n\t\t\t\tprocess.setFinishtime(time);\n\t\t\t\tfinlist.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t\telse{\n\t\t\t\ttime+=q;\n\t\t\t\tprocess.reduceTime(q);\n\t\t\t\tque.add(process);\n\t\t\t\tque.remove(0);\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process pro:finlist){\n\t\t\tSystem.out.println(pro.getName() + \" \" + pro.getFinishtime());\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
//????????????????????????
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
//?????????
String[] arrayString = bf.readLine().split(" ");
int num=Integer.parseInt(arrayString[0]);
int q=Integer.parseInt(arrayString[1]);
ArrayList<Process> que=new ArrayList<Process>();
ArrayList<Process> finlist=new ArrayList<Process>();
String list;
while((list=bf.readLine())!=null){
String[] str=list.split(" ");
Process process=new Process(str[0],Integer.parseInt(str[1]));
que.add(process);
}
int time=0;
while(que.size()!=0){
Process process = que.get(0);
if(process.getTime()<=q){
time+=process.getTime();
process.setFinishtime(time);
finlist.add(process);
que.remove(0);
}
else{
time+=q;
process.reduceTime(q);
que.add(process);
que.remove(0);
}
}
for(Process pro:finlist){
System.out.println(pro.getName() + " " + pro.getFinishtime());
}
}
}
class Process{
private String name;
private int time;
private int finishtime;
public Process(String name,int time){
this.setName(name);
this.setTime(time);
}
public void reduceTime(int q) {
this.time-=q;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getFinishtime() {
return finishtime;
}
public void setFinishtime(int finishtime) {
this.finishtime = finishtime;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
0,
13,
17,
23,
13,
23,
13,
6,
13,
41,
13,
20,
41,
13,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
18,
13,
13,
29,
13,
12,
13,
30,
0,
18,
13,
13,
20,
0,
13,
18,
13,
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,
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,
13,
13,
13,
42,
2,
18,
13,
13,
17,
30,
41,
13,
4,
13,
0,
13,
18,
13,
13,
0,
13,
18,
13,
13,
0,
13,
13,
14,
2,
2,
13,
13,
17,
30,
0,
13,
2,
13,
2,
13,
13,
4,
18,
18,
13,
13,
17,
13,
13,
30,
4,
13,
13,
2,
13,
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
],
[
4,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
12,
24
],
[
24,
25
],
[
12,
26
],
[
26,
27
],
[
0,
28
],
[
187,
29
],
[
187,
30
],
[
30,
31
],
[
30,
32
],
[
187,
33
],
[
33,
34
],
[
33,
35
],
[
187,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
41,
43
],
[
38,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
38,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
56,
58
],
[
38,
59
],
[
59,
60
],
[
187,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
63,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
61,
74
],
[
74,
75
],
[
61,
76
],
[
76,
77
],
[
187,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
80,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
80,
94
],
[
94,
95
],
[
94,
96
],
[
80,
97
],
[
97,
98
],
[
80,
99
],
[
99,
100
],
[
80,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
106,
107
],
[
106,
108
],
[
101,
109
],
[
109,
110
],
[
110,
111
],
[
101,
112
],
[
113,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
113,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
113,
124
],
[
124,
125
],
[
124,
126
],
[
124,
127
],
[
80,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
128,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
141,
143
],
[
134,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
146,
148
],
[
134,
149
],
[
149,
150
],
[
149,
151
],
[
134,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
152,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
163,
165
],
[
158,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
166,
171
],
[
166,
172
],
[
166,
173
],
[
152,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
175,
178
],
[
178,
179
],
[
178,
180
],
[
80,
181
],
[
181,
182
],
[
182,
183
],
[
78,
184
],
[
184,
185
],
[
0,
186
],
[
186,
187
],
[
186,
188
]
] | [
"import java.util.Scanner;\n\nclass Data{\n\tString name;\n\tint time;\n\tData next;\n\t\n\tData(String s,int t){\n\t\tname=s;\n\t\ttime=t;\n\t\tnext=null;\n\t}\n}\n\npublic class Main {\n\tstatic Data first=new Data(\"\",0);\n\tstatic Data attention=first;\n\t\n\tstatic Data dequeue(){\n\t\tData tmp=first.next;\n\t\tif(attention==tmp){\n\t\t\tattention=first;\n\t\t}\n\t\tfirst.next=tmp.next;\n\t\treturn tmp;\n\t}\n\t\n\tstatic void enqueue(String s,int t){\n\t\tattention.next=new Data(s,t);\n\t\tattention=attention.next;\n\t}\n\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\tint finish=0;\n\t\tString s;\n\t\tint t;\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}\n\n\t\twhile(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tscan.close();\n\t\t\n\t}\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Data{\n\tString name;\n\tint time;\n\tData next;\n\t\n\tData(String s,int t){\n\t\tname=s;\n\t\ttime=t;\n\t\tnext=null;\n\t}\n}",
"Data",
"String name;",
"name",
"int time;",
"time",
"Data next;",
"next",
"Data(String s,int t){\n\t\tname=s;\n\t\ttime=t;\n\t\tnext=null;\n\t}",
"Data",
"{\n\t\tname=s;\n\t\ttime=t;\n\t\tnext=null;\n\t}",
"name=s",
"name",
"s",
"time=t",
"time",
"t",
"next=null",
"next",
"null",
"String s",
"s",
"int t",
"t",
"public class Main {\n\tstatic Data first=new Data(\"\",0);\n\tstatic Data attention=first;\n\t\n\tstatic Data dequeue(){\n\t\tData tmp=first.next;\n\t\tif(attention==tmp){\n\t\t\tattention=first;\n\t\t}\n\t\tfirst.next=tmp.next;\n\t\treturn tmp;\n\t}\n\t\n\tstatic void enqueue(String s,int t){\n\t\tattention.next=new Data(s,t);\n\t\tattention=attention.next;\n\t}\n\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\tint finish=0;\n\t\tString s;\n\t\tint t;\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}\n\n\t\twhile(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tscan.close();\n\t\t\n\t}\n\n}",
"Main",
"static Data first=new Data(\"\",0);",
"first",
"new Data(\"\",0)",
"static Data attention=first;",
"attention",
"first",
"static Data dequeue(){\n\t\tData tmp=first.next;\n\t\tif(attention==tmp){\n\t\t\tattention=first;\n\t\t}\n\t\tfirst.next=tmp.next;\n\t\treturn tmp;\n\t}",
"dequeue",
"{\n\t\tData tmp=first.next;\n\t\tif(attention==tmp){\n\t\t\tattention=first;\n\t\t}\n\t\tfirst.next=tmp.next;\n\t\treturn tmp;\n\t}",
"Data tmp=first.next;",
"tmp",
"first.next",
"first",
"first.next",
"if(attention==tmp){\n\t\t\tattention=first;\n\t\t}",
"attention==tmp",
"attention",
"tmp",
"{\n\t\t\tattention=first;\n\t\t}",
"attention=first",
"attention",
"first",
"first.next=tmp.next",
"first.next",
"first",
"first.next",
"tmp.next",
"tmp",
"tmp.next",
"return tmp;",
"tmp",
"static void enqueue(String s,int t){\n\t\tattention.next=new Data(s,t);\n\t\tattention=attention.next;\n\t}",
"enqueue",
"{\n\t\tattention.next=new Data(s,t);\n\t\tattention=attention.next;\n\t}",
"attention.next=new Data(s,t)",
"attention.next",
"attention",
"attention.next",
"new Data(s,t)",
"attention=attention.next",
"attention",
"attention.next",
"attention",
"attention.next",
"String s",
"s",
"int t",
"t",
"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\tint finish=0;\n\t\tString s;\n\t\tint t;\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}\n\n\t\twhile(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tscan.close();\n\t\t\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\tint finish=0;\n\t\tString s;\n\t\tint t;\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}\n\n\t\twhile(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tscan.close();\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 finish=0;",
"finish",
"0",
"String s;",
"s",
"int t;",
"t",
"for(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}",
"{\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}",
"s=scan.next()",
"s",
"scan.next()",
"scan.next",
"scan",
"t=scan.nextInt()",
"t",
"scan.nextInt()",
"scan.nextInt",
"scan",
"enqueue(s,t)",
"enqueue",
"s",
"t",
"while(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}",
"first.next!=null",
"first.next",
"first",
"first.next",
"null",
"{\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}",
"Data tmp=dequeue();",
"tmp",
"dequeue()",
"dequeue",
"s=tmp.name",
"s",
"tmp.name",
"tmp",
"tmp.name",
"t=tmp.time",
"t",
"tmp.time",
"tmp",
"tmp.time",
"finish+=q",
"finish",
"q",
"if(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}",
"t-q<=0",
"t-q",
"t",
"q",
"0",
"{//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}",
"finish=finish+(t-q)",
"finish",
"finish+(t-q)",
"finish",
"(t-q)",
"t",
"q",
"System.out.printf(\"%s %d\\n\",s,finish)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"s",
"finish",
"{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}",
"enqueue(s,t-q)",
"enqueue",
"s",
"t-q",
"t",
"q",
"scan.close()",
"scan.close",
"scan",
"String[] args",
"args",
"public class Main {\n\tstatic Data first=new Data(\"\",0);\n\tstatic Data attention=first;\n\t\n\tstatic Data dequeue(){\n\t\tData tmp=first.next;\n\t\tif(attention==tmp){\n\t\t\tattention=first;\n\t\t}\n\t\tfirst.next=tmp.next;\n\t\treturn tmp;\n\t}\n\t\n\tstatic void enqueue(String s,int t){\n\t\tattention.next=new Data(s,t);\n\t\tattention=attention.next;\n\t}\n\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\tint finish=0;\n\t\tString s;\n\t\tint t;\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}\n\n\t\twhile(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tscan.close();\n\t\t\n\t}\n\n}",
"public class Main {\n\tstatic Data first=new Data(\"\",0);\n\tstatic Data attention=first;\n\t\n\tstatic Data dequeue(){\n\t\tData tmp=first.next;\n\t\tif(attention==tmp){\n\t\t\tattention=first;\n\t\t}\n\t\tfirst.next=tmp.next;\n\t\treturn tmp;\n\t}\n\t\n\tstatic void enqueue(String s,int t){\n\t\tattention.next=new Data(s,t);\n\t\tattention=attention.next;\n\t}\n\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\tint finish=0;\n\t\tString s;\n\t\tint t;\n\t\tfor(int i=0;i<n;i++){\n\t\t\ts=scan.next();\n\t\t\tt=scan.nextInt();\n\t\t\tenqueue(s,t);\n\t\t}\n\n\t\twhile(first.next!=null){\n\t\t\tData tmp=dequeue();\n\t\t\ts=tmp.name;\n\t\t\tt=tmp.time;\n\t\t\tfinish+=q;\n\t\t\tif(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ\n\t\t\t\tfinish=finish+(t-q);\n\t\t\t\tSystem.out.printf(\"%s %d\\n\",s,finish);\n\t\t\t}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ\n\t\t\t\tenqueue(s,t-q);\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tscan.close();\n\t\t\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
class Data{
String name;
int time;
Data next;
Data(String s,int t){
name=s;
time=t;
next=null;
}
}
public class Main {
static Data first=new Data("",0);
static Data attention=first;
static Data dequeue(){
Data tmp=first.next;
if(attention==tmp){
attention=first;
}
first.next=tmp.next;
return tmp;
}
static void enqueue(String s,int t){
attention.next=new Data(s,t);
attention=attention.next;
}
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();//ใใญใปในๆฐใ
int q=scan.nextInt();//ใฏใฉใณใฟใ
int finish=0;
String s;
int t;
for(int i=0;i<n;i++){
s=scan.next();
t=scan.nextInt();
enqueue(s,t);
}
while(first.next!=null){
Data tmp=dequeue();
s=tmp.name;
t=tmp.time;
finish+=q;
if(t-q<=0){//ใใญใปในใ็ตไบใใๅ ดๅ
finish=finish+(t-q);
System.out.printf("%s %d\n",s,finish);
}else{//ใใญใปในใใพใ ็ตไบใใชใๅ ดๅ
enqueue(s,t-q);
}
}
scan.close();
}
} |
[
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,
41,
13,
17,
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,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
2,
13,
13,
17,
30,
4,
18,
13,
2,
2,
13,
17,
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
],
[
123,
8
],
[
123,
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
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
35,
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
],
[
11,
56
],
[
56,
57
],
[
57,
58
],
[
11,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
59,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
67,
72
],
[
64,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
75,
77
],
[
64,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
83,
84
],
[
83,
85
],
[
64,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
97,
97
],
[
97,
98
],
[
97,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
92,
103
],
[
103,
104
],
[
103,
105
],
[
86,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
106,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
116,
116
],
[
116,
117
],
[
116,
118
],
[
116,
119
],
[
9,
120
],
[
120,
121
],
[
0,
122
],
[
122,
123
],
[
122,
124
]
] | [
"import java.util.Scanner;\nimport java.util.LinkedList;\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tLinkedList<String> processes = new LinkedList<>();\n\t\tint numProcesses = scanner.nextInt();\n\t\tint quantum = scanner.nextInt();\n\t\tint timestamp = 0;\n\t\tString result = \"\";\n\t\t//get all processes from scanner\n\t\tscanner.nextLine();\n\t\tfor (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\twhile (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tLinkedList<String> processes = new LinkedList<>();\n\t\tint numProcesses = scanner.nextInt();\n\t\tint quantum = scanner.nextInt();\n\t\tint timestamp = 0;\n\t\tString result = \"\";\n\t\t//get all processes from scanner\n\t\tscanner.nextLine();\n\t\tfor (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\twhile (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tLinkedList<String> processes = new LinkedList<>();\n\t\tint numProcesses = scanner.nextInt();\n\t\tint quantum = scanner.nextInt();\n\t\tint timestamp = 0;\n\t\tString result = \"\";\n\t\t//get all processes from scanner\n\t\tscanner.nextLine();\n\t\tfor (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\twhile (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tLinkedList<String> processes = new LinkedList<>();\n\t\tint numProcesses = scanner.nextInt();\n\t\tint quantum = scanner.nextInt();\n\t\tint timestamp = 0;\n\t\tString result = \"\";\n\t\t//get all processes from scanner\n\t\tscanner.nextLine();\n\t\tfor (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\twhile (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"LinkedList<String> processes = new LinkedList<>();",
"processes",
"new LinkedList<>()",
"int numProcesses = scanner.nextInt();",
"numProcesses",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int quantum = scanner.nextInt();",
"quantum",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int timestamp = 0;",
"timestamp",
"0",
"String result = \"\";",
"result",
"\"\"",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"for (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numProcesses",
"i",
"numProcesses",
"i++",
"i++",
"i",
"{\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}",
"{\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}",
"processes.add(scanner.nextLine())",
"processes.add",
"processes",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"scanner.close()",
"scanner.close",
"scanner",
"while (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}",
"!processes.isEmpty()",
"processes.isEmpty()",
"processes.isEmpty",
"processes",
"{\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}",
"String[] process = processes.remove().split(\" \");",
"process",
"processes.remove().split(\" \")",
"processes.remove().split",
"processes.remove()",
"processes.remove",
"processes",
"\" \"",
"String name = process[0];",
"name",
"process[0]",
"process",
"0",
"int timeLeft = Integer.parseInt(process[1]);",
"timeLeft",
"Integer.parseInt(process[1])",
"Integer.parseInt",
"Integer",
"process[1]",
"process",
"1",
"if (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}",
"timeLeft-quantum > 0",
"timeLeft-quantum",
"timeLeft",
"quantum",
"0",
"{\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}",
"processes.add(name + \" \" + (timeLeft-quantum))",
"processes.add",
"processes",
"name + \" \" + (timeLeft-quantum)",
"name + \" \" + (timeLeft-quantum)",
"name",
"\" \"",
"(timeLeft-quantum)",
"timeLeft",
"quantum",
"timestamp += quantum",
"timestamp",
"quantum",
"{\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}",
"timestamp += timeLeft",
"timestamp",
"timeLeft",
"System.out.println(name + \" \" + (timestamp))",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + (timestamp)",
"name + \" \" + (timestamp)",
"name",
"\" \"",
"(timestamp)",
"String[] args",
"args",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tLinkedList<String> processes = new LinkedList<>();\n\t\tint numProcesses = scanner.nextInt();\n\t\tint quantum = scanner.nextInt();\n\t\tint timestamp = 0;\n\t\tString result = \"\";\n\t\t//get all processes from scanner\n\t\tscanner.nextLine();\n\t\tfor (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\twhile (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tLinkedList<String> processes = new LinkedList<>();\n\t\tint numProcesses = scanner.nextInt();\n\t\tint quantum = scanner.nextInt();\n\t\tint timestamp = 0;\n\t\tString result = \"\";\n\t\t//get all processes from scanner\n\t\tscanner.nextLine();\n\t\tfor (int i = 0; i < numProcesses; i++) {\n\t\t\tprocesses.add(scanner.nextLine());\n\t\t}\n\t\tscanner.close();\n\t\t\n\t\twhile (!processes.isEmpty()) {\n\t\t\t//parse process\n\t\t\tString[] process = processes.remove().split(\" \");\n\t\t\tString name = process[0];\n\t\t\tint timeLeft = Integer.parseInt(process[1]);\n\t\t\t\n\t\t\t//decrement time left and add back to queue if necessary\n\t\t\tif (timeLeft-quantum > 0) {\n\t\t\t\tprocesses.add(name + \" \" + (timeLeft-quantum));\n\t\t\t\ttimestamp += quantum;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttimestamp += timeLeft;\n\t\t\t\tSystem.out.println(name + \" \" + (timestamp));\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.Scanner;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
LinkedList<String> processes = new LinkedList<>();
int numProcesses = scanner.nextInt();
int quantum = scanner.nextInt();
int timestamp = 0;
String result = "";
//get all processes from scanner
scanner.nextLine();
for (int i = 0; i < numProcesses; i++) {
processes.add(scanner.nextLine());
}
scanner.close();
while (!processes.isEmpty()) {
//parse process
String[] process = processes.remove().split(" ");
String name = process[0];
int timeLeft = Integer.parseInt(process[1]);
//decrement time left and add back to queue if necessary
if (timeLeft-quantum > 0) {
processes.add(name + " " + (timeLeft-quantum));
timestamp += quantum;
}
else {
timestamp += timeLeft;
System.out.println(name + " " + (timestamp));
}
}
}
}
|
[
7,
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,
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,
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,
41,
13,
20,
41,
13,
41,
13,
0,
13,
17,
42,
2,
17,
0,
13,
4,
18,
13,
30,
14,
2,
18,
13,
13,
13,
30,
4,
18,
13,
18,
13,
13,
4,
18,
13,
17,
0,
13,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
17,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
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
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
15,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
13,
26
],
[
26,
27
],
[
13,
28
],
[
28,
29
],
[
0,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
42,
47
],
[
38,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
51,
56
],
[
48,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
62,
64
],
[
48,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
70,
71
],
[
70,
72
],
[
48,
73
],
[
73,
74
],
[
73,
75
],
[
48,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
76,
81
],
[
81,
82
],
[
81,
83
],
[
76,
84
],
[
84,
85
],
[
85,
86
],
[
76,
87
],
[
88,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
91,
96
],
[
88,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
48,
101
],
[
101,
102
],
[
101,
103
],
[
48,
104
],
[
104,
105
],
[
48,
106
],
[
106,
107
],
[
48,
108
],
[
108,
109
],
[
108,
110
],
[
48,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
120,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
130,
131
],
[
130,
132
],
[
126,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
126,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
126,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
126,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
120,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
150,
156
],
[
156,
157
],
[
157,
158
],
[
156,
159
],
[
150,
160
],
[
160,
161
],
[
160,
162
],
[
48,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
32,
169
],
[
169,
170
]
] | [
"import java.io.*;\nimport java.util.*;\n\nclass Ps {\n String name;\n Integer t;\n \n public Ps( String name, Integer t )\n {\n this.name = name;\n this.t = t;\n }\n}\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 \n LinkedList<Ps> queue = new LinkedList<Ps>();\n \n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }\n \n StringBuilder output = new StringBuilder( ); \n Ps ps; \n int time;\n \ttime = 0;\n while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\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 Ps {\n String name;\n Integer t;\n \n public Ps( String name, Integer t )\n {\n this.name = name;\n this.t = t;\n }\n}",
"Ps",
"String name;",
"name",
"Integer t;",
"t",
"public Ps( String name, Integer t )\n {\n this.name = name;\n this.t = t;\n }",
"Ps",
"{\n this.name = name;\n this.t = t;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.t = t",
"this.t",
"this",
"this.t",
"t",
"String name",
"name",
"Integer t",
"t",
"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 \n LinkedList<Ps> queue = new LinkedList<Ps>();\n \n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }\n \n StringBuilder output = new StringBuilder( ); \n Ps ps; \n int time;\n \ttime = 0;\n while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\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 \n LinkedList<Ps> queue = new LinkedList<Ps>();\n \n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }\n \n StringBuilder output = new StringBuilder( ); \n Ps ps; \n int time;\n \ttime = 0;\n while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\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 \n LinkedList<Ps> queue = new LinkedList<Ps>();\n \n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }\n \n StringBuilder output = new StringBuilder( ); \n Ps ps; \n int time;\n \ttime = 0;\n while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\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 \n LinkedList<Ps> queue = new LinkedList<Ps>();\n \n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }\n \n StringBuilder output = new StringBuilder( ); \n Ps ps; \n int time;\n \ttime = 0;\n while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\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 \n LinkedList<Ps> queue = new LinkedList<Ps>();\n \n for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }\n \n StringBuilder output = new StringBuilder( ); \n Ps ps; \n int time;\n \ttime = 0;\n while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\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<Ps> queue = new LinkedList<Ps>();",
"queue",
"new LinkedList<Ps>()",
"for( int i=0; i<n; i++ ) {\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], 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 queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }",
"{\n str = kb.readLine().split( \" \" );\n queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );\n }",
"str = kb.readLine().split( \" \" )",
"str",
"kb.readLine().split( \" \" )",
"kb.readLine().split",
"kb.readLine()",
"kb.readLine",
"kb",
"\" \"",
"queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) )",
"queue.offer",
"queue",
"new Ps( str[0], Integer.parseInt( str[1] ) )",
"StringBuilder output = new StringBuilder( );",
"output",
"new StringBuilder( )",
"Ps ps;",
"ps",
"int time;",
"time",
"time = 0",
"time",
"0",
"while( null != ( ps = queue.poll() ) ) {\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\n }",
"null != ( ps = queue.poll() )",
"null",
"( ps = queue.poll() )",
"ps",
"queue.poll()",
"queue.poll",
"queue",
"{\n \t\n if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }\n }",
"if( ps.t <= q ) {\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n } else {\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }",
"ps.t <= q",
"ps.t",
"ps",
"ps.t",
"q",
"{\n output.append( ps.name );\n output.append( \" \" );\n time += ps.t; \n output.append( time );\n output.append( \"\\n\" );\n \n }",
"output.append( ps.name )",
"output.append",
"output",
"ps.name",
"ps",
"ps.name",
"output.append( \" \" )",
"output.append",
"output",
"\" \"",
"time += ps.t",
"time",
"ps.t",
"ps",
"ps.t",
"output.append( time )",
"output.append",
"output",
"time",
"output.append( \"\\n\" )",
"output.append",
"output",
"\"\\n\"",
"{\n \tps.t -= q;\n queue.offer( ps );\n time += q; \n }",
"ps.t -= q",
"ps.t",
"ps",
"ps.t",
"q",
"queue.offer( ps )",
"queue.offer",
"queue",
"ps",
"time += q",
"time",
"q",
"System.out.print( output )",
"System.out.print",
"System.out",
"System",
"System.out",
"output",
"String[] args",
"args"
] | import java.io.*;
import java.util.*;
class Ps {
String name;
Integer t;
public Ps( String name, Integer t )
{
this.name = name;
this.t = t;
}
}
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<Ps> queue = new LinkedList<Ps>();
for( int i=0; i<n; i++ ) {
str = kb.readLine().split( " " );
queue.offer( new Ps( str[0], Integer.parseInt( str[1] ) ) );
}
StringBuilder output = new StringBuilder( );
Ps ps;
int time;
time = 0;
while( null != ( ps = queue.poll() ) ) {
if( ps.t <= q ) {
output.append( ps.name );
output.append( " " );
time += ps.t;
output.append( time );
output.append( "\n" );
} else {
ps.t -= q;
queue.offer( ps );
time += q;
}
}
System.out.print( output );
} catch( IOException e ) {
System.err.println( e );
}
}
} |
[
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,
11,
1,
41,
13,
17,
40,
4,
18,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
2,
18,
13,
13,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
145,
11
],
[
145,
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
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
58,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
58,
67
],
[
68,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
75,
81
],
[
74,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
85,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
88,
93
],
[
94,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
94,
99
],
[
74,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
100,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
100,
110
],
[
110,
111
],
[
110,
112
],
[
145,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
113,
119
],
[
119,
120
],
[
145,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
121,
125
],
[
125,
126
],
[
121,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
127,
140
],
[
140,
141
],
[
127,
142
],
[
142,
143
],
[
0,
144
],
[
144,
145
],
[
144,
146
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\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\tclass 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\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main",
"void run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}",
"run",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\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",
"Queue<Process> que = new LinkedList<Process>();",
"que",
"new LinkedList<Process>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.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 = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"{\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}",
"String name = scan.next();",
"name",
"scan.next()",
"scan.next",
"scan",
"int time = scan.nextInt();",
"time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"que.add(new Process(name, time))",
"que.add",
"que",
"new Process(name, time)",
"for (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"int time = 0;",
"int time = 0;",
"time",
"0",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"{\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"Process p = que.poll();",
"p",
"que.poll()",
"que.poll",
"que",
"if (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}",
"p.time - q <= 0",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"0",
"{\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t}",
"time += p.time",
"time",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + time",
"p.name + \" \" + time",
"p.name",
"p",
"p.name",
"\" \"",
"time",
"{\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"que.add(p)",
"que.add",
"que",
"p",
"time += q",
"time",
"q",
"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",
"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",
"public class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"public class Main {\n\tclass 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\tvoid run() {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\n\t\tQueue<Process> que = new LinkedList<Process>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tque.add(new Process(name, time));\n\t\t}\n\t\tfor (int time = 0; !que.isEmpty();) {\n\t\t\tProcess p = que.poll();\n\t\t\tif (p.time - q <= 0) {\n\t\t\t\ttime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\tp.time -= q;\n\t\t\t\tque.add(p);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
class Process {
String name;
int time;
Process(String name, int time) {
this.name = name;
this.time = time;
}
}
void run() {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int q = scan.nextInt();
Queue<Process> que = new LinkedList<Process>();
for (int i = 0; i < n; i++) {
String name = scan.next();
int time = scan.nextInt();
que.add(new Process(name, time));
}
for (int time = 0; !que.isEmpty();) {
Process p = que.poll();
if (p.time - q <= 0) {
time += p.time;
System.out.println(p.name + " " + time);
} else {
p.time -= q;
que.add(p);
time += q;
}
}
}
public static void main(String[] args) {
new Main().run();
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
13,
0,
13,
17,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
29,
13,
6,
13,
41,
13,
17,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
13,
0,
13,
17,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
0,
13,
17,
40,
13,
29,
13,
6,
13,
41,
13,
20,
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,
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,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
17,
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
],
[
4,
11
],
[
11,
12
],
[
4,
13
],
[
13,
14
],
[
4,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
22
],
[
22,
23
],
[
22,
24
],
[
17,
25
],
[
25,
26
],
[
25,
27
],
[
4,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
4,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
37,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
44,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
43,
52
],
[
52,
53
],
[
35,
54
],
[
54,
55
],
[
4,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
61,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
64,
73
],
[
73,
74
],
[
58,
75
],
[
75,
76
],
[
0,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
81
],
[
77,
82
],
[
82,
83
],
[
77,
84
],
[
84,
85
],
[
77,
86
],
[
86,
87
],
[
77,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
95
],
[
95,
96
],
[
95,
97
],
[
90,
98
],
[
98,
99
],
[
98,
100
],
[
77,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
77,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
116,
122
],
[
122,
123
],
[
122,
124
],
[
116,
125
],
[
125,
126
],
[
108,
127
],
[
127,
128
],
[
77,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
131,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
137,
143
],
[
143,
144
],
[
143,
145
],
[
137,
146
],
[
146,
147
],
[
131,
148
],
[
148,
149
],
[
0,
150
],
[
255,
151
],
[
255,
152
],
[
152,
153
],
[
152,
154
],
[
255,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
161,
163
],
[
157,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
157,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
157,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
179,
180
],
[
179,
181
],
[
174,
182
],
[
182,
183
],
[
183,
184
],
[
174,
185
],
[
186,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
187,
190
],
[
190,
191
],
[
191,
192
],
[
186,
193
],
[
193,
194
],
[
194,
195
],
[
193,
196
],
[
196,
197
],
[
197,
198
],
[
157,
199
],
[
199,
200
],
[
199,
201
],
[
157,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
202,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
207,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
207,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
218,
222
],
[
222,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
225,
227
],
[
222,
228
],
[
228,
229
],
[
229,
230
],
[
228,
231
],
[
222,
232
],
[
232,
233
],
[
233,
234
],
[
232,
235
],
[
235,
236
],
[
235,
237
],
[
218,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
241,
242
],
[
241,
243
],
[
238,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
244,
249
],
[
244,
250
],
[
244,
251
],
[
155,
252
],
[
252,
253
],
[
0,
254
],
[
254,
255
],
[
254,
256
]
] | [
"import java.util.*;\n\nclass IntQue{\n final int MAX=100000;\n int[] q;\n int head,tail;\n IntQue(){\n q=new int[MAX];\n head=0;tail=0;\n }\n boolean isEmpty(){\n return head==tail;\n }\n void enqueue(int time){\n q[tail]=time;\n if(tail+1==MAX) tail=0;\n else tail++;\n }\n int dequeue(){\n int t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }\n}\nclass StringQue{\n final int MAX=100000;\n String[] q;\n int head,tail;\n StringQue(){\n q=new String[MAX];\n head=0;tail=0;\n }\n boolean isEmpty(){\n return head==tail;\n }\n void enqueue(String name){\n q[tail]=name;\n if(tail+1==MAX) tail=0;\n else tail++;\n }\n String dequeue(){\n String t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }\n}\npublic class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n IntQue iq=new IntQue();\n StringQue sq=new StringQue();\n int n=sc.nextInt();\n int qms=sc.nextInt();\n for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }\n int total=0;\n while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class IntQue{\n final int MAX=100000;\n int[] q;\n int head,tail;\n IntQue(){\n q=new int[MAX];\n head=0;tail=0;\n }\n boolean isEmpty(){\n return head==tail;\n }\n void enqueue(int time){\n q[tail]=time;\n if(tail+1==MAX) tail=0;\n else tail++;\n }\n int dequeue(){\n int t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }\n}",
"IntQue",
"final int MAX=100000;",
"MAX",
"100000",
"int[] q;",
"q",
"int head",
"head",
"tail;",
"tail",
"IntQue(){\n q=new int[MAX];\n head=0;tail=0;\n }",
"IntQue",
"{\n q=new int[MAX];\n head=0;tail=0;\n }",
"q=new int[MAX]",
"q",
"new int[MAX]",
"MAX",
"head=0",
"head",
"0",
"tail=0",
"tail",
"0",
"boolean isEmpty(){\n return head==tail;\n }",
"isEmpty",
"{\n return head==tail;\n }",
"return head==tail;",
"head==tail",
"head",
"tail",
"void enqueue(int time){\n q[tail]=time;\n if(tail+1==MAX) tail=0;\n else tail++;\n }",
"enqueue",
"{\n q[tail]=time;\n if(tail+1==MAX) tail=0;\n else tail++;\n }",
"q[tail]=time",
"q[tail]",
"q",
"tail",
"time",
"if(tail+1==MAX) tail=0;\n else tail++;",
"tail+1==MAX",
"tail+1",
"tail",
"1",
"MAX",
"tail=0",
"tail",
"0",
"tail++",
"tail",
"int time",
"time",
"int dequeue(){\n int t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }",
"dequeue",
"{\n int t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }",
"int t=q[head];",
"t",
"q[head]",
"q",
"head",
"if(head+1==MAX) head=0;\n else head++;",
"head+1==MAX",
"head+1",
"head",
"1",
"MAX",
"head=0",
"head",
"0",
"head++",
"head",
"return t;",
"t",
"class StringQue{\n final int MAX=100000;\n String[] q;\n int head,tail;\n StringQue(){\n q=new String[MAX];\n head=0;tail=0;\n }\n boolean isEmpty(){\n return head==tail;\n }\n void enqueue(String name){\n q[tail]=name;\n if(tail+1==MAX) tail=0;\n else tail++;\n }\n String dequeue(){\n String t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }\n}",
"StringQue",
"final int MAX=100000;",
"MAX",
"100000",
"String[] q;",
"q",
"int head",
"head",
"tail;",
"tail",
"StringQue(){\n q=new String[MAX];\n head=0;tail=0;\n }",
"StringQue",
"{\n q=new String[MAX];\n head=0;tail=0;\n }",
"q=new String[MAX]",
"q",
"new String[MAX]",
"MAX",
"head=0",
"head",
"0",
"tail=0",
"tail",
"0",
"boolean isEmpty(){\n return head==tail;\n }",
"isEmpty",
"{\n return head==tail;\n }",
"return head==tail;",
"head==tail",
"head",
"tail",
"void enqueue(String name){\n q[tail]=name;\n if(tail+1==MAX) tail=0;\n else tail++;\n }",
"enqueue",
"{\n q[tail]=name;\n if(tail+1==MAX) tail=0;\n else tail++;\n }",
"q[tail]=name",
"q[tail]",
"q",
"tail",
"name",
"if(tail+1==MAX) tail=0;\n else tail++;",
"tail+1==MAX",
"tail+1",
"tail",
"1",
"MAX",
"tail=0",
"tail",
"0",
"tail++",
"tail",
"String name",
"name",
"String dequeue(){\n String t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }",
"dequeue",
"{\n String t=q[head];\n if(head+1==MAX) head=0;\n else head++;\n return t;\n }",
"String t=q[head];",
"t",
"q[head]",
"q",
"head",
"if(head+1==MAX) head=0;\n else head++;",
"head+1==MAX",
"head+1",
"head",
"1",
"MAX",
"head=0",
"head",
"0",
"head++",
"head",
"return t;",
"t",
"public class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n IntQue iq=new IntQue();\n StringQue sq=new StringQue();\n int n=sc.nextInt();\n int qms=sc.nextInt();\n for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }\n int total=0;\n while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }\n }\n}",
"Main",
"private static Scanner sc=new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"public static void main(String[] args){\n IntQue iq=new IntQue();\n StringQue sq=new StringQue();\n int n=sc.nextInt();\n int qms=sc.nextInt();\n for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }\n int total=0;\n while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }\n }",
"main",
"{\n IntQue iq=new IntQue();\n StringQue sq=new StringQue();\n int n=sc.nextInt();\n int qms=sc.nextInt();\n for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }\n int total=0;\n while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }\n }",
"IntQue iq=new IntQue();",
"iq",
"new IntQue()",
"StringQue sq=new StringQue();",
"sq",
"new StringQue()",
"int n=sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int qms=sc.nextInt();",
"qms",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }",
"{\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }",
"sq.enqueue(sc.next())",
"sq.enqueue",
"sq",
"sc.next()",
"sc.next",
"sc",
"iq.enqueue(sc.nextInt())",
"iq.enqueue",
"iq",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int total=0;",
"total",
"0",
"while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }",
"!(iq.isEmpty())",
"(iq.isEmpty())",
"iq.isEmpty",
"iq",
"{\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }",
"String name=sq.dequeue();",
"name",
"sq.dequeue()",
"sq.dequeue",
"sq",
"int time=iq.dequeue();",
"time",
"iq.dequeue()",
"iq.dequeue",
"iq",
"if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }",
"time>qms",
"time",
"qms",
"{\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }",
"total=total+qms",
"total",
"total+qms",
"total",
"qms",
"sq.enqueue(name)",
"sq.enqueue",
"sq",
"name",
"iq.enqueue(time-qms)",
"iq.enqueue",
"iq",
"time-qms",
"time",
"qms",
"{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }",
"total=total+time",
"total",
"total+time",
"total",
"time",
"System.out.printf(\"%s %d\\n\",name,total)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"name",
"total",
"String[] args",
"args",
"public class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n IntQue iq=new IntQue();\n StringQue sq=new StringQue();\n int n=sc.nextInt();\n int qms=sc.nextInt();\n for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }\n int total=0;\n while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }\n }\n}",
"public class Main {\n private static Scanner sc=new Scanner(System.in);\n public static void main(String[] args){\n IntQue iq=new IntQue();\n StringQue sq=new StringQue();\n int n=sc.nextInt();\n int qms=sc.nextInt();\n for(int i=0;i<n;i++){\n sq.enqueue(sc.next());\n iq.enqueue(sc.nextInt());\n }\n int total=0;\n while(!(iq.isEmpty())){\n String name=sq.dequeue();\n int time=iq.dequeue();\n if(time>qms){\n total=total+qms;\n sq.enqueue(name);\n iq.enqueue(time-qms);\n }else{\n total=total+time;\n System.out.printf(\"%s %d\\n\",name,total);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
class IntQue{
final int MAX=100000;
int[] q;
int head,tail;
IntQue(){
q=new int[MAX];
head=0;tail=0;
}
boolean isEmpty(){
return head==tail;
}
void enqueue(int time){
q[tail]=time;
if(tail+1==MAX) tail=0;
else tail++;
}
int dequeue(){
int t=q[head];
if(head+1==MAX) head=0;
else head++;
return t;
}
}
class StringQue{
final int MAX=100000;
String[] q;
int head,tail;
StringQue(){
q=new String[MAX];
head=0;tail=0;
}
boolean isEmpty(){
return head==tail;
}
void enqueue(String name){
q[tail]=name;
if(tail+1==MAX) tail=0;
else tail++;
}
String dequeue(){
String t=q[head];
if(head+1==MAX) head=0;
else head++;
return t;
}
}
public class Main {
private static Scanner sc=new Scanner(System.in);
public static void main(String[] args){
IntQue iq=new IntQue();
StringQue sq=new StringQue();
int n=sc.nextInt();
int qms=sc.nextInt();
for(int i=0;i<n;i++){
sq.enqueue(sc.next());
iq.enqueue(sc.nextInt());
}
int total=0;
while(!(iq.isEmpty())){
String name=sq.dequeue();
int time=iq.dequeue();
if(time>qms){
total=total+qms;
sq.enqueue(name);
iq.enqueue(time-qms);
}else{
total=total+time;
System.out.printf("%s %d\n",name,total);
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
17,
0,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
20,
17,
0,
13,
17,
0,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
18,
13,
13,
20,
42,
2,
13,
13,
30,
41,
13,
4,
13,
41,
13,
4,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
4,
13,
13,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
18,
13,
13,
29,
13,
12,
13,
30,
14,
2,
13,
13,
30,
29,
13,
30,
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
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
16,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
16,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
16,
33
],
[
33,
34
],
[
33,
35
],
[
16,
37
],
[
37,
38
],
[
37,
39
],
[
16,
40
],
[
40,
41
],
[
40,
42
],
[
16,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
43,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
55,
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
],
[
67,
68
],
[
67,
69
],
[
66,
70
],
[
16,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
75,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
82,
85
],
[
85,
86
],
[
85,
87
],
[
75,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
75,
93
],
[
93,
94
],
[
93,
95
],
[
75,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
96,
102
],
[
102,
103
],
[
102,
104
],
[
96,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
106,
112
],
[
112,
113
],
[
112,
114
],
[
106,
115
],
[
14,
116
],
[
116,
117
],
[
4,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
120,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
132,
134
],
[
118,
135
],
[
135,
136
],
[
4,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
142,
144
],
[
139,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
151,
152
],
[
151,
153
],
[
139,
154
],
[
154,
155
],
[
4,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
163,
164
],
[
164,
165
],
[
159,
166
],
[
166,
167
],
[
167,
168
],
[
156,
169
],
[
169,
170
],
[
156,
171
],
[
171,
172
],
[
0,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
173,
177
],
[
177,
178
],
[
173,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
181,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
179,
192
],
[
192,
193
],
[
179,
194
],
[
194,
195
]
] | [
"import java.util.Scanner;\n\nclass Main {\n\n static Scanner scan;\n static P[] p;\n static int head;\n static int tail;\n\n public static void main(String[] args) {\n\tint elaps = 0;\n\t\n\t// get from std in: n, q\n\tscan = new Scanner(System.in);\n\tfinal int n = scan.nextInt();\n\tfinal int q = scan.nextInt();\n\n\t// create a queue\n\tp = new P[100000];\n\thead = 0;\n\ttail = n;\n\n\tfor (int i = 0; i < n; i++) {\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}\n\n\twhile(head != tail) {\n\t P u = dequeue();\n\t int c = min(q, u.t);\n\t u.t -= c;\n\t elaps += c;\n\t if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }\n\t}\n }\n\n static void enqueue(P x) {\n\tp[tail] = x;\n\ttail = (tail + 1) % p.length;\n }\n \n static P dequeue() {\n\tP x = p[head];\n\thead = (head + 1) % p.length;\n\treturn x;\n }\n\n static int min(int a, int b) {\n\tif(a < b) {\n\t return a;\n\t} else {\n\t return b;\n\t}\n }\n}\n\nclass P {\n public String name;\n public int t;\n\n public P(String name, int t) {\n\tthis.name = name;\n\tthis.t = t;\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n\n static Scanner scan;\n static P[] p;\n static int head;\n static int tail;\n\n public static void main(String[] args) {\n\tint elaps = 0;\n\t\n\t// get from std in: n, q\n\tscan = new Scanner(System.in);\n\tfinal int n = scan.nextInt();\n\tfinal int q = scan.nextInt();\n\n\t// create a queue\n\tp = new P[100000];\n\thead = 0;\n\ttail = n;\n\n\tfor (int i = 0; i < n; i++) {\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}\n\n\twhile(head != tail) {\n\t P u = dequeue();\n\t int c = min(q, u.t);\n\t u.t -= c;\n\t elaps += c;\n\t if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }\n\t}\n }\n\n static void enqueue(P x) {\n\tp[tail] = x;\n\ttail = (tail + 1) % p.length;\n }\n \n static P dequeue() {\n\tP x = p[head];\n\thead = (head + 1) % p.length;\n\treturn x;\n }\n\n static int min(int a, int b) {\n\tif(a < b) {\n\t return a;\n\t} else {\n\t return b;\n\t}\n }\n}",
"Main",
"static Scanner scan;",
"scan",
"static P[] p;",
"p",
"static int head;",
"head",
"static int tail;",
"tail",
"public static void main(String[] args) {\n\tint elaps = 0;\n\t\n\t// get from std in: n, q\n\tscan = new Scanner(System.in);\n\tfinal int n = scan.nextInt();\n\tfinal int q = scan.nextInt();\n\n\t// create a queue\n\tp = new P[100000];\n\thead = 0;\n\ttail = n;\n\n\tfor (int i = 0; i < n; i++) {\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}\n\n\twhile(head != tail) {\n\t P u = dequeue();\n\t int c = min(q, u.t);\n\t u.t -= c;\n\t elaps += c;\n\t if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }\n\t}\n }",
"main",
"{\n\tint elaps = 0;\n\t\n\t// get from std in: n, q\n\tscan = new Scanner(System.in);\n\tfinal int n = scan.nextInt();\n\tfinal int q = scan.nextInt();\n\n\t// create a queue\n\tp = new P[100000];\n\thead = 0;\n\ttail = n;\n\n\tfor (int i = 0; i < n; i++) {\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}\n\n\twhile(head != tail) {\n\t P u = dequeue();\n\t int c = min(q, u.t);\n\t u.t -= c;\n\t elaps += c;\n\t if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }\n\t}\n }",
"int elaps = 0;",
"elaps",
"0",
"scan = new Scanner(System.in)",
"scan",
"new Scanner(System.in)",
"final int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"final int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"p = new P[100000]",
"p",
"new P[100000]",
"100000",
"head = 0",
"head",
"0",
"tail = n",
"tail",
"n",
"for (int i = 0; i < n; i++) {\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}",
"{\n\t String name = scan.next();\n\t int t = scan.nextInt();\n\t p[i] = new P(name, t);\n\t}",
"String name = scan.next();",
"name",
"scan.next()",
"scan.next",
"scan",
"int t = scan.nextInt();",
"t",
"scan.nextInt()",
"scan.nextInt",
"scan",
"p[i] = new P(name, t)",
"p[i]",
"p",
"i",
"new P(name, t)",
"while(head != tail) {\n\t P u = dequeue();\n\t int c = min(q, u.t);\n\t u.t -= c;\n\t elaps += c;\n\t if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }\n\t}",
"head != tail",
"head",
"tail",
"{\n\t P u = dequeue();\n\t int c = min(q, u.t);\n\t u.t -= c;\n\t elaps += c;\n\t if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }\n\t}",
"P u = dequeue();",
"u",
"dequeue()",
"dequeue",
"int 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",
"elaps += c",
"elaps",
"c",
"if(u.t > 0) enqueue(u);\n\t else {\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }",
"u.t > 0",
"u.t",
"u",
"u.t",
"0",
"enqueue(u)",
"enqueue",
"u",
"{\n\t\tSystem.out.printf(\"%s %d\\n\", u.name, elaps);\n\t }",
"System.out.printf(\"%s %d\\n\", u.name, elaps)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"u.name",
"u",
"u.name",
"elaps",
"String[] args",
"args",
"static void enqueue(P x) {\n\tp[tail] = x;\n\ttail = (tail + 1) % p.length;\n }",
"enqueue",
"{\n\tp[tail] = x;\n\ttail = (tail + 1) % p.length;\n }",
"p[tail] = x",
"p[tail]",
"p",
"tail",
"x",
"tail = (tail + 1) % p.length",
"tail",
"(tail + 1) % p.length",
"(tail + 1)",
"tail",
"1",
"p.length",
"p",
"p.length",
"P x",
"x",
"static P dequeue() {\n\tP x = p[head];\n\thead = (head + 1) % p.length;\n\treturn x;\n }",
"dequeue",
"{\n\tP x = p[head];\n\thead = (head + 1) % p.length;\n\treturn x;\n }",
"P x = p[head];",
"x",
"p[head]",
"p",
"head",
"head = (head + 1) % p.length",
"head",
"(head + 1) % p.length",
"(head + 1)",
"head",
"1",
"p.length",
"p",
"p.length",
"return x;",
"x",
"static int min(int a, int b) {\n\tif(a < b) {\n\t return a;\n\t} else {\n\t return b;\n\t}\n }",
"min",
"{\n\tif(a < b) {\n\t return a;\n\t} else {\n\t return b;\n\t}\n }",
"if(a < b) {\n\t return a;\n\t} else {\n\t return b;\n\t}",
"a < b",
"a",
"b",
"{\n\t return a;\n\t}",
"return a;",
"a",
"{\n\t return b;\n\t}",
"return b;",
"b",
"int a",
"a",
"int b",
"b",
"class P {\n public String name;\n public int t;\n\n public P(String name, int t) {\n\tthis.name = name;\n\tthis.t = t;\n }\n}",
"P",
"public String name;",
"name",
"public int t;",
"t",
"public P(String name, int t) {\n\tthis.name = name;\n\tthis.t = t;\n }",
"P",
"{\n\tthis.name = name;\n\tthis.t = t;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.t = t",
"this.t",
"this",
"this.t",
"t",
"String name",
"name",
"int t",
"t"
] | import java.util.Scanner;
class Main {
static Scanner scan;
static P[] p;
static int head;
static int tail;
public static void main(String[] args) {
int elaps = 0;
// get from std in: n, q
scan = new Scanner(System.in);
final int n = scan.nextInt();
final int q = scan.nextInt();
// create a queue
p = new P[100000];
head = 0;
tail = n;
for (int i = 0; i < n; i++) {
String name = scan.next();
int t = scan.nextInt();
p[i] = new P(name, t);
}
while(head != tail) {
P u = dequeue();
int c = min(q, u.t);
u.t -= c;
elaps += c;
if(u.t > 0) enqueue(u);
else {
System.out.printf("%s %d\n", u.name, elaps);
}
}
}
static void enqueue(P x) {
p[tail] = x;
tail = (tail + 1) % p.length;
}
static P dequeue() {
P x = p[head];
head = (head + 1) % p.length;
return x;
}
static int min(int a, int b) {
if(a < b) {
return a;
} else {
return b;
}
}
}
class P {
public String name;
public int t;
public P(String name, int t) {
this.name = name;
this.t = t;
}
}
|
[
7,
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,
41,
13,
4,
18,
13,
41,
13,
17,
41,
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,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
2,
4,
18,
13,
18,
13,
17,
13,
14,
2,
13,
17,
30,
4,
18,
13,
2,
2,
13,
17,
13,
0,
13,
13,
30,
0,
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
],
[
128,
11
],
[
128,
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
],
[
28,
29
],
[
29,
30
],
[
14,
31
],
[
31,
32
],
[
31,
33
],
[
14,
34
],
[
34,
35
],
[
14,
36
],
[
36,
37
],
[
14,
38
],
[
38,
39
],
[
39,
40
],
[
14,
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
],
[
54,
57
],
[
57,
58
],
[
58,
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
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
66,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
80,
82
],
[
66,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
85,
92
],
[
66,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
102,
102
],
[
102,
103
],
[
102,
104
],
[
102,
105
],
[
97,
106
],
[
106,
107
],
[
106,
108
],
[
93,
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
],
[
121,
123
],
[
121,
124
],
[
12,
125
],
[
125,
126
],
[
0,
127
],
[
127,
128
],
[
127,
129
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\n// You cant store primitive types in queue?\n\npublic class Main{\n public static void main(String[] args) {\n Queue<String> q = new LinkedList<>();\n\n Scanner input1 = new Scanner(System.in);\n int length = input1.nextInt();\n int QUANTUM = input1.nextInt();\n int totalTime=0;\n int result; // This is the time of each item\n String name;\n\n input1.nextLine();\n // Takes all the inputs and put into the queue\n for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }\n\n while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\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 public static void main(String[] args) {\n Queue<String> q = new LinkedList<>();\n\n Scanner input1 = new Scanner(System.in);\n int length = input1.nextInt();\n int QUANTUM = input1.nextInt();\n int totalTime=0;\n int result; // This is the time of each item\n String name;\n\n input1.nextLine();\n // Takes all the inputs and put into the queue\n for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }\n\n while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Queue<String> q = new LinkedList<>();\n\n Scanner input1 = new Scanner(System.in);\n int length = input1.nextInt();\n int QUANTUM = input1.nextInt();\n int totalTime=0;\n int result; // This is the time of each item\n String name;\n\n input1.nextLine();\n // Takes all the inputs and put into the queue\n for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }\n\n while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }\n }",
"main",
"{\n Queue<String> q = new LinkedList<>();\n\n Scanner input1 = new Scanner(System.in);\n int length = input1.nextInt();\n int QUANTUM = input1.nextInt();\n int totalTime=0;\n int result; // This is the time of each item\n String name;\n\n input1.nextLine();\n // Takes all the inputs and put into the queue\n for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }\n\n while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }\n }",
"Queue<String> q = new LinkedList<>();",
"q",
"new LinkedList<>()",
"Scanner input1 = new Scanner(System.in);",
"input1",
"new Scanner(System.in)",
"int length = input1.nextInt();",
"length",
"input1.nextInt()",
"input1.nextInt",
"input1",
"int QUANTUM = input1.nextInt();",
"QUANTUM",
"input1.nextInt()",
"input1.nextInt",
"input1",
"int totalTime=0;",
"totalTime",
"0",
"int result;",
"result",
"String name;",
"name",
"input1.nextLine()",
"input1.nextLine",
"input1",
"for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<length",
"i",
"length",
"i++",
"i++",
"i",
"{\n q.add(input1.nextLine());\n }",
"{\n q.add(input1.nextLine());\n }",
"q.add(input1.nextLine())",
"q.add",
"q",
"input1.nextLine()",
"input1.nextLine",
"input1",
"while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }",
"q.size()!=0",
"q.size()",
"q.size",
"q",
"0",
"{\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }",
"String removed = q.remove();",
"removed",
"q.remove()",
"q.remove",
"q",
"String[] removeItem = removed.split(\" \");",
"removeItem",
"removed.split(\" \")",
"removed.split",
"removed",
"\" \"",
"name =removeItem[0]",
"name",
"removeItem[0]",
"removeItem",
"0",
"result = Integer.valueOf(removeItem[1])-QUANTUM",
"result",
"Integer.valueOf(removeItem[1])-QUANTUM",
"Integer.valueOf(removeItem[1])",
"Integer.valueOf",
"Integer",
"removeItem[1]",
"removeItem",
"1",
"QUANTUM",
"if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }",
"result >0",
"result",
"0",
"{\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }",
"q.add(name+\" \"+result)",
"q.add",
"q",
"name+\" \"+result",
"name+\" \"+result",
"name",
"\" \"",
"result",
"totalTime += QUANTUM",
"totalTime",
"QUANTUM",
"{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }",
"totalTime += result+QUANTUM",
"totalTime",
"result+QUANTUM",
"result",
"QUANTUM",
"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 public static void main(String[] args) {\n Queue<String> q = new LinkedList<>();\n\n Scanner input1 = new Scanner(System.in);\n int length = input1.nextInt();\n int QUANTUM = input1.nextInt();\n int totalTime=0;\n int result; // This is the time of each item\n String name;\n\n input1.nextLine();\n // Takes all the inputs and put into the queue\n for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }\n\n while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }\n }\n}",
"public class Main{\n public static void main(String[] args) {\n Queue<String> q = new LinkedList<>();\n\n Scanner input1 = new Scanner(System.in);\n int length = input1.nextInt();\n int QUANTUM = input1.nextInt();\n int totalTime=0;\n int result; // This is the time of each item\n String name;\n\n input1.nextLine();\n // Takes all the inputs and put into the queue\n for(int i=0;i<length;i++){\n q.add(input1.nextLine());\n }\n\n while (q.size()!=0){\n String removed = q.remove();\n String[] removeItem = removed.split(\" \");\n\n name =removeItem[0];\n result = Integer.valueOf(removeItem[1])-QUANTUM;\n if (result >0){\n q.add(name+\" \"+result);\n totalTime += QUANTUM;\n }\n else{\n totalTime += result+QUANTUM;\n System.out.println(name+\" \"+totalTime);\n }\n\n }\n }\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
// You cant store primitive types in queue?
public class Main{
public static void main(String[] args) {
Queue<String> q = new LinkedList<>();
Scanner input1 = new Scanner(System.in);
int length = input1.nextInt();
int QUANTUM = input1.nextInt();
int totalTime=0;
int result; // This is the time of each item
String name;
input1.nextLine();
// Takes all the inputs and put into the queue
for(int i=0;i<length;i++){
q.add(input1.nextLine());
}
while (q.size()!=0){
String removed = q.remove();
String[] removeItem = removed.split(" ");
name =removeItem[0];
result = Integer.valueOf(removeItem[1])-QUANTUM;
if (result >0){
q.add(name+" "+result);
totalTime += QUANTUM;
}
else{
totalTime += result+QUANTUM;
System.out.println(name+" "+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,
4,
18,
13,
41,
13,
4,
18,
13,
17,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
17,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
4,
18,
13,
18,
13,
17,
40,
13,
0,
13,
4,
18,
13,
42,
2,
2,
13,
17,
2,
13,
13,
30,
14,
2,
4,
18,
13,
13,
13,
30,
4,
18,
13,
2,
4,
18,
13,
13,
13,
4,
18,
13,
4,
18,
13,
13,
40,
13,
40,
13,
0,
13,
2,
13,
13,
30,
0,
13,
2,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
13,
17,
13,
40,
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
],
[
183,
17
],
[
183,
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
],
[
31,
34
],
[
31,
35
],
[
20,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
41,
42
],
[
41,
43
],
[
20,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
49,
51
],
[
20,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
20,
57
],
[
57,
58
],
[
57,
59
],
[
20,
60
],
[
60,
61
],
[
60,
62
],
[
20,
63
],
[
63,
64
],
[
63,
65
],
[
20,
66
],
[
66,
67
],
[
66,
68
],
[
20,
69
],
[
69,
70
],
[
69,
71
],
[
20,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
72,
77
],
[
77,
78
],
[
77,
79
],
[
72,
80
],
[
80,
81
],
[
81,
82
],
[
72,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
87,
91
],
[
84,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
95,
96
],
[
95,
97
],
[
84,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
104,
105
],
[
104,
106
],
[
84,
107
],
[
107,
108
],
[
84,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
20,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
119,
121
],
[
114,
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
],
[
143,
144
],
[
144,
145
],
[
143,
146
],
[
130,
147
],
[
147,
148
],
[
130,
149
],
[
149,
150
],
[
130,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
153,
155
],
[
123,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
162,
163
],
[
161,
164
],
[
156,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
165,
170
],
[
171,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
172,
175
],
[
171,
176
],
[
171,
177
],
[
156,
178
],
[
178,
179
],
[
18,
180
],
[
180,
181
],
[
0,
182
],
[
182,
183
],
[
182,
184
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str = br.readLine();\n\t\tString[] head = str.split(\" \", 2);\n\t\tint n = Integer.parseInt(head[0]); // ????????????????????ยฐ\n\t\tint q = Integer.parseInt(head[1]); // ???????????????\n\t\tstr = br.readLine();\n\t\tList<String> name = new ArrayList<>();\n\t\tList<Integer> time = new ArrayList<>();\n\t\tint top = 0;\n\t\tint end = 0;\n\t\tint clock = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}\n\t\twhile (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\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",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str = br.readLine();\n\t\tString[] head = str.split(\" \", 2);\n\t\tint n = Integer.parseInt(head[0]); // ????????????????????ยฐ\n\t\tint q = Integer.parseInt(head[1]); // ???????????????\n\t\tstr = br.readLine();\n\t\tList<String> name = new ArrayList<>();\n\t\tList<Integer> time = new ArrayList<>();\n\t\tint top = 0;\n\t\tint end = 0;\n\t\tint clock = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}\n\t\twhile (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\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\t\tString str = br.readLine();\n\t\tString[] head = str.split(\" \", 2);\n\t\tint n = Integer.parseInt(head[0]); // ????????????????????ยฐ\n\t\tint q = Integer.parseInt(head[1]); // ???????????????\n\t\tstr = br.readLine();\n\t\tList<String> name = new ArrayList<>();\n\t\tList<Integer> time = new ArrayList<>();\n\t\tint top = 0;\n\t\tint end = 0;\n\t\tint clock = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}\n\t\twhile (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str = br.readLine();\n\t\tString[] head = str.split(\" \", 2);\n\t\tint n = Integer.parseInt(head[0]); // ????????????????????ยฐ\n\t\tint q = Integer.parseInt(head[1]); // ???????????????\n\t\tstr = br.readLine();\n\t\tList<String> name = new ArrayList<>();\n\t\tList<Integer> time = new ArrayList<>();\n\t\tint top = 0;\n\t\tint end = 0;\n\t\tint clock = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}\n\t\twhile (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\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 str = br.readLine();",
"str",
"br.readLine()",
"br.readLine",
"br",
"String[] head = str.split(\" \", 2);",
"head",
"str.split(\" \", 2)",
"str.split",
"str",
"\" \"",
"2",
"int n = Integer.parseInt(head[0]);",
"n",
"Integer.parseInt(head[0])",
"Integer.parseInt",
"Integer",
"head[0]",
"head",
"0",
"int q = Integer.parseInt(head[1]);",
"q",
"Integer.parseInt(head[1])",
"Integer.parseInt",
"Integer",
"head[1]",
"head",
"1",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"List<String> name = new ArrayList<>();",
"name",
"new ArrayList<>()",
"List<Integer> time = new ArrayList<>();",
"time",
"new ArrayList<>()",
"int top = 0;",
"top",
"0",
"int end = 0;",
"end",
"0",
"int clock = 0;",
"clock",
"0",
"for (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}",
"{\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}",
"String[] data = str.split(\" \", 2);",
"data",
"str.split(\" \", 2)",
"str.split",
"str",
"\" \"",
"2",
"name.add(data[0])",
"name.add",
"name",
"data[0]",
"data",
"0",
"time.add(Integer.parseInt(data[1]))",
"time.add",
"time",
"Integer.parseInt(data[1])",
"Integer.parseInt",
"Integer",
"data[1]",
"data",
"1",
"end++",
"end",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"while (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}\n\t\t}",
"top == 0 || top != end",
"top == 0",
"top",
"0",
"top != end",
"top",
"end",
"{\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}\n\t\t}",
"if (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}",
"time.get(top) > q",
"time.get(top)",
"time.get",
"time",
"top",
"q",
"{\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t}",
"time.add(time.get(top) - q)",
"time.add",
"time",
"time.get(top) - q",
"time.get(top)",
"time.get",
"time",
"top",
"q",
"name.add(name.get(top))",
"name.add",
"name",
"name.get(top)",
"name.get",
"name",
"top",
"top++",
"top",
"end++",
"end",
"clock = clock + q",
"clock",
"clock + q",
"clock",
"q",
"{\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}",
"clock = clock + time.get(top)",
"clock",
"clock + time.get(top)",
"clock",
"time.get(top)",
"time.get",
"time",
"top",
"System.out.println(name.get(top) + \" \" + clock)",
"System.out.println",
"System.out",
"System",
"System.out",
"name.get(top) + \" \" + clock",
"name.get(top) + \" \" + clock",
"name.get(top)",
"name.get",
"name",
"top",
"\" \"",
"clock",
"top++",
"top",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str = br.readLine();\n\t\tString[] head = str.split(\" \", 2);\n\t\tint n = Integer.parseInt(head[0]); // ????????????????????ยฐ\n\t\tint q = Integer.parseInt(head[1]); // ???????????????\n\t\tstr = br.readLine();\n\t\tList<String> name = new ArrayList<>();\n\t\tList<Integer> time = new ArrayList<>();\n\t\tint top = 0;\n\t\tint end = 0;\n\t\tint clock = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}\n\t\twhile (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tString str = br.readLine();\n\t\tString[] head = str.split(\" \", 2);\n\t\tint n = Integer.parseInt(head[0]); // ????????????????????ยฐ\n\t\tint q = Integer.parseInt(head[1]); // ???????????????\n\t\tstr = br.readLine();\n\t\tList<String> name = new ArrayList<>();\n\t\tList<Integer> time = new ArrayList<>();\n\t\tint top = 0;\n\t\tint end = 0;\n\t\tint clock = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] data = str.split(\" \", 2);\n\t\t\tname.add(data[0]);\n\t\t\ttime.add(Integer.parseInt(data[1]));\n\t\t\tend++;\n\t\t\tstr = br.readLine();\n\t\t}\n\t\twhile (top == 0 || top != end) {\n\t\t\tif (time.get(top) > q) {\n\t\t\t\ttime.add(time.get(top) - q);\n\t\t\t\tname.add(name.get(top));\n\t\t\t\ttop++;\n\t\t\t\tend++;\n\t\t\t\tclock = clock + q;\n\t\t\t} else {\n\t\t\t\tclock = clock + time.get(top);\n\t\t\t\tSystem.out.println(name.get(top) + \" \" + clock);\n\t\t\t\ttop++;\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
String[] head = str.split(" ", 2);
int n = Integer.parseInt(head[0]); // ????????????????????ยฐ
int q = Integer.parseInt(head[1]); // ???????????????
str = br.readLine();
List<String> name = new ArrayList<>();
List<Integer> time = new ArrayList<>();
int top = 0;
int end = 0;
int clock = 0;
for (int i = 0; i < n; i++) {
String[] data = str.split(" ", 2);
name.add(data[0]);
time.add(Integer.parseInt(data[1]));
end++;
str = br.readLine();
}
while (top == 0 || top != end) {
if (time.get(top) > q) {
time.add(time.get(top) - q);
name.add(name.get(top));
top++;
end++;
clock = clock + q;
} else {
clock = clock + time.get(top);
System.out.println(name.get(top) + " " + clock);
top++;
}
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
4,
13,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
17,
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,
4,
18,
4,
18,
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,
4,
18,
13,
17,
13,
30,
4,
18,
13,
2,
4,
18,
13,
17,
17,
0,
13,
4,
18,
13,
17,
4,
18,
13,
2,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
30,
0,
13,
13,
0,
13,
2,
4,
18,
13,
17,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
17,
4,
18,
13,
17,
29,
4,
18,
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
],
[
193,
17
],
[
193,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
20,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
18,
31
],
[
31,
32
],
[
193,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
39,
40
],
[
39,
41
],
[
35,
42
],
[
42,
43
],
[
42,
44
],
[
35,
45
],
[
45,
46
],
[
45,
47
],
[
35,
48
],
[
48,
49
],
[
48,
50
],
[
35,
51
],
[
51,
52
],
[
51,
53
],
[
35,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
56,
61
],
[
35,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
67,
68
],
[
67,
69
],
[
35,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
35,
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
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
93,
98
],
[
90,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
102,
103
],
[
102,
104
],
[
90,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
108,
111
],
[
111,
112
],
[
111,
113
],
[
35,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
114,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
121,
126
],
[
120,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
131,
136
],
[
127,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
127,
143
],
[
143,
144
],
[
144,
145
],
[
143,
146
],
[
146,
147
],
[
146,
148
],
[
127,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
127,
153
],
[
153,
154
],
[
154,
155
],
[
153,
156
],
[
120,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
164,
167
],
[
163,
168
],
[
157,
169
],
[
169,
170
],
[
170,
171
],
[
169,
172
],
[
172,
173
],
[
173,
174
],
[
172,
175
],
[
157,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
157,
180
],
[
180,
181
],
[
181,
182
],
[
180,
183
],
[
157,
184
],
[
184,
185
],
[
185,
186
],
[
184,
187
],
[
35,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.lang.StringBuffer;\n\n/*Question\n/?????? namei ??ยจ????????????????????? timei ????????? n ???????????????????????????????????????????????ยง????????????\n/??????????????????????????ยฑ?????\\???????????ยฐ??ยจ?????ยฐ????????????????????ยง??????CPU ?????????????????????????????????????????????\n/???????????????????????ยง q ms?????????????????????????????ยจ???????????????????????????????????????????????????\n/q ms ????????????????????ยฃ????????????????????????????????????????????????????????ยฐ?????????????????????????????????????ยฐ?????ยง??????????CPU ????ยฌ??????????????????????????????????????????????\n/????????ยฐ????????????????????? 100 ms??ยจ???????ยฌ??????????????????????????????\\?????????????????????\n/A(150) - B(80) - C(200) - D(200)\n/?????????????????? A ??? 100 ms ??????????????????????????????????????? 50 ms ?????????????????\\??????????ยฐ?????ยง????????????????\n/B(80) - C(200) - D(200) - A(50)\n/?ยฌ???????????????? B ??? 80 ms ??????????????????????????? 180 ms ??ยง?????????????????\\??????????????????????????????\n/C(200) - D(200) - A(50)\n/?ยฌ???????????????? C ??? 100 ms ?????????????????????????????????????????? 100 ms ??????????????????????ยฐ?????ยง????????????????\n/D(200) - A(50) - C(100)\n/????????????????????ยจ??????????????????????????????????????ยง???????????ยฐ??????????????????\n/??????????????????????????ยฑ?????\\???????????ยฐ???????????\\??ยฌ????????????????????ยฐ???????????????????????????????????? \n*/\n\n/*Input\n/??\\????????ยข????????\\??????????????ยง??????\n/n q\n/name1 time1\n/name2 time2\n/...\n/namen timen\n/????????????????????????????????ยฐ?????ยจ?????ยด??ยฐ n ??ยจ????????????????????ยจ?????ยด??ยฐ q ?????????????????????????????ยง?????????????????????\n/?ยถ???? n ?????ยง??????????????????????????ยฑ?????????????????????????????????????????? namei ??ยจ??ยด??ยฐ timei ????????????????????ยง??????????????????????????? \n*/\n\npublic class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tString i = RoundSchedule();\n\t\tSystem.out.print(i);\n\t}\n\n\t/*RoundSchedule????????????\n\t/??????????????????????????ยฑ?????\\???????????ยฐ???????????\\??????????????????\n\t/??ยจ????????????n??ยจq???????ยด??????????n??????????????????????????????\n\t/???????????????????????????q??ยจ??????????????\\????????????????????ยง????????????q?????????????ยฐ????\n\t/@return String\n\t*/\n\n\tstatic String RoundSchedule() throws Exception {\n\t\tBufferedReader sc = new BufferedReader(new InputStreamReader(System.in));\n\t\t//????????ยจ\n\t\tStringBuffer br = new StringBuffer();\n\t\t//??\\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?\n\t\tList<String> x = new ArrayList<String>();\n\t\tList<Integer> y = new ArrayList<Integer>();\n\t\t//?????????????????????????ยด???ยจ\n\t\tint t = 0;\n\t\t//????ยจ?????????????????ยด???ยจ\n\t\tint k = 0;\n\t\t//1???????????\\???\n\t\tString[] s = sc.readLine().split(\" \");\n\t\t//??????????????ยฐ??ยจ??????????????????????ยด???ยจ\n\t\tint n = Integer.parseInt(s[0]);\n\t\tint q = Integer.parseInt(s[1]);\n\t\t//???????????????????????ยจ?????????????ยด?\n\t\tfor (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}\n\t\t/*????????????????????ยฃ????????????????????????\n\t\t/???????????????????????????q??ยจ??????????????\\????????????????????????????????ยง????????????q?????????????ยฐ????\n\t\t*/\n\t\twhile (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn br.toString();\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.List;",
"List",
"java.util",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.lang.StringBuffer;",
"StringBuffer",
"java.lang",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tString i = RoundSchedule();\n\t\tSystem.out.print(i);\n\t}\n\n\t/*RoundSchedule????????????\n\t/??????????????????????????ยฑ?????\\???????????ยฐ???????????\\??????????????????\n\t/??ยจ????????????n??ยจq???????ยด??????????n??????????????????????????????\n\t/???????????????????????????q??ยจ??????????????\\????????????????????ยง????????????q?????????????ยฐ????\n\t/@return String\n\t*/\n\n\tstatic String RoundSchedule() throws Exception {\n\t\tBufferedReader sc = new BufferedReader(new InputStreamReader(System.in));\n\t\t//????????ยจ\n\t\tStringBuffer br = new StringBuffer();\n\t\t//??\\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?\n\t\tList<String> x = new ArrayList<String>();\n\t\tList<Integer> y = new ArrayList<Integer>();\n\t\t//?????????????????????????ยด???ยจ\n\t\tint t = 0;\n\t\t//????ยจ?????????????????ยด???ยจ\n\t\tint k = 0;\n\t\t//1???????????\\???\n\t\tString[] s = sc.readLine().split(\" \");\n\t\t//??????????????ยฐ??ยจ??????????????????????ยด???ยจ\n\t\tint n = Integer.parseInt(s[0]);\n\t\tint q = Integer.parseInt(s[1]);\n\t\t//???????????????????????ยจ?????????????ยด?\n\t\tfor (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}\n\t\t/*????????????????????ยฃ????????????????????????\n\t\t/???????????????????????????q??ยจ??????????????\\????????????????????????????????ยง????????????q?????????????ยฐ????\n\t\t*/\n\t\twhile (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn br.toString();\n\t}\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tString i = RoundSchedule();\n\t\tSystem.out.print(i);\n\t}",
"main",
"{\n\t\tString i = RoundSchedule();\n\t\tSystem.out.print(i);\n\t}",
"String i = RoundSchedule();",
"i",
"RoundSchedule()",
"RoundSchedule",
"System.out.print(i)",
"System.out.print",
"System.out",
"System",
"System.out",
"i",
"String[] args",
"args",
"static String RoundSchedule() throws Exception {\n\t\tBufferedReader sc = new BufferedReader(new InputStreamReader(System.in));\n\t\t//????????ยจ\n\t\tStringBuffer br = new StringBuffer();\n\t\t//??\\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?\n\t\tList<String> x = new ArrayList<String>();\n\t\tList<Integer> y = new ArrayList<Integer>();\n\t\t//?????????????????????????ยด???ยจ\n\t\tint t = 0;\n\t\t//????ยจ?????????????????ยด???ยจ\n\t\tint k = 0;\n\t\t//1???????????\\???\n\t\tString[] s = sc.readLine().split(\" \");\n\t\t//??????????????ยฐ??ยจ??????????????????????ยด???ยจ\n\t\tint n = Integer.parseInt(s[0]);\n\t\tint q = Integer.parseInt(s[1]);\n\t\t//???????????????????????ยจ?????????????ยด?\n\t\tfor (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}\n\t\t/*????????????????????ยฃ????????????????????????\n\t\t/???????????????????????????q??ยจ??????????????\\????????????????????????????????ยง????????????q?????????????ยฐ????\n\t\t*/\n\t\twhile (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn br.toString();\n\t}",
"RoundSchedule",
"{\n\t\tBufferedReader sc = new BufferedReader(new InputStreamReader(System.in));\n\t\t//????????ยจ\n\t\tStringBuffer br = new StringBuffer();\n\t\t//??\\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?\n\t\tList<String> x = new ArrayList<String>();\n\t\tList<Integer> y = new ArrayList<Integer>();\n\t\t//?????????????????????????ยด???ยจ\n\t\tint t = 0;\n\t\t//????ยจ?????????????????ยด???ยจ\n\t\tint k = 0;\n\t\t//1???????????\\???\n\t\tString[] s = sc.readLine().split(\" \");\n\t\t//??????????????ยฐ??ยจ??????????????????????ยด???ยจ\n\t\tint n = Integer.parseInt(s[0]);\n\t\tint q = Integer.parseInt(s[1]);\n\t\t//???????????????????????ยจ?????????????ยด?\n\t\tfor (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}\n\t\t/*????????????????????ยฃ????????????????????????\n\t\t/???????????????????????????q??ยจ??????????????\\????????????????????????????????ยง????????????q?????????????ยฐ????\n\t\t*/\n\t\twhile (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn br.toString();\n\t}",
"BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));",
"sc",
"new BufferedReader(new InputStreamReader(System.in))",
"StringBuffer br = new StringBuffer();",
"br",
"new StringBuffer()",
"List<String> x = new ArrayList<String>();",
"x",
"new ArrayList<String>()",
"List<Integer> y = new ArrayList<Integer>();",
"y",
"new ArrayList<Integer>()",
"int t = 0;",
"t",
"0",
"int k = 0;",
"k",
"0",
"String[] s = sc.readLine().split(\" \");",
"s",
"sc.readLine().split(\" \")",
"sc.readLine().split",
"sc.readLine()",
"sc.readLine",
"sc",
"\" \"",
"int n = Integer.parseInt(s[0]);",
"n",
"Integer.parseInt(s[0])",
"Integer.parseInt",
"Integer",
"s[0]",
"s",
"0",
"int q = Integer.parseInt(s[1]);",
"q",
"Integer.parseInt(s[1])",
"Integer.parseInt",
"Integer",
"s[1]",
"s",
"1",
"for (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}",
"{\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}",
"s = sc.readLine().split(\" \")",
"s",
"sc.readLine().split(\" \")",
"sc.readLine().split",
"sc.readLine()",
"sc.readLine",
"sc",
"\" \"",
"x.add(s[0])",
"x.add",
"x",
"s[0]",
"s",
"0",
"y.add(Integer.parseInt(s[1]))",
"y.add",
"y",
"Integer.parseInt(s[1])",
"Integer.parseInt",
"Integer",
"s[1]",
"s",
"1",
"while (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}",
"!x.isEmpty()",
"x.isEmpty()",
"x.isEmpty",
"x",
"{\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}",
"if (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}",
"y.get(0) <= q",
"y.get(0)",
"y.get",
"y",
"0",
"q",
"{\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}",
"br.append(x.get(0)+\" \")",
"br.append",
"br",
"x.get(0)+\" \"",
"x.get(0)",
"x.get",
"x",
"0",
"\" \"",
"k += y.get(0)",
"k",
"y.get(0)",
"y.get",
"y",
"0",
"br.append(k+\"\\n\")",
"br.append",
"br",
"k+\"\\n\"",
"k",
"\"\\n\"",
"x.remove(0)",
"x.remove",
"x",
"0",
"y.remove(0)",
"y.remove",
"y",
"0",
"{\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}",
"k += q",
"k",
"q",
"t = y.get(0)-q",
"t",
"y.get(0)-q",
"y.get(0)",
"y.get",
"y",
"0",
"q",
"x.add(x.get(0))",
"x.add",
"x",
"x.get(0)",
"x.get",
"x",
"0",
"y.add(t)",
"y.add",
"y",
"t",
"x.remove(0)",
"x.remove",
"x",
"0",
"y.remove(0)",
"y.remove",
"y",
"0",
"return br.toString();",
"br.toString()",
"br.toString",
"br",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tString i = RoundSchedule();\n\t\tSystem.out.print(i);\n\t}\n\n\t/*RoundSchedule????????????\n\t/??????????????????????????ยฑ?????\\???????????ยฐ???????????\\??????????????????\n\t/??ยจ????????????n??ยจq???????ยด??????????n??????????????????????????????\n\t/???????????????????????????q??ยจ??????????????\\????????????????????ยง????????????q?????????????ยฐ????\n\t/@return String\n\t*/\n\n\tstatic String RoundSchedule() throws Exception {\n\t\tBufferedReader sc = new BufferedReader(new InputStreamReader(System.in));\n\t\t//????????ยจ\n\t\tStringBuffer br = new StringBuffer();\n\t\t//??\\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?\n\t\tList<String> x = new ArrayList<String>();\n\t\tList<Integer> y = new ArrayList<Integer>();\n\t\t//?????????????????????????ยด???ยจ\n\t\tint t = 0;\n\t\t//????ยจ?????????????????ยด???ยจ\n\t\tint k = 0;\n\t\t//1???????????\\???\n\t\tString[] s = sc.readLine().split(\" \");\n\t\t//??????????????ยฐ??ยจ??????????????????????ยด???ยจ\n\t\tint n = Integer.parseInt(s[0]);\n\t\tint q = Integer.parseInt(s[1]);\n\t\t//???????????????????????ยจ?????????????ยด?\n\t\tfor (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}\n\t\t/*????????????????????ยฃ????????????????????????\n\t\t/???????????????????????????q??ยจ??????????????\\????????????????????????????????ยง????????????q?????????????ยฐ????\n\t\t*/\n\t\twhile (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn br.toString();\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) throws Exception {\n\t\tString i = RoundSchedule();\n\t\tSystem.out.print(i);\n\t}\n\n\t/*RoundSchedule????????????\n\t/??????????????????????????ยฑ?????\\???????????ยฐ???????????\\??????????????????\n\t/??ยจ????????????n??ยจq???????ยด??????????n??????????????????????????????\n\t/???????????????????????????q??ยจ??????????????\\????????????????????ยง????????????q?????????????ยฐ????\n\t/@return String\n\t*/\n\n\tstatic String RoundSchedule() throws Exception {\n\t\tBufferedReader sc = new BufferedReader(new InputStreamReader(System.in));\n\t\t//????????ยจ\n\t\tStringBuffer br = new StringBuffer();\n\t\t//??\\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?\n\t\tList<String> x = new ArrayList<String>();\n\t\tList<Integer> y = new ArrayList<Integer>();\n\t\t//?????????????????????????ยด???ยจ\n\t\tint t = 0;\n\t\t//????ยจ?????????????????ยด???ยจ\n\t\tint k = 0;\n\t\t//1???????????\\???\n\t\tString[] s = sc.readLine().split(\" \");\n\t\t//??????????????ยฐ??ยจ??????????????????????ยด???ยจ\n\t\tint n = Integer.parseInt(s[0]);\n\t\tint q = Integer.parseInt(s[1]);\n\t\t//???????????????????????ยจ?????????????ยด?\n\t\tfor (int i = 0;i < n;i++) {\n\t\t\ts = sc.readLine().split(\" \");\n\t\t\tx.add(s[0]);\n\t\t\ty.add(Integer.parseInt(s[1]));\n\t\t}\n\t\t/*????????????????????ยฃ????????????????????????\n\t\t/???????????????????????????q??ยจ??????????????\\????????????????????????????????ยง????????????q?????????????ยฐ????\n\t\t*/\n\t\twhile (!x.isEmpty()){\n\t\t\tif (y.get(0) <= q) {\n\t\t\t\tbr.append(x.get(0)+\" \");\n\t\t\t\tk += y.get(0);\n\t\t\t\tbr.append(k+\"\\n\");\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t}else {\n\t\t\t\tk += q;\n\t\t\t\tt = y.get(0)-q;\n\t\t\t\tx.add(x.get(0));\n\t\t\t\ty.add(t);\n\t\t\t\tx.remove(0);\n\t\t\t\ty.remove(0);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\treturn br.toString();\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.lang.StringBuffer;
/*Question
/?????? namei ??ยจ????????????????????? timei ????????? n ???????????????????????????????????????????????ยง????????????
/??????????????????????????ยฑ?????\???????????ยฐ??ยจ?????ยฐ????????????????????ยง??????CPU ?????????????????????????????????????????????
/???????????????????????ยง q ms?????????????????????????????ยจ???????????????????????????????????????????????????
/q ms ????????????????????ยฃ????????????????????????????????????????????????????????ยฐ?????????????????????????????????????ยฐ?????ยง??????????CPU ????ยฌ??????????????????????????????????????????????
/????????ยฐ????????????????????? 100 ms??ยจ???????ยฌ??????????????????????????????\?????????????????????
/A(150) - B(80) - C(200) - D(200)
/?????????????????? A ??? 100 ms ??????????????????????????????????????? 50 ms ?????????????????\??????????ยฐ?????ยง????????????????
/B(80) - C(200) - D(200) - A(50)
/?ยฌ???????????????? B ??? 80 ms ??????????????????????????? 180 ms ??ยง?????????????????\??????????????????????????????
/C(200) - D(200) - A(50)
/?ยฌ???????????????? C ??? 100 ms ?????????????????????????????????????????? 100 ms ??????????????????????ยฐ?????ยง????????????????
/D(200) - A(50) - C(100)
/????????????????????ยจ??????????????????????????????????????ยง???????????ยฐ??????????????????
/??????????????????????????ยฑ?????\???????????ยฐ???????????\??ยฌ????????????????????ยฐ????????????????????????????????????
*/
/*Input
/??\????????ยข????????\??????????????ยง??????
/n q
/name1 time1
/name2 time2
/...
/namen timen
/????????????????????????????????ยฐ?????ยจ?????ยด??ยฐ n ??ยจ????????????????????ยจ?????ยด??ยฐ q ?????????????????????????????ยง?????????????????????
/?ยถ???? n ?????ยง??????????????????????????ยฑ?????????????????????????????????????????? namei ??ยจ??ยด??ยฐ timei ????????????????????ยง???????????????????????????
*/
public class Main {
public static void main(String[] args) throws Exception {
String i = RoundSchedule();
System.out.print(i);
}
/*RoundSchedule????????????
/??????????????????????????ยฑ?????\???????????ยฐ???????????\??????????????????
/??ยจ????????????n??ยจq???????ยด??????????n??????????????????????????????
/???????????????????????????q??ยจ??????????????\????????????????????ยง????????????q?????????????ยฐ????
/@return String
*/
static String RoundSchedule() throws Exception {
BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
//????????ยจ
StringBuffer br = new StringBuffer();
//??\?????ยจ??ยง?????????????????????????????ยจ?????????????ยด?
List<String> x = new ArrayList<String>();
List<Integer> y = new ArrayList<Integer>();
//?????????????????????????ยด???ยจ
int t = 0;
//????ยจ?????????????????ยด???ยจ
int k = 0;
//1???????????\???
String[] s = sc.readLine().split(" ");
//??????????????ยฐ??ยจ??????????????????????ยด???ยจ
int n = Integer.parseInt(s[0]);
int q = Integer.parseInt(s[1]);
//???????????????????????ยจ?????????????ยด?
for (int i = 0;i < n;i++) {
s = sc.readLine().split(" ");
x.add(s[0]);
y.add(Integer.parseInt(s[1]));
}
/*????????????????????ยฃ????????????????????????
/???????????????????????????q??ยจ??????????????\????????????????????????????????ยง????????????q?????????????ยฐ????
*/
while (!x.isEmpty()){
if (y.get(0) <= q) {
br.append(x.get(0)+" ");
k += y.get(0);
br.append(k+"\n");
x.remove(0);
y.remove(0);
}else {
k += q;
t = y.get(0)-q;
x.add(x.get(0));
y.add(t);
x.remove(0);
y.remove(0);
}
}
return br.toString();
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
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,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
17,
4,
18,
13,
30,
14,
2,
17,
2,
4,
18,
13,
13,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
2,
13,
13,
30,
0,
13,
2,
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
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
11,
19
],
[
19,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
11,
24
],
[
24,
25
],
[
24,
26
],
[
11,
27
],
[
27,
28
],
[
27,
29
],
[
11,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
11,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
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
],
[
53,
56
],
[
56,
57
],
[
57,
58
],
[
52,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
62,
63
],
[
63,
64
],
[
11,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
75,
79
],
[
72,
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
],
[
92,
93
],
[
90,
94
],
[
80,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
72,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
100,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
114,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
114,
118
],
[
114,
119
],
[
9,
120
],
[
120,
121
]
] | [
"import java.util.*;\nimport java.io.*;\n\nclass Main{\n public static void main(String[] args) throws IOException{\n\tScanner sc = new Scanner(System.in);\n\n\tint i;\n\tint n;\n\tint t;\n\tint gettime = 0;\n\t\n\tQueue<String> p = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tn = sc.nextInt();\n\tt = sc.nextInt();\n\t\n\tfor(i=0; i<n; i++){\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}\n\t\n\twhile(0 < p.size()){\n\t if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\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\tScanner sc = new Scanner(System.in);\n\n\tint i;\n\tint n;\n\tint t;\n\tint gettime = 0;\n\t\n\tQueue<String> p = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tn = sc.nextInt();\n\tt = sc.nextInt();\n\t\n\tfor(i=0; i<n; i++){\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}\n\t\n\twhile(0 < p.size()){\n\t if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }\n\t}\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\tScanner sc = new Scanner(System.in);\n\n\tint i;\n\tint n;\n\tint t;\n\tint gettime = 0;\n\t\n\tQueue<String> p = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tn = sc.nextInt();\n\tt = sc.nextInt();\n\t\n\tfor(i=0; i<n; i++){\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}\n\t\n\twhile(0 < p.size()){\n\t if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }\n\t}\n }",
"main",
"{\n\tScanner sc = new Scanner(System.in);\n\n\tint i;\n\tint n;\n\tint t;\n\tint gettime = 0;\n\t\n\tQueue<String> p = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\t\n\tn = sc.nextInt();\n\tt = sc.nextInt();\n\t\n\tfor(i=0; i<n; i++){\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}\n\t\n\twhile(0 < p.size()){\n\t if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }\n\t}\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int i;",
"i",
"int n;",
"n",
"int t;",
"t",
"int gettime = 0;",
"gettime",
"0",
"Queue<String> p = new LinkedList<String>();",
"p",
"new LinkedList<String>()",
"Queue<Integer> time = new LinkedList<Integer>();",
"time",
"new LinkedList<Integer>()",
"n = sc.nextInt()",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"t = sc.nextInt()",
"t",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(i=0; i<n; i++){\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}",
"{\n\t p.add(sc.next());\n\t time.add(sc.nextInt());\n\t}",
"p.add(sc.next())",
"p.add",
"p",
"sc.next()",
"sc.next",
"sc",
"time.add(sc.nextInt())",
"time.add",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(0 < p.size()){\n\t if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }\n\t}",
"0 < p.size()",
"0",
"p.size()",
"p.size",
"p",
"{\n\t if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }\n\t}",
"if(0 < (time.peek() - t)){\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }else{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }",
"0 < (time.peek() - t)",
"0",
"(time.peek() - t)",
"time.peek()",
"time.peek",
"time",
"t",
"{\n\t\tp.add(p.poll());\n\t\ttime.add(time.poll() - t);\n\t\tgettime = gettime + t;\n\t }",
"p.add(p.poll())",
"p.add",
"p",
"p.poll()",
"p.poll",
"p",
"time.add(time.poll() - t)",
"time.add",
"time",
"time.poll() - t",
"time.poll()",
"time.poll",
"time",
"t",
"gettime = gettime + t",
"gettime",
"gettime + t",
"gettime",
"t",
"{\n\t\tgettime = gettime + time.poll();\n\t\tSystem.out.println(p.poll() + \" \" + gettime);\n\t }",
"gettime = gettime + time.poll()",
"gettime",
"gettime + time.poll()",
"gettime",
"time.poll()",
"time.poll",
"time",
"System.out.println(p.poll() + \" \" + gettime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.poll() + \" \" + gettime",
"p.poll() + \" \" + gettime",
"p.poll()",
"p.poll",
"p",
"\" \"",
"gettime",
"String[] args",
"args"
] | import java.util.*;
import java.io.*;
class Main{
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
int i;
int n;
int t;
int gettime = 0;
Queue<String> p = new LinkedList<String>();
Queue<Integer> time = new LinkedList<Integer>();
n = sc.nextInt();
t = sc.nextInt();
for(i=0; i<n; i++){
p.add(sc.next());
time.add(sc.nextInt());
}
while(0 < p.size()){
if(0 < (time.peek() - t)){
p.add(p.poll());
time.add(time.poll() - t);
gettime = gettime + t;
}else{
gettime = gettime + time.poll();
System.out.println(p.poll() + " " + gettime);
}
}
}
}
|
[
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,
13,
41,
13,
20,
13,
41,
13,
20,
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,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
124,
11
],
[
124,
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,
32
],
[
32,
33
],
[
32,
34
],
[
14,
36
],
[
36,
37
],
[
36,
38
],
[
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
],
[
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
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
90,
96
],
[
96,
97
],
[
96,
98
],
[
90,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
84,
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
],
[
12,
121
],
[
121,
122
],
[
0,
123
],
[
123,
124
],
[
123,
125
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int c = sc.nextInt(), ms = sc.nextInt();\n String[] name = new String[c];\n int[] time = new int[c];\n Queue<Integer> queue = new LinkedList<>();\n for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n int total = 0;\n while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\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\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int c = sc.nextInt(), ms = sc.nextInt();\n String[] name = new String[c];\n int[] time = new int[c];\n Queue<Integer> queue = new LinkedList<>();\n for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n int total = 0;\n while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int c = sc.nextInt(), ms = sc.nextInt();\n String[] name = new String[c];\n int[] time = new int[c];\n Queue<Integer> queue = new LinkedList<>();\n for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n int total = 0;\n while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int c = sc.nextInt(), ms = sc.nextInt();\n String[] name = new String[c];\n int[] time = new int[c];\n Queue<Integer> queue = new LinkedList<>();\n for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n int total = 0;\n while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int c = sc.nextInt()",
"c",
"sc.nextInt()",
"sc.nextInt",
"sc",
"ms = sc.nextInt();",
"ms",
"sc.nextInt()",
"sc.nextInt",
"sc",
"String[] name = new String[c];",
"name",
"new String[c]",
"c",
"int[] time = new int[c];",
"time",
"new int[c]",
"c",
"Queue<Integer> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < c",
"i",
"c",
"i++",
"i++",
"i",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.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",
"queue.add(i)",
"queue.add",
"queue",
"i",
"int total = 0;",
"total",
"0",
"while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }",
"int i = queue.remove();",
"i",
"queue.remove()",
"queue.remove",
"queue",
"if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }",
"time[i] > ms",
"time[i]",
"time",
"i",
"ms",
"{\n time[i] -= ms;\n total += ms;\n queue.add(i);\n }",
"time[i] -= ms",
"time[i]",
"time",
"i",
"ms",
"total += ms",
"total",
"ms",
"queue.add(i)",
"queue.add",
"queue",
"i",
"{\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }",
"total += time[i]",
"total",
"time[i]",
"time",
"i",
"System.out.println(name[i] + \" \" + total)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[i] + \" \" + total",
"name[i] + \" \" + total",
"name[i]",
"name",
"i",
"\" \"",
"total",
"String[] args",
"args",
"public class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int c = sc.nextInt(), ms = sc.nextInt();\n String[] name = new String[c];\n int[] time = new int[c];\n Queue<Integer> queue = new LinkedList<>();\n for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n int total = 0;\n while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int c = sc.nextInt(), ms = sc.nextInt();\n String[] name = new String[c];\n int[] time = new int[c];\n Queue<Integer> queue = new LinkedList<>();\n for (int i = 0; i < c; i++) {\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n int total = 0;\n while (!queue.isEmpty()) {\n int i = queue.remove();\n if (time[i] > ms) {\n time[i] -= ms;\n total += ms;\n queue.add(i);\n } else {\n total += time[i];\n System.out.println(name[i] + \" \" + total);\n }\n }\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 sc = new Scanner(System.in);
int c = sc.nextInt(), ms = sc.nextInt();
String[] name = new String[c];
int[] time = new int[c];
Queue<Integer> queue = new LinkedList<>();
for (int i = 0; i < c; i++) {
name[i] = sc.next();
time[i] = sc.nextInt();
queue.add(i);
}
int total = 0;
while (!queue.isEmpty()) {
int i = queue.remove();
if (time[i] > ms) {
time[i] -= ms;
total += ms;
queue.add(i);
} else {
total += time[i];
System.out.println(name[i] + " " + total);
}
}
}
} |
[
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,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
42,
4,
18,
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,
4,
18,
13,
4,
18,
13,
42,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
17,
23,
13,
6,
13,
41,
13,
20,
41,
13,
17,
41,
13,
17,
12,
13,
30,
23,
13,
12,
13,
30,
14,
2,
18,
4,
18,
13,
13,
13,
13,
30,
0,
13,
18,
4,
18,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
13,
13,
17,
13,
4,
18,
13,
13,
14,
2,
4,
18,
13,
17,
29,
17,
30,
0,
13,
13,
0,
18,
4,
18,
13,
13,
13,
13,
40,
13,
14,
2,
13,
4,
18,
13,
0,
13,
17,
29,
17,
23,
13,
12,
13,
30,
4,
18,
13,
20,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
0,
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
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
22,
23
],
[
22,
24
],
[
0,
25
],
[
25,
26
],
[
25,
27
],
[
0,
28
],
[
28,
29
],
[
28,
30
],
[
0,
31
],
[
215,
32
],
[
215,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
39,
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
],
[
54,
56
],
[
43,
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
],
[
70,
73
],
[
73,
74
],
[
74,
75
],
[
70,
76
],
[
76,
77
],
[
77,
78
],
[
43,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
35,
84
],
[
84,
85
],
[
85,
86
],
[
35,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
33,
91
],
[
91,
92
],
[
0,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
93,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
101,
102
],
[
101,
103
],
[
93,
104
],
[
104,
105
],
[
104,
106
],
[
104,
107
],
[
107,
108
],
[
93,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
114,
119
],
[
113,
120
],
[
112,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
124,
129
],
[
121,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
137,
142
],
[
136,
143
],
[
136,
144
],
[
121,
145
],
[
145,
146
],
[
146,
147
],
[
145,
148
],
[
121,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
150,
154
],
[
149,
155
],
[
155,
156
],
[
112,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
162,
167
],
[
161,
168
],
[
157,
169
],
[
169,
170
],
[
111,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
171,
177
],
[
177,
178
],
[
177,
179
],
[
111,
180
],
[
180,
181
],
[
109,
182
],
[
182,
183
],
[
93,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
187,
190
],
[
184,
191
],
[
191,
192
],
[
184,
193
],
[
193,
194
],
[
93,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
195,
199
],
[
199,
200
],
[
195,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
203,
207
],
[
207,
208
],
[
207,
209
],
[
201,
210
],
[
210,
211
],
[
201,
212
],
[
212,
213
],
[
0,
214
],
[
214,
215
],
[
214,
216
]
] | [
"import java.io.File;\nimport java.io.FileNotFoundException;\nimport java.lang.management.ManagementFactory;\nimport java.lang.management.ThreadMXBean;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\nimport java.util.PriorityQueue;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws FileNotFoundException {\n\n\t\tScanner scan = new Scanner(System.in);\n\t\t// Scanner scan = new Scanner(new\n\t\t// File(\"D:\\\\UserArea\\\\J0124567\\\\Downloads\\\\2010-input.txt\"));\n\n\t\twhile (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}\n\n\t\tscan.close();\n\t\tSystem.exit(0);\n\t}\n}\n\nclass Qu {\n\tclass Proc {\n\t\tpublic Proc(String _name, int _time) {\n\t\t\tname = new String(_name);\n\t\t\ttime = _time;\n\t\t}\n\n\t\tString name;\n\t\tint time;\n\t}\n\n\tList<Proc> proc = new ArrayList<Proc>();\n\tint pt = 0;\n\tint total = 0;\n\n\tpublic Qu(int n) {\n\t}\n\n\tpublic boolean process(int q) {\n\t\tif (proc.get(pt).time <= q) {\n\t\t\ttotal += proc.get(pt).time;\n\t\t\tSystem.out.println(proc.get(pt).name + \" \" + total);\n\t\t\tproc.remove(pt);\n\t\t\tif (proc.size() == 0)\n\t\t\t\treturn false;\n\t\t} else {\n\t\t\ttotal += q;\n\t\t\tproc.get(pt).time -= q;\n\t\t\tpt++;\n\t\t}\n\t\tif (pt == proc.size())\n\t\t\tpt = 0;\n\t\treturn true;\n\t}\n\n\tpublic void add(String _name, int _time) {\n\t\tproc.add(new Proc(_name, _time));\n\t}\n\n}",
"import java.io.File;",
"File",
"java.io",
"import java.io.FileNotFoundException;",
"FileNotFoundException",
"java.io",
"import java.lang.management.ManagementFactory;",
"ManagementFactory",
"java.lang.management",
"import java.lang.management.ThreadMXBean;",
"ThreadMXBean",
"java.lang.management",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Collections;",
"Collections",
"java.util",
"import java.util.Comparator;",
"Comparator",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.PriorityQueue;",
"PriorityQueue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) throws FileNotFoundException {\n\n\t\tScanner scan = new Scanner(System.in);\n\t\t// Scanner scan = new Scanner(new\n\t\t// File(\"D:\\\\UserArea\\\\J0124567\\\\Downloads\\\\2010-input.txt\"));\n\n\t\twhile (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}\n\n\t\tscan.close();\n\t\tSystem.exit(0);\n\t}\n}",
"Main",
"public static void main(String[] args) throws FileNotFoundException {\n\n\t\tScanner scan = new Scanner(System.in);\n\t\t// Scanner scan = new Scanner(new\n\t\t// File(\"D:\\\\UserArea\\\\J0124567\\\\Downloads\\\\2010-input.txt\"));\n\n\t\twhile (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}\n\n\t\tscan.close();\n\t\tSystem.exit(0);\n\t}",
"main",
"{\n\n\t\tScanner scan = new Scanner(System.in);\n\t\t// Scanner scan = new Scanner(new\n\t\t// File(\"D:\\\\UserArea\\\\J0124567\\\\Downloads\\\\2010-input.txt\"));\n\n\t\twhile (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}\n\n\t\tscan.close();\n\t\tSystem.exit(0);\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"while (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}",
"scan.hasNext()",
"scan.hasNext",
"scan",
"{\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Qu qu = new Qu(n);",
"qu",
"new Qu(n)",
"for (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}",
"{\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}",
"qu.add(scan.next(), scan.nextInt())",
"qu.add",
"qu",
"scan.next()",
"scan.next",
"scan",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while (qu.process(q))\n\t\t\t\t;",
"qu.process(q)",
"qu.process",
"qu",
"q",
"scan.close()",
"scan.close",
"scan",
"System.exit(0)",
"System.exit",
"System",
"0",
"String[] args",
"args",
"class Qu {\n\tclass Proc {\n\t\tpublic Proc(String _name, int _time) {\n\t\t\tname = new String(_name);\n\t\t\ttime = _time;\n\t\t}\n\n\t\tString name;\n\t\tint time;\n\t}\n\n\tList<Proc> proc = new ArrayList<Proc>();\n\tint pt = 0;\n\tint total = 0;\n\n\tpublic Qu(int n) {\n\t}\n\n\tpublic boolean process(int q) {\n\t\tif (proc.get(pt).time <= q) {\n\t\t\ttotal += proc.get(pt).time;\n\t\t\tSystem.out.println(proc.get(pt).name + \" \" + total);\n\t\t\tproc.remove(pt);\n\t\t\tif (proc.size() == 0)\n\t\t\t\treturn false;\n\t\t} else {\n\t\t\ttotal += q;\n\t\t\tproc.get(pt).time -= q;\n\t\t\tpt++;\n\t\t}\n\t\tif (pt == proc.size())\n\t\t\tpt = 0;\n\t\treturn true;\n\t}\n\n\tpublic void add(String _name, int _time) {\n\t\tproc.add(new Proc(_name, _time));\n\t}\n\n}",
"Qu",
"List<Proc> proc = new ArrayList<Proc>();",
"proc",
"new ArrayList<Proc>()",
"int pt = 0;",
"pt",
"0",
"int total = 0;",
"total",
"0",
"public Qu(int n) {\n\t}",
"Qu",
"{\n\t}",
"int n",
"n",
"public boolean process(int q) {\n\t\tif (proc.get(pt).time <= q) {\n\t\t\ttotal += proc.get(pt).time;\n\t\t\tSystem.out.println(proc.get(pt).name + \" \" + total);\n\t\t\tproc.remove(pt);\n\t\t\tif (proc.size() == 0)\n\t\t\t\treturn false;\n\t\t} else {\n\t\t\ttotal += q;\n\t\t\tproc.get(pt).time -= q;\n\t\t\tpt++;\n\t\t}\n\t\tif (pt == proc.size())\n\t\t\tpt = 0;\n\t\treturn true;\n\t}",
"process",
"{\n\t\tif (proc.get(pt).time <= q) {\n\t\t\ttotal += proc.get(pt).time;\n\t\t\tSystem.out.println(proc.get(pt).name + \" \" + total);\n\t\t\tproc.remove(pt);\n\t\t\tif (proc.size() == 0)\n\t\t\t\treturn false;\n\t\t} else {\n\t\t\ttotal += q;\n\t\t\tproc.get(pt).time -= q;\n\t\t\tpt++;\n\t\t}\n\t\tif (pt == proc.size())\n\t\t\tpt = 0;\n\t\treturn true;\n\t}",
"if (proc.get(pt).time <= q) {\n\t\t\ttotal += proc.get(pt).time;\n\t\t\tSystem.out.println(proc.get(pt).name + \" \" + total);\n\t\t\tproc.remove(pt);\n\t\t\tif (proc.size() == 0)\n\t\t\t\treturn false;\n\t\t} else {\n\t\t\ttotal += q;\n\t\t\tproc.get(pt).time -= q;\n\t\t\tpt++;\n\t\t}",
"proc.get(pt).time <= q",
"proc.get(pt).time",
"proc.get(pt)",
"proc.get",
"proc",
"pt",
"proc.get(pt).time",
"q",
"{\n\t\t\ttotal += proc.get(pt).time;\n\t\t\tSystem.out.println(proc.get(pt).name + \" \" + total);\n\t\t\tproc.remove(pt);\n\t\t\tif (proc.size() == 0)\n\t\t\t\treturn false;\n\t\t}",
"total += proc.get(pt).time",
"total",
"proc.get(pt).time",
"proc.get(pt)",
"proc.get",
"proc",
"pt",
"proc.get(pt).time",
"System.out.println(proc.get(pt).name + \" \" + total)",
"System.out.println",
"System.out",
"System",
"System.out",
"proc.get(pt).name + \" \" + total",
"proc.get(pt).name + \" \" + total",
"proc.get(pt).name",
"proc.get(pt)",
"proc.get",
"proc",
"pt",
"proc.get(pt).name",
"\" \"",
"total",
"proc.remove(pt)",
"proc.remove",
"proc",
"pt",
"if (proc.size() == 0)\n\t\t\t\treturn false;",
"proc.size() == 0",
"proc.size()",
"proc.size",
"proc",
"0",
"return false;",
"false",
"{\n\t\t\ttotal += q;\n\t\t\tproc.get(pt).time -= q;\n\t\t\tpt++;\n\t\t}",
"total += q",
"total",
"q",
"proc.get(pt).time -= q",
"proc.get(pt).time",
"proc.get(pt)",
"proc.get",
"proc",
"pt",
"proc.get(pt).time",
"q",
"pt++",
"pt",
"if (pt == proc.size())\n\t\t\tpt = 0;",
"pt == proc.size()",
"pt",
"proc.size()",
"proc.size",
"proc",
"pt = 0",
"pt",
"0",
"return true;",
"true",
"int q",
"q",
"public void add(String _name, int _time) {\n\t\tproc.add(new Proc(_name, _time));\n\t}",
"add",
"{\n\t\tproc.add(new Proc(_name, _time));\n\t}",
"proc.add(new Proc(_name, _time))",
"proc.add",
"proc",
"new Proc(_name, _time)",
"String _name",
"_name",
"int _time",
"_time",
"class Proc {\n\t\tpublic Proc(String _name, int _time) {\n\t\t\tname = new String(_name);\n\t\t\ttime = _time;\n\t\t}\n\n\t\tString name;\n\t\tint time;\n\t}",
"Proc",
"String name;",
"name",
"int time;",
"time",
"public Proc(String _name, int _time) {\n\t\t\tname = new String(_name);\n\t\t\ttime = _time;\n\t\t}",
"Proc",
"{\n\t\t\tname = new String(_name);\n\t\t\ttime = _time;\n\t\t}",
"name = new String(_name)",
"name",
"new String(_name)",
"time = _time",
"time",
"_time",
"String _name",
"_name",
"int _time",
"_time",
"public class Main {\n\n\tpublic static void main(String[] args) throws FileNotFoundException {\n\n\t\tScanner scan = new Scanner(System.in);\n\t\t// Scanner scan = new Scanner(new\n\t\t// File(\"D:\\\\UserArea\\\\J0124567\\\\Downloads\\\\2010-input.txt\"));\n\n\t\twhile (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}\n\n\t\tscan.close();\n\t\tSystem.exit(0);\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws FileNotFoundException {\n\n\t\tScanner scan = new Scanner(System.in);\n\t\t// Scanner scan = new Scanner(new\n\t\t// File(\"D:\\\\UserArea\\\\J0124567\\\\Downloads\\\\2010-input.txt\"));\n\n\t\twhile (scan.hasNext()) {\n\t\t\tint n = scan.nextInt();\n\t\t\tint q = scan.nextInt();\n\n\t\t\tQu qu = new Qu(n);\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tqu.add(scan.next(), scan.nextInt());\n\t\t\t}\n\t\t\twhile (qu.process(q))\n\t\t\t\t;\n\t\t}\n\n\t\tscan.close();\n\t\tSystem.exit(0);\n\t}\n}",
"Main"
] | import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner scan = new Scanner(System.in);
// Scanner scan = new Scanner(new
// File("D:\\UserArea\\J0124567\\Downloads\\2010-input.txt"));
while (scan.hasNext()) {
int n = scan.nextInt();
int q = scan.nextInt();
Qu qu = new Qu(n);
for (int i = 0; i < n; i++) {
qu.add(scan.next(), scan.nextInt());
}
while (qu.process(q))
;
}
scan.close();
System.exit(0);
}
}
class Qu {
class Proc {
public Proc(String _name, int _time) {
name = new String(_name);
time = _time;
}
String name;
int time;
}
List<Proc> proc = new ArrayList<Proc>();
int pt = 0;
int total = 0;
public Qu(int n) {
}
public boolean process(int q) {
if (proc.get(pt).time <= q) {
total += proc.get(pt).time;
System.out.println(proc.get(pt).name + " " + total);
proc.remove(pt);
if (proc.size() == 0)
return false;
} else {
total += q;
proc.get(pt).time -= q;
pt++;
}
if (pt == proc.size())
pt = 0;
return true;
}
public void add(String _name, int _time) {
proc.add(new Proc(_name, _time));
}
} |
[
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,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
17,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
4,
18,
13,
13,
42,
2,
13,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
30,
0,
13,
13,
40,
13,
4,
18,
18,
13,
13,
2,
2,
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
],
[
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
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
38,
40
],
[
31,
41
],
[
41,
42
],
[
42,
43
],
[
31,
44
],
[
45,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
45,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
8,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
59,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
70,
71
],
[
71,
72
],
[
59,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
81,
83
],
[
77,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
77,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
73,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
107,
109
],
[
107,
110
],
[
6,
111
],
[
111,
112
]
] | [
"import java.util.*;\n\nclass Main{\n public static void main(String[] args){\n Queue<String> queue = new ArrayDeque<String>();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); //ๅฆ็ใใๆฐ\n int q = sc.nextInt(); //ใฏใชใณใฟใ \n int sum = 0; //ๅฆ็ใใๆฐ\n int sumTime = 0; //ๅ่จๅฆ็ๆ้\n for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }\n /*ๅฆ็้จๅ*/\n while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }\n\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class Main{\n public static void main(String[] args){\n Queue<String> queue = new ArrayDeque<String>();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); //ๅฆ็ใใๆฐ\n int q = sc.nextInt(); //ใฏใชใณใฟใ \n int sum = 0; //ๅฆ็ใใๆฐ\n int sumTime = 0; //ๅ่จๅฆ็ๆ้\n for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }\n /*ๅฆ็้จๅ*/\n while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }\n\n }\n}",
"Main",
"public static void main(String[] args){\n Queue<String> queue = new ArrayDeque<String>();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); //ๅฆ็ใใๆฐ\n int q = sc.nextInt(); //ใฏใชใณใฟใ \n int sum = 0; //ๅฆ็ใใๆฐ\n int sumTime = 0; //ๅ่จๅฆ็ๆ้\n for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }\n /*ๅฆ็้จๅ*/\n while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }\n\n }",
"main",
"{\n Queue<String> queue = new ArrayDeque<String>();\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); //ๅฆ็ใใๆฐ\n int q = sc.nextInt(); //ใฏใชใณใฟใ \n int sum = 0; //ๅฆ็ใใๆฐ\n int sumTime = 0; //ๅ่จๅฆ็ๆ้\n for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }\n /*ๅฆ็้จๅ*/\n while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }\n\n }",
"Queue<String> queue = new ArrayDeque<String>();",
"queue",
"new ArrayDeque<String>()",
"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 sum = 0;",
"sum",
"0",
"int sumTime = 0;",
"sumTime",
"0",
"for(int i = 0; i < 2*n; i++){\n String x = sc.next();\n queue.add(x);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < 2*n",
"i",
"2*n",
"2",
"n",
"i++",
"i++",
"i",
"{\n String x = sc.next();\n queue.add(x);\n }",
"{\n String x = sc.next();\n queue.add(x);\n }",
"String x = sc.next();",
"x",
"sc.next()",
"sc.next",
"sc",
"queue.add(x)",
"queue.add",
"queue",
"x",
"while(sum != n){\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }",
"sum != n",
"sum",
"n",
"{\n String name = queue.poll();\n int time = Integer.parseInt(queue.poll());\n if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }\n }",
"String name = queue.poll();",
"name",
"queue.poll()",
"queue.poll",
"queue",
"int time = Integer.parseInt(queue.poll());",
"time",
"Integer.parseInt(queue.poll())",
"Integer.parseInt",
"Integer",
"queue.poll()",
"queue.poll",
"queue",
"if(time > q){\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }\n else{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }",
"time > q",
"time",
"q",
"{\n sumTime += q;\n time -= q;\n queue.add(name);\n queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ\n }",
"sumTime += q",
"sumTime",
"q",
"time -= q",
"time",
"q",
"queue.add(name)",
"queue.add",
"queue",
"name",
"queue.add(String.valueOf(time))",
"queue.add",
"queue",
"String.valueOf(time)",
"String.valueOf",
"String",
"time",
"{\n sumTime += time;\n sum++;\n System.out.println(name +\" \"+sumTime);\n }",
"sumTime += time",
"sumTime",
"time",
"sum++",
"sum",
"System.out.println(name +\" \"+sumTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"name +\" \"+sumTime",
"name +\" \"+sumTime",
"name",
"\" \"",
"sumTime",
"String[] args",
"args"
] | import java.util.*;
class Main{
public static void main(String[] args){
Queue<String> queue = new ArrayDeque<String>();
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); //ๅฆ็ใใๆฐ
int q = sc.nextInt(); //ใฏใชใณใฟใ
int sum = 0; //ๅฆ็ใใๆฐ
int sumTime = 0; //ๅ่จๅฆ็ๆ้
for(int i = 0; i < 2*n; i++){
String x = sc.next();
queue.add(x);
}
/*ๅฆ็้จๅ*/
while(sum != n){
String name = queue.poll();
int time = Integer.parseInt(queue.poll());
if(time > q){
sumTime += q;
time -= q;
queue.add(name);
queue.add(String.valueOf(time)); //intใInteger็ต็ฑใงStringใซๅคๆใใฆใใ
}
else{
sumTime += time;
sum++;
System.out.println(name +" "+sumTime);
}
}
}
}
|
[
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,
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,
13,
13,
13,
13,
13,
4,
18,
13,
23,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
17,
41,
13,
17,
42,
2,
13,
13,
30,
0,
13,
17,
0,
13,
17,
11,
1,
0,
13,
17,
2,
13,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
2,
18,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
40,
13,
0,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
14,
13,
30,
0,
18,
13,
2,
13,
13,
18,
13,
13,
0,
18,
13,
2,
13,
13,
18,
13,
13,
9,
0,
13,
13,
23,
13,
23,
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,
26
],
[
26,
27
],
[
26,
28
],
[
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
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
48,
49
],
[
42,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
55,
56
],
[
8,
57
],
[
57,
58
],
[
57,
59
],
[
57,
60
],
[
57,
61
],
[
57,
62
],
[
8,
63
],
[
63,
64
],
[
64,
65
],
[
6,
66
],
[
66,
67
],
[
4,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
73,
74
],
[
70,
75
],
[
75,
76
],
[
75,
77
],
[
70,
78
],
[
78,
79
],
[
70,
80
],
[
80,
81
],
[
80,
82
],
[
70,
83
],
[
83,
84
],
[
83,
85
],
[
70,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
94,
96
],
[
90,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
97,
107
],
[
107,
108
],
[
108,
109
],
[
97,
110
],
[
111,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
129,
134
],
[
135,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
135,
140
],
[
123,
141
],
[
141,
142
],
[
123,
143
],
[
143,
144
],
[
143,
145
],
[
119,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
146,
152
],
[
152,
153
],
[
152,
154
],
[
146,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
158,
164
],
[
164,
165
],
[
164,
166
],
[
157,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
170,
172
],
[
167,
173
],
[
173,
174
],
[
173,
175
],
[
111,
176
],
[
90,
177
],
[
177,
178
],
[
177,
179
],
[
68,
180
],
[
180,
181
],
[
68,
182
],
[
182,
183
],
[
68,
184
],
[
184,
185
],
[
68,
186
],
[
186,
187
]
] | [
"import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\t//้
ๅไฝใ\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}\n\n\tpublic static void Queue( String[] pro, int[] array,int num,int time){\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tboolean judge_end = false;\n\t\t\n\t\t//ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile( end_count < num ){\t\t\t\t\t\t\t\t\t\t//ๅ
จ้จ็ตใใฃใใ็ตใใ\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\t\t\t\t\t\t\t\t\t//ไปๅ็ตใใฃใๆฐใๅบใ\n\t\t}\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\t//้
ๅไฝใ\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}\n\n\tpublic static void Queue( String[] pro, int[] array,int num,int time){\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tboolean judge_end = false;\n\t\t\n\t\t//ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile( end_count < num ){\t\t\t\t\t\t\t\t\t\t//ๅ
จ้จ็ตใใฃใใ็ตใใ\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\t\t\t\t\t\t\t\t\t//ไปๅ็ตใใฃใๆฐใๅบใ\n\t\t}\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\t//้
ๅไฝใ\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint num = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint time = scanner.nextInt();//่ฆ็ด ๆฐ\n\t\tint[] array = new int[num];\n\t\tString[] pro = new String[num];\n\t\t\n\t\t//้
ๅไฝใ\n\t\tfor(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}\n\t\t\n\t\tQueue(pro, array,num,time);\n\t\t\n\t\tscanner.close();\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int num = scanner.nextInt();",
"num",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int time = scanner.nextInt();",
"time",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int[] array = new int[num];",
"array",
"new int[num]",
"num",
"String[] pro = new String[num];",
"pro",
"new String[num]",
"num",
"for(int i = 0; i < num; i ++ ){\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i ++",
"i ++",
"i",
"{\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}",
"{\n\t\t\tpro[i] = scanner.next();\t\t//ใใผใฏ\n\t\t\tarray[i] = scanner.nextInt();\t//ๆฐๅญ\n\t\t}",
"pro[i] = scanner.next()",
"pro[i]",
"pro",
"i",
"scanner.next()",
"scanner.next",
"scanner",
"array[i] = scanner.nextInt()",
"array[i]",
"array",
"i",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"Queue(pro, array,num,time)",
"Queue",
"pro",
"array",
"num",
"time",
"scanner.close()",
"scanner.close",
"scanner",
"String args[]",
"args",
"public static void Queue( String[] pro, int[] array,int num,int time){\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tboolean judge_end = false;\n\t\t\n\t\t//ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile( end_count < num ){\t\t\t\t\t\t\t\t\t\t//ๅ
จ้จ็ตใใฃใใ็ตใใ\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\t\t\t\t\t\t\t\t\t//ไปๅ็ตใใฃใๆฐใๅบใ\n\t\t}\n\t}",
"Queue",
"{\n\t\tint sub;\n\t\tint i;\n\t\tint end_count = 0;\n\t\tint end_count_now;\n\t\tint time_count = 0;\n\t\tboolean judge_end = false;\n\t\t\n\t\t//ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ\n\t\twhile( end_count < num ){\t\t\t\t\t\t\t\t\t\t//ๅ
จ้จ็ตใใฃใใ็ตใใ\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\t\t\t\t\t\t\t\t\t//ไปๅ็ตใใฃใๆฐใๅบใ\n\t\t}\n\t}",
"int sub;",
"sub",
"int i;",
"i",
"int end_count = 0;",
"end_count",
"0",
"int end_count_now;",
"end_count_now",
"int time_count = 0;",
"time_count",
"0",
"boolean judge_end = false;",
"judge_end",
"false",
"while( end_count < num ){\t\t\t\t\t\t\t\t\t\t//ๅ
จ้จ็ตใใฃใใ็ตใใ\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\t\t\t\t\t\t\t\t\t//ไปๅ็ตใใฃใๆฐใๅบใ\n\t\t}",
"end_count < num",
"end_count",
"num",
"{\t\t\t\t\t\t\t\t\t\t//ๅ
จ้จ็ตใใฃใใ็ตใใ\n\t\t\tend_count_now = 0;\n\t\t\tjudge_end = false;\n\t\t\t\n\t\t\tfor( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tend_count += end_count_now;\t\t\t\t\t\t\t\t\t//ไปๅ็ตใใฃใๆฐใๅบใ\n\t\t}",
"end_count_now = 0",
"end_count_now",
"0",
"judge_end = false",
"judge_end",
"false",
"for( i = 0; i < num - end_count; i ++ ){\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}",
"i = 0;",
"i = 0",
"i",
"0",
"i < num - end_count",
"i",
"num - end_count",
"num",
"end_count",
"i ++",
"i ++",
"i",
"{\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}",
"{\n\t\t\t\tsub = array[i] - time;\n\t\t\t\tif(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}",
"sub = array[i] - time",
"sub",
"array[i] - time",
"array[i]",
"array",
"i",
"time",
"if(sub <= 0){\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}else{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}",
"sub <= 0",
"sub",
"0",
"{\n\t\t\t\t\ttime_count += array[i];\t\t\t\t\t\t\t\t//ๆ้ๅใ ใ่ถณใ\n\t\t\t\t\tSystem.out.println(pro[i] + \" \" + time_count);\t\t//ๆ้ๅ
ใชใๅบๅ\n\t\t\t\t\tend_count_now ++;\t\t\t\t\t\t\t\t\t//ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ\n\t\t\t\t\tjudge_end = true;\t\t\t\t\t\t\t\t\t//็ตใใฃใใใฎใใใ็คบๅ\n\t\t\t\t}",
"time_count += array[i]",
"time_count",
"array[i]",
"array",
"i",
"System.out.println(pro[i] + \" \" + time_count)",
"System.out.println",
"System.out",
"System",
"System.out",
"pro[i] + \" \" + time_count",
"pro[i] + \" \" + time_count",
"pro[i]",
"pro",
"i",
"\" \"",
"time_count",
"end_count_now ++",
"end_count_now",
"judge_end = true",
"judge_end",
"true",
"{\n\t\t\t\t\tarray[i] -= time;\t\t\t\t\t\t\t\t\t//ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ\n\t\t\t\t\ttime_count += time;\t\t\t\t\t\t\t\t\t//ๅ่จๆ้ใซใฏ่ถณใ\n\t\t\t\t\tif(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}\n\t\t\t\t}",
"array[i] -= time",
"array[i]",
"array",
"i",
"time",
"time_count += time",
"time_count",
"time",
"if(judge_end) {\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}",
"judge_end",
"{\t\t\t\t\t\t\t\t\t\t//็ตใใฃใฆใใใฎใใใใฐ\n\t\t\t\t\t\tarray[i - end_count_now] = array[i];\t\t\t//็ตใใฃใฆใๆฐใ ใๅใธ\n\t\t\t\t\t\tpro[i - end_count_now] = pro[i];\t\t\t\t//ใใผใฏใไธ็ทใซ\n\t\t\t\t\t}",
"array[i - end_count_now] = array[i]",
"array[i - end_count_now]",
"array",
"i - end_count_now",
"i",
"end_count_now",
"array[i]",
"array",
"i",
"pro[i - end_count_now] = pro[i]",
"pro[i - end_count_now]",
"pro",
"i - end_count_now",
"i",
"end_count_now",
"pro[i]",
"pro",
"i",
"continue;",
"end_count += end_count_now",
"end_count",
"end_count_now",
"String[] pro",
"pro",
"int[] array",
"array",
"int num",
"num",
"int time",
"time"
] | import java.util.Scanner;
class Main {
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();//่ฆ็ด ๆฐ
int time = scanner.nextInt();//่ฆ็ด ๆฐ
int[] array = new int[num];
String[] pro = new String[num];
//้
ๅไฝใ
for(int i = 0; i < num; i ++ ){
pro[i] = scanner.next(); //ใใผใฏ
array[i] = scanner.nextInt(); //ๆฐๅญ
}
Queue(pro, array,num,time);
scanner.close();
}
public static void Queue( String[] pro, int[] array,int num,int time){
int sub;
int i;
int end_count = 0;
int end_count_now;
int time_count = 0;
boolean judge_end = false;
//ใฉใฆใณใใญใใณในใฑใธใฅใผใชใณใฐ
while( end_count < num ){ //ๅ
จ้จ็ตใใฃใใ็ตใใ
end_count_now = 0;
judge_end = false;
for( i = 0; i < num - end_count; i ++ ){
sub = array[i] - time;
if(sub <= 0){
time_count += array[i]; //ๆ้ๅใ ใ่ถณใ
System.out.println(pro[i] + " " + time_count); //ๆ้ๅ
ใชใๅบๅ
end_count_now ++; //ไปๅใฃใฆใใไธญใงใฎ็ตใใฃใๆฐ
judge_end = true; //็ตใใฃใใใฎใใใ็คบๅ
}else{
array[i] -= time; //ๅฆ็ใใใฎใง่ฆ็ด ใใๅผใ
time_count += time; //ๅ่จๆ้ใซใฏ่ถณใ
if(judge_end) { //็ตใใฃใฆใใใฎใใใใฐ
array[i - end_count_now] = array[i]; //็ตใใฃใฆใๆฐใ ใๅใธ
pro[i - end_count_now] = pro[i]; //ใใผใฏใไธ็ทใซ
}
}
continue;
}
end_count += end_count_now; //ไปๅ็ตใใฃใๆฐใๅบใ
}
}
}
|
[
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,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
0,
13,
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,
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
] | [
[
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
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
27,
28
],
[
27,
29
],
[
23,
30
],
[
30,
31
],
[
30,
32
],
[
23,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
23,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
23,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
23,
48
],
[
48,
49
],
[
48,
50
],
[
23,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
51,
61
],
[
61,
62
],
[
62,
63
],
[
51,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
69,
70
],
[
70,
71
],
[
65,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
76,
77
],
[
65,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
23,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
87,
88
],
[
23,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
93,
94
],
[
23,
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
],
[
115,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
125,
125
],
[
125,
126
],
[
125,
127
],
[
125,
128
],
[
111,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
129,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
129,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
21,
144
],
[
144,
145
]
] | [
"import java.util.Scanner;\nimport java.util.Arrays;\nimport java.util.Deque;\nimport java.util.ArrayDeque;\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\n\nclass Main{\n\tpublic static void main(String[] args)throws Exception{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tDeque<String> name_stack = new ArrayDeque<>();\n\t\tDeque<Integer> time_stack = new ArrayDeque<>();\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tString nothing = scanner.nextLine();\n\t\tint all_time = 0;\n\n\t\tfor(int i = 0; i < n-1; i++){\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}\n\t\t\n\t\tname_stack.offer(scanner.next());\n\t\ttime_stack.offer(scanner.nextInt());\n\n\t\twhile(!(name_stack.isEmpty())){\n\t\t\tString name = name_stack.poll();\n\t\t\tint time = time_stack.poll();\n\n\t\t\tif(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}\n\t\t}\n\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"class Main{\n\tpublic static void main(String[] args)throws Exception{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tDeque<String> name_stack = new ArrayDeque<>();\n\t\tDeque<Integer> time_stack = new ArrayDeque<>();\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tString nothing = scanner.nextLine();\n\t\tint all_time = 0;\n\n\t\tfor(int i = 0; i < n-1; i++){\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}\n\t\t\n\t\tname_stack.offer(scanner.next());\n\t\ttime_stack.offer(scanner.nextInt());\n\n\t\twhile(!(name_stack.isEmpty())){\n\t\t\tString name = name_stack.poll();\n\t\t\tint time = time_stack.poll();\n\n\t\t\tif(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}\n\t\t}\n\n\t}\n}",
"Main",
"public static void main(String[] args)throws Exception{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tDeque<String> name_stack = new ArrayDeque<>();\n\t\tDeque<Integer> time_stack = new ArrayDeque<>();\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tString nothing = scanner.nextLine();\n\t\tint all_time = 0;\n\n\t\tfor(int i = 0; i < n-1; i++){\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}\n\t\t\n\t\tname_stack.offer(scanner.next());\n\t\ttime_stack.offer(scanner.nextInt());\n\n\t\twhile(!(name_stack.isEmpty())){\n\t\t\tString name = name_stack.poll();\n\t\t\tint time = time_stack.poll();\n\n\t\t\tif(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tDeque<String> name_stack = new ArrayDeque<>();\n\t\tDeque<Integer> time_stack = new ArrayDeque<>();\n\t\tint n = scanner.nextInt();\n\t\tint q = scanner.nextInt();\n\t\tString nothing = scanner.nextLine();\n\t\tint all_time = 0;\n\n\t\tfor(int i = 0; i < n-1; i++){\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}\n\t\t\n\t\tname_stack.offer(scanner.next());\n\t\ttime_stack.offer(scanner.nextInt());\n\n\t\twhile(!(name_stack.isEmpty())){\n\t\t\tString name = name_stack.poll();\n\t\t\tint time = time_stack.poll();\n\n\t\t\tif(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"Deque<String> name_stack = new ArrayDeque<>();",
"name_stack",
"new ArrayDeque<>()",
"Deque<Integer> time_stack = new ArrayDeque<>();",
"time_stack",
"new ArrayDeque<>()",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int q = scanner.nextInt();",
"q",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"String nothing = scanner.nextLine();",
"nothing",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"int all_time = 0;",
"all_time",
"0",
"for(int i = 0; i < n-1; i++){\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}",
"{\n\t\t\tname_stack.offer(scanner.next());\n\t\t\ttime_stack.offer(scanner.nextInt());\n\t\t\tnothing = scanner.nextLine();\n\t\t}",
"name_stack.offer(scanner.next())",
"name_stack.offer",
"name_stack",
"scanner.next()",
"scanner.next",
"scanner",
"time_stack.offer(scanner.nextInt())",
"time_stack.offer",
"time_stack",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"nothing = scanner.nextLine()",
"nothing",
"scanner.nextLine()",
"scanner.nextLine",
"scanner",
"name_stack.offer(scanner.next())",
"name_stack.offer",
"name_stack",
"scanner.next()",
"scanner.next",
"scanner",
"time_stack.offer(scanner.nextInt())",
"time_stack.offer",
"time_stack",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"while(!(name_stack.isEmpty())){\n\t\t\tString name = name_stack.poll();\n\t\t\tint time = time_stack.poll();\n\n\t\t\tif(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}\n\t\t}",
"!(name_stack.isEmpty())",
"(name_stack.isEmpty())",
"name_stack.isEmpty",
"name_stack",
"{\n\t\t\tString name = name_stack.poll();\n\t\t\tint time = time_stack.poll();\n\n\t\t\tif(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}\n\t\t}",
"String name = name_stack.poll();",
"name",
"name_stack.poll()",
"name_stack.poll",
"name_stack",
"int time = time_stack.poll();",
"time",
"time_stack.poll()",
"time_stack.poll",
"time_stack",
"if(time <= q){\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}else{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\tall_time += time;\n\t\t\t\tSystem.out.println(name + \" \" + all_time);\n\t\t\t}",
"all_time += time",
"all_time",
"time",
"System.out.println(name + \" \" + all_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + all_time",
"name + \" \" + all_time",
"name",
"\" \"",
"all_time",
"{\n\t\t\t\tall_time += q;\n\t\t\t\ttime -= q;\n\t\t\t\tname_stack.offer(name);\n\t\t\t\ttime_stack.offer(time);\n\t\t\t}",
"all_time += q",
"all_time",
"q",
"time -= q",
"time",
"q",
"name_stack.offer(name)",
"name_stack.offer",
"name_stack",
"name",
"time_stack.offer(time)",
"time_stack.offer",
"time_stack",
"time",
"String[] args",
"args"
] | import java.util.Scanner;
import java.util.Arrays;
import java.util.Deque;
import java.util.ArrayDeque;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main{
public static void main(String[] args)throws Exception{
Scanner scanner = new Scanner(System.in);
Deque<String> name_stack = new ArrayDeque<>();
Deque<Integer> time_stack = new ArrayDeque<>();
int n = scanner.nextInt();
int q = scanner.nextInt();
String nothing = scanner.nextLine();
int all_time = 0;
for(int i = 0; i < n-1; i++){
name_stack.offer(scanner.next());
time_stack.offer(scanner.nextInt());
nothing = scanner.nextLine();
}
name_stack.offer(scanner.next());
time_stack.offer(scanner.nextInt());
while(!(name_stack.isEmpty())){
String name = name_stack.poll();
int time = time_stack.poll();
if(time <= q){
all_time += time;
System.out.println(name + " " + all_time);
}else{
all_time += q;
time -= q;
name_stack.offer(name);
time_stack.offer(time);
}
}
}
} |
[
7,
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,
17,
4,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
2,
4,
18,
13,
18,
13,
17,
13,
14,
2,
13,
17,
30,
0,
13,
2,
13,
4,
18,
13,
18,
13,
17,
4,
18,
18,
13,
13,
2,
2,
18,
13,
17,
17,
13,
30,
0,
13,
2,
13,
13,
0,
18,
13,
17,
4,
18,
13,
13,
4,
18,
13,
2,
2,
18,
13,
17,
17,
18,
13,
17,
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
],
[
147,
14
],
[
147,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
17,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
17,
31
],
[
31,
32
],
[
31,
33
],
[
17,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
17,
38
],
[
38,
39
],
[
38,
40
],
[
17,
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
],
[
54,
57
],
[
57,
58
],
[
58,
59
],
[
17,
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
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
66,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
84,
86
],
[
80,
87
],
[
66,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
92,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
109,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
109,
114
],
[
88,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
115,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
133,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
133,
138
],
[
138,
139
],
[
138,
140
],
[
17,
141
],
[
141,
142
],
[
142,
143
],
[
15,
144
],
[
144,
145
],
[
0,
146
],
[
146,
147
],
[
146,
148
]
] | [
"\nimport java.util.Scanner;\nimport java.util.LinkedList;\nimport java.util.Queue; \nimport java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String argv[]) {\n\n Scanner in = new Scanner(System.in);\n int numTask = in.nextInt();\n int maxTime = in.nextInt();\n int curr=0;\n in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\");\n\n Queue<String> q = new LinkedList<>();\n // accessing the numbers in the second line\n for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }\n\n while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }\n\n in.close();\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String argv[]) {\n\n Scanner in = new Scanner(System.in);\n int numTask = in.nextInt();\n int maxTime = in.nextInt();\n int curr=0;\n in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\");\n\n Queue<String> q = new LinkedList<>();\n // accessing the numbers in the second line\n for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }\n\n while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }\n\n in.close();\n }\n}",
"Main",
"public static void main(String argv[]) {\n\n Scanner in = new Scanner(System.in);\n int numTask = in.nextInt();\n int maxTime = in.nextInt();\n int curr=0;\n in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\");\n\n Queue<String> q = new LinkedList<>();\n // accessing the numbers in the second line\n for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }\n\n while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }\n\n in.close();\n }",
"main",
"{\n\n Scanner in = new Scanner(System.in);\n int numTask = in.nextInt();\n int maxTime = in.nextInt();\n int curr=0;\n in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\");\n\n Queue<String> q = new LinkedList<>();\n // accessing the numbers in the second line\n for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }\n\n while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }\n\n in.close();\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int numTask = in.nextInt();",
"numTask",
"in.nextInt()",
"in.nextInt",
"in",
"int maxTime = in.nextInt();",
"maxTime",
"in.nextInt()",
"in.nextInt",
"in",
"int curr=0;",
"curr",
"0",
"in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\")",
"in.skip",
"in",
"\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\"",
"Queue<String> q = new LinkedList<>();",
"q",
"new LinkedList<>()",
"for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numTask",
"i",
"numTask",
"i++",
"i++",
"i",
"{\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }",
"{\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }",
"q.add(in.nextLine())",
"q.add",
"q",
"in.nextLine()",
"in.nextLine",
"in",
"while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }",
"q.size() > 0",
"q.size()",
"q.size",
"q",
"0",
"{\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }",
"String element = q.remove();",
"element",
"q.remove()",
"q.remove",
"q",
"String[] oneTask = element.split(\" \");",
"oneTask",
"element.split(\" \")",
"element.split",
"element",
"\" \"",
"int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;",
"timeDiff",
"Integer.parseInt(oneTask[1]) - maxTime",
"Integer.parseInt(oneTask[1])",
"Integer.parseInt",
"Integer",
"oneTask[1]",
"oneTask",
"1",
"maxTime",
"if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }",
"timeDiff<=0",
"timeDiff",
"0",
"{\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }",
"curr = curr + Integer.parseInt(oneTask[1])",
"curr",
"curr + Integer.parseInt(oneTask[1])",
"curr",
"Integer.parseInt(oneTask[1])",
"Integer.parseInt",
"Integer",
"oneTask[1]",
"oneTask",
"1",
"System.out.println(oneTask[0] + ' ' + curr)",
"System.out.println",
"System.out",
"System",
"System.out",
"oneTask[0] + ' ' + curr",
"oneTask[0] + ' ' + curr",
"oneTask[0]",
"oneTask",
"0",
"' '",
"curr",
"{\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }",
"curr = curr + maxTime",
"curr",
"curr + maxTime",
"curr",
"maxTime",
"oneTask[1] = Integer.toString(timeDiff)",
"oneTask[1]",
"oneTask",
"1",
"Integer.toString(timeDiff)",
"Integer.toString",
"Integer",
"timeDiff",
"q.add(oneTask[0] + ' ' + oneTask[1])",
"q.add",
"q",
"oneTask[0] + ' ' + oneTask[1]",
"oneTask[0] + ' ' + oneTask[1]",
"oneTask[0]",
"oneTask",
"0",
"' '",
"oneTask[1]",
"oneTask",
"1",
"in.close()",
"in.close",
"in",
"String argv[]",
"argv",
"public class Main {\n\n\tpublic static void main(String argv[]) {\n\n Scanner in = new Scanner(System.in);\n int numTask = in.nextInt();\n int maxTime = in.nextInt();\n int curr=0;\n in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\");\n\n Queue<String> q = new LinkedList<>();\n // accessing the numbers in the second line\n for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }\n\n while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }\n\n in.close();\n }\n}",
"public class Main {\n\n\tpublic static void main(String argv[]) {\n\n Scanner in = new Scanner(System.in);\n int numTask = in.nextInt();\n int maxTime = in.nextInt();\n int curr=0;\n in.skip(\"(\\r\\n|[\\n\\r\\u2028\\u2029\\u0085])?\");\n\n Queue<String> q = new LinkedList<>();\n // accessing the numbers in the second line\n for (int i = 0; i < numTask; i++){\n// \tString str = in.nextLine();\n \tq.add(in.nextLine());\n }\n\n while(q.size() > 0){\n \t String element = q.remove();\n \t String[] oneTask = element.split(\" \");\n \t int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;\n \t if(timeDiff<=0)\n \t {\n \t\t curr = curr + Integer.parseInt(oneTask[1]);\n \t\t System.out.println(oneTask[0] + ' ' + curr);\n \t }\n \t else\n \t {\n \t\t curr = curr + maxTime;\n \t\t oneTask[1] = Integer.toString(timeDiff);\n \t\t q.add(oneTask[0] + ' ' + oneTask[1]);\n \t }\n }\n\n in.close();\n }\n}",
"Main"
] |
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;
import java.util.*;
public class Main {
public static void main(String argv[]) {
Scanner in = new Scanner(System.in);
int numTask = in.nextInt();
int maxTime = in.nextInt();
int curr=0;
in.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
Queue<String> q = new LinkedList<>();
// accessing the numbers in the second line
for (int i = 0; i < numTask; i++){
// String str = in.nextLine();
q.add(in.nextLine());
}
while(q.size() > 0){
String element = q.remove();
String[] oneTask = element.split(" ");
int timeDiff = Integer.parseInt(oneTask[1]) - maxTime;
if(timeDiff<=0)
{
curr = curr + Integer.parseInt(oneTask[1]);
System.out.println(oneTask[0] + ' ' + curr);
}
else
{
curr = curr + maxTime;
oneTask[1] = Integer.toString(timeDiff);
q.add(oneTask[0] + ' ' + oneTask[1]);
}
}
in.close();
}
}
|
[
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,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
13,
23,
13,
12,
13,
30,
14,
2,
18,
13,
13,
13,
30,
4,
18,
18,
13,
13,
17,
4,
18,
13,
17,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
18,
13,
13,
40,
13,
23,
13,
12,
13,
30,
14,
2,
13,
17,
30,
4,
18,
18,
13,
13,
17,
4,
18,
13,
17,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
18,
13,
13,
40,
13,
29,
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,
41,
13,
20,
41,
13,
17,
41,
13,
13,
42,
2,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
2,
4,
18,
13,
13,
17,
30,
0,
13,
4,
18,
13,
4,
18,
13,
20,
40,
13,
30,
0,
13,
13,
4,
18,
13,
20,
42,
2,
40,
13,
17,
30,
41,
13,
4,
18,
13,
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
],
[
264,
58
],
[
264,
59
],
[
59,
60
],
[
264,
61
],
[
61,
62
],
[
264,
63
],
[
63,
64
],
[
264,
65
],
[
65,
66
],
[
264,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
67,
74
],
[
74,
75
],
[
264,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
86,
91
],
[
85,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
78,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
78,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
107,
109
],
[
78,
110
],
[
110,
111
],
[
76,
112
],
[
112,
113
],
[
264,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
121,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
116,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
116,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
143,
144
],
[
143,
145
],
[
116,
146
],
[
146,
147
],
[
116,
148
],
[
148,
149
],
[
264,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
159,
160
],
[
152,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
152,
166
],
[
166,
167
],
[
166,
168
],
[
152,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
174,
175
],
[
174,
176
],
[
169,
177
],
[
177,
178
],
[
178,
179
],
[
169,
180
],
[
181,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
182,
185
],
[
152,
186
],
[
186,
187
],
[
186,
188
],
[
152,
189
],
[
189,
190
],
[
189,
191
],
[
152,
192
],
[
192,
193
],
[
192,
194
],
[
152,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
199,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
207,
211
],
[
206,
212
],
[
205,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
216,
217
],
[
217,
218
],
[
213,
219
],
[
219,
220
],
[
220,
221
],
[
219,
222
],
[
213,
223
],
[
223,
224
],
[
205,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
],
[
225,
229
],
[
229,
230
],
[
230,
231
],
[
229,
232
],
[
152,
233
],
[
233,
234
],
[
234,
235
],
[
235,
236
],
[
234,
237
],
[
233,
238
],
[
238,
239
],
[
239,
240
],
[
239,
241
],
[
241,
242
],
[
242,
243
],
[
238,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
244,
249
],
[
250,
250
],
[
250,
251
],
[
251,
252
],
[
252,
253
],
[
250,
254
],
[
250,
255
],
[
255,
256
],
[
256,
257
],
[
255,
258
],
[
258,
259
],
[
259,
260
],
[
150,
261
],
[
261,
262
],
[
0,
263
],
[
263,
264
],
[
263,
265
]
] | [
"import java.util.*;\n\nclass process {\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\n\npublic class Main {\n int length, front, rear;\n process[] queue;\n\n // ??????????????????????????????????????????????????????????????????\n Main(int len) {\n queue = new process[len];\n }\n\n // ??????????????ยจ????????\\???\n void enqueue(process val) {\n if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }\n\n queue[rear] = val;\n rear = (rear+1)%queue.length;\n length++;\n }\n\n // ????????????????????\\???\n process dequeue() {\n if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }\n\n process ret = queue[front];\n front = (front+1)%queue.length;\n length--;\n return ret;\n }\n\n // main ????????????\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\n Main queue = new Main(n);\n for (int i=0; i<n; i++) {\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }\n Main result = new Main(n);\n\n int elapsed = 0;\n int n_ = n;\n while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }\n\n while (n_-- > 0) {\n process r = result.dequeue();\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class process {\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 int length, front, rear;\n process[] queue;\n\n // ??????????????????????????????????????????????????????????????????\n Main(int len) {\n queue = new process[len];\n }\n\n // ??????????????ยจ????????\\???\n void enqueue(process val) {\n if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }\n\n queue[rear] = val;\n rear = (rear+1)%queue.length;\n length++;\n }\n\n // ????????????????????\\???\n process dequeue() {\n if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }\n\n process ret = queue[front];\n front = (front+1)%queue.length;\n length--;\n return ret;\n }\n\n // main ????????????\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\n Main queue = new Main(n);\n for (int i=0; i<n; i++) {\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }\n Main result = new Main(n);\n\n int elapsed = 0;\n int n_ = n;\n while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }\n\n while (n_-- > 0) {\n process r = result.dequeue();\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"Main",
"int length",
"length",
"front",
"front",
"rear;",
"rear",
"process[] queue;",
"queue",
"// ??????????????????????????????????????????????????????????????????\n Main(int len) {\n queue = new process[len];\n }",
"Main",
"{\n queue = new process[len];\n }",
"queue = new process[len]",
"queue",
"new process[len]",
"len",
"int len",
"len",
"// ??????????????ยจ????????\\???\n void enqueue(process val) {\n if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }\n\n queue[rear] = val;\n rear = (rear+1)%queue.length;\n length++;\n }",
"enqueue",
"{\n if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }\n\n queue[rear] = val;\n rear = (rear+1)%queue.length;\n length++;\n }",
"if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }",
"queue.length == length",
"queue.length",
"queue",
"queue.length",
"length",
"{\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }",
"System.out.println(\"Fatal error: the queue is full.\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"Fatal error: the queue is full.\"",
"System.exit(1)",
"System.exit",
"System",
"1",
"queue[rear] = val",
"queue[rear]",
"queue",
"rear",
"val",
"rear = (rear+1)%queue.length",
"rear",
"(rear+1)%queue.length",
"(rear+1)",
"rear",
"1",
"queue.length",
"queue",
"queue.length",
"length++",
"length",
"process val",
"val",
"// ????????????????????\\???\n process dequeue() {\n if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }\n\n process ret = queue[front];\n front = (front+1)%queue.length;\n length--;\n return ret;\n }",
"dequeue",
"{\n if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }\n\n process ret = queue[front];\n front = (front+1)%queue.length;\n length--;\n return ret;\n }",
"if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }",
"length == 0",
"length",
"0",
"{\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }",
"System.out.println(\"Fatal error: the queue is empty.\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"Fatal error: the queue is empty.\"",
"System.exit(1)",
"System.exit",
"System",
"1",
"process ret = queue[front];",
"ret",
"queue[front]",
"queue",
"front",
"front = (front+1)%queue.length",
"front",
"(front+1)%queue.length",
"(front+1)",
"front",
"1",
"queue.length",
"queue",
"queue.length",
"length--",
"length",
"return ret;",
"ret",
"// main ????????????\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\n Main queue = new Main(n);\n for (int i=0; i<n; i++) {\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }\n Main result = new Main(n);\n\n int elapsed = 0;\n int n_ = n;\n while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }\n\n while (n_-- > 0) {\n process r = result.dequeue();\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Main queue = new Main(n);\n for (int i=0; i<n; i++) {\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }\n Main result = new Main(n);\n\n int elapsed = 0;\n int n_ = n;\n while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }\n\n while (n_-- > 0) {\n process r = result.dequeue();\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",
"Main queue = new Main(n);",
"queue",
"new Main(n)",
"for (int i=0; i<n; i++) {\n queue.enqueue(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 queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }",
"{\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }",
"queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())))",
"queue.enqueue",
"queue",
"new process(sc.next(), Integer.parseInt(sc.next()))",
"Main result = new Main(n);",
"result",
"new Main(n)",
"int elapsed = 0;",
"elapsed",
"0",
"int n_ = n;",
"n_",
"n",
"while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }",
"n > 0",
"n",
"0",
"{\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }",
"process p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }",
"p.getTime() - q <= 0",
"p.getTime() - q",
"p.getTime()",
"p.getTime",
"p",
"q",
"0",
"{\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n }",
"elapsed += p.getTime()",
"elapsed",
"p.getTime()",
"p.getTime",
"p",
"result.enqueue(new process(p.getName(), elapsed))",
"result.enqueue",
"result",
"new process(p.getName(), elapsed)",
"n--",
"n",
"{\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }",
"elapsed += q",
"elapsed",
"q",
"queue.enqueue(new process(p.getName(), p.getTime()-q))",
"queue.enqueue",
"queue",
"new process(p.getName(), p.getTime()-q)",
"while (n_-- > 0) {\n process r = result.dequeue();\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }",
"n_-- > 0",
"n_--",
"n_",
"0",
"{\n process r = result.dequeue();\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }",
"process r = result.dequeue();",
"r",
"result.dequeue()",
"result.dequeue",
"result",
"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 int length, front, rear;\n process[] queue;\n\n // ??????????????????????????????????????????????????????????????????\n Main(int len) {\n queue = new process[len];\n }\n\n // ??????????????ยจ????????\\???\n void enqueue(process val) {\n if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }\n\n queue[rear] = val;\n rear = (rear+1)%queue.length;\n length++;\n }\n\n // ????????????????????\\???\n process dequeue() {\n if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }\n\n process ret = queue[front];\n front = (front+1)%queue.length;\n length--;\n return ret;\n }\n\n // main ????????????\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\n Main queue = new Main(n);\n for (int i=0; i<n; i++) {\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }\n Main result = new Main(n);\n\n int elapsed = 0;\n int n_ = n;\n while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }\n\n while (n_-- > 0) {\n process r = result.dequeue();\n System.out.println(r.getName() + \" \" + String.valueOf(r.getTime()));\n }\n }\n}",
"public class Main {\n int length, front, rear;\n process[] queue;\n\n // ??????????????????????????????????????????????????????????????????\n Main(int len) {\n queue = new process[len];\n }\n\n // ??????????????ยจ????????\\???\n void enqueue(process val) {\n if (queue.length == length) {\n System.out.println(\"Fatal error: the queue is full.\");\n System.exit(1);\n }\n\n queue[rear] = val;\n rear = (rear+1)%queue.length;\n length++;\n }\n\n // ????????????????????\\???\n process dequeue() {\n if (length == 0) {\n System.out.println(\"Fatal error: the queue is empty.\");\n System.exit(1);\n }\n\n process ret = queue[front];\n front = (front+1)%queue.length;\n length--;\n return ret;\n }\n\n // main ????????????\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\n Main queue = new Main(n);\n for (int i=0; i<n; i++) {\n queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));\n }\n Main result = new Main(n);\n\n int elapsed = 0;\n int n_ = n;\n while (n > 0) {\n process p = queue.dequeue();\n if (p.getTime() - q <= 0) {\n elapsed += p.getTime();\n result.enqueue(new process(p.getName(), elapsed));\n n--;\n } else {\n elapsed += q;\n queue.enqueue(new process(p.getName(), p.getTime()-q));\n }\n }\n\n while (n_-- > 0) {\n process r = result.dequeue();\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 {
int length, front, rear;
process[] queue;
// ??????????????????????????????????????????????????????????????????
Main(int len) {
queue = new process[len];
}
// ??????????????ยจ????????\???
void enqueue(process val) {
if (queue.length == length) {
System.out.println("Fatal error: the queue is full.");
System.exit(1);
}
queue[rear] = val;
rear = (rear+1)%queue.length;
length++;
}
// ????????????????????\???
process dequeue() {
if (length == 0) {
System.out.println("Fatal error: the queue is empty.");
System.exit(1);
}
process ret = queue[front];
front = (front+1)%queue.length;
length--;
return ret;
}
// main ????????????
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Main queue = new Main(n);
for (int i=0; i<n; i++) {
queue.enqueue(new process(sc.next(), Integer.parseInt(sc.next())));
}
Main result = new Main(n);
int elapsed = 0;
int n_ = n;
while (n > 0) {
process p = queue.dequeue();
if (p.getTime() - q <= 0) {
elapsed += p.getTime();
result.enqueue(new process(p.getName(), elapsed));
n--;
} else {
elapsed += q;
queue.enqueue(new process(p.getName(), p.getTime()-q));
}
}
while (n_-- > 0) {
process r = result.dequeue();
System.out.println(r.getName() + " " + String.valueOf(r.getTime()));
}
}
} |
[
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,
2,
13,
17,
41,
13,
17,
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,
42,
17,
30,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
2,
2,
13,
17,
13,
2,
18,
13,
13,
13,
0,
18,
13,
2,
2,
13,
17,
13,
18,
13,
13,
0,
13,
2,
13,
13,
0,
13,
2,
2,
13,
17,
13,
0,
13,
2,
2,
13,
17,
13,
30,
0,
13,
2,
13,
18,
13,
13,
14,
2,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
3,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
0,
13,
2,
2,
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
],
[
27,
28
],
[
27,
29
],
[
8,
30
],
[
30,
31
],
[
30,
32
],
[
8,
33
],
[
33,
34
],
[
33,
35
],
[
8,
37
],
[
37,
38
],
[
37,
39
],
[
8,
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
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
65,
66
],
[
66,
67
],
[
8,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
78,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
77,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
91,
99
],
[
99,
100
],
[
99,
101
],
[
77,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
77,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
77,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
71,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
126,
128
],
[
121,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
134,
139
],
[
140,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
140,
145
],
[
133,
146
],
[
129,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
148,
153
],
[
154,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
154,
159
],
[
147,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
6,
167
],
[
167,
168
]
] | [
"import java.util.Scanner;\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\n int s = 0;\n int g = n-1;\n\n int tt = 0;\n\n String[] name = new String[n];\n int[] time = new int[n];\n\n for(int i=0; i<n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n\n while(true){\n if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }\n }\n\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"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\n int s = 0;\n int g = n-1;\n\n int tt = 0;\n\n String[] name = new String[n];\n int[] time = new int[n];\n\n for(int i=0; i<n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n\n while(true){\n if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }\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\n int s = 0;\n int g = n-1;\n\n int tt = 0;\n\n String[] name = new String[n];\n int[] time = new int[n];\n\n for(int i=0; i<n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n\n while(true){\n if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }\n }\n\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n int s = 0;\n int g = n-1;\n\n int tt = 0;\n\n String[] name = new String[n];\n int[] time = new int[n];\n\n for(int i=0; i<n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n }\n\n while(true){\n if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%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",
"int s = 0;",
"s",
"0",
"int g = n-1;",
"g",
"n-1",
"n",
"1",
"int tt = 0;",
"tt",
"0",
"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 }",
"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 }",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\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",
"while(true){\n if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }\n }",
"true",
"{\n if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }\n }",
"if(time[s] > q){\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }\n else{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }",
"time[s] > q",
"time[s]",
"time",
"s",
"q",
"{\n time[(g+1)%n] = time[s]-q;\n name[(g+1)%n] = name[s];\n tt = tt+q;\n g = (g+1)%n;\n s = (s+1)%n;\n }",
"time[(g+1)%n] = time[s]-q",
"time[(g+1)%n]",
"time",
"(g+1)%n",
"(g+1)",
"g",
"1",
"n",
"time[s]-q",
"time[s]",
"time",
"s",
"q",
"name[(g+1)%n] = name[s]",
"name[(g+1)%n]",
"name",
"(g+1)%n",
"(g+1)",
"g",
"1",
"n",
"name[s]",
"name",
"s",
"tt = tt+q",
"tt",
"tt+q",
"tt",
"q",
"g = (g+1)%n",
"g",
"(g+1)%n",
"(g+1)",
"g",
"1",
"n",
"s = (s+1)%n",
"s",
"(s+1)%n",
"(s+1)",
"s",
"1",
"n",
"{\n tt = tt+time[s];\n if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }\n }",
"tt = tt+time[s]",
"tt",
"tt+time[s]",
"tt",
"time[s]",
"time",
"s",
"if(s == g){\n System.out.println(name[s]+\" \"+tt);\n break;\n }\n else{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }",
"s == g",
"s",
"g",
"{\n System.out.println(name[s]+\" \"+tt);\n break;\n }",
"System.out.println(name[s]+\" \"+tt)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[s]+\" \"+tt",
"name[s]+\" \"+tt",
"name[s]",
"name",
"s",
"\" \"",
"tt",
"break;",
"{\n System.out.println(name[s]+\" \"+tt);\n s = (s+1)%n;\n }",
"System.out.println(name[s]+\" \"+tt)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[s]+\" \"+tt",
"name[s]+\" \"+tt",
"name[s]",
"name",
"s",
"\" \"",
"tt",
"s = (s+1)%n",
"s",
"(s+1)%n",
"(s+1)",
"s",
"1",
"n",
"String[] args",
"args"
] | import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
int s = 0;
int g = n-1;
int tt = 0;
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();
}
while(true){
if(time[s] > q){
time[(g+1)%n] = time[s]-q;
name[(g+1)%n] = name[s];
tt = tt+q;
g = (g+1)%n;
s = (s+1)%n;
}
else{
tt = tt+time[s];
if(s == g){
System.out.println(name[s]+" "+tt);
break;
}
else{
System.out.println(name[s]+" "+tt);
s = (s+1)%n;
}
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
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,
17,
41,
13,
17,
12,
13,
30,
0,
13,
2,
13,
17,
0,
13,
20,
13,
23,
13,
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,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
29,
13,
6,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
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,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
20,
41,
13,
17,
42,
17,
30,
14,
4,
18,
13,
3,
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,
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
],
[
12,
13
],
[
10,
14
],
[
14,
15
],
[
10,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
22,
23
],
[
22,
24
],
[
16,
25
],
[
25,
26
],
[
16,
27
],
[
27,
28
],
[
0,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
29,
33
],
[
33,
34
],
[
29,
35
],
[
35,
36
],
[
35,
37
],
[
29,
38
],
[
38,
39
],
[
38,
40
],
[
29,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
46,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
41,
53
],
[
53,
54
],
[
29,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
29,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
29,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
80,
81
],
[
75,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
75,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
87,
97
],
[
97,
98
],
[
98,
99
],
[
73,
100
],
[
100,
101
],
[
29,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
104,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
104,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
116,
126
],
[
126,
127
],
[
127,
128
],
[
104,
129
],
[
129,
130
],
[
0,
131
],
[
268,
132
],
[
268,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
136,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
149,
154
],
[
143,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
157,
160
],
[
160,
161
],
[
160,
162
],
[
143,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
168,
169
],
[
168,
170
],
[
143,
171
],
[
171,
172
],
[
171,
173
],
[
143,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
179,
180
],
[
179,
181
],
[
174,
182
],
[
182,
183
],
[
183,
184
],
[
174,
185
],
[
186,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
189,
194
],
[
186,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
197,
199
],
[
186,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
202,
205
],
[
205,
206
],
[
205,
207
],
[
186,
208
],
[
208,
209
],
[
209,
210
],
[
208,
211
],
[
143,
212
],
[
212,
213
],
[
212,
214
],
[
143,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
218,
222
],
[
217,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
226,
227
],
[
217,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
229,
233
],
[
228,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
237,
239
],
[
234,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
240,
245
],
[
246,
246
],
[
246,
247
],
[
247,
248
],
[
247,
249
],
[
246,
250
],
[
246,
251
],
[
228,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
252,
256
],
[
256,
257
],
[
257,
258
],
[
257,
259
],
[
256,
260
],
[
252,
261
],
[
261,
262
],
[
262,
263
],
[
261,
264
],
[
133,
265
],
[
265,
266
],
[
0,
267
],
[
267,
268
],
[
267,
269
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nclass Process {\n String name;\n int time;\n\n Process(String s, int n) {\n name = s;\n time = n;\n }\n}\n\n// I want to use Generics but General type array T[] cannot define.\n// add(i, elm) of List<T> shift elements to right.\n// So I do not use Generics here.\nclass Queue {\n int size;\n Process[] buf;\n int head = 0;\n int tail = 0;\n\n Queue(int n) {\n size = n + 1;\n buf = new Process[size];\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n\n boolean isFull() {\n return head == (tail + 1) % size;\n }\n\n void enqueue(Process x) {\n if (isFull()) {\n throw new IndexOutOfBoundsException(\"Queue is full\");\n }\n\n buf[tail] = x;\n if ((tail + 1) == size) {\n tail = 0;\n } else {\n tail++;\n }\n }\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IndexOutOfBoundsException(\"Queue is empty\");\n }\n\n Process x = buf[head];\n if ((head + 1) == size) {\n head = 0;\n } else {\n head++;\n }\n\n return x;\n }\n}\n\npublic class Main {\n public static void main(String[] args) {\n try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\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 Process {\n String name;\n int time;\n\n Process(String s, int n) {\n name = s;\n time = n;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String s, int n) {\n name = s;\n time = n;\n }",
"Process",
"{\n name = s;\n time = n;\n }",
"name = s",
"name",
"s",
"time = n",
"time",
"n",
"String s",
"s",
"int n",
"n",
"class Queue {\n int size;\n Process[] buf;\n int head = 0;\n int tail = 0;\n\n Queue(int n) {\n size = n + 1;\n buf = new Process[size];\n }\n\n boolean isEmpty() {\n return head == tail;\n }\n\n boolean isFull() {\n return head == (tail + 1) % size;\n }\n\n void enqueue(Process x) {\n if (isFull()) {\n throw new IndexOutOfBoundsException(\"Queue is full\");\n }\n\n buf[tail] = x;\n if ((tail + 1) == size) {\n tail = 0;\n } else {\n tail++;\n }\n }\n\n Process dequeue() {\n if (isEmpty()) {\n throw new IndexOutOfBoundsException(\"Queue is empty\");\n }\n\n Process x = buf[head];\n if ((head + 1) == size) {\n head = 0;\n } else {\n head++;\n }\n\n return x;\n }\n}",
"Queue",
"int size;",
"size",
"Process[] buf;",
"buf",
"int head = 0;",
"head",
"0",
"int tail = 0;",
"tail",
"0",
"Queue(int n) {\n size = n + 1;\n buf = new Process[size];\n }",
"Queue",
"{\n size = n + 1;\n buf = new Process[size];\n }",
"size = n + 1",
"size",
"n + 1",
"n",
"1",
"buf = new Process[size]",
"buf",
"new Process[size]",
"size",
"int n",
"n",
"boolean isEmpty() {\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"boolean isFull() {\n return head == (tail + 1) % size;\n }",
"isFull",
"{\n return head == (tail + 1) % size;\n }",
"return head == (tail + 1) % size;",
"head == (tail + 1) % size",
"head",
"(tail + 1) % size",
"(tail + 1)",
"tail",
"1",
"size",
"void enqueue(Process x) {\n if (isFull()) {\n throw new IndexOutOfBoundsException(\"Queue is full\");\n }\n\n buf[tail] = x;\n if ((tail + 1) == size) {\n tail = 0;\n } else {\n tail++;\n }\n }",
"enqueue",
"{\n if (isFull()) {\n throw new IndexOutOfBoundsException(\"Queue is full\");\n }\n\n buf[tail] = x;\n if ((tail + 1) == size) {\n tail = 0;\n } else {\n tail++;\n }\n }",
"if (isFull()) {\n throw new IndexOutOfBoundsException(\"Queue is full\");\n }",
"isFull()",
"isFull",
"{\n throw new IndexOutOfBoundsException(\"Queue is full\");\n }",
"throw new IndexOutOfBoundsException(\"Queue is full\");",
"new IndexOutOfBoundsException(\"Queue is full\")",
"buf[tail] = x",
"buf[tail]",
"buf",
"tail",
"x",
"if ((tail + 1) == size) {\n tail = 0;\n } else {\n tail++;\n }",
"(tail + 1) == size",
"(tail + 1)",
"tail",
"1",
"size",
"{\n tail = 0;\n }",
"tail = 0",
"tail",
"0",
"{\n tail++;\n }",
"tail++",
"tail",
"Process x",
"x",
"Process dequeue() {\n if (isEmpty()) {\n throw new IndexOutOfBoundsException(\"Queue is empty\");\n }\n\n Process x = buf[head];\n if ((head + 1) == size) {\n head = 0;\n } else {\n head++;\n }\n\n return x;\n }",
"dequeue",
"{\n if (isEmpty()) {\n throw new IndexOutOfBoundsException(\"Queue is empty\");\n }\n\n Process x = buf[head];\n if ((head + 1) == size) {\n head = 0;\n } else {\n head++;\n }\n\n return x;\n }",
"if (isEmpty()) {\n throw new IndexOutOfBoundsException(\"Queue is empty\");\n }",
"isEmpty()",
"isEmpty",
"{\n throw new IndexOutOfBoundsException(\"Queue is empty\");\n }",
"throw new IndexOutOfBoundsException(\"Queue is empty\");",
"new IndexOutOfBoundsException(\"Queue is empty\")",
"Process x = buf[head];",
"x",
"buf[head]",
"buf",
"head",
"if ((head + 1) == size) {\n head = 0;\n } else {\n head++;\n }",
"(head + 1) == size",
"(head + 1)",
"head",
"1",
"size",
"{\n head = 0;\n }",
"head = 0",
"head",
"0",
"{\n head++;\n }",
"head++",
"head",
"return x;",
"x",
"public class Main {\n public static void main(String[] args) {\n try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"main",
"{\n try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }",
"try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\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 String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }\n\n }",
"BufferedReader in = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader in = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] line = in.readLine().split(\" \");",
"line",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"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 queue = new Queue(n);",
"queue",
"new Queue(n)",
"for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }",
"{\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }",
"line = in.readLine().split(\" \")",
"line",
"in.readLine().split(\" \")",
"in.readLine().split",
"in.readLine()",
"in.readLine",
"in",
"\" \"",
"String name = line[0];",
"name",
"line[0]",
"line",
"0",
"int time = Integer.parseInt(line[1]);",
"time",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"queue.enqueue(new Process(name, time))",
"queue.enqueue",
"queue",
"new Process(name, time)",
"int currTime = 0;",
"currTime",
"0",
"while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }",
"true",
"{\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }",
"if (queue.isEmpty()) break;",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"break;",
"Process p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }",
"p.time <= q",
"p.time",
"p",
"p.time",
"q",
"{\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n }",
"currTime += p.time",
"currTime",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + currTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + currTime",
"p.name + \" \" + currTime",
"p.name",
"p",
"p.name",
"\" \"",
"currTime",
"{\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }",
"currTime += q",
"currTime",
"q",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {\n String[] line = in.readLine().split(\" \");\n int n = Integer.parseInt(line[0]);\n int q = Integer.parseInt(line[1]);\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n line = in.readLine().split(\" \");\n String name = line[0];\n int time = Integer.parseInt(line[1]);\n queue.enqueue(new Process(name, time));\n }\n\n int currTime = 0;\n while (true) {\n if (queue.isEmpty()) break;\n\n Process p = queue.dequeue();\n if (p.time <= q) {\n currTime += p.time;\n System.out.println(p.name + \" \" + currTime);\n } else {\n currTime += q;\n p.time -= q;\n queue.enqueue(p);\n }\n }\n\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Process {
String name;
int time;
Process(String s, int n) {
name = s;
time = n;
}
}
// I want to use Generics but General type array T[] cannot define.
// add(i, elm) of List<T> shift elements to right.
// So I do not use Generics here.
class Queue {
int size;
Process[] buf;
int head = 0;
int tail = 0;
Queue(int n) {
size = n + 1;
buf = new Process[size];
}
boolean isEmpty() {
return head == tail;
}
boolean isFull() {
return head == (tail + 1) % size;
}
void enqueue(Process x) {
if (isFull()) {
throw new IndexOutOfBoundsException("Queue is full");
}
buf[tail] = x;
if ((tail + 1) == size) {
tail = 0;
} else {
tail++;
}
}
Process dequeue() {
if (isEmpty()) {
throw new IndexOutOfBoundsException("Queue is empty");
}
Process x = buf[head];
if ((head + 1) == size) {
head = 0;
} else {
head++;
}
return x;
}
}
public class Main {
public static void main(String[] args) {
try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
String[] line = in.readLine().split(" ");
int n = Integer.parseInt(line[0]);
int q = Integer.parseInt(line[1]);
Queue queue = new Queue(n);
for (int i = 0; i < n; i++) {
line = in.readLine().split(" ");
String name = line[0];
int time = Integer.parseInt(line[1]);
queue.enqueue(new Process(name, time));
}
int currTime = 0;
while (true) {
if (queue.isEmpty()) break;
Process p = queue.dequeue();
if (p.time <= q) {
currTime += p.time;
System.out.println(p.name + " " + currTime);
} else {
currTime += q;
p.time -= q;
queue.enqueue(p);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
[
7,
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
17,
0,
18,
13,
17,
4,
18,
13,
0,
18,
13,
17,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
18,
13,
17,
4,
18,
13,
2,
13,
13,
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
],
[
142,
8
],
[
142,
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
],
[
20,
23
],
[
23,
24
],
[
24,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
28,
31
],
[
31,
32
],
[
32,
33
],
[
11,
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
],
[
46,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
46,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
46,
65
],
[
65,
66
],
[
66,
67
],
[
65,
68
],
[
11,
69
],
[
69,
70
],
[
70,
71
],
[
11,
72
],
[
72,
73
],
[
72,
74
],
[
11,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
75,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
80,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
80,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
96,
97
],
[
96,
98
],
[
80,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
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
],
[
115,
117
],
[
115,
118
],
[
99,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
127,
128
],
[
127,
129
],
[
119,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
119,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
9,
139
],
[
139,
140
],
[
0,
141
],
[
141,
142
],
[
141,
143
]
] | [
"import java.util.Queue;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] wjy){\n Scanner in = new Scanner(System.in);\n Queue<String[]> input = new ArrayDeque<String[]>();\n int num = Integer.parseInt(in.next()) ;\n int quan = Integer.parseInt(in.next());\n for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }\n in.close();\n int calculate = 0;\n while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }\n }\n}\n",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] wjy){\n Scanner in = new Scanner(System.in);\n Queue<String[]> input = new ArrayDeque<String[]>();\n int num = Integer.parseInt(in.next()) ;\n int quan = Integer.parseInt(in.next());\n for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }\n in.close();\n int calculate = 0;\n while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }\n }\n}",
"Main",
"public static void main(String[] wjy){\n Scanner in = new Scanner(System.in);\n Queue<String[]> input = new ArrayDeque<String[]>();\n int num = Integer.parseInt(in.next()) ;\n int quan = Integer.parseInt(in.next());\n for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }\n in.close();\n int calculate = 0;\n while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }\n }",
"main",
"{\n Scanner in = new Scanner(System.in);\n Queue<String[]> input = new ArrayDeque<String[]>();\n int num = Integer.parseInt(in.next()) ;\n int quan = Integer.parseInt(in.next());\n for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }\n in.close();\n int calculate = 0;\n while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"Queue<String[]> input = new ArrayDeque<String[]>();",
"input",
"new ArrayDeque<String[]>()",
"int num = Integer.parseInt(in.next()) ;",
"num",
"Integer.parseInt(in.next())",
"Integer.parseInt",
"Integer",
"in.next()",
"in.next",
"in",
"int quan = Integer.parseInt(in.next());",
"quan",
"Integer.parseInt(in.next())",
"Integer.parseInt",
"Integer",
"in.next()",
"in.next",
"in",
"for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<num",
"i",
"num",
"i++",
"i++",
"i",
"{\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }",
"{\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }",
"String[] a = new String[2];",
"a",
"new String[2]",
"2",
"a[0] = in.next()",
"a[0]",
"a",
"0",
"in.next()",
"in.next",
"in",
"a[1] = in.next()",
"a[1]",
"a",
"1",
"in.next()",
"in.next",
"in",
"input.add(a)",
"input.add",
"input",
"a",
"in.close()",
"in.close",
"in",
"int calculate = 0;",
"calculate",
"0",
"while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }",
"!input.isEmpty()",
"input.isEmpty()",
"input.isEmpty",
"input",
"{\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }",
"String[] k = input.remove();",
"k",
"input.remove()",
"input.remove",
"input",
"String name =(String) k[0];",
"name",
"(String) k[0]",
"k",
"0",
"int time =Integer.parseInt(k[1]);",
"time",
"Integer.parseInt(k[1])",
"Integer.parseInt",
"Integer",
"k[1]",
"k",
"1",
"if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }",
"time<=quan",
"time",
"quan",
"{\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }",
"calculate=calculate+time",
"calculate",
"calculate+time",
"calculate",
"time",
"System.out.println(name +\" \"+calculate)",
"System.out.println",
"System.out",
"System",
"System.out",
"name +\" \"+calculate",
"name +\" \"+calculate",
"name",
"\" \"",
"calculate",
"{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }",
"k[1]=Integer.toString((time-quan))",
"k[1]",
"k",
"1",
"Integer.toString((time-quan))",
"Integer.toString",
"Integer",
"(time-quan)",
"time",
"quan",
"input.offer(k)",
"input.offer",
"input",
"k",
"calculate=calculate+quan",
"calculate",
"calculate+quan",
"calculate",
"quan",
"String[] wjy",
"wjy",
"public class Main {\n public static void main(String[] wjy){\n Scanner in = new Scanner(System.in);\n Queue<String[]> input = new ArrayDeque<String[]>();\n int num = Integer.parseInt(in.next()) ;\n int quan = Integer.parseInt(in.next());\n for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }\n in.close();\n int calculate = 0;\n while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] wjy){\n Scanner in = new Scanner(System.in);\n Queue<String[]> input = new ArrayDeque<String[]>();\n int num = Integer.parseInt(in.next()) ;\n int quan = Integer.parseInt(in.next());\n for (int i=0;i<num;i++) {\n String[] a = new String[2];\n a[0] = in.next();\n a[1] = in.next();\n input.add(a);\n }\n in.close();\n int calculate = 0;\n while (!input.isEmpty()){\n String[] k = input.remove();\n String name =(String) k[0];\n int time =Integer.parseInt(k[1]);\n if (time<=quan){\n calculate=calculate+time;\n System.out.println(name +\" \"+calculate);\n }\n else{\n k[1]=Integer.toString((time-quan));\n input.offer(k);\n calculate=calculate+quan;\n }\n }\n }\n}",
"Main"
] | import java.util.Queue;
import java.util.*;
public class Main {
public static void main(String[] wjy){
Scanner in = new Scanner(System.in);
Queue<String[]> input = new ArrayDeque<String[]>();
int num = Integer.parseInt(in.next()) ;
int quan = Integer.parseInt(in.next());
for (int i=0;i<num;i++) {
String[] a = new String[2];
a[0] = in.next();
a[1] = in.next();
input.add(a);
}
in.close();
int calculate = 0;
while (!input.isEmpty()){
String[] k = input.remove();
String name =(String) k[0];
int time =Integer.parseInt(k[1]);
if (time<=quan){
calculate=calculate+time;
System.out.println(name +" "+calculate);
}
else{
k[1]=Integer.toString((time-quan));
input.offer(k);
calculate=calculate+quan;
}
}
}
}
|
[
7,
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,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
2,
2,
4,
18,
13,
17,
4,
18,
13,
41,
13,
17,
41,
13,
13,
41,
13,
17,
41,
13,
20,
13,
42,
2,
4,
18,
13,
17,
30,
41,
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,
0,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
2,
13,
13,
0,
13,
17,
30,
0,
13,
13,
0,
13,
17,
0,
13,
17,
14,
2,
2,
2,
13,
17,
2,
4,
18,
13,
17,
2,
13,
17,
30,
0,
18,
13,
13,
2,
2,
13,
17,
13,
40,
13,
0,
13,
13,
4,
18,
13,
14,
2,
2,
13,
17,
2,
4,
18,
13,
17,
30,
0,
18,
13,
13,
2,
2,
13,
17,
13,
40,
13,
4,
18,
13,
14,
2,
2,
13,
17,
2,
4,
18,
13,
17,
30,
0,
13,
13,
4,
18,
13,
4,
18,
13,
2,
2,
13,
17,
13,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
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
],
[
242,
11
],
[
242,
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
],
[
28,
29
],
[
29,
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
],
[
45,
46
],
[
44,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
48,
52
],
[
48,
53
],
[
53,
54
],
[
54,
55
],
[
14,
56
],
[
56,
57
],
[
56,
58
],
[
14,
59
],
[
59,
60
],
[
59,
61
],
[
14,
62
],
[
62,
63
],
[
62,
64
],
[
14,
65
],
[
65,
66
],
[
65,
67
],
[
14,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
70,
74
],
[
69,
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
],
[
105,
107
],
[
97,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
112,
121
],
[
121,
122
],
[
121,
123
],
[
108,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
128,
130
],
[
124,
131
],
[
131,
132
],
[
131,
133
],
[
75,
134
],
[
134,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
140,
144
],
[
136,
145
],
[
145,
146
],
[
145,
147
],
[
134,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
154,
154
],
[
154,
155
],
[
154,
156
],
[
154,
157
],
[
148,
158
],
[
158,
159
],
[
148,
160
],
[
160,
161
],
[
160,
162
],
[
148,
163
],
[
163,
164
],
[
164,
165
],
[
134,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
171,
175
],
[
166,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
182,
182
],
[
182,
183
],
[
182,
184
],
[
182,
185
],
[
176,
186
],
[
186,
187
],
[
176,
188
],
[
188,
189
],
[
189,
190
],
[
166,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
196,
197
],
[
197,
198
],
[
198,
199
],
[
196,
200
],
[
191,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
201,
205
],
[
205,
206
],
[
206,
207
],
[
201,
208
],
[
208,
209
],
[
209,
210
],
[
208,
211
],
[
212,
212
],
[
212,
213
],
[
212,
214
],
[
212,
215
],
[
14,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
216,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
223,
225
],
[
216,
226
],
[
226,
227
],
[
227,
228
],
[
216,
229
],
[
230,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
233,
234
],
[
233,
235
],
[
231,
236
],
[
236,
237
],
[
236,
238
],
[
12,
239
],
[
239,
240
],
[
0,
241
],
[
241,
242
],
[
241,
243
]
] | [
"\nimport java.util.LinkedList; \nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\n\t\tQueue<String> qu = new LinkedList<>();\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint amt = scan.nextInt();\n\t\tint quant = scan.nextInt();\n\t\t\n\t\tfor(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\tint q = quant;\n\t\tint i=0;\n\t\tString[] results = new String[amt];\n\t\twhile(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}\n\t\t\n\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\tpublic static void main(String[] args) {\n\n\t\tQueue<String> qu = new LinkedList<>();\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint amt = scan.nextInt();\n\t\tint quant = scan.nextInt();\n\t\t\n\t\tfor(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\tint q = quant;\n\t\tint i=0;\n\t\tString[] results = new String[amt];\n\t\twhile(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}\n\t\t\n\t}\n\t\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tQueue<String> qu = new LinkedList<>();\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint amt = scan.nextInt();\n\t\tint quant = scan.nextInt();\n\t\t\n\t\tfor(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\tint q = quant;\n\t\tint i=0;\n\t\tString[] results = new String[amt];\n\t\twhile(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}\n\t\t\n\t}",
"main",
"{\n\n\t\tQueue<String> qu = new LinkedList<>();\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint amt = scan.nextInt();\n\t\tint quant = scan.nextInt();\n\t\t\n\t\tfor(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\tint q = quant;\n\t\tint i=0;\n\t\tString[] results = new String[amt];\n\t\twhile(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}\n\t\t\n\t}",
"Queue<String> qu = new LinkedList<>();",
"qu",
"new LinkedList<>()",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int amt = scan.nextInt();",
"amt",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int quant = scan.nextInt();",
"quant",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<amt",
"i",
"amt",
"i++",
"i++",
"i",
"{\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}",
"{\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}",
"qu.add(scan.next() + \" \" + scan.next())",
"qu.add",
"qu",
"scan.next() + \" \" + scan.next()",
"scan.next() + \" \" + scan.next()",
"scan.next()",
"scan.next",
"scan",
"\" \"",
"scan.next()",
"scan.next",
"scan",
"int timer = 0;",
"timer",
"0",
"int q = quant;",
"q",
"quant",
"int i=0;",
"i",
"0",
"String[] results = new String[amt];",
"results",
"new String[amt]",
"amt",
"while(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}",
"qu.size() > 0",
"qu.size()",
"qu.size",
"qu",
"0",
"{\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}",
"String[] temparr = qu.peek().split(\"\\\\s+\");",
"temparr",
"qu.peek().split(\"\\\\s+\")",
"qu.peek().split",
"qu.peek()",
"qu.peek",
"qu",
"\"\\\\s+\"",
"String name = temparr[0];",
"name",
"temparr[0]",
"temparr",
"0",
"int num = Integer.parseInt(temparr[1]);",
"num",
"Integer.parseInt(temparr[1])",
"Integer.parseInt",
"Integer",
"temparr[1]",
"temparr",
"1",
"if(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}",
"q>num",
"q",
"num",
"{\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t}",
"timer += num",
"timer",
"num",
"num=0",
"num",
"0",
"if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}",
"num>q",
"num",
"q",
"{\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t}",
"timer += q",
"timer",
"q",
"num = num - q",
"num",
"num - q",
"num",
"q",
"q=0",
"q",
"0",
"{\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}",
"timer += q",
"timer",
"q",
"num=0",
"num",
"0",
"q=0",
"q",
"0",
"if(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}",
"num==0 && qu.size() > 0 && q==0",
"num==0 && qu.size() > 0 && q==0",
"num==0",
"num",
"0",
"qu.size() > 0",
"qu.size()",
"qu.size",
"qu",
"0",
"q==0",
"q",
"0",
"{\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t}",
"results[i]=name + \" \" + timer",
"results[i]",
"results",
"i",
"name + \" \" + timer",
"name + \" \" + timer",
"name",
"\" \"",
"timer",
"i++",
"i",
"q = quant",
"q",
"quant",
"qu.remove()",
"qu.remove",
"qu",
"if(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}",
"num==0 && qu.size() > 0",
"num==0",
"num",
"0",
"qu.size() > 0",
"qu.size()",
"qu.size",
"qu",
"0",
"{\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t}",
"results[i]= name + \" \" + timer",
"results[i]",
"results",
"i",
"name + \" \" + timer",
"name + \" \" + timer",
"name",
"\" \"",
"timer",
"i++",
"i",
"qu.remove()",
"qu.remove",
"qu",
"if(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}",
"q==0 && qu.size() > 0",
"q==0",
"q",
"0",
"qu.size() > 0",
"qu.size()",
"qu.size",
"qu",
"0",
"{\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}",
"q = quant",
"q",
"quant",
"qu.remove()",
"qu.remove",
"qu",
"qu.add(name + \" \" + num)",
"qu.add",
"qu",
"name + \" \" + num",
"name + \" \" + num",
"name",
"\" \"",
"num",
"for(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}",
"int j=0;",
"int j=0;",
"j",
"0",
"j<results.length",
"j",
"results.length",
"results",
"results.length",
"j++",
"j++",
"j",
"{\n\t\t\tSystem.out.println(results[j]);\n\t\t}",
"{\n\t\t\tSystem.out.println(results[j]);\n\t\t}",
"System.out.println(results[j])",
"System.out.println",
"System.out",
"System",
"System.out",
"results[j]",
"results",
"j",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\tQueue<String> qu = new LinkedList<>();\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint amt = scan.nextInt();\n\t\tint quant = scan.nextInt();\n\t\t\n\t\tfor(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\tint q = quant;\n\t\tint i=0;\n\t\tString[] results = new String[amt];\n\t\twhile(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}\n\t\t\n\t}\n\t\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\tQueue<String> qu = new LinkedList<>();\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tint amt = scan.nextInt();\n\t\tint quant = scan.nextInt();\n\t\t\n\t\tfor(int i=0; i<amt; i++){\n\t\t\tqu.add(scan.next() + \" \" + scan.next());\n\t\t\t\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\tint q = quant;\n\t\tint i=0;\n\t\tString[] results = new String[amt];\n\t\twhile(qu.size() > 0) {\n\t\t\tString[] temparr = qu.peek().split(\"\\\\s+\");\n\t\t\tString name = temparr[0];\n\t\t\tint num = Integer.parseInt(temparr[1]);\n\t\t\tif(q>num) {\n\t\t\t\ttimer += num;\n\t\t\t\t//q= q-num;\n\t\t\t\tnum=0;\n\n\t\t\t} else if(num>q){\n\t\t\t\ttimer += q;\n\t\t\t\tnum = num - q;\n\t\t\t\tq=0;\n\n\t\t\t} else {\n\n\t\t\t\ttimer += q;\n\t\t\t\tnum=0;\n\t\t\t\tq=0;\n\n\t\t\t}\n\n\t\t\tif(num==0 && qu.size() > 0 && q==0) {\n\t\t\t\tresults[i]=name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t} else\n\t\t\tif(num==0 && qu.size() > 0) {\n\t\t\t\tresults[i]= name + \" \" + timer;\n\t\t\t\ti++;\n\t\t\t\tqu.remove();\n\n\t\t\t} else\n\t\t\tif(q==0 && qu.size() > 0) {\n\t\t\t\tq = quant;\n\t\t\t\tqu.remove();\n\t\t\t\tqu.add(name + \" \" + num);\n\t\t\t}\n\t\t\t\n\t\t}\n\t\tfor(int j=0; j<results.length;j++) {\n\t\t\tSystem.out.println(results[j]);\n\t\t}\n\t\t\n\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<String> qu = new LinkedList<>();
Scanner scan = new Scanner(System.in);
int amt = scan.nextInt();
int quant = scan.nextInt();
for(int i=0; i<amt; i++){
qu.add(scan.next() + " " + scan.next());
}
int timer = 0;
int q = quant;
int i=0;
String[] results = new String[amt];
while(qu.size() > 0) {
String[] temparr = qu.peek().split("\\s+");
String name = temparr[0];
int num = Integer.parseInt(temparr[1]);
if(q>num) {
timer += num;
//q= q-num;
num=0;
} else if(num>q){
timer += q;
num = num - q;
q=0;
} else {
timer += q;
num=0;
q=0;
}
if(num==0 && qu.size() > 0 && q==0) {
results[i]=name + " " + timer;
i++;
q = quant;
qu.remove();
} else
if(num==0 && qu.size() > 0) {
results[i]= name + " " + timer;
i++;
qu.remove();
} else
if(q==0 && qu.size() > 0) {
q = quant;
qu.remove();
qu.add(name + " " + num);
}
}
for(int j=0; j<results.length;j++) {
System.out.println(results[j]);
}
}
}
|
[
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,
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,
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,
13,
4,
18,
13,
13,
4,
18,
13,
2,
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
],
[
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
],
[
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
],
[
56,
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
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
80,
85
],
[
86,
86
],
[
86,
87
],
[
86,
88
],
[
86,
89
],
[
72,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
90,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
101,
102
],
[
101,
103
],
[
6,
104
],
[
104,
105
],
[
0,
106
],
[
106,
107
],
[
106,
108
]
] | [
"import java.util.*;\npublic class Main {\n\tpublic static void main(String [] args) {\n\t\t\n\t\tLinkedList<String> names = new LinkedList<String>();\n\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint numLines = in.nextInt();\n\t\tint t = in.nextInt();\n\t\tint totalTime = 0;\n\t\n\t\tfor(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\twhile(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}\n\t}\n\t\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String [] args) {\n\t\t\n\t\tLinkedList<String> names = new LinkedList<String>();\n\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint numLines = in.nextInt();\n\t\tint t = in.nextInt();\n\t\tint totalTime = 0;\n\t\n\t\tfor(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\twhile(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}\n\t}\n\t\n}",
"Main",
"public static void main(String [] args) {\n\t\t\n\t\tLinkedList<String> names = new LinkedList<String>();\n\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint numLines = in.nextInt();\n\t\tint t = in.nextInt();\n\t\tint totalTime = 0;\n\t\n\t\tfor(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\twhile(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\t\n\t\tLinkedList<String> names = new LinkedList<String>();\n\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint numLines = in.nextInt();\n\t\tint t = in.nextInt();\n\t\tint totalTime = 0;\n\t\n\t\tfor(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\twhile(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}\n\t}",
"LinkedList<String> names = new LinkedList<String>();",
"names",
"new LinkedList<String>()",
"LinkedList<Integer> times = new LinkedList<Integer>();",
"times",
"new LinkedList<Integer>()",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int numLines = in.nextInt();",
"numLines",
"in.nextInt()",
"in.nextInt",
"in",
"int t = in.nextInt();",
"t",
"in.nextInt()",
"in.nextInt",
"in",
"int totalTime = 0;",
"totalTime",
"0",
"for(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < numLines",
"i",
"numLines",
"i++",
"i++",
"i",
"{\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}",
"{\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}",
"names.add(in.next())",
"names.add",
"names",
"in.next()",
"in.next",
"in",
"times.add(in.nextInt())",
"times.add",
"times",
"in.nextInt()",
"in.nextInt",
"in",
"while(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}",
"!times.isEmpty()",
"times.isEmpty()",
"times.isEmpty",
"times",
"{\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}",
"String name = names.removeFirst();",
"name",
"names.removeFirst()",
"names.removeFirst",
"names",
"int time = times.removeFirst();",
"time",
"times.removeFirst()",
"times.removeFirst",
"times",
"if(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}",
"time <= t",
"time",
"t",
"{\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}",
"totalTime += time",
"totalTime",
"time",
"System.out.println(name + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + totalTime",
"name + \" \" + totalTime",
"name",
"\" \"",
"totalTime",
"{\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}",
"totalTime += t",
"totalTime",
"t",
"names.addLast(name)",
"names.addLast",
"names",
"name",
"times.addLast(time - t)",
"times.addLast",
"times",
"time - t",
"time",
"t",
"String [] args",
"args",
"public class Main {\n\tpublic static void main(String [] args) {\n\t\t\n\t\tLinkedList<String> names = new LinkedList<String>();\n\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint numLines = in.nextInt();\n\t\tint t = in.nextInt();\n\t\tint totalTime = 0;\n\t\n\t\tfor(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\twhile(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}\n\t}\n\t\n}",
"public class Main {\n\tpublic static void main(String [] args) {\n\t\t\n\t\tLinkedList<String> names = new LinkedList<String>();\n\t\tLinkedList<Integer> times = new LinkedList<Integer>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint numLines = in.nextInt();\n\t\tint t = in.nextInt();\n\t\tint totalTime = 0;\n\t\n\t\tfor(int i = 0; i < numLines; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\twhile(!times.isEmpty()) {\n\t\t\tString name = names.removeFirst();\n\t\t\tint time = times.removeFirst();\n\t\t\t\n\t\t\tif(time <= t) {\n\t\t\t\ttotalTime += time;\n\t\t\t\tSystem.out.println(name + \" \" + totalTime);\n\t\t\t}\n\t\t\t\n\t\t\telse {\n\t\t\t\ttotalTime += t;\n\t\t\t\tnames.addLast(name);\n\t\t\t\ttimes.addLast(time - t);\n\t\t\t}\n\t\t}\n\t}\n\t\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String [] args) {
LinkedList<String> names = new LinkedList<String>();
LinkedList<Integer> times = new LinkedList<Integer>();
Scanner in = new Scanner(System.in);
int numLines = in.nextInt();
int t = in.nextInt();
int totalTime = 0;
for(int i = 0; i < numLines; i++) {
names.add(in.next());
times.add(in.nextInt());
}
while(!times.isEmpty()) {
String name = names.removeFirst();
int time = times.removeFirst();
if(time <= t) {
totalTime += time;
System.out.println(name + " " + totalTime);
}
else {
totalTime += t;
names.addLast(name);
times.addLast(time - t);
}
}
}
}
|
[
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,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
4,
18,
13,
18,
13,
17,
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,
14,
2,
4,
18,
13,
18,
13,
17,
13,
30,
41,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
20,
0,
13,
13,
30,
0,
18,
13,
17,
4,
18,
13,
2,
4,
18,
13,
18,
13,
17,
13,
4,
18,
13,
13,
0,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
17,
17,
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
],
[
155,
11
],
[
155,
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
],
[
14,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
45,
47
],
[
43,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
53,
55
],
[
43,
56
],
[
56,
57
],
[
57,
58
],
[
43,
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
],
[
14,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
74,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
90,
91
],
[
90,
92
],
[
86,
93
],
[
85,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
94,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
94,
107
],
[
107,
108
],
[
107,
109
],
[
85,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
122,
123
],
[
122,
124
],
[
118,
125
],
[
110,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
110,
130
],
[
130,
131
],
[
130,
132
],
[
14,
133
],
[
133,
134
],
[
133,
135
],
[
133,
136
],
[
137,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
138,
143
],
[
144,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
144,
149
],
[
149,
150
],
[
149,
151
],
[
12,
152
],
[
152,
153
],
[
0,
154
],
[
154,
155
],
[
154,
156
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tQueue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] l1 = sc.nextLine().split(\" \");\n\t\tint quantum = Integer.valueOf(l1[1]), eclipsedTime=0;\n\t\tfor (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}\n\t\twhile(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}\n\t\tfor(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}\n\t}\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\n\tpublic static void main(String[] args) {\n\t\tQueue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] l1 = sc.nextLine().split(\" \");\n\t\tint quantum = Integer.valueOf(l1[1]), eclipsedTime=0;\n\t\tfor (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}\n\t\twhile(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}\n\t\tfor(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tQueue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] l1 = sc.nextLine().split(\" \");\n\t\tint quantum = Integer.valueOf(l1[1]), eclipsedTime=0;\n\t\tfor (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}\n\t\twhile(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}\n\t\tfor(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}\n\t}",
"main",
"{\n\t\tQueue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] l1 = sc.nextLine().split(\" \");\n\t\tint quantum = Integer.valueOf(l1[1]), eclipsedTime=0;\n\t\tfor (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}\n\t\twhile(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}\n\t\tfor(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}\n\t}",
"Queue<String[]> tasks = new LinkedList<String[]>()",
"tasks",
"new LinkedList<String[]>()",
"finished = new LinkedList<String[]>();",
"finished",
"new LinkedList<String[]>()",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String[] l1 = sc.nextLine().split(\" \");",
"l1",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"int quantum = Integer.valueOf(l1[1])",
"quantum",
"Integer.valueOf(l1[1])",
"Integer.valueOf",
"Integer",
"l1[1]",
"l1",
"1",
"eclipsedTime=0;",
"eclipsedTime",
"0",
"for (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < Integer.valueOf(l1[0])",
"i",
"Integer.valueOf(l1[0])",
"Integer.valueOf",
"Integer",
"l1[0]",
"l1",
"0",
"i++",
"i++",
"i",
"{\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}",
"{\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}",
"String[] line = sc.nextLine().split(\" \");",
"line",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"tasks.add(new String[]{line[0],line[1]})",
"tasks.add",
"tasks",
"new String[]{line[0],line[1]}",
"while(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}",
"tasks.size()>0",
"tasks.size()",
"tasks.size",
"tasks",
"0",
"{\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}",
"String[] currentTask = tasks.poll();",
"currentTask",
"tasks.poll()",
"tasks.poll",
"tasks",
"if(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}",
"Integer.valueOf(currentTask[1])<=quantum",
"Integer.valueOf(currentTask[1])",
"Integer.valueOf",
"Integer",
"currentTask[1]",
"currentTask",
"1",
"quantum",
"{ \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}",
"int partialTime = Integer.valueOf(currentTask[1]);",
"partialTime",
"Integer.valueOf(currentTask[1])",
"Integer.valueOf",
"Integer",
"currentTask[1]",
"currentTask",
"1",
"finished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)})",
"finished.add",
"finished",
"new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)}",
"eclipsedTime+=partialTime",
"eclipsedTime",
"partialTime",
"{\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}",
"currentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum)",
"currentTask[1]",
"currentTask",
"1",
"Integer.toString(Integer.valueOf(currentTask[1])-quantum)",
"Integer.toString",
"Integer",
"Integer.valueOf(currentTask[1])-quantum",
"Integer.valueOf(currentTask[1])",
"Integer.valueOf",
"Integer",
"currentTask[1]",
"currentTask",
"1",
"quantum",
"tasks.add(currentTask)",
"tasks.add",
"tasks",
"currentTask",
"eclipsedTime+=quantum",
"eclipsedTime",
"quantum",
"for(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}",
"String[] task",
"finished",
"{\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}",
"{\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}",
"System.out.println(task[0]+\" \"+task[1])",
"System.out.println",
"System.out",
"System",
"System.out",
"task[0]+\" \"+task[1]",
"task[0]+\" \"+task[1]",
"task[0]",
"task",
"0",
"\" \"",
"task[1]",
"task",
"1",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tQueue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] l1 = sc.nextLine().split(\" \");\n\t\tint quantum = Integer.valueOf(l1[1]), eclipsedTime=0;\n\t\tfor (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}\n\t\twhile(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}\n\t\tfor(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tQueue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] l1 = sc.nextLine().split(\" \");\n\t\tint quantum = Integer.valueOf(l1[1]), eclipsedTime=0;\n\t\tfor (int i = 0; i < Integer.valueOf(l1[0]); i++) {\n\t\t\tString[] line = sc.nextLine().split(\" \");\n\t\t\ttasks.add(new String[]{line[0],line[1]});\n\t\t}\n\t\twhile(tasks.size()>0) {\n\t\t\tString[] currentTask = tasks.poll();\n\t\t\tif(Integer.valueOf(currentTask[1])<=quantum) { \n\t\t\t\tint partialTime = Integer.valueOf(currentTask[1]);\n\t\t\t\tfinished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});\n\t\t\t\teclipsedTime+=partialTime;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurrentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);\n\t\t\t\ttasks.add(currentTask);\n\t\t\t\teclipsedTime+=quantum;\n\t\t\t}\n\n\t\t}\n\t\tfor(String[] task: finished) {\n\t\t\tSystem.out.println(task[0]+\" \"+task[1]);\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) {
Queue<String[]> tasks = new LinkedList<String[]>(), finished = new LinkedList<String[]>();
Scanner sc = new Scanner(System.in);
String[] l1 = sc.nextLine().split(" ");
int quantum = Integer.valueOf(l1[1]), eclipsedTime=0;
for (int i = 0; i < Integer.valueOf(l1[0]); i++) {
String[] line = sc.nextLine().split(" ");
tasks.add(new String[]{line[0],line[1]});
}
while(tasks.size()>0) {
String[] currentTask = tasks.poll();
if(Integer.valueOf(currentTask[1])<=quantum) {
int partialTime = Integer.valueOf(currentTask[1]);
finished.add(new String[] {currentTask[0],Integer.toString(partialTime+eclipsedTime)});
eclipsedTime+=partialTime;
}
else {
currentTask[1]=Integer.toString(Integer.valueOf(currentTask[1])-quantum);
tasks.add(currentTask);
eclipsedTime+=quantum;
}
}
for(String[] task: finished) {
System.out.println(task[0]+" "+task[1]);
}
}
}
|
[
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,
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,
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,
41,
13,
20,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
136,
11
],
[
136,
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
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
29,
35
],
[
35,
36
],
[
36,
37
],
[
36,
38
],
[
35,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
35,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
29,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
48,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
60,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
60,
65
],
[
12,
66
],
[
66,
67
],
[
12,
68
],
[
68,
69
],
[
136,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
76,
77
],
[
76,
78
],
[
72,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
72,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
72,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
94,
95
],
[
94,
96
],
[
89,
97
],
[
97,
98
],
[
98,
99
],
[
89,
100
],
[
101,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
101,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
101,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
72,
123
],
[
123,
124
],
[
123,
125
],
[
123,
126
],
[
70,
127
],
[
127,
128
],
[
136,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
129,
133
],
[
133,
134
],
[
0,
135
],
[
135,
136
],
[
135,
137
]
] | [
"\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\tstatic class NameTime {\n\t\tString name;\n\t\tint time;\n\t\t\n\t}\n\t\n\tpublic static void queue1(Queue<NameTime> q, int t) {\n\t\tint time = 0;\n\t\twhile (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<NameTime> q = new LinkedList<>();\n\t\tint n = scan.nextInt();\n\t\tint t = scan.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}\n\t\tqueue1(q, 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\tstatic class NameTime {\n\t\tString name;\n\t\tint time;\n\t\t\n\t}\n\t\n\tpublic static void queue1(Queue<NameTime> q, int t) {\n\t\tint time = 0;\n\t\twhile (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<NameTime> q = new LinkedList<>();\n\t\tint n = scan.nextInt();\n\t\tint t = scan.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}\n\t\tqueue1(q, t);\n\t\t\n\t}\n}",
"Main",
"public static void queue1(Queue<NameTime> q, int t) {\n\t\tint time = 0;\n\t\twhile (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"queue1",
"{\n\t\tint time = 0;\n\t\twhile (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"int time = 0;",
"time",
"0",
"while (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}",
"NameTime nt = q.remove();",
"nt",
"q.remove()",
"q.remove",
"q",
"if (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}",
"nt.time > t",
"nt.time",
"nt",
"nt.time",
"t",
"{\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}",
"time += t",
"time",
"t",
"nt.time -= t",
"nt.time",
"nt",
"nt.time",
"t",
"q.add(nt)",
"q.add",
"q",
"nt",
"{\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}",
"time += nt.time",
"time",
"nt.time",
"nt",
"nt.time",
"System.out.println(nt.name + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"nt.name + \" \" + time",
"nt.name + \" \" + time",
"nt.name",
"nt",
"nt.name",
"\" \"",
"time",
"Queue<NameTime> q",
"q",
"int t",
"t",
"public static void main(String[] args) {\n\t\t\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<NameTime> q = new LinkedList<>();\n\t\tint n = scan.nextInt();\n\t\tint t = scan.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}\n\t\tqueue1(q, t);\n\t\t\n\t}",
"main",
"{\n\t\t\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<NameTime> q = new LinkedList<>();\n\t\tint n = scan.nextInt();\n\t\tint t = scan.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}\n\t\tqueue1(q, t);\n\t\t\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"Queue<NameTime> q = new LinkedList<>();",
"q",
"new LinkedList<>()",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int t = scan.nextInt();",
"t",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"++i",
"++i",
"i",
"{\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}",
"{\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}",
"NameTime nt = new NameTime();",
"nt",
"new NameTime()",
"nt.name = scan.next()",
"nt.name",
"nt",
"nt.name",
"scan.next()",
"scan.next",
"scan",
"nt.time = scan.nextInt()",
"nt.time",
"nt",
"nt.time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"q.add(nt)",
"q.add",
"q",
"nt",
"queue1(q, t)",
"queue1",
"q",
"t",
"String[] args",
"args",
"static class NameTime {\n\t\tString name;\n\t\tint time;\n\t\t\n\t}",
"NameTime",
"String name;",
"name",
"int time;",
"time",
"public class Main {\n\tstatic class NameTime {\n\t\tString name;\n\t\tint time;\n\t\t\n\t}\n\t\n\tpublic static void queue1(Queue<NameTime> q, int t) {\n\t\tint time = 0;\n\t\twhile (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<NameTime> q = new LinkedList<>();\n\t\tint n = scan.nextInt();\n\t\tint t = scan.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}\n\t\tqueue1(q, t);\n\t\t\n\t}\n}",
"public class Main {\n\tstatic class NameTime {\n\t\tString name;\n\t\tint time;\n\t\t\n\t}\n\t\n\tpublic static void queue1(Queue<NameTime> q, int t) {\n\t\tint time = 0;\n\t\twhile (!q.isEmpty()) {\n\t\t\tNameTime nt = q.remove();\n\t\t\tif (nt.time > t) {\n\t\t\t\ttime += t;\n\t\t\t\tnt.time -= t;\n\t\t\t\tq.add(nt);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += nt.time;\n\t\t\t\tSystem.out.println(nt.name + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner scan = new Scanner(System.in);\n\t\tQueue<NameTime> q = new LinkedList<>();\n\t\tint n = scan.nextInt();\n\t\tint t = scan.nextInt();\n\t\t\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tNameTime nt = new NameTime();\n\t\t\tnt.name = scan.next();\n\t\t\tnt.time = scan.nextInt();\n\t\t\tq.add(nt);\n\t\t}\n\t\tqueue1(q, t);\n\t\t\n\t}\n}",
"Main"
] |
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
static class NameTime {
String name;
int time;
}
public static void queue1(Queue<NameTime> q, int t) {
int time = 0;
while (!q.isEmpty()) {
NameTime nt = q.remove();
if (nt.time > t) {
time += t;
nt.time -= t;
q.add(nt);
}
else {
time += nt.time;
System.out.println(nt.name + " " + time);
}
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Queue<NameTime> q = new LinkedList<>();
int n = scan.nextInt();
int t = scan.nextInt();
for (int i = 0; i < n; ++i) {
NameTime nt = new NameTime();
nt.name = scan.next();
nt.time = scan.nextInt();
q.add(nt);
}
queue1(q, t);
}
}
|
[
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,
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,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
4,
18,
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
],
[
126,
11
],
[
126,
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
],
[
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
],
[
14,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
70,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
82,
86
],
[
75,
87
],
[
87,
88
],
[
88,
89
],
[
75,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
94,
95
],
[
75,
96
],
[
96,
97
],
[
97,
98
],
[
69,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
99,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
111,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
111,
115
],
[
111,
116
],
[
99,
117
],
[
117,
118
],
[
118,
119
],
[
99,
120
],
[
120,
121
],
[
121,
122
],
[
12,
123
],
[
123,
124
],
[
0,
125
],
[
125,
126
],
[
125,
127
]
] | [
"import java.util.Queue;\nimport java.util.ArrayDeque;\nimport java.util.Scanner;\n\npublic class Main {\n\t\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\tQueue<String> name = new ArrayDeque<String>();\n\t\tint N = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint tlen = 0;\n\t\tfor (int i=0; i<N; i++) {\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}\n\t}\t\n}",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\t\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\tQueue<String> name = new ArrayDeque<String>();\n\t\tint N = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint tlen = 0;\n\t\tfor (int i=0; i<N; i++) {\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}\n\t}\t\n}",
"Main",
"public static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\tQueue<String> name = new ArrayDeque<String>();\n\t\tint N = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint tlen = 0;\n\t\tfor (int i=0; i<N; i++) {\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\tQueue<String> name = new ArrayDeque<String>();\n\t\tint N = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint tlen = 0;\n\t\tfor (int i=0; i<N; i++) {\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<Integer> queue = new ArrayDeque<Integer>();",
"queue",
"new ArrayDeque<Integer>()",
"Queue<String> name = new ArrayDeque<String>();",
"name",
"new ArrayDeque<String>()",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int tlen = 0;",
"tlen",
"0",
"for (int i=0; i<N; i++) {\n\t\t\tname.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\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}",
"name.add(sc.next())",
"name.add",
"name",
"sc.next()",
"sc.next",
"sc",
"queue.add(sc.nextInt())",
"queue.add",
"queue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}",
"queue.size()!=0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}",
"if (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}",
"queue.element() > q",
"queue.element()",
"queue.element",
"queue",
"q",
"{\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t}",
"tlen += q",
"tlen",
"q",
"queue.add(queue.element() - q)",
"queue.add",
"queue",
"queue.element() - q",
"queue.element()",
"queue.element",
"queue",
"q",
"queue.remove()",
"queue.remove",
"queue",
"name.add(name.element())",
"name.add",
"name",
"name.element()",
"name.element",
"name",
"name.remove()",
"name.remove",
"name",
"{\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}",
"tlen += queue.element()",
"tlen",
"queue.element()",
"queue.element",
"queue",
"System.out.println(name.element()+\" \"+tlen)",
"System.out.println",
"System.out",
"System",
"System.out",
"name.element()+\" \"+tlen",
"name.element()+\" \"+tlen",
"name.element()",
"name.element",
"name",
"\" \"",
"tlen",
"queue.remove()",
"queue.remove",
"queue",
"name.remove()",
"name.remove",
"name",
"String arg[]",
"arg",
"public class Main {\n\t\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\tQueue<String> name = new ArrayDeque<String>();\n\t\tint N = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint tlen = 0;\n\t\tfor (int i=0; i<N; i++) {\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}\n\t}\t\n}",
"public class Main {\n\t\n\tpublic static void main(String arg[]){\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue<Integer> queue = new ArrayDeque<Integer>();\n\t\tQueue<String> name = new ArrayDeque<String>();\n\t\tint N = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tint tlen = 0;\n\t\tfor (int i=0; i<N; i++) {\n\t\t\tname.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (queue.size()!=0) {\n\t\t\t\n\t\t\tif (queue.element() > q){\n\t\t\t\ttlen += q;\n\t\t\t\tqueue.add(queue.element() - q);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.add(name.element());\n\t\t\t\tname.remove();\n\t\t\t} else {\n\t\t\t\ttlen += queue.element();\n\t\t\t\tSystem.out.println(name.element()+\" \"+tlen);\n\t\t\t\tqueue.remove();\n\t\t\t\tname.remove();\n\t\t\t}\n\t\t}\n\t}\t\n}",
"Main"
] | import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main {
public static void main(String arg[]){
Scanner sc = new Scanner(System.in);
Queue<Integer> queue = new ArrayDeque<Integer>();
Queue<String> name = new ArrayDeque<String>();
int N = sc.nextInt();
int q = sc.nextInt();
int tlen = 0;
for (int i=0; i<N; i++) {
name.add(sc.next());
queue.add(sc.nextInt());
}
while (queue.size()!=0) {
if (queue.element() > q){
tlen += q;
queue.add(queue.element() - q);
queue.remove();
name.add(name.element());
name.remove();
} else {
tlen += queue.element();
System.out.println(name.element()+" "+tlen);
queue.remove();
name.remove();
}
}
}
}
|
[
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,
17,
41,
13,
20,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
41,
13,
17,
41,
13,
13,
42,
2,
13,
13,
30,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
40,
13,
30,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
0,
13,
13,
40,
13,
40,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
130,
5
],
[
130,
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,
29
],
[
29,
30
],
[
29,
31
],
[
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
],
[
48,
49
],
[
49,
50
],
[
45,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
45,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
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
],
[
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
],
[
83,
101
],
[
101,
102
],
[
77,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
108,
109
],
[
108,
110
],
[
103,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
103,
120
],
[
120,
121
],
[
120,
122
],
[
103,
123
],
[
123,
124
],
[
103,
125
],
[
125,
126
],
[
6,
127
],
[
127,
128
],
[
0,
129
],
[
129,
130
],
[
129,
131
]
] | [
"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 count = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tint totalTime = 0;\n\t\tString[] queue = new String[200000];\n\t\tint[] restTime = new int[200000];\n\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}\n\n\t\tint qhead = 0;\n\t\tint qtail = count;\n\n\t\twhile(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}\n\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 count = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tint totalTime = 0;\n\t\tString[] queue = new String[200000];\n\t\tint[] restTime = new int[200000];\n\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}\n\n\t\tint qhead = 0;\n\t\tint qtail = count;\n\n\t\twhile(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}\n\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 count = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tint totalTime = 0;\n\t\tString[] queue = new String[200000];\n\t\tint[] restTime = new int[200000];\n\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}\n\n\t\tint qhead = 0;\n\t\tint qtail = count;\n\n\t\twhile(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint count = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tint totalTime = 0;\n\t\tString[] queue = new String[200000];\n\t\tint[] restTime = new int[200000];\n\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}\n\n\t\tint qhead = 0;\n\t\tint qtail = count;\n\n\t\twhile(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int count = sc.nextInt();",
"count",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int totalTime = 0;",
"totalTime",
"0",
"String[] queue = new String[200000];",
"queue",
"new String[200000]",
"200000",
"int[] restTime = new int[200000];",
"restTime",
"new int[200000]",
"200000",
"for(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < count",
"i",
"count",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = 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[i] = name",
"queue[i]",
"queue",
"i",
"name",
"restTime[i] = time",
"restTime[i]",
"restTime",
"i",
"time",
"int qhead = 0;",
"qhead",
"0",
"int qtail = count;",
"qtail",
"count",
"while(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}",
"qhead != qtail",
"qhead",
"qtail",
"{\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}",
"if(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}",
"restTime[qhead] <= q",
"restTime[qhead]",
"restTime",
"qhead",
"q",
"{\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t}",
"totalTime += restTime[qhead]",
"totalTime",
"restTime[qhead]",
"restTime",
"qhead",
"System.out.println(queue[qhead] + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"queue[qhead] + \" \" + totalTime",
"queue[qhead] + \" \" + totalTime",
"queue[qhead]",
"queue",
"qhead",
"\" \"",
"totalTime",
"qhead++",
"qhead",
"{\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}",
"queue[qtail] = queue[qhead]",
"queue[qtail]",
"queue",
"qtail",
"queue[qhead]",
"queue",
"qhead",
"restTime[qtail] = restTime[qhead] - q",
"restTime[qtail]",
"restTime",
"qtail",
"restTime[qhead] - q",
"restTime[qhead]",
"restTime",
"qhead",
"q",
"totalTime += q",
"totalTime",
"q",
"qhead++",
"qhead",
"qtail++",
"qtail",
"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 count = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tint totalTime = 0;\n\t\tString[] queue = new String[200000];\n\t\tint[] restTime = new int[200000];\n\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}\n\n\t\tint qhead = 0;\n\t\tint qtail = count;\n\n\t\twhile(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}\n\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 count = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tint totalTime = 0;\n\t\tString[] queue = new String[200000];\n\t\tint[] restTime = new int[200000];\n\n\t\tfor(int i = 0; i < count; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\n\t\t\tqueue[i] = name;\n\t\t\trestTime[i] = time;\n\t\t}\n\n\t\tint qhead = 0;\n\t\tint qtail = count;\n\n\t\twhile(qhead != qtail) {\n\t\t\tif(restTime[qhead] <= q) {\n\t\t\t\ttotalTime += restTime[qhead];\n\t\t\t\tSystem.out.println(queue[qhead] + \" \" + totalTime);\n\t\t\t\tqhead++;\n\t\t\t} else {\n\t\t\t\tqueue[qtail] = queue[qhead];\n\t\t\t\trestTime[qtail] = restTime[qhead] - q;\n\t\t\t\ttotalTime += q;\n\t\t\t\tqhead++;\n\t\t\t\tqtail++;\n\t\t\t}\n\t\t}\n\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 count = sc.nextInt();
int q = sc.nextInt();
int totalTime = 0;
String[] queue = new String[200000];
int[] restTime = new int[200000];
for(int i = 0; i < count; i++) {
String name = sc.next();
int time = sc.nextInt();
queue[i] = name;
restTime[i] = time;
}
int qhead = 0;
int qtail = count;
while(qhead != qtail) {
if(restTime[qhead] <= q) {
totalTime += restTime[qhead];
System.out.println(queue[qhead] + " " + totalTime);
qhead++;
} else {
queue[qtail] = queue[qhead];
restTime[qtail] = restTime[qhead] - q;
totalTime += q;
qhead++;
qtail++;
}
}
}
}
|
[
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,
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,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
4,
18,
13,
17,
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
],
[
158,
11
],
[
158,
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
],
[
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
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
51,
52
],
[
46,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
57,
58
],
[
14,
59
],
[
59,
60
],
[
60,
61
],
[
14,
62
],
[
62,
63
],
[
62,
64
],
[
14,
65
],
[
65,
66
],
[
65,
67
],
[
14,
68
],
[
68,
69
],
[
68,
70
],
[
14,
71
],
[
71,
72
],
[
71,
73
],
[
14,
74
],
[
74,
75
],
[
74,
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
],
[
101,
104
],
[
97,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
97,
109
],
[
109,
110
],
[
109,
111
],
[
93,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
112,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
14,
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
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
142,
146
],
[
136,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
152,
153
],
[
153,
154
],
[
12,
155
],
[
155,
156
],
[
0,
157
],
[
157,
158
],
[
157,
159
]
] | [
"\nimport java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tQueue <String> N = new LinkedList<>();\n\t\tQueue <Integer> Q = new LinkedList<>();\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n\t\tint task = sc.nextInt();\t\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tQueue <String> N_ans = new LinkedList<>();\n\t\tQueue <Integer> Q_ans = new LinkedList<>();\n\t\t\n\t\t\n\t\tint time = 0;\n\t\tint R = 0;\n\t\tString S = \"\";\n\t\twhile (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}\n\t}\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\n\tpublic static void main(String[] args) {\n\t\tQueue <String> N = new LinkedList<>();\n\t\tQueue <Integer> Q = new LinkedList<>();\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n\t\tint task = sc.nextInt();\t\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tQueue <String> N_ans = new LinkedList<>();\n\t\tQueue <Integer> Q_ans = new LinkedList<>();\n\t\t\n\t\t\n\t\tint time = 0;\n\t\tint R = 0;\n\t\tString S = \"\";\n\t\twhile (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tQueue <String> N = new LinkedList<>();\n\t\tQueue <Integer> Q = new LinkedList<>();\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n\t\tint task = sc.nextInt();\t\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tQueue <String> N_ans = new LinkedList<>();\n\t\tQueue <Integer> Q_ans = new LinkedList<>();\n\t\t\n\t\t\n\t\tint time = 0;\n\t\tint R = 0;\n\t\tString S = \"\";\n\t\twhile (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}\n\t}",
"main",
"{\n\t\tQueue <String> N = new LinkedList<>();\n\t\tQueue <Integer> Q = new LinkedList<>();\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n\t\tint task = sc.nextInt();\t\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tQueue <String> N_ans = new LinkedList<>();\n\t\tQueue <Integer> Q_ans = new LinkedList<>();\n\t\t\n\t\t\n\t\tint time = 0;\n\t\tint R = 0;\n\t\tString S = \"\";\n\t\twhile (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}\n\t}",
"Queue <String> N = new LinkedList<>();",
"N",
"new LinkedList<>()",
"Queue <Integer> Q = new LinkedList<>();",
"Q",
"new LinkedList<>()",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int task = sc.nextInt();",
"task",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}",
"N.add(sc.next())",
"N.add",
"N",
"sc.next()",
"sc.next",
"sc",
"Q.add(sc.nextInt())",
"Q.add",
"Q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.close()",
"sc.close",
"sc",
"Queue <String> N_ans = new LinkedList<>();",
"N_ans",
"new LinkedList<>()",
"Queue <Integer> Q_ans = new LinkedList<>();",
"Q_ans",
"new LinkedList<>()",
"int time = 0;",
"time",
"0",
"int R = 0;",
"R",
"0",
"String S = \"\";",
"S",
"\"\"",
"while (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}",
"!Q.isEmpty()",
"Q.isEmpty()",
"Q.isEmpty",
"Q",
"{\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}",
"R = Q.poll()",
"R",
"Q.poll()",
"Q.poll",
"Q",
"S = N.poll()",
"S",
"N.poll()",
"N.poll",
"N",
"if (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}",
"R>task",
"R",
"task",
"{\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}",
"R-=task",
"R",
"task",
"Q.add(R)",
"Q.add",
"Q",
"R",
"N.add(S)",
"N.add",
"N",
"S",
"time+=task",
"time",
"task",
"{\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}",
"time+=R",
"time",
"R",
"Q_ans.add(time)",
"Q_ans.add",
"Q_ans",
"time",
"N_ans.add(S)",
"N_ans.add",
"N_ans",
"S",
"for(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}",
"{\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}",
"System.out.print(N_ans.poll() + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"N_ans.poll() + \" \"",
"N_ans.poll()",
"N_ans.poll",
"N_ans",
"\" \"",
"System.out.println(Q_ans.poll())",
"System.out.println",
"System.out",
"System",
"System.out",
"Q_ans.poll()",
"Q_ans.poll",
"Q_ans",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tQueue <String> N = new LinkedList<>();\n\t\tQueue <Integer> Q = new LinkedList<>();\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n\t\tint task = sc.nextInt();\t\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tQueue <String> N_ans = new LinkedList<>();\n\t\tQueue <Integer> Q_ans = new LinkedList<>();\n\t\t\n\t\t\n\t\tint time = 0;\n\t\tint R = 0;\n\t\tString S = \"\";\n\t\twhile (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tQueue <String> N = new LinkedList<>();\n\t\tQueue <Integer> Q = new LinkedList<>();\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n\t\tint task = sc.nextInt();\t\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tN.add(sc.next());\n\t\t\tQ.add(sc.nextInt());\n\t\t}\n\t\tsc.close();\n\t\t\n\t\tQueue <String> N_ans = new LinkedList<>();\n\t\tQueue <Integer> Q_ans = new LinkedList<>();\n\t\t\n\t\t\n\t\tint time = 0;\n\t\tint R = 0;\n\t\tString S = \"\";\n\t\twhile (!Q.isEmpty()) {\n\t\t\tR = Q.poll();\n\t\t\tS = N.poll();\n\t\t\tif (R>task){\n\t\t\t\tR-=task;\n\t\t\t\tQ.add(R);\n\t\t\t\tN.add(S);\n\t\t\t\ttime+=task;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime+=R;\n\t\t\t\tQ_ans.add(time);\n\t\t\t\tN_ans.add(S);\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tSystem.out.print(N_ans.poll() + \" \");\n\t\t\tSystem.out.println(Q_ans.poll());\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) {
Queue <String> N = new LinkedList<>();
Queue <Integer> Q = new LinkedList<>();
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int task = sc.nextInt();
for(int i = 0; i < n; i++) {
N.add(sc.next());
Q.add(sc.nextInt());
}
sc.close();
Queue <String> N_ans = new LinkedList<>();
Queue <Integer> Q_ans = new LinkedList<>();
int time = 0;
int R = 0;
String S = "";
while (!Q.isEmpty()) {
R = Q.poll();
S = N.poll();
if (R>task){
R-=task;
Q.add(R);
N.add(S);
time+=task;
}
else {
time+=R;
Q_ans.add(time);
N_ans.add(S);
}
}
for(int i = 0; i < n; i++) {
System.out.print(N_ans.poll() + " ");
System.out.println(Q_ans.poll());
}
}
}
|
[
7,
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,
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,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
4,
18,
13,
0,
13,
13,
0,
13,
4,
18,
13,
13,
14,
4,
18,
13,
30,
4,
18,
13,
20,
30,
4,
18,
13,
13,
41,
13,
20,
28,
13,
13,
30,
30,
4,
18,
13,
2,
2,
4,
18,
13,
17,
4,
18,
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,
29,
20,
23,
13,
12,
13,
30,
29,
2,
13,
17,
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
],
[
184,
14
],
[
184,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
17,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
17,
31
],
[
31,
32
],
[
31,
33
],
[
17,
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
],
[
46,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
17,
61
],
[
61,
62
],
[
61,
63
],
[
17,
64
],
[
64,
65
],
[
64,
66
],
[
17,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
68,
72
],
[
67,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
73,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
73,
88
],
[
88,
89
],
[
88,
90
],
[
73,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
73,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
97,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
17,
111
],
[
111,
112
],
[
111,
113
],
[
17,
114
],
[
114,
115
],
[
114,
116
],
[
114,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
123,
127
],
[
123,
128
],
[
128,
129
],
[
129,
130
],
[
17,
131
],
[
131,
132
],
[
132,
133
],
[
15,
134
],
[
134,
135
],
[
184,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
136,
140
],
[
140,
141
],
[
136,
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
],
[
136,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
162,
163
],
[
136,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
136,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
169,
174
],
[
174,
175
],
[
136,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
0,
183
],
[
183,
184
],
[
183,
185
]
] | [
"import java.io.PrintWriter;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\n\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\n Deque<Process> procs = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }\n\n Deque<Process> finishedProcs = new ArrayDeque<>();\n\n int totalQ = 0;\n\n while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }\n\n PrintWriter pw = new PrintWriter(System.out);\n for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }\n\n pw.flush();\n }\n\n private static class Process {\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 String getName() {\n return name;\n }\n\n public int getTime() {\n return time;\n }\n\n public Process progress(int ms) {\n return new Process(name, time - ms);\n }\n\n public boolean finished() {\n return time <= 0;\n }\n }\n}",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\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\n Deque<Process> procs = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }\n\n Deque<Process> finishedProcs = new ArrayDeque<>();\n\n int totalQ = 0;\n\n while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }\n\n PrintWriter pw = new PrintWriter(System.out);\n for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }\n\n pw.flush();\n }\n\n private static class Process {\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 String getName() {\n return name;\n }\n\n public int getTime() {\n return time;\n }\n\n public Process progress(int ms) {\n return new Process(name, time - ms);\n }\n\n public boolean finished() {\n return time <= 0;\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\n Deque<Process> procs = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }\n\n Deque<Process> finishedProcs = new ArrayDeque<>();\n\n int totalQ = 0;\n\n while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }\n\n PrintWriter pw = new PrintWriter(System.out);\n for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }\n\n pw.flush();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Deque<Process> procs = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }\n\n Deque<Process> finishedProcs = new ArrayDeque<>();\n\n int totalQ = 0;\n\n while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }\n\n PrintWriter pw = new PrintWriter(System.out);\n for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }\n\n pw.flush();\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",
"Deque<Process> procs = new ArrayDeque<>();",
"procs",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }",
"{\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"procs.push(new Process(name, time))",
"procs.push",
"procs",
"new Process(name, time)",
"Deque<Process> finishedProcs = new ArrayDeque<>();",
"finishedProcs",
"new ArrayDeque<>()",
"int totalQ = 0;",
"totalQ",
"0",
"while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }",
"procs.size() > 0",
"procs.size()",
"procs.size",
"procs",
"0",
"{\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }",
"Process p = procs.removeLast();",
"p",
"procs.removeLast()",
"procs.removeLast",
"procs",
"int quantum = Math.min(q, p.getTime());",
"quantum",
"Math.min(q, p.getTime())",
"Math.min",
"Math",
"q",
"p.getTime()",
"p.getTime",
"p",
"totalQ += quantum",
"totalQ",
"quantum",
"p = p.progress(quantum)",
"p",
"p.progress(quantum)",
"p.progress",
"p",
"quantum",
"if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }",
"p.finished()",
"p.finished",
"p",
"{\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n }",
"finishedProcs.addLast(new Process(p.getName(), totalQ))",
"finishedProcs.addLast",
"finishedProcs",
"new Process(p.getName(), totalQ)",
"{\n procs.addFirst(p);\n }",
"procs.addFirst(p)",
"procs.addFirst",
"procs",
"p",
"PrintWriter pw = new PrintWriter(System.out);",
"pw",
"new PrintWriter(System.out)",
"for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }",
"Process p",
"finishedProcs",
"{\n pw.println(p.getName() + \" \" + p.getTime());\n }",
"{\n pw.println(p.getName() + \" \" + p.getTime());\n }",
"pw.println(p.getName() + \" \" + p.getTime())",
"pw.println",
"pw",
"p.getName() + \" \" + p.getTime()",
"p.getName() + \" \" + p.getTime()",
"p.getName()",
"p.getName",
"p",
"\" \"",
"p.getTime()",
"p.getTime",
"p",
"pw.flush()",
"pw.flush",
"pw",
"String[] args",
"args",
"private static class Process {\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 String getName() {\n return name;\n }\n\n public int getTime() {\n return time;\n }\n\n public Process progress(int ms) {\n return new Process(name, time - ms);\n }\n\n public boolean finished() {\n return time <= 0;\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 String getName() {\n return name;\n }",
"getName",
"{\n return name;\n }",
"return name;",
"name",
"public int getTime() {\n return time;\n }",
"getTime",
"{\n return time;\n }",
"return time;",
"time",
"public Process progress(int ms) {\n return new Process(name, time - ms);\n }",
"progress",
"{\n return new Process(name, time - ms);\n }",
"return new Process(name, time - ms);",
"new Process(name, time - ms)",
"int ms",
"ms",
"public boolean finished() {\n return time <= 0;\n }",
"finished",
"{\n return time <= 0;\n }",
"return time <= 0;",
"time <= 0",
"time",
"0",
"public class Main {\n\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\n Deque<Process> procs = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }\n\n Deque<Process> finishedProcs = new ArrayDeque<>();\n\n int totalQ = 0;\n\n while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }\n\n PrintWriter pw = new PrintWriter(System.out);\n for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }\n\n pw.flush();\n }\n\n private static class Process {\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 String getName() {\n return name;\n }\n\n public int getTime() {\n return time;\n }\n\n public Process progress(int ms) {\n return new Process(name, time - ms);\n }\n\n public boolean finished() {\n return time <= 0;\n }\n }\n}",
"public class Main {\n\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\n Deque<Process> procs = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n procs.push(new Process(name, time));\n }\n\n Deque<Process> finishedProcs = new ArrayDeque<>();\n\n int totalQ = 0;\n\n while (procs.size() > 0) {\n Process p = procs.removeLast();\n int quantum = Math.min(q, p.getTime());\n totalQ += quantum;\n p = p.progress(quantum);\n if (p.finished()) {\n finishedProcs.addLast(new Process(p.getName(), totalQ));\n } else {\n procs.addFirst(p);\n }\n }\n\n PrintWriter pw = new PrintWriter(System.out);\n for (Process p : finishedProcs) {\n pw.println(p.getName() + \" \" + p.getTime());\n }\n\n pw.flush();\n }\n\n private static class Process {\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 String getName() {\n return name;\n }\n\n public int getTime() {\n return time;\n }\n\n public Process progress(int ms) {\n return new Process(name, time - ms);\n }\n\n public boolean finished() {\n return time <= 0;\n }\n }\n}",
"Main"
] | import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
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();
Deque<Process> procs = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
String name = sc.next();
int time = sc.nextInt();
procs.push(new Process(name, time));
}
Deque<Process> finishedProcs = new ArrayDeque<>();
int totalQ = 0;
while (procs.size() > 0) {
Process p = procs.removeLast();
int quantum = Math.min(q, p.getTime());
totalQ += quantum;
p = p.progress(quantum);
if (p.finished()) {
finishedProcs.addLast(new Process(p.getName(), totalQ));
} else {
procs.addFirst(p);
}
}
PrintWriter pw = new PrintWriter(System.out);
for (Process p : finishedProcs) {
pw.println(p.getName() + " " + p.getTime());
}
pw.flush();
}
private static class Process {
private String name;
private int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public String getName() {
return name;
}
public int getTime() {
return time;
}
public Process progress(int ms) {
return new Process(name, time - ms);
}
public boolean finished() {
return time <= 0;
}
}
}
|
[
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,
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
],
[
154,
11
],
[
154,
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
],
[
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
],
[
77,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
82,
88
],
[
88,
89
],
[
88,
90
],
[
82,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
92,
102
],
[
91,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
103,
108
],
[
82,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
82,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
120,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
120,
125
],
[
12,
126
],
[
126,
127
],
[
154,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
128,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
138,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
136,
149
],
[
149,
150
],
[
136,
151
],
[
151,
152
],
[
0,
153
],
[
153,
154
],
[
153,
155
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main{\n\n public static void main(String args[]) {\n Scanner scan = new Scanner(System.in);\n String[] row = scan.nextLine().split(\" \");\n\n int n = Integer.parseInt(row[0]);\n int q = Integer.parseInt(row[1]);\n\n Queue<Process> que = new LinkedList<Process>();\n for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }\n\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n private final static class Process {\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}\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 public static void main(String args[]) {\n Scanner scan = new Scanner(System.in);\n String[] row = scan.nextLine().split(\" \");\n\n int n = Integer.parseInt(row[0]);\n int q = Integer.parseInt(row[1]);\n\n Queue<Process> que = new LinkedList<Process>();\n for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }\n\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n private final static class Process {\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[]) {\n Scanner scan = new Scanner(System.in);\n String[] row = scan.nextLine().split(\" \");\n\n int n = Integer.parseInt(row[0]);\n int q = Integer.parseInt(row[1]);\n\n Queue<Process> que = new LinkedList<Process>();\n for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }\n\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }",
"main",
"{\n Scanner scan = new Scanner(System.in);\n String[] row = scan.nextLine().split(\" \");\n\n int n = Integer.parseInt(row[0]);\n int q = Integer.parseInt(row[1]);\n\n Queue<Process> que = new LinkedList<Process>();\n for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }\n\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"String[] row = scan.nextLine().split(\" \");",
"row",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"int n = Integer.parseInt(row[0]);",
"n",
"Integer.parseInt(row[0])",
"Integer.parseInt",
"Integer",
"row[0]",
"row",
"0",
"int q = Integer.parseInt(row[1]);",
"q",
"Integer.parseInt(row[1])",
"Integer.parseInt",
"Integer",
"row[1]",
"row",
"1",
"Queue<Process> que = new LinkedList<Process>();",
"que",
"new LinkedList<Process>()",
"for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }",
"{\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }",
"String[] strArray = scan.nextLine().split(\" \");",
"strArray",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));",
"process",
"new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]))",
"que.offer(process)",
"que.offer",
"que",
"process",
"int resultTime = 0;",
"resultTime",
"0",
"while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }",
"que.size() > 0",
"que.size()",
"que.size",
"que",
"0",
"{\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }",
"Process process = que.poll();",
"process",
"que.poll()",
"que.poll",
"que",
"resultTime += q",
"resultTime",
"q",
"if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }",
"(process.processTime = process.processTime - q) > 0",
"(process.processTime = process.processTime - q)",
"process.processTime",
"process",
"process.processTime",
"process.processTime - q",
"process.processTime",
"process",
"process.processTime",
"q",
"0",
"{\n\n que.offer(process);\n continue;\n }",
"que.offer(process)",
"que.offer",
"que",
"process",
"continue;",
"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 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 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[]) {\n Scanner scan = new Scanner(System.in);\n String[] row = scan.nextLine().split(\" \");\n\n int n = Integer.parseInt(row[0]);\n int q = Integer.parseInt(row[1]);\n\n Queue<Process> que = new LinkedList<Process>();\n for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }\n\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n private final static class Process {\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[]) {\n Scanner scan = new Scanner(System.in);\n String[] row = scan.nextLine().split(\" \");\n\n int n = Integer.parseInt(row[0]);\n int q = Integer.parseInt(row[1]);\n\n Queue<Process> que = new LinkedList<Process>();\n for (int i=0; i<n; i++) {\n String[] strArray = scan.nextLine().split(\" \");\n\n Process process = new Process(strArray[0],\n\t\t\t\t\t Integer.parseInt(strArray[1]));\n que.offer(process);\n }\n\n int resultTime = 0;\n while (que.size() > 0) {\n Process process = que.poll();\n resultTime += q;\n if ((process.processTime = process.processTime - q) > 0) {\n\n que.offer(process);\n continue;\n }\n resultTime += process.processTime;\n\n System.out.println(process.name + \" \" + resultTime);\n }\n\n }\n\n private final static class Process {\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.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main{
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
String[] row = scan.nextLine().split(" ");
int n = Integer.parseInt(row[0]);
int q = Integer.parseInt(row[1]);
Queue<Process> que = new LinkedList<Process>();
for (int i=0; i<n; i++) {
String[] strArray = scan.nextLine().split(" ");
Process process = new Process(strArray[0],
Integer.parseInt(strArray[1]));
que.offer(process);
}
int resultTime = 0;
while (que.size() > 0) {
Process process = que.poll();
resultTime += q;
if ((process.processTime = process.processTime - q) > 0) {
que.offer(process);
continue;
}
resultTime += process.processTime;
System.out.println(process.name + " " + resultTime);
}
}
private final static class Process {
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,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
17,
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,
41,
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,
20,
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,
4,
18,
4,
18,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
13,
17,
30,
0,
13,
13,
4,
18,
13,
2,
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,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
20,
13,
0,
13,
17,
0,
13,
17,
23,
13,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
12,
13,
30,
0,
13,
2,
2,
13,
17,
13,
29,
18,
13,
2,
2,
2,
13,
17,
13,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
276,
11
],
[
276,
12
],
[
12,
13
],
[
12,
14
],
[
276,
15
],
[
15,
16
],
[
15,
17
],
[
276,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
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
],
[
65,
67
],
[
40,
68
],
[
68,
69
],
[
68,
70
],
[
40,
71
],
[
71,
72
],
[
71,
73
],
[
40,
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
],
[
40,
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
],
[
113,
114
],
[
111,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
131,
132
],
[
132,
133
],
[
126,
134
],
[
124,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
122,
139
],
[
110,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
147,
151
],
[
140,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
40,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
162,
163
],
[
18,
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
],
[
175,
177
],
[
174,
178
],
[
178,
179
],
[
178,
180
],
[
172,
181
],
[
181,
182
],
[
172,
183
],
[
183,
184
],
[
166,
185
],
[
185,
186
],
[
185,
187
],
[
187,
188
],
[
188,
189
],
[
166,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
166,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
198,
200
],
[
195,
201
],
[
201,
202
],
[
0,
203
],
[
203,
204
],
[
203,
205
],
[
205,
206
],
[
203,
207
],
[
207,
208
],
[
203,
209
],
[
209,
210
],
[
203,
211
],
[
211,
212
],
[
203,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
215,
219
],
[
219,
220
],
[
219,
221
],
[
215,
223
],
[
223,
224
],
[
223,
225
],
[
215,
226
],
[
226,
227
],
[
226,
228
],
[
213,
229
],
[
229,
230
],
[
203,
231
],
[
231,
232
],
[
231,
233
],
[
233,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
203,
238
],
[
238,
239
],
[
238,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
241,
245
],
[
240,
246
],
[
246,
247
],
[
246,
248
],
[
248,
249
],
[
249,
250
],
[
249,
251
],
[
248,
252
],
[
238,
253
],
[
253,
254
],
[
203,
255
],
[
255,
256
],
[
255,
257
],
[
257,
258
],
[
258,
259
],
[
258,
260
],
[
260,
261
],
[
261,
262
],
[
261,
263
],
[
260,
264
],
[
257,
265
],
[
265,
266
],
[
266,
267
],
[
266,
268
],
[
268,
269
],
[
269,
270
],
[
270,
271
],
[
270,
272
],
[
269,
273
],
[
268,
274
],
[
0,
275
],
[
275,
276
],
[
275,
277
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int size = 100005;\n\t\t\n\t\ttry {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}\n\nclass Process{\n\tprivate String name;\n\tprivate int t;\n\t\n\tProcess(String arg_name, int arg_time){\n\t\tname = arg_name;\n\t\tt = arg_time;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\tpublic int getTime() {\n\t\treturn t;\n\t}\n\t\n\tpublic void setTime(int arg_time) {\n\t\tt = arg_time;\n\t}\n}\n\nclass Queue{\n\tprivate Process[] table;\n\tprivate int head, tail, size;\n\t\n\tQueue(int arg_size) {\n\t\tsize = arg_size;\n\t\ttable = new Process[size];\n\t\thead = 0;\n\t\ttail = 0;\n\t}\n\t\n\tboolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\t\n\tvoid push(Process process) {\n\t\ttable[tail] = process;\n\t\ttail = (tail+1)%size;\n\t}\n\t\n\tpublic Process pop() {\n\t\thead = (head+1)%size;\n\t\treturn table[(head-1+size)%size];\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\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int size = 100005;\n\t\t\n\t\ttry {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main",
"public static final int BIG_NUM = 2000000000;",
"BIG_NUM",
"2000000000",
"public static final int MOD = 1000000007;",
"MOD",
"1000000007",
"public static void main(String[] args) {\n\t\t// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int size = 100005;\n\t\t\n\t\ttry {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"main",
"{\n\t\t// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int size = 100005;\n\t\t\n\t\ttry {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"final int size = 100005;",
"size",
"100005",
"try {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}",
"catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}",
"NumberFormatException e",
"{\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}",
"IOException e",
"{\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t}",
"String[] input_str = br.readLine().split(\"\\\\s+\");",
"input_str",
"br.readLine().split(\"\\\\s+\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s+\"",
"int n = Integer.parseInt(input_str[0]);",
"n",
"Integer.parseInt(input_str[0])",
"Integer.parseInt",
"Integer",
"input_str[0]",
"input_str",
"0",
"int q = Integer.parseInt(input_str[1]);",
"q",
"Integer.parseInt(input_str[1])",
"Integer.parseInt",
"Integer",
"input_str[1]",
"input_str",
"1",
"int elapse = 0;",
"elapse",
"0",
"Queue queue = new Queue(size);",
"queue",
"new Queue(size)",
"StringBuilder ans = new StringBuilder();",
"ans",
"new StringBuilder()",
"for(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}",
"{\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}",
"input_str = br.readLine().split(\"\\\\s+\")",
"input_str",
"br.readLine().split(\"\\\\s+\")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\"\\\\s+\"",
"queue.push(new Process(input_str[0], Integer.parseInt(input_str[1])))",
"queue.push",
"queue",
"new Process(input_str[0], Integer.parseInt(input_str[1]))",
"while(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}",
"Process tmp = queue.pop();",
"tmp",
"queue.pop()",
"queue.pop",
"queue",
"if(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}",
"tmp.getTime() <= q",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"q",
"{\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t}",
"elapse += tmp.getTime()",
"elapse",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"ans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\")",
"ans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append",
"ans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse))",
"ans.append(tmp.getName()).append(\" \").append",
"ans.append(tmp.getName()).append(\" \")",
"ans.append(tmp.getName()).append",
"ans.append(tmp.getName())",
"ans.append",
"ans",
"tmp.getName()",
"tmp.getName",
"tmp",
"\" \"",
"Integer.toString(elapse)",
"Integer.toString",
"Integer",
"elapse",
"\"\\n\"",
"{\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}",
"elapse += q",
"elapse",
"q",
"tmp.setTime(tmp.getTime() - q)",
"tmp.setTime",
"tmp",
"tmp.getTime() - q",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"q",
"queue.push(tmp)",
"queue.push",
"queue",
"tmp",
"System.out.print(ans.toString())",
"System.out.print",
"System.out",
"System",
"System.out",
"ans.toString()",
"ans.toString",
"ans",
"String[] args",
"args",
"class Process{\n\tprivate String name;\n\tprivate int t;\n\t\n\tProcess(String arg_name, int arg_time){\n\t\tname = arg_name;\n\t\tt = arg_time;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\t\n\tpublic int getTime() {\n\t\treturn t;\n\t}\n\t\n\tpublic void setTime(int arg_time) {\n\t\tt = arg_time;\n\t}\n}",
"Process",
"private String name;",
"name",
"private int t;",
"t",
"Process(String arg_name, int arg_time){\n\t\tname = arg_name;\n\t\tt = arg_time;\n\t}",
"Process",
"{\n\t\tname = arg_name;\n\t\tt = arg_time;\n\t}",
"name = arg_name",
"name",
"arg_name",
"t = arg_time",
"t",
"arg_time",
"String arg_name",
"arg_name",
"int arg_time",
"arg_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 t;\n\t}",
"getTime",
"{\n\t\treturn t;\n\t}",
"return t;",
"t",
"public void setTime(int arg_time) {\n\t\tt = arg_time;\n\t}",
"setTime",
"{\n\t\tt = arg_time;\n\t}",
"t = arg_time",
"t",
"arg_time",
"int arg_time",
"arg_time",
"class Queue{\n\tprivate Process[] table;\n\tprivate int head, tail, size;\n\t\n\tQueue(int arg_size) {\n\t\tsize = arg_size;\n\t\ttable = new Process[size];\n\t\thead = 0;\n\t\ttail = 0;\n\t}\n\t\n\tboolean isEmpty() {\n\t\treturn head == tail;\n\t}\n\t\n\tvoid push(Process process) {\n\t\ttable[tail] = process;\n\t\ttail = (tail+1)%size;\n\t}\n\t\n\tpublic Process pop() {\n\t\thead = (head+1)%size;\n\t\treturn table[(head-1+size)%size];\n\t}\n}",
"Queue",
"private Process[] table;",
"table",
"private int head",
"head",
"tail",
"tail",
"size;",
"size",
"Queue(int arg_size) {\n\t\tsize = arg_size;\n\t\ttable = new Process[size];\n\t\thead = 0;\n\t\ttail = 0;\n\t}",
"Queue",
"{\n\t\tsize = arg_size;\n\t\ttable = new Process[size];\n\t\thead = 0;\n\t\ttail = 0;\n\t}",
"size = arg_size",
"size",
"arg_size",
"table = new Process[size]",
"table",
"new Process[size]",
"size",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"int arg_size",
"arg_size",
"boolean isEmpty() {\n\t\treturn head == tail;\n\t}",
"isEmpty",
"{\n\t\treturn head == tail;\n\t}",
"return head == tail;",
"head == tail",
"head",
"tail",
"void push(Process process) {\n\t\ttable[tail] = process;\n\t\ttail = (tail+1)%size;\n\t}",
"push",
"{\n\t\ttable[tail] = process;\n\t\ttail = (tail+1)%size;\n\t}",
"table[tail] = process",
"table[tail]",
"table",
"tail",
"process",
"tail = (tail+1)%size",
"tail",
"(tail+1)%size",
"(tail+1)",
"tail",
"1",
"size",
"Process process",
"process",
"public Process pop() {\n\t\thead = (head+1)%size;\n\t\treturn table[(head-1+size)%size];\n\t}",
"pop",
"{\n\t\thead = (head+1)%size;\n\t\treturn table[(head-1+size)%size];\n\t}",
"head = (head+1)%size",
"head",
"(head+1)%size",
"(head+1)",
"head",
"1",
"size",
"return table[(head-1+size)%size];",
"table[(head-1+size)%size]",
"table",
"(head-1+size)%size",
"(head-1+size)",
"head-1",
"head",
"1",
"size",
"size",
"public class Main {\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int size = 100005;\n\t\t\n\t\ttry {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static final int BIG_NUM = 2000000000;\n\tpublic static final int MOD = 1000000007;\n\n\tpublic static void main(String[] args) {\n\t\t// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tfinal int size = 100005;\n\t\t\n\t\ttry {\n\t\t\tString[] input_str = br.readLine().split(\"\\\\s+\");\n\t\t\tint n = Integer.parseInt(input_str[0]);\n\t\t\tint q = Integer.parseInt(input_str[1]);\n\t\t\tint elapse = 0;\n\t\t\tQueue queue = new Queue(size);\n\t\t\tStringBuilder ans = new StringBuilder();\n\t\t\t\n\t\t\tfor(int i=0; i<n; i++) {\n\t\t\t\tinput_str = br.readLine().split(\"\\\\s+\");\n\t\t\t\tqueue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));\n\t\t\t}\n\t\t\t\n\t\t\twhile(!queue.isEmpty()) {\n\t\t\t\tProcess tmp = queue.pop();\n\t\t\t\tif(tmp.getTime() <= q) {\n\t\t\t\t\telapse += tmp.getTime();\n\t\t\t\t\tans.append(tmp.getName()).append(\" \").append(Integer.toString(elapse)).append(\"\\n\");\n\t\t\t\t} else {\n\t\t\t\t\telapse += q;\n\t\t\t\t\ttmp.setTime(tmp.getTime() - q);\n\t\t\t\t\tqueue.push(tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.print(ans.toString());\n\t\t} catch (NumberFormatException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t} catch (IOException e) {\n\t\t\t// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ\n\t\t\te.printStackTrace();\n\t\t}\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static final int BIG_NUM = 2000000000;
public static final int MOD = 1000000007;
public static void main(String[] args) {
// TODO ่ชๅ็ๆใใใใกใฝใใใปในใฟใ
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final int size = 100005;
try {
String[] input_str = br.readLine().split("\\s+");
int n = Integer.parseInt(input_str[0]);
int q = Integer.parseInt(input_str[1]);
int elapse = 0;
Queue queue = new Queue(size);
StringBuilder ans = new StringBuilder();
for(int i=0; i<n; i++) {
input_str = br.readLine().split("\\s+");
queue.push(new Process(input_str[0], Integer.parseInt(input_str[1])));
}
while(!queue.isEmpty()) {
Process tmp = queue.pop();
if(tmp.getTime() <= q) {
elapse += tmp.getTime();
ans.append(tmp.getName()).append(" ").append(Integer.toString(elapse)).append("\n");
} else {
elapse += q;
tmp.setTime(tmp.getTime() - q);
queue.push(tmp);
}
}
System.out.print(ans.toString());
} catch (NumberFormatException e) {
// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ
e.printStackTrace();
} catch (IOException e) {
// TODO ่ชๅ็ๆใใใ catch ใใญใใฏ
e.printStackTrace();
}
}
}
class Process{
private String name;
private int t;
Process(String arg_name, int arg_time){
name = arg_name;
t = arg_time;
}
public String getName() {
return name;
}
public int getTime() {
return t;
}
public void setTime(int arg_time) {
t = arg_time;
}
}
class Queue{
private Process[] table;
private int head, tail, size;
Queue(int arg_size) {
size = arg_size;
table = new Process[size];
head = 0;
tail = 0;
}
boolean isEmpty() {
return head == tail;
}
void push(Process process) {
table[tail] = process;
tail = (tail+1)%size;
}
public Process pop() {
head = (head+1)%size;
return table[(head-1+size)%size];
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
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,
0,
13,
0,
13,
0,
13,
0,
13,
17,
0,
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,
2,
2,
13,
17,
13,
42,
17,
30,
41,
13,
4,
18,
4,
18,
4,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
0,
18,
13,
40,
13,
2,
2,
18,
13,
17,
17,
4,
18,
13,
13,
30,
0,
18,
13,
17,
4,
18,
13,
2,
13,
13,
4,
13,
2,
2,
18,
13,
17,
17,
18,
13,
17,
0,
13,
13,
14,
2,
13,
13,
30,
3,
4,
13,
4,
18,
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,
12,
13,
30,
29,
2,
2,
13,
17,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
4,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
17,
0,
13,
4,
13,
13,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
242,
8
],
[
242,
9
],
[
9,
10
],
[
242,
11
],
[
11,
12
],
[
242,
13
],
[
13,
14
],
[
242,
15
],
[
15,
16
],
[
242,
17
],
[
17,
18
],
[
242,
19
],
[
19,
20
],
[
242,
21
],
[
21,
22
],
[
242,
23
],
[
23,
24
],
[
242,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
28,
30
],
[
27,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
27,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
27,
41
],
[
41,
42
],
[
41,
43
],
[
44,
45
],
[
44,
46
],
[
27,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
53,
55
],
[
27,
56
],
[
56,
57
],
[
56,
58
],
[
27,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
60,
65
],
[
65,
66
],
[
65,
67
],
[
60,
68
],
[
68,
69
],
[
69,
70
],
[
60,
71
],
[
72,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
72,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
72,
83
],
[
83,
84
],
[
83,
85
],
[
86,
86
],
[
86,
87
],
[
86,
88
],
[
86,
89
],
[
27,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
95,
101
],
[
92,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
107,
108
],
[
107,
109
],
[
92,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
118,
123
],
[
124,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
124,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
110,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
141,
142
],
[
141,
143
],
[
133,
144
],
[
144,
145
],
[
144,
146
],
[
147,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
147,
152
],
[
152,
153
],
[
152,
154
],
[
133,
155
],
[
155,
156
],
[
155,
157
],
[
92,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
27,
164
],
[
164,
165
],
[
27,
166
],
[
166,
167
],
[
167,
168
],
[
25,
169
],
[
169,
170
],
[
242,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
179,
180
],
[
179,
181
],
[
174,
182
],
[
182,
183
],
[
183,
184
],
[
174,
185
],
[
186,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
189,
190
],
[
189,
191
],
[
187,
192
],
[
192,
193
],
[
192,
194
],
[
242,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
199,
203
],
[
195,
204
],
[
204,
205
],
[
242,
206
],
[
206,
207
],
[
206,
208
],
[
208,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
209,
213
],
[
208,
214
],
[
214,
215
],
[
214,
216
],
[
216,
217
],
[
216,
218
],
[
206,
219
],
[
219,
220
],
[
242,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
226,
227
],
[
226,
228
],
[
223,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
229,
233
],
[
223,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
236,
238
],
[
223,
239
],
[
239,
240
],
[
0,
241
],
[
241,
242
],
[
241,
243
]
] | [
"import java.io.IOException;\nimport java.util.Scanner;\npublic class Main {\n\n\tprivate static int max; // ่ฆ็ด ใฎๆฐ\n\tprivate static int run; // ๅฆ็้ๅบฆ\n\tprivate static Object q[]; // queue\n\tprivate static String end[]; // ๅฆ็ๆธใฟ\n\tprivate static int count; // ๅฆ็ๆธใฟๆฐ\n\tprivate static int front; // ๅ
้ ญ\n\tprivate static int rear; // ๆซๅฐพ\n\tprivate static int time; // ๅ่จๅฆ็ๆ้\n\n\tpublic static void main(String[] args) throws IOException{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tmax = sc.nextInt();\n\t\trun = sc.nextInt();\n\n\t\tq = new Object[max+1];\n\t\tfront = rear = count = time = 0;\n\t\tend = new String[max];\n\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}\n\n\t\twhile(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tsc.close();\n\t}\n\n\tpublic static void show() {\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}\n\t}\n\n\t/*\n\t * ใใคใณใฟใฎไฝ็ฝฎ\n\t */\n\tpublic static int next(int a) {\n\t\treturn (a + 1) % max;\n\t}\n\n\t/*\n\t * ๅ
ฅใใ\n\t */\n\tpublic static void enqueue(Object x) {\n/*\t\tif(next(rear) == front) {\n\t\t\tthrow new IllegalStateException();\n\t\t}*/\n\t\tq[rear] = x;\n\t\trear = next(rear);\n\t}\n\n\t/*\n\t * ๅใๅบใ\n\t */\n\tpublic static Object dequeue() {\n\t\tObject x = q[front];\n\t\tq[front] = null;\n\t\tfront = next(front);\n\t\treturn x;\n\t}\n}",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tprivate static int max; // ่ฆ็ด ใฎๆฐ\n\tprivate static int run; // ๅฆ็้ๅบฆ\n\tprivate static Object q[]; // queue\n\tprivate static String end[]; // ๅฆ็ๆธใฟ\n\tprivate static int count; // ๅฆ็ๆธใฟๆฐ\n\tprivate static int front; // ๅ
้ ญ\n\tprivate static int rear; // ๆซๅฐพ\n\tprivate static int time; // ๅ่จๅฆ็ๆ้\n\n\tpublic static void main(String[] args) throws IOException{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tmax = sc.nextInt();\n\t\trun = sc.nextInt();\n\n\t\tq = new Object[max+1];\n\t\tfront = rear = count = time = 0;\n\t\tend = new String[max];\n\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}\n\n\t\twhile(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tsc.close();\n\t}\n\n\tpublic static void show() {\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}\n\t}\n\n\t/*\n\t * ใใคใณใฟใฎไฝ็ฝฎ\n\t */\n\tpublic static int next(int a) {\n\t\treturn (a + 1) % max;\n\t}\n\n\t/*\n\t * ๅ
ฅใใ\n\t */\n\tpublic static void enqueue(Object x) {\n/*\t\tif(next(rear) == front) {\n\t\t\tthrow new IllegalStateException();\n\t\t}*/\n\t\tq[rear] = x;\n\t\trear = next(rear);\n\t}\n\n\t/*\n\t * ๅใๅบใ\n\t */\n\tpublic static Object dequeue() {\n\t\tObject x = q[front];\n\t\tq[front] = null;\n\t\tfront = next(front);\n\t\treturn x;\n\t}\n}",
"Main",
"private static int max; // ่ฆ็ด ใฎๆฐ",
"max",
"private static int run; // ๅฆ็้ๅบฆ",
"run",
"private static Object q[]; // queue",
"q",
"private static String end[]; // ๅฆ็ๆธใฟ",
"end",
"private static int count; // ๅฆ็ๆธใฟๆฐ",
"count",
"private static int front; // ๅ
้ ญ",
"front",
"private static int rear; // ๆซๅฐพ",
"rear",
"private static int time; // ๅ่จๅฆ็ๆ้",
"time",
"public static void main(String[] args) throws IOException{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tmax = sc.nextInt();\n\t\trun = sc.nextInt();\n\n\t\tq = new Object[max+1];\n\t\tfront = rear = count = time = 0;\n\t\tend = new String[max];\n\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}\n\n\t\twhile(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tmax = sc.nextInt();\n\t\trun = sc.nextInt();\n\n\t\tq = new Object[max+1];\n\t\tfront = rear = count = time = 0;\n\t\tend = new String[max];\n\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}\n\n\t\twhile(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"max = sc.nextInt()",
"max",
"sc.nextInt()",
"sc.nextInt",
"sc",
"run = sc.nextInt()",
"run",
"sc.nextInt()",
"sc.nextInt",
"sc",
"q = new Object[max+1]",
"q",
"new Object[max+1]",
"max+1",
"max",
"1",
"front = rear = count = time = 0",
"front",
"rear = count = time = 0",
"rear",
"count = time = 0",
"count",
"time = 0",
"time",
"0",
"end = new String[max]",
"end",
"new String[max]",
"max",
"for(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<max",
"i",
"max",
"i++",
"i++",
"i",
"{\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}",
"{\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}",
"String a = sc.next();",
"a",
"sc.next()",
"sc.next",
"sc",
"int b = sc.nextInt();",
"b",
"sc.nextInt()",
"sc.nextInt",
"sc",
"enqueue(a + \" \" +b)",
"enqueue",
"a + \" \" +b",
"a + \" \" +b",
"a",
"\" \"",
"b",
"while(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"String[] line = dequeue().toString().split(\" \");",
"line",
"dequeue().toString().split(\" \")",
"dequeue().toString().split",
"dequeue().toString()",
"dequeue().toString",
"dequeue()",
"dequeue",
"\" \"",
"int x = Integer.parseInt(line[1]);",
"x",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"if(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}",
"x <= run",
"x",
"run",
"{\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}",
"time += x",
"time",
"x",
"end[count++] = line[0] + \" \" + Integer.toString(time)",
"end[count++]",
"end",
"count++",
"count",
"line[0] + \" \" + Integer.toString(time)",
"line[0] + \" \" + Integer.toString(time)",
"line[0]",
"line",
"0",
"\" \"",
"Integer.toString(time)",
"Integer.toString",
"Integer",
"time",
"{\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}",
"line[1] = Integer.toString(x - run)",
"line[1]",
"line",
"1",
"Integer.toString(x - run)",
"Integer.toString",
"Integer",
"x - run",
"x",
"run",
"enqueue(line[0] + \" \" + line[1])",
"enqueue",
"line[0] + \" \" + line[1]",
"line[0] + \" \" + line[1]",
"line[0]",
"line",
"0",
"\" \"",
"line[1]",
"line",
"1",
"time += run",
"time",
"run",
"if(count == max) {\n\t\t\t\tbreak;\n\t\t\t}",
"count == max",
"count",
"max",
"{\n\t\t\t\tbreak;\n\t\t\t}",
"break;",
"show()",
"show",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public static void show() {\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}\n\t}",
"show",
"{\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}\n\t}",
"for(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<max",
"i",
"max",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(end[i]);\n\t\t}",
"{\n\t\t\tSystem.out.println(end[i]);\n\t\t}",
"System.out.println(end[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"end[i]",
"end",
"i",
"/*\n\t * ใใคใณใฟใฎไฝ็ฝฎ\n\t */\n\tpublic static int next(int a) {\n\t\treturn (a + 1) % max;\n\t}",
"next",
"{\n\t\treturn (a + 1) % max;\n\t}",
"return (a + 1) % max;",
"(a + 1) % max",
"(a + 1)",
"a",
"1",
"max",
"int a",
"a",
"/*\n\t * ๅ
ฅใใ\n\t */\n\tpublic static void enqueue(Object x) {\n/*\t\tif(next(rear) == front) {\n\t\t\tthrow new IllegalStateException();\n\t\t}*/\n\t\tq[rear] = x;\n\t\trear = next(rear);\n\t}",
"enqueue",
"{\n/*\t\tif(next(rear) == front) {\n\t\t\tthrow new IllegalStateException();\n\t\t}*/\n\t\tq[rear] = x;\n\t\trear = next(rear);\n\t}",
"q[rear] = x",
"q[rear]",
"q",
"rear",
"x",
"rear = next(rear)",
"rear",
"next(rear)",
"next",
"rear",
"Object x",
"x",
"/*\n\t * ๅใๅบใ\n\t */\n\tpublic static Object dequeue() {\n\t\tObject x = q[front];\n\t\tq[front] = null;\n\t\tfront = next(front);\n\t\treturn x;\n\t}",
"dequeue",
"{\n\t\tObject x = q[front];\n\t\tq[front] = null;\n\t\tfront = next(front);\n\t\treturn x;\n\t}",
"Object x = q[front];",
"x",
"q[front]",
"q",
"front",
"q[front] = null",
"q[front]",
"q",
"front",
"null",
"front = next(front)",
"front",
"next(front)",
"next",
"front",
"return x;",
"x",
"public class Main {\n\n\tprivate static int max; // ่ฆ็ด ใฎๆฐ\n\tprivate static int run; // ๅฆ็้ๅบฆ\n\tprivate static Object q[]; // queue\n\tprivate static String end[]; // ๅฆ็ๆธใฟ\n\tprivate static int count; // ๅฆ็ๆธใฟๆฐ\n\tprivate static int front; // ๅ
้ ญ\n\tprivate static int rear; // ๆซๅฐพ\n\tprivate static int time; // ๅ่จๅฆ็ๆ้\n\n\tpublic static void main(String[] args) throws IOException{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tmax = sc.nextInt();\n\t\trun = sc.nextInt();\n\n\t\tq = new Object[max+1];\n\t\tfront = rear = count = time = 0;\n\t\tend = new String[max];\n\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}\n\n\t\twhile(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tsc.close();\n\t}\n\n\tpublic static void show() {\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}\n\t}\n\n\t/*\n\t * ใใคใณใฟใฎไฝ็ฝฎ\n\t */\n\tpublic static int next(int a) {\n\t\treturn (a + 1) % max;\n\t}\n\n\t/*\n\t * ๅ
ฅใใ\n\t */\n\tpublic static void enqueue(Object x) {\n/*\t\tif(next(rear) == front) {\n\t\t\tthrow new IllegalStateException();\n\t\t}*/\n\t\tq[rear] = x;\n\t\trear = next(rear);\n\t}\n\n\t/*\n\t * ๅใๅบใ\n\t */\n\tpublic static Object dequeue() {\n\t\tObject x = q[front];\n\t\tq[front] = null;\n\t\tfront = next(front);\n\t\treturn x;\n\t}\n}",
"public class Main {\n\n\tprivate static int max; // ่ฆ็ด ใฎๆฐ\n\tprivate static int run; // ๅฆ็้ๅบฆ\n\tprivate static Object q[]; // queue\n\tprivate static String end[]; // ๅฆ็ๆธใฟ\n\tprivate static int count; // ๅฆ็ๆธใฟๆฐ\n\tprivate static int front; // ๅ
้ ญ\n\tprivate static int rear; // ๆซๅฐพ\n\tprivate static int time; // ๅ่จๅฆ็ๆ้\n\n\tpublic static void main(String[] args) throws IOException{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tmax = sc.nextInt();\n\t\trun = sc.nextInt();\n\n\t\tq = new Object[max+1];\n\t\tfront = rear = count = time = 0;\n\t\tend = new String[max];\n\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tString a = sc.next();\n\t\t\tint b = sc.nextInt();\n\t\t\tenqueue(a + \" \" +b);\n\t\t}\n\n\t\twhile(true) {\n\t\t\tString[] line = dequeue().toString().split(\" \");\n\t\t\tint x = Integer.parseInt(line[1]);\n\t\t\t// ๅฆ็ๆ้ไปฅๅ
ใชใ\n\t\t\tif(x <= run) {\n\t\t\t\ttime += x;\n\t\t\t\tend[count++] = line[0] + \" \" + Integer.toString(time);\n\t\t\t// ๅฆ็ๆ้ไปฅไธใชใ\n\t\t\t}else {\n\t\t\t\tline[1] = Integer.toString(x - run);\n\t\t\t\tenqueue(line[0] + \" \" + line[1]);\n\t\t\t\ttime += run;\n\t\t\t}\n\n\t\t\tif(count == max) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tshow();\n\n\t\tsc.close();\n\t}\n\n\tpublic static void show() {\n\t\tfor(int i=0;i<max;i++) {\n\t\t\tSystem.out.println(end[i]);\n\t\t}\n\t}\n\n\t/*\n\t * ใใคใณใฟใฎไฝ็ฝฎ\n\t */\n\tpublic static int next(int a) {\n\t\treturn (a + 1) % max;\n\t}\n\n\t/*\n\t * ๅ
ฅใใ\n\t */\n\tpublic static void enqueue(Object x) {\n/*\t\tif(next(rear) == front) {\n\t\t\tthrow new IllegalStateException();\n\t\t}*/\n\t\tq[rear] = x;\n\t\trear = next(rear);\n\t}\n\n\t/*\n\t * ๅใๅบใ\n\t */\n\tpublic static Object dequeue() {\n\t\tObject x = q[front];\n\t\tq[front] = null;\n\t\tfront = next(front);\n\t\treturn x;\n\t}\n}",
"Main"
] | import java.io.IOException;
import java.util.Scanner;
public class Main {
private static int max; // ่ฆ็ด ใฎๆฐ
private static int run; // ๅฆ็้ๅบฆ
private static Object q[]; // queue
private static String end[]; // ๅฆ็ๆธใฟ
private static int count; // ๅฆ็ๆธใฟๆฐ
private static int front; // ๅ
้ ญ
private static int rear; // ๆซๅฐพ
private static int time; // ๅ่จๅฆ็ๆ้
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
max = sc.nextInt();
run = sc.nextInt();
q = new Object[max+1];
front = rear = count = time = 0;
end = new String[max];
for(int i=0;i<max;i++) {
String a = sc.next();
int b = sc.nextInt();
enqueue(a + " " +b);
}
while(true) {
String[] line = dequeue().toString().split(" ");
int x = Integer.parseInt(line[1]);
// ๅฆ็ๆ้ไปฅๅ
ใชใ
if(x <= run) {
time += x;
end[count++] = line[0] + " " + Integer.toString(time);
// ๅฆ็ๆ้ไปฅไธใชใ
}else {
line[1] = Integer.toString(x - run);
enqueue(line[0] + " " + line[1]);
time += run;
}
if(count == max) {
break;
}
}
show();
sc.close();
}
public static void show() {
for(int i=0;i<max;i++) {
System.out.println(end[i]);
}
}
/*
* ใใคใณใฟใฎไฝ็ฝฎ
*/
public static int next(int a) {
return (a + 1) % max;
}
/*
* ๅ
ฅใใ
*/
public static void enqueue(Object x) {
/* if(next(rear) == front) {
throw new IllegalStateException();
}*/
q[rear] = x;
rear = next(rear);
}
/*
* ๅใๅบใ
*/
public static Object dequeue() {
Object x = q[front];
q[front] = null;
front = next(front);
return x;
}
}
|
[
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,
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,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
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,
4,
18,
13,
13,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
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
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
10,
14
],
[
14,
15
],
[
10,
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
],
[
0,
33
],
[
139,
34
],
[
139,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
41,
43
],
[
37,
44
],
[
44,
45
],
[
44,
46
],
[
37,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
37,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
37,
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
],
[
70,
73
],
[
37,
74
],
[
74,
75
],
[
74,
76
],
[
37,
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
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
88,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
94,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
102,
107
],
[
108,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
108,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
88,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
117,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
117,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
133,
135
],
[
35,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n class Node{\n\t\n\tString name;\n\tint time;\n\t\n\tpublic Node(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}\n\npublic class Main{\n\t\n\tpublic static void main(String[] args) {\n\t\tQueue<Node> q = new LinkedList<>();\n\t\tQueue<String> result = new LinkedList<>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint processes = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tfor(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\t\n\t}\n\t\t\n}\n\t",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Node{\n\t\n\tString name;\n\tint time;\n\t\n\tpublic Node(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Node",
"String name;",
"name",
"int time;",
"time",
"public 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",
"public class Main{\n\t\n\tpublic static void main(String[] args) {\n\t\tQueue<Node> q = new LinkedList<>();\n\t\tQueue<String> result = new LinkedList<>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint processes = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tfor(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\t\n\t}\n\t\t\n}",
"Main",
"public static void main(String[] args) {\n\t\tQueue<Node> q = new LinkedList<>();\n\t\tQueue<String> result = new LinkedList<>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint processes = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tfor(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\t\n\t}",
"main",
"{\n\t\tQueue<Node> q = new LinkedList<>();\n\t\tQueue<String> result = new LinkedList<>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint processes = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tfor(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\t\n\t}",
"Queue<Node> q = new LinkedList<>();",
"q",
"new LinkedList<>()",
"Queue<String> result = new LinkedList<>();",
"result",
"new LinkedList<>()",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int processes = in.nextInt();",
"processes",
"in.nextInt()",
"in.nextInt",
"in",
"int quantum = in.nextInt();",
"quantum",
"in.nextInt()",
"in.nextInt",
"in",
"for(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < processes",
"i",
"processes",
"i++",
"i++",
"i",
"{\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}",
"{\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}",
"q.add(new Node(in.next(), in.nextInt()))",
"q.add",
"q",
"new Node(in.next(), in.nextInt())",
"int timer = 0;",
"timer",
"0",
"while(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}",
"!(q.isEmpty())",
"(q.isEmpty())",
"q.isEmpty",
"q",
"{\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}",
"Node task = q.remove();",
"task",
"q.remove()",
"q.remove",
"q",
"if(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}",
"task.time <= quantum",
"task.time",
"task",
"task.time",
"quantum",
"{\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}",
"timer = timer + task.time",
"timer",
"timer + task.time",
"timer",
"task.time",
"task",
"task.time",
"System.out.println(task.name + \" \" + Integer.toString(timer))",
"System.out.println",
"System.out",
"System",
"System.out",
"task.name + \" \" + Integer.toString(timer)",
"task.name + \" \" + Integer.toString(timer)",
"task.name",
"task",
"task.name",
"\" \"",
"Integer.toString(timer)",
"Integer.toString",
"Integer",
"timer",
"{\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}",
"task.time = task.time - quantum",
"task.time",
"task",
"task.time",
"task.time - quantum",
"task.time",
"task",
"task.time",
"quantum",
"q.add(task)",
"q.add",
"q",
"task",
"timer = timer + quantum",
"timer",
"timer + quantum",
"timer",
"quantum",
"String[] args",
"args",
"public class Main{\n\t\n\tpublic static void main(String[] args) {\n\t\tQueue<Node> q = new LinkedList<>();\n\t\tQueue<String> result = new LinkedList<>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint processes = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tfor(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\t\n\t}\n\t\t\n}",
"public class Main{\n\t\n\tpublic static void main(String[] args) {\n\t\tQueue<Node> q = new LinkedList<>();\n\t\tQueue<String> result = new LinkedList<>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint processes = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tfor(int i = 0; i < processes; i++) {\n\t\t\tq.add(new Node(in.next(), in.nextInt()));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\twhile(!(q.isEmpty())) {\n\t\t\tNode task = q.remove();\n\t\t\tif(task.time <= quantum) {\n\t\t\t\ttimer = timer + task.time;\n\t\t\t\tSystem.out.println(task.name + \" \" + Integer.toString(timer));\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttask.time = task.time - quantum;\n\t\t\t\tq.add(task);\n\t\t\t\ttimer = timer + quantum;\n\t\t\t}\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\t\n\t}\n\t\t\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
class Node{
String name;
int time;
public Node(String name, int time) {
this.name = name;
this.time = time;
}
}
public class Main{
public static void main(String[] args) {
Queue<Node> q = new LinkedList<>();
Queue<String> result = new LinkedList<>();
Scanner in = new Scanner(System.in);
int processes = in.nextInt();
int quantum = in.nextInt();
for(int i = 0; i < processes; i++) {
q.add(new Node(in.next(), in.nextInt()));
}
int timer = 0;
while(!(q.isEmpty())) {
Node task = q.remove();
if(task.time <= quantum) {
timer = timer + task.time;
System.out.println(task.name + " " + Integer.toString(timer));
}
else {
task.time = task.time - quantum;
q.add(task);
timer = timer + quantum;
}
}
}
}
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.