node_ids
sequencelengths 4
1.4k
| edge_index
sequencelengths 1
2.22k
| text
sequencelengths 4
1.4k
| source
stringlengths 14
427k
|
---|---|---|---|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
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,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
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
],
[
128,
11
],
[
128,
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
],
[
45,
46
],
[
44,
47
],
[
14,
48
],
[
48,
49
],
[
48,
50
],
[
14,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
51,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
71,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
74,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
80,
85
],
[
62,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
86,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
14,
99
],
[
99,
100
],
[
100,
101
],
[
12,
102
],
[
102,
103
],
[
128,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
104,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
112,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
110,
123
],
[
123,
124
],
[
110,
125
],
[
125,
126
],
[
0,
127
],
[
127,
128
],
[
127,
129
]
] | [
"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 sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tQueue<Process> Q = new ArrayDeque<>();\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\n\t\tint t = 0;\n\t\twhile (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\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}\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 sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tQueue<Process> Q = new ArrayDeque<>();\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\n\t\tint t = 0;\n\t\twhile (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\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}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tQueue<Process> Q = new ArrayDeque<>();\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\n\t\tint t = 0;\n\t\twhile (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tQueue<Process> Q = new ArrayDeque<>();\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\n\t\tint t = 0;\n\t\twhile (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Process> Q = new ArrayDeque<>();",
"Q",
"new ArrayDeque<>()",
"for (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}",
"{\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}",
"Q.add(new Process(sc.next(), sc.nextInt()))",
"Q.add",
"Q",
"new Process(sc.next(), sc.nextInt())",
"int t = 0;",
"t",
"0",
"while (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}",
"!Q.isEmpty()",
"Q.isEmpty()",
"Q.isEmpty",
"Q",
"{\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}",
"Process p = Q.poll();",
"p",
"Q.poll()",
"Q.poll",
"Q",
"if (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}",
"p.time<=q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t}",
"t += p.time",
"t",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + t)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + t",
"p.name + \" \" + t",
"p.name",
"p",
"p.name",
"\" \"",
"t",
"{\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}",
"t += q",
"t",
"q",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"Q.add(p)",
"Q.add",
"Q",
"p",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"static class Process {\n\t\tString name;\n\t\tint time;\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}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"Process",
"{\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tQueue<Process> Q = new ArrayDeque<>();\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\n\t\tint t = 0;\n\t\twhile (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\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}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tQueue<Process> Q = new ArrayDeque<>();\n\n\t\tfor (int i=0; i<n; i++) {\n\t\t\tQ.add(new Process(sc.next(), sc.nextInt()));\n\t\t}\n\n\t\tint t = 0;\n\t\twhile (!Q.isEmpty()) {\n\t\t\tProcess p = Q.poll();\n\t\t\tif (p.time<=q) {\n\t\t\t\tt += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + t);\n\t\t\t} else {\n\t\t\t\tt += q;\n\t\t\t\tp.time -= q;\n\t\t\t\tQ.add(p);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\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}\n\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Queue<Process> Q = new ArrayDeque<>();
for (int i=0; i<n; i++) {
Q.add(new Process(sc.next(), sc.nextInt()));
}
int t = 0;
while (!Q.isEmpty()) {
Process p = Q.poll();
if (p.time<=q) {
t += p.time;
System.out.println(p.name + " " + t);
} else {
t += q;
p.time -= q;
Q.add(p);
}
}
sc.close();
}
static class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
4,
18,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
14,
2,
18,
4,
18,
13,
13,
13,
30,
0,
13,
18,
4,
18,
13,
13,
4,
18,
13,
2,
2,
18,
4,
18,
13,
13,
17,
13,
4,
18,
13,
30,
0,
13,
13,
4,
18,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
20,
4,
18,
13,
13,
13,
13,
4,
18,
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,
0,
13,
13,
23,
13,
6,
13,
12,
13,
30,
4,
18,
18,
13,
13,
4,
18,
13,
13,
23,
13,
12,
13,
30,
4,
18,
13,
8,
13,
17,
17,
23,
13,
23,
13,
12,
13,
30,
4,
18,
13,
8,
13,
17,
17,
23,
13,
23,
13,
12,
13,
30,
4,
18,
13,
13,
29,
18,
13,
2,
18,
13,
13,
17,
23,
13,
12,
13,
30,
4,
18,
13,
13,
29,
18,
13,
17,
23,
13,
12,
13,
30,
29,
8,
2,
13,
17,
4,
13,
13,
2,
13,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
2,
2,
13,
4,
13,
13,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
20,
17,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
13,
29,
17,
30,
0,
13,
17,
38,
5,
13,
30,
4,
18,
13,
30,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
29,
17,
29,
17,
12,
13,
30,
14,
2,
4,
13,
17,
29,
18,
13,
40,
13,
29,
40,
17,
12,
13,
30,
29,
2,
2,
17,
13,
2,
13,
17,
23,
13,
12,
13,
30,
42,
2,
4,
13,
40,
4,
13,
18,
13,
13,
40,
13,
12,
13,
30,
4,
13,
29,
4,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
20,
41,
13,
4,
13,
42,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
17,
41,
13,
4,
13,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
14,
2,
2,
13,
17,
2,
17,
13,
37,
20,
41,
13,
17,
42,
4,
13,
13,
30,
14,
2,
2,
17,
13,
2,
13,
17,
30,
0,
13,
17,
0,
13,
2,
13,
17,
37,
20,
0,
13,
4,
13,
29,
8,
13,
40,
13,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
38,
5,
13,
30,
30,
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
],
[
635,
11
],
[
635,
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
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
14,
44
],
[
44,
45
],
[
44,
46
],
[
14,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
48,
52
],
[
47,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
56,
60
],
[
55,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
74,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
75,
79
],
[
74,
80
],
[
74,
81
],
[
62,
82
],
[
82,
83
],
[
83,
84
],
[
54,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
89,
94
],
[
85,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
98,
99
],
[
99,
100
],
[
12,
101
],
[
101,
102
],
[
12,
103
],
[
103,
104
],
[
12,
105
],
[
105,
106
],
[
635,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
109,
116
],
[
116,
117
],
[
116,
118
],
[
109,
119
],
[
119,
120
],
[
119,
121
],
[
109,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
122,
126
],
[
122,
127
],
[
109,
128
],
[
128,
129
],
[
129,
130
],
[
109,
131
],
[
131,
132
],
[
132,
133
],
[
107,
134
],
[
134,
135
],
[
635,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
136,
140
],
[
140,
141
],
[
136,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
148,
149
],
[
148,
150
],
[
142,
151
],
[
151,
152
],
[
142,
153
],
[
153,
154
],
[
136,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
155,
161
],
[
161,
162
],
[
635,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
168,
173
],
[
173,
174
],
[
174,
175
],
[
173,
176
],
[
165,
177
],
[
177,
178
],
[
163,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
182,
185
],
[
185,
186
],
[
185,
187
],
[
185,
188
],
[
179,
189
],
[
189,
190
],
[
179,
191
],
[
191,
192
],
[
163,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
196,
199
],
[
199,
200
],
[
199,
201
],
[
199,
202
],
[
193,
203
],
[
203,
204
],
[
193,
205
],
[
205,
206
],
[
163,
207
],
[
207,
208
],
[
207,
209
],
[
209,
210
],
[
210,
211
],
[
211,
212
],
[
210,
213
],
[
209,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
217,
221
],
[
207,
222
],
[
222,
223
],
[
163,
224
],
[
224,
225
],
[
224,
226
],
[
226,
227
],
[
227,
228
],
[
228,
229
],
[
227,
230
],
[
226,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
224,
235
],
[
235,
236
],
[
163,
237
],
[
237,
238
],
[
237,
239
],
[
239,
240
],
[
240,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
241,
245
],
[
245,
246
],
[
245,
247
],
[
245,
248
],
[
248,
249
],
[
248,
250
],
[
241,
251
],
[
237,
252
],
[
252,
253
],
[
237,
254
],
[
254,
255
],
[
163,
256
],
[
256,
257
],
[
256,
258
],
[
258,
259
],
[
259,
260
],
[
260,
261
],
[
261,
262
],
[
261,
263
],
[
263,
264
],
[
263,
265
],
[
263,
266
],
[
260,
267
],
[
256,
268
],
[
268,
269
],
[
256,
270
],
[
270,
271
],
[
635,
272
],
[
272,
273
],
[
272,
274
],
[
274,
275
],
[
272,
276
],
[
276,
277
],
[
276,
278
],
[
272,
280
],
[
280,
281
],
[
280,
282
],
[
272,
283
],
[
283,
284
],
[
283,
285
],
[
272,
286
],
[
286,
287
],
[
286,
288
],
[
288,
289
],
[
289,
290
],
[
289,
291
],
[
286,
292
],
[
292,
293
],
[
272,
294
],
[
294,
295
],
[
294,
296
],
[
296,
297
],
[
297,
298
],
[
298,
299
],
[
298,
300
],
[
297,
301
],
[
301,
302
],
[
297,
303
],
[
303,
304
],
[
304,
305
],
[
304,
306
],
[
303,
307
],
[
307,
308
],
[
308,
309
],
[
308,
310
],
[
310,
311
],
[
311,
312
],
[
312,
313
],
[
307,
314
],
[
314,
315
],
[
315,
316
],
[
315,
317
],
[
317,
318
],
[
318,
319
],
[
317,
320
],
[
303,
321
],
[
321,
322
],
[
322,
323
],
[
322,
324
],
[
321,
325
],
[
325,
326
],
[
296,
327
],
[
327,
328
],
[
272,
329
],
[
329,
330
],
[
329,
331
],
[
331,
332
],
[
332,
333
],
[
333,
334
],
[
334,
335
],
[
333,
336
],
[
332,
337
],
[
337,
338
],
[
338,
339
],
[
338,
340
],
[
340,
341
],
[
331,
342
],
[
342,
343
],
[
343,
344
],
[
272,
345
],
[
345,
346
],
[
345,
347
],
[
347,
348
],
[
348,
349
],
[
349,
350
],
[
350,
351
],
[
350,
352
],
[
349,
353
],
[
353,
354
],
[
353,
355
],
[
345,
356
],
[
356,
357
],
[
272,
358
],
[
358,
359
],
[
358,
360
],
[
360,
361
],
[
361,
362
],
[
362,
363
],
[
363,
364
],
[
362,
365
],
[
365,
366
],
[
366,
367
],
[
366,
368
],
[
368,
369
],
[
368,
370
],
[
361,
371
],
[
371,
372
],
[
272,
373
],
[
373,
374
],
[
373,
375
],
[
375,
376
],
[
376,
377
],
[
375,
378
],
[
378,
379
],
[
379,
380
],
[
272,
381
],
[
381,
382
],
[
381,
383
],
[
383,
384
],
[
384,
385
],
[
385,
386
],
[
386,
387
],
[
384,
388
],
[
388,
389
],
[
383,
390
],
[
390,
391
],
[
390,
392
],
[
383,
393
],
[
393,
394
],
[
393,
395
],
[
395,
396
],
[
383,
397
],
[
397,
398
],
[
398,
399
],
[
398,
400
],
[
397,
401
],
[
401,
402
],
[
402,
403
],
[
403,
404
],
[
402,
405
],
[
401,
406
],
[
406,
407
],
[
406,
408
],
[
408,
409
],
[
383,
410
],
[
410,
411
],
[
411,
412
],
[
412,
413
],
[
272,
414
],
[
414,
415
],
[
414,
416
],
[
416,
417
],
[
417,
418
],
[
417,
419
],
[
416,
421
],
[
421,
422
],
[
422,
423
],
[
423,
424
],
[
423,
425
],
[
421,
426
],
[
426,
427
],
[
426,
428
],
[
421,
429
],
[
429,
430
],
[
430,
431
],
[
421,
432
],
[
432,
433
],
[
433,
434
],
[
434,
435
],
[
434,
436
],
[
433,
437
],
[
437,
438
],
[
416,
439
],
[
439,
440
],
[
414,
441
],
[
441,
442
],
[
272,
443
],
[
443,
444
],
[
443,
445
],
[
445,
446
],
[
446,
447
],
[
447,
448
],
[
448,
449
],
[
447,
450
],
[
450,
451
],
[
272,
452
],
[
452,
453
],
[
452,
454
],
[
454,
455
],
[
455,
456
],
[
455,
457
],
[
454,
459
],
[
459,
460
],
[
460,
461
],
[
461,
462
],
[
461,
463
],
[
459,
464
],
[
464,
465
],
[
464,
466
],
[
459,
467
],
[
467,
468
],
[
468,
469
],
[
459,
470
],
[
470,
471
],
[
471,
472
],
[
472,
473
],
[
472,
474
],
[
471,
475
],
[
475,
476
],
[
454,
477
],
[
477,
478
],
[
452,
479
],
[
479,
480
],
[
272,
481
],
[
481,
482
],
[
481,
483
],
[
483,
484
],
[
484,
485
],
[
485,
486
],
[
486,
487
],
[
484,
488
],
[
488,
489
],
[
483,
490
],
[
490,
491
],
[
490,
492
],
[
483,
493
],
[
493,
494
],
[
493,
495
],
[
495,
496
],
[
483,
497
],
[
497,
498
],
[
498,
499
],
[
498,
500
],
[
497,
501
],
[
501,
502
],
[
502,
503
],
[
502,
504
],
[
501,
505
],
[
505,
506
],
[
505,
507
],
[
507,
508
],
[
483,
509
],
[
509,
510
],
[
510,
511
],
[
511,
512
],
[
511,
513
],
[
510,
514
],
[
514,
515
],
[
514,
516
],
[
509,
517
],
[
517,
518
],
[
483,
519
],
[
519,
520
],
[
519,
521
],
[
483,
522
],
[
522,
523
],
[
523,
524
],
[
523,
525
],
[
522,
526
],
[
526,
527
],
[
527,
528
],
[
528,
529
],
[
529,
530
],
[
529,
531
],
[
528,
532
],
[
532,
533
],
[
532,
534
],
[
527,
535
],
[
535,
536
],
[
536,
537
],
[
536,
538
],
[
535,
539
],
[
539,
540
],
[
539,
541
],
[
541,
542
],
[
541,
543
],
[
527,
544
],
[
544,
545
],
[
526,
546
],
[
546,
547
],
[
546,
548
],
[
548,
549
],
[
483,
550
],
[
550,
551
],
[
551,
552
],
[
551,
553
],
[
553,
554
],
[
551,
555
],
[
272,
556
],
[
556,
557
],
[
556,
558
],
[
558,
559
],
[
559,
560
],
[
559,
561
],
[
558,
563
],
[
563,
564
],
[
564,
565
],
[
565,
566
],
[
565,
567
],
[
563,
568
],
[
568,
569
],
[
568,
570
],
[
563,
571
],
[
571,
572
],
[
572,
573
],
[
563,
574
],
[
574,
575
],
[
575,
576
],
[
576,
577
],
[
576,
578
],
[
575,
579
],
[
579,
580
],
[
558,
581
],
[
581,
582
],
[
556,
583
],
[
583,
584
],
[
272,
585
],
[
585,
586
],
[
585,
587
],
[
587,
588
],
[
588,
589
],
[
589,
590
],
[
590,
591
],
[
589,
592
],
[
592,
593
],
[
272,
594
],
[
594,
595
],
[
594,
596
],
[
596,
597
],
[
597,
598
],
[
597,
599
],
[
596,
601
],
[
601,
602
],
[
602,
603
],
[
603,
604
],
[
603,
605
],
[
601,
606
],
[
606,
607
],
[
606,
608
],
[
601,
609
],
[
609,
610
],
[
610,
611
],
[
601,
612
],
[
612,
613
],
[
613,
614
],
[
614,
615
],
[
614,
616
],
[
613,
617
],
[
617,
618
],
[
596,
619
],
[
619,
620
],
[
594,
621
],
[
621,
622
],
[
272,
623
],
[
623,
624
],
[
623,
625
],
[
625,
626
],
[
626,
627
],
[
627,
628
],
[
627,
629
],
[
626,
630
],
[
630,
631
],
[
631,
632
],
[
632,
633
],
[
0,
634
],
[
634,
635
],
[
634,
636
]
] | [
"import java.util.*;\nimport java.io.*;\nimport java.math.*;\n\npublic class Main {\n\n\tvoid solve (FastScanner in, PrintWriter out, Methods ms) {\n\n\t\tint n = in.nextInt(), q = in.nextInt();\n\t\tArrayDeque<Process> dq = new ArrayDeque<>();\n\t\tfor (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));\n\t\t\n\t\tint time = 0;\n\t\twhile (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess (String s, int n) {\n\t\t\tname = s; time = n;\n\t\t}\n\t\tvoid decTime (int n) {\n\t\t\ttime -= n;\n\t\t}\n\t}\n\n\n\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tFastScanner in = new FastScanner(System.in);\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tMethods ms = new Methods();\n\t\tmain.solve(in, out, ms);\n\t\tin.close();\n\t\tout.close();\n\t}\n\n\tstatic class Methods {\n\n\t\tpublic void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}\n\n\t\tpublic void yesno (PrintWriter out, boolean b) {out.println(b?\"Yes\":\"No\");}\n\n\t\tpublic void YESNO (PrintWriter out, boolean b) {out.println(b?\"YES\":\"NO\");}\n\n\t\tpublic int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}\n\n\t\tpublic int min (int... ar) {Arrays.sort(ar); return ar[0];}\n\n\t\tpublic long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}\n\n\t\tpublic long lcm (long a, long b) {return a/gcd(a,b)*b;}\n\n\t}\n\n\tstatic class FastScanner {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int length = 0, p = 0;\n\n\t\tpublic FastScanner (InputStream stream) {\n\t\t\tin = stream;\n\t\t}\n\n\t\tpublic boolean hasNextByte () {\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic int readByte () {\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}\n\n\t\tpublic boolean isPrintable (int n) {return 33<=n&&n<=126;}\n\n\t\tpublic void skip () {\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}\n\n\t\tpublic boolean hasNext () {skip(); return hasNextByte();}\n\n\t\tpublic String next () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic String[] nextArray (int n) {\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic int nextInt () {return Math.toIntExact(nextLong());}\n\n\t\tpublic int[] nextIntArray (int n) {\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic long nextLong () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}\n\n\t\tpublic long[] nextLongArray (int n) {\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic double nextDouble () {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic double[] nextDoubleArray (int n) {\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic void close () {\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}\n\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"import java.math.*;",
"math.*",
"java",
"public class Main {\n\n\tvoid solve (FastScanner in, PrintWriter out, Methods ms) {\n\n\t\tint n = in.nextInt(), q = in.nextInt();\n\t\tArrayDeque<Process> dq = new ArrayDeque<>();\n\t\tfor (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));\n\t\t\n\t\tint time = 0;\n\t\twhile (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess (String s, int n) {\n\t\t\tname = s; time = n;\n\t\t}\n\t\tvoid decTime (int n) {\n\t\t\ttime -= n;\n\t\t}\n\t}\n\n\n\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tFastScanner in = new FastScanner(System.in);\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tMethods ms = new Methods();\n\t\tmain.solve(in, out, ms);\n\t\tin.close();\n\t\tout.close();\n\t}\n\n\tstatic class Methods {\n\n\t\tpublic void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}\n\n\t\tpublic void yesno (PrintWriter out, boolean b) {out.println(b?\"Yes\":\"No\");}\n\n\t\tpublic void YESNO (PrintWriter out, boolean b) {out.println(b?\"YES\":\"NO\");}\n\n\t\tpublic int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}\n\n\t\tpublic int min (int... ar) {Arrays.sort(ar); return ar[0];}\n\n\t\tpublic long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}\n\n\t\tpublic long lcm (long a, long b) {return a/gcd(a,b)*b;}\n\n\t}\n\n\tstatic class FastScanner {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int length = 0, p = 0;\n\n\t\tpublic FastScanner (InputStream stream) {\n\t\t\tin = stream;\n\t\t}\n\n\t\tpublic boolean hasNextByte () {\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic int readByte () {\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}\n\n\t\tpublic boolean isPrintable (int n) {return 33<=n&&n<=126;}\n\n\t\tpublic void skip () {\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}\n\n\t\tpublic boolean hasNext () {skip(); return hasNextByte();}\n\n\t\tpublic String next () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic String[] nextArray (int n) {\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic int nextInt () {return Math.toIntExact(nextLong());}\n\n\t\tpublic int[] nextIntArray (int n) {\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic long nextLong () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}\n\n\t\tpublic long[] nextLongArray (int n) {\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic double nextDouble () {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic double[] nextDoubleArray (int n) {\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic void close () {\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}\n\n\t}\n\n}",
"Main",
"void solve (FastScanner in, PrintWriter out, Methods ms) {\n\n\t\tint n = in.nextInt(), q = in.nextInt();\n\t\tArrayDeque<Process> dq = new ArrayDeque<>();\n\t\tfor (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));\n\t\t\n\t\tint time = 0;\n\t\twhile (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}",
"solve",
"{\n\n\t\tint n = in.nextInt(), q = in.nextInt();\n\t\tArrayDeque<Process> dq = new ArrayDeque<>();\n\t\tfor (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));\n\t\t\n\t\tint time = 0;\n\t\twhile (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}",
"int n = in.nextInt()",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"q = in.nextInt();",
"q",
"in.nextInt()",
"in.nextInt",
"in",
"ArrayDeque<Process> dq = new ArrayDeque<>();",
"dq",
"new ArrayDeque<>()",
"for (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"dq.addLast(new Process(in.next(), in.nextInt()));",
"dq.addLast(new Process(in.next(), in.nextInt()))",
"dq.addLast",
"dq",
"new Process(in.next(), in.nextInt())",
"int time = 0;",
"time",
"0",
"while (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}",
"dq.size() > 0",
"dq.size()",
"dq.size",
"dq",
"0",
"{\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}",
"if (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}",
"dq.getFirst().time <= q",
"dq.getFirst().time",
"dq.getFirst()",
"dq.getFirst",
"dq",
"dq.getFirst().time",
"q",
"{\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}",
"time += dq.getFirst().time",
"time",
"dq.getFirst().time",
"dq.getFirst()",
"dq.getFirst",
"dq",
"dq.getFirst().time",
"out.println(dq.getFirst().name+\" \"+time)",
"out.println",
"out",
"dq.getFirst().name+\" \"+time",
"dq.getFirst().name+\" \"+time",
"dq.getFirst().name",
"dq.getFirst()",
"dq.getFirst",
"dq",
"dq.getFirst().name",
"\" \"",
"time",
"dq.removeFirst()",
"dq.removeFirst",
"dq",
"{\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}",
"time += q",
"time",
"q",
"dq.getFirst().decTime(q)",
"dq.getFirst().decTime",
"dq.getFirst()",
"dq.getFirst",
"dq",
"q",
"dq.addLast(dq.removeFirst())",
"dq.addLast",
"dq",
"dq.removeFirst()",
"dq.removeFirst",
"dq",
"FastScanner in",
"in",
"PrintWriter out",
"out",
"Methods ms",
"ms",
"public static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tFastScanner in = new FastScanner(System.in);\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tMethods ms = new Methods();\n\t\tmain.solve(in, out, ms);\n\t\tin.close();\n\t\tout.close();\n\t}",
"main",
"{\n\t\tMain main = new Main();\n\t\tFastScanner in = new FastScanner(System.in);\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tMethods ms = new Methods();\n\t\tmain.solve(in, out, ms);\n\t\tin.close();\n\t\tout.close();\n\t}",
"Main main = new Main();",
"main",
"new Main()",
"FastScanner in = new FastScanner(System.in);",
"in",
"new FastScanner(System.in)",
"PrintWriter out = new PrintWriter(System.out);",
"out",
"new PrintWriter(System.out)",
"Methods ms = new Methods();",
"ms",
"new Methods()",
"main.solve(in, out, ms)",
"main.solve",
"main",
"in",
"out",
"ms",
"in.close()",
"in.close",
"in",
"out.close()",
"out.close",
"out",
"String[] args",
"args",
"static class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess (String s, int n) {\n\t\t\tname = s; time = n;\n\t\t}\n\t\tvoid decTime (int n) {\n\t\t\ttime -= n;\n\t\t}\n\t}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process (String s, int n) {\n\t\t\tname = s; time = n;\n\t\t}",
"Process",
"{\n\t\t\tname = s; time = n;\n\t\t}",
"name = s",
"name",
"s",
"time = n",
"time",
"n",
"String s",
"s",
"int n",
"n",
"void decTime (int n) {\n\t\t\ttime -= n;\n\t\t}",
"decTime",
"{\n\t\t\ttime -= n;\n\t\t}",
"time -= n",
"time",
"n",
"int n",
"n",
"static class Methods {\n\n\t\tpublic void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}\n\n\t\tpublic void yesno (PrintWriter out, boolean b) {out.println(b?\"Yes\":\"No\");}\n\n\t\tpublic void YESNO (PrintWriter out, boolean b) {out.println(b?\"YES\":\"NO\");}\n\n\t\tpublic int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}\n\n\t\tpublic int min (int... ar) {Arrays.sort(ar); return ar[0];}\n\n\t\tpublic long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}\n\n\t\tpublic long lcm (long a, long b) {return a/gcd(a,b)*b;}\n\n\t}",
"Methods",
"public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}",
"print",
"{System.out.println(Arrays.deepToString(ar));}",
"System.out.println(Arrays.deepToString(ar))",
"System.out.println",
"System.out",
"System",
"System.out",
"Arrays.deepToString(ar)",
"Arrays.deepToString",
"Arrays",
"ar",
"Object... ar",
"ar",
"public void yesno (PrintWriter out, boolean b) {out.println(b?\"Yes\":\"No\");}",
"yesno",
"{out.println(b?\"Yes\":\"No\");}",
"out.println(b?\"Yes\":\"No\")",
"out.println",
"out",
"b?\"Yes\":\"No\"",
"b",
"\"Yes\"",
"\"No\"",
"PrintWriter out",
"out",
"boolean b",
"b",
"public void YESNO (PrintWriter out, boolean b) {out.println(b?\"YES\":\"NO\");}",
"YESNO",
"{out.println(b?\"YES\":\"NO\");}",
"out.println(b?\"YES\":\"NO\")",
"out.println",
"out",
"b?\"YES\":\"NO\"",
"b",
"\"YES\"",
"\"NO\"",
"PrintWriter out",
"out",
"boolean b",
"b",
"public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}",
"max",
"{Arrays.sort(ar); return ar[ar.length-1];}",
"Arrays.sort(ar)",
"Arrays.sort",
"Arrays",
"ar",
"return ar[ar.length-1];",
"ar[ar.length-1]",
"ar",
"ar.length-1",
"ar.length",
"ar",
"ar.length",
"1",
"int... ar",
"ar",
"public int min (int... ar) {Arrays.sort(ar); return ar[0];}",
"min",
"{Arrays.sort(ar); return ar[0];}",
"Arrays.sort(ar)",
"Arrays.sort",
"Arrays",
"ar",
"return ar[0];",
"ar[0]",
"ar",
"0",
"int... ar",
"ar",
"public long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}",
"gcd",
"{return b>0?gcd(b,a%b):a;}",
"return b>0?gcd(b,a%b):a;",
"b>0?gcd(b,a%b):a",
"b>0",
"b",
"0",
"gcd(b,a%b)",
"gcd",
"b",
"a%b",
"a",
"b",
"a",
"long a",
"a",
"long b",
"b",
"public long lcm (long a, long b) {return a/gcd(a,b)*b;}",
"lcm",
"{return a/gcd(a,b)*b;}",
"return a/gcd(a,b)*b;",
"a/gcd(a,b)*b",
"a/gcd(a,b)",
"a",
"gcd(a,b)",
"gcd",
"a",
"b",
"b",
"long a",
"a",
"long b",
"b",
"static class FastScanner {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int length = 0, p = 0;\n\n\t\tpublic FastScanner (InputStream stream) {\n\t\t\tin = stream;\n\t\t}\n\n\t\tpublic boolean hasNextByte () {\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic int readByte () {\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}\n\n\t\tpublic boolean isPrintable (int n) {return 33<=n&&n<=126;}\n\n\t\tpublic void skip () {\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}\n\n\t\tpublic boolean hasNext () {skip(); return hasNextByte();}\n\n\t\tpublic String next () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic String[] nextArray (int n) {\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic int nextInt () {return Math.toIntExact(nextLong());}\n\n\t\tpublic int[] nextIntArray (int n) {\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic long nextLong () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}\n\n\t\tpublic long[] nextLongArray (int n) {\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic double nextDouble () {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic double[] nextDoubleArray (int n) {\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic void close () {\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}\n\n\t}",
"FastScanner",
"private InputStream in;",
"in",
"private byte[] buffer = new byte[1024];",
"buffer",
"new byte[1024]",
"1024",
"private int length = 0",
"length",
"0",
"p = 0;",
"p",
"0",
"public FastScanner (InputStream stream) {\n\t\t\tin = stream;\n\t\t}",
"FastScanner",
"{\n\t\t\tin = stream;\n\t\t}",
"in = stream",
"in",
"stream",
"InputStream stream",
"stream",
"public boolean hasNextByte () {\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}",
"hasNextByte",
"{\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}",
"if (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}",
"p < length",
"p",
"length",
"return true;",
"true",
"{\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}",
"p = 0",
"p",
"0",
"try {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}",
"catch (Exception e) {e.printStackTrace();}",
"Exception e",
"{e.printStackTrace();}",
"e.printStackTrace()",
"e.printStackTrace",
"e",
"{length = in.read(buffer);}",
"length = in.read(buffer)",
"length",
"in.read(buffer)",
"in.read",
"in",
"buffer",
"if (length <= 0) return false;",
"length <= 0",
"length",
"0",
"return false;",
"false",
"return true;",
"true",
"public int readByte () {\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}",
"readByte",
"{\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}",
"if (hasNextByte() == true) return buffer[p++];",
"hasNextByte() == true",
"hasNextByte()",
"hasNextByte",
"true",
"return buffer[p++];",
"buffer[p++]",
"buffer",
"p++",
"p",
"return -1;",
"-1",
"1",
"public boolean isPrintable (int n) {return 33<=n&&n<=126;}",
"isPrintable",
"{return 33<=n&&n<=126;}",
"return 33<=n&&n<=126;",
"33<=n&&n<=126",
"33<=n",
"33",
"n",
"n<=126",
"n",
"126",
"int n",
"n",
"public void skip () {\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}",
"skip",
"{\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}",
"while (hasNextByte() && !isPrintable(buffer[p])) p++;",
"hasNextByte() && !isPrintable(buffer[p])",
"hasNextByte()",
"hasNextByte",
"!isPrintable(buffer[p])",
"isPrintable(buffer[p])",
"isPrintable",
"buffer[p]",
"buffer",
"p",
"p++",
"p",
"public boolean hasNext () {skip(); return hasNextByte();}",
"hasNext",
"{skip(); return hasNextByte();}",
"skip()",
"skip",
"return hasNextByte();",
"hasNextByte()",
"hasNextByte",
"public String next () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}",
"next",
"{\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}",
"if (!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int t = readByte();",
"t",
"readByte()",
"readByte",
"while (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}",
"isPrintable(t)",
"isPrintable",
"t",
"{\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}",
"sb.appendCodePoint(t)",
"sb.appendCodePoint",
"sb",
"t",
"t = readByte()",
"t",
"readByte()",
"readByte",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"public String[] nextArray (int n) {\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}",
"nextArray",
"{\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}",
"String[] ar = new String[n];",
"ar",
"new String[n]",
"n",
"for (int i=0; i<n; i++) ar[i] = next();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"ar[i] = next();",
"ar[i] = next()",
"ar[i]",
"ar",
"i",
"next()",
"next",
"return ar;",
"ar",
"int n",
"n",
"public int nextInt () {return Math.toIntExact(nextLong());}",
"nextInt",
"{return Math.toIntExact(nextLong());}",
"return Math.toIntExact(nextLong());",
"Math.toIntExact(nextLong())",
"Math.toIntExact",
"Math",
"nextLong()",
"nextLong",
"public int[] nextIntArray (int n) {\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}",
"nextIntArray",
"{\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}",
"int[] ar = new int[n];",
"ar",
"new int[n]",
"n",
"for (int i=0; i<n; i++) ar[i] = nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"ar[i] = nextInt();",
"ar[i] = nextInt()",
"ar[i]",
"ar",
"i",
"nextInt()",
"nextInt",
"return ar;",
"ar",
"int n",
"n",
"public long nextLong () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}",
"nextLong",
"{\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}",
"if (!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"boolean minus = false;",
"minus",
"false",
"int temp = readByte();",
"temp",
"readByte()",
"readByte",
"if (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}",
"temp == '-'",
"temp",
"'-'",
"{\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}",
"minus = true",
"minus",
"true",
"temp = readByte()",
"temp",
"readByte()",
"readByte",
"if (temp<'0' || '9'<temp) throw new NumberFormatException();",
"temp<'0' || '9'<temp",
"temp<'0'",
"temp",
"'0'",
"'9'<temp",
"'9'",
"temp",
"throw new NumberFormatException();",
"new NumberFormatException()",
"long n = 0;",
"n",
"0",
"while (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}",
"isPrintable(temp)",
"isPrintable",
"temp",
"{\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}",
"if ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();",
"'0'<=temp && temp<='9'",
"'0'<=temp",
"'0'",
"temp",
"temp<='9'",
"temp",
"'9'",
"{\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}",
"n *= 10",
"n",
"10",
"n += temp - '0'",
"n",
"temp - '0'",
"temp",
"'0'",
"throw new NumberFormatException();",
"new NumberFormatException()",
"temp = readByte()",
"temp",
"readByte()",
"readByte",
"return minus? -n : n;",
"minus? -n : n",
"minus",
"-n",
"n",
"n",
"public long[] nextLongArray (int n) {\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}",
"nextLongArray",
"{\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}",
"long[] ar = new long[n];",
"ar",
"new long[n]",
"n",
"for (int i=0; i<n; i++) ar[i] = nextLong();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"ar[i] = nextLong();",
"ar[i] = nextLong()",
"ar[i]",
"ar",
"i",
"nextLong()",
"nextLong",
"return ar;",
"ar",
"int n",
"n",
"public double nextDouble () {\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"nextDouble",
"{\n\t\t\treturn Double.parseDouble(next());\n\t\t}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"public double[] nextDoubleArray (int n) {\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}",
"nextDoubleArray",
"{\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}",
"double[] ar = new double[n];",
"ar",
"new double[n]",
"n",
"for (int i=0; i<n; i++) ar[i] = nextDouble();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"ar[i] = nextDouble();",
"ar[i] = nextDouble()",
"ar[i]",
"ar",
"i",
"nextDouble()",
"nextDouble",
"return ar;",
"ar",
"int n",
"n",
"public void close () {\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}",
"close",
"{\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}",
"try {in.close();}\n\t\t\tcatch(Exception e){}",
"catch(Exception e){}",
"Exception e",
"{}",
"{in.close();}",
"in.close()",
"in.close",
"in",
"public class Main {\n\n\tvoid solve (FastScanner in, PrintWriter out, Methods ms) {\n\n\t\tint n = in.nextInt(), q = in.nextInt();\n\t\tArrayDeque<Process> dq = new ArrayDeque<>();\n\t\tfor (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));\n\t\t\n\t\tint time = 0;\n\t\twhile (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess (String s, int n) {\n\t\t\tname = s; time = n;\n\t\t}\n\t\tvoid decTime (int n) {\n\t\t\ttime -= n;\n\t\t}\n\t}\n\n\n\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tFastScanner in = new FastScanner(System.in);\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tMethods ms = new Methods();\n\t\tmain.solve(in, out, ms);\n\t\tin.close();\n\t\tout.close();\n\t}\n\n\tstatic class Methods {\n\n\t\tpublic void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}\n\n\t\tpublic void yesno (PrintWriter out, boolean b) {out.println(b?\"Yes\":\"No\");}\n\n\t\tpublic void YESNO (PrintWriter out, boolean b) {out.println(b?\"YES\":\"NO\");}\n\n\t\tpublic int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}\n\n\t\tpublic int min (int... ar) {Arrays.sort(ar); return ar[0];}\n\n\t\tpublic long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}\n\n\t\tpublic long lcm (long a, long b) {return a/gcd(a,b)*b;}\n\n\t}\n\n\tstatic class FastScanner {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int length = 0, p = 0;\n\n\t\tpublic FastScanner (InputStream stream) {\n\t\t\tin = stream;\n\t\t}\n\n\t\tpublic boolean hasNextByte () {\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic int readByte () {\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}\n\n\t\tpublic boolean isPrintable (int n) {return 33<=n&&n<=126;}\n\n\t\tpublic void skip () {\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}\n\n\t\tpublic boolean hasNext () {skip(); return hasNextByte();}\n\n\t\tpublic String next () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic String[] nextArray (int n) {\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic int nextInt () {return Math.toIntExact(nextLong());}\n\n\t\tpublic int[] nextIntArray (int n) {\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic long nextLong () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}\n\n\t\tpublic long[] nextLongArray (int n) {\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic double nextDouble () {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic double[] nextDoubleArray (int n) {\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic void close () {\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}\n\n\t}\n\n}",
"public class Main {\n\n\tvoid solve (FastScanner in, PrintWriter out, Methods ms) {\n\n\t\tint n = in.nextInt(), q = in.nextInt();\n\t\tArrayDeque<Process> dq = new ArrayDeque<>();\n\t\tfor (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));\n\t\t\n\t\tint time = 0;\n\t\twhile (dq.size() > 0) {\n\t\t\t\n\t\t\tif (dq.getFirst().time <= q) {\n\t\t\t\ttime += dq.getFirst().time;\n\t\t\t\tout.println(dq.getFirst().name+\" \"+time);\n\t\t\t\tdq.removeFirst();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttime += q;\n\t\t\t\tdq.getFirst().decTime(q);\n\t\t\t\tdq.addLast(dq.removeFirst());\n\t\t\t}\n\t\t\t\n\t\t}\n\n\t}\n\t\n\tstatic class Process {\n\t\tString name;\n\t\tint time;\n\t\tProcess (String s, int n) {\n\t\t\tname = s; time = n;\n\t\t}\n\t\tvoid decTime (int n) {\n\t\t\ttime -= n;\n\t\t}\n\t}\n\n\n\n\tpublic static void main(String[] args) {\n\t\tMain main = new Main();\n\t\tFastScanner in = new FastScanner(System.in);\n\t\tPrintWriter out = new PrintWriter(System.out);\n\t\tMethods ms = new Methods();\n\t\tmain.solve(in, out, ms);\n\t\tin.close();\n\t\tout.close();\n\t}\n\n\tstatic class Methods {\n\n\t\tpublic void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}\n\n\t\tpublic void yesno (PrintWriter out, boolean b) {out.println(b?\"Yes\":\"No\");}\n\n\t\tpublic void YESNO (PrintWriter out, boolean b) {out.println(b?\"YES\":\"NO\");}\n\n\t\tpublic int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}\n\n\t\tpublic int min (int... ar) {Arrays.sort(ar); return ar[0];}\n\n\t\tpublic long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}\n\n\t\tpublic long lcm (long a, long b) {return a/gcd(a,b)*b;}\n\n\t}\n\n\tstatic class FastScanner {\n\n\t\tprivate InputStream in;\n\t\tprivate byte[] buffer = new byte[1024];\n\t\tprivate int length = 0, p = 0;\n\n\t\tpublic FastScanner (InputStream stream) {\n\t\t\tin = stream;\n\t\t}\n\n\t\tpublic boolean hasNextByte () {\n\t\t\tif (p < length) return true;\n\t\t\telse {\n\t\t\t\tp = 0;\n\t\t\t\ttry {length = in.read(buffer);}\n\t\t\t\tcatch (Exception e) {e.printStackTrace();}\n\t\t\t\tif (length <= 0) return false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic int readByte () {\n\t\t\tif (hasNextByte() == true) return buffer[p++];\n\t\t\treturn -1;\n\t\t}\n\n\t\tpublic boolean isPrintable (int n) {return 33<=n&&n<=126;}\n\n\t\tpublic void skip () {\n\t\t\twhile (hasNextByte() && !isPrintable(buffer[p])) p++;\n\t\t}\n\n\t\tpublic boolean hasNext () {skip(); return hasNextByte();}\n\n\t\tpublic String next () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tStringBuilder sb = new StringBuilder();\n\t\t\tint t = readByte();\n\t\t\twhile (isPrintable(t)) {\n\t\t\t\tsb.appendCodePoint(t);\n\t\t\t\tt = readByte();\n\t\t\t}\n\t\t\treturn sb.toString();\n\t\t}\n\n\t\tpublic String[] nextArray (int n) {\n\t\t\tString[] ar = new String[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = next();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic int nextInt () {return Math.toIntExact(nextLong());}\n\n\t\tpublic int[] nextIntArray (int n) {\n\t\t\tint[] ar = new int[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextInt();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic long nextLong () {\n\t\t\tif (!hasNext()) throw new NoSuchElementException();\n\t\t\tboolean minus = false;\n\t\t\tint temp = readByte();\n\t\t\tif (temp == '-') {\n\t\t\t\tminus = true;\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\tif (temp<'0' || '9'<temp) throw new NumberFormatException();\n\t\t\tlong n = 0;\n\t\t\twhile (isPrintable(temp)) {\n\t\t\t\tif ('0'<=temp && temp<='9') {\n\t\t\t\t\tn *= 10;\n\t\t\t\t\tn += temp - '0';\n\t\t\t\t}\n\t\t\t\telse throw new NumberFormatException();\n\t\t\t\ttemp = readByte();\n\t\t\t}\n\t\t\treturn minus? -n : n;\n\t\t}\n\n\t\tpublic long[] nextLongArray (int n) {\n\t\t\tlong[] ar = new long[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextLong();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic double nextDouble () {\n\t\t\treturn Double.parseDouble(next());\n\t\t}\n\n\t\tpublic double[] nextDoubleArray (int n) {\n\t\t\tdouble[] ar = new double[n];\n\t\t\tfor (int i=0; i<n; i++) ar[i] = nextDouble();\n\t\t\treturn ar;\n\t\t}\n\n\t\tpublic void close () {\n\t\t\ttry {in.close();}\n\t\t\tcatch(Exception e){}\n\t\t}\n\n\t}\n\n}",
"Main"
] | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
void solve (FastScanner in, PrintWriter out, Methods ms) {
int n = in.nextInt(), q = in.nextInt();
ArrayDeque<Process> dq = new ArrayDeque<>();
for (int i=0; i<n; i++) dq.addLast(new Process(in.next(), in.nextInt()));
int time = 0;
while (dq.size() > 0) {
if (dq.getFirst().time <= q) {
time += dq.getFirst().time;
out.println(dq.getFirst().name+" "+time);
dq.removeFirst();
}
else {
time += q;
dq.getFirst().decTime(q);
dq.addLast(dq.removeFirst());
}
}
}
static class Process {
String name;
int time;
Process (String s, int n) {
name = s; time = n;
}
void decTime (int n) {
time -= n;
}
}
public static void main(String[] args) {
Main main = new Main();
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
Methods ms = new Methods();
main.solve(in, out, ms);
in.close();
out.close();
}
static class Methods {
public void print (Object... ar) {System.out.println(Arrays.deepToString(ar));}
public void yesno (PrintWriter out, boolean b) {out.println(b?"Yes":"No");}
public void YESNO (PrintWriter out, boolean b) {out.println(b?"YES":"NO");}
public int max (int... ar) {Arrays.sort(ar); return ar[ar.length-1];}
public int min (int... ar) {Arrays.sort(ar); return ar[0];}
public long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
public long lcm (long a, long b) {return a/gcd(a,b)*b;}
}
static class FastScanner {
private InputStream in;
private byte[] buffer = new byte[1024];
private int length = 0, p = 0;
public FastScanner (InputStream stream) {
in = stream;
}
public boolean hasNextByte () {
if (p < length) return true;
else {
p = 0;
try {length = in.read(buffer);}
catch (Exception e) {e.printStackTrace();}
if (length <= 0) return false;
}
return true;
}
public int readByte () {
if (hasNextByte() == true) return buffer[p++];
return -1;
}
public boolean isPrintable (int n) {return 33<=n&&n<=126;}
public void skip () {
while (hasNextByte() && !isPrintable(buffer[p])) p++;
}
public boolean hasNext () {skip(); return hasNextByte();}
public String next () {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int t = readByte();
while (isPrintable(t)) {
sb.appendCodePoint(t);
t = readByte();
}
return sb.toString();
}
public String[] nextArray (int n) {
String[] ar = new String[n];
for (int i=0; i<n; i++) ar[i] = next();
return ar;
}
public int nextInt () {return Math.toIntExact(nextLong());}
public int[] nextIntArray (int n) {
int[] ar = new int[n];
for (int i=0; i<n; i++) ar[i] = nextInt();
return ar;
}
public long nextLong () {
if (!hasNext()) throw new NoSuchElementException();
boolean minus = false;
int temp = readByte();
if (temp == '-') {
minus = true;
temp = readByte();
}
if (temp<'0' || '9'<temp) throw new NumberFormatException();
long n = 0;
while (isPrintable(temp)) {
if ('0'<=temp && temp<='9') {
n *= 10;
n += temp - '0';
}
else throw new NumberFormatException();
temp = readByte();
}
return minus? -n : n;
}
public long[] nextLongArray (int n) {
long[] ar = new long[n];
for (int i=0; i<n; i++) ar[i] = nextLong();
return ar;
}
public double nextDouble () {
return Double.parseDouble(next());
}
public double[] nextDoubleArray (int n) {
double[] ar = new double[n];
for (int i=0; i<n; i++) ar[i] = nextDouble();
return ar;
}
public void close () {
try {in.close();}
catch(Exception e){}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
18,
4,
18,
13,
17,
17,
41,
13,
4,
18,
13,
18,
4,
18,
13,
17,
17,
41,
13,
17,
41,
13,
20,
42,
4,
18,
13,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
17,
41,
13,
4,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
2,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
17,
17,
17,
13,
30,
0,
13,
13,
41,
13,
2,
2,
18,
4,
18,
13,
17,
17,
17,
4,
18,
13,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
18,
4,
18,
13,
17,
17,
29,
2,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
152,
5
],
[
152,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
19,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
23,
26
],
[
22,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
33,
38
],
[
8,
39
],
[
39,
40
],
[
39,
41
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
8,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
45,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
8,
56
],
[
56,
57
],
[
57,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
60,
64
],
[
59,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
68,
71
],
[
65,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
74,
76
],
[
74,
77
],
[
65,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
86,
86
],
[
86,
87
],
[
86,
88
],
[
86,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
90,
95
],
[
96,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
97,
102
],
[
96,
103
],
[
96,
104
],
[
78,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
109,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
113,
118
],
[
112,
119
],
[
112,
120
],
[
120,
121
],
[
121,
122
],
[
105,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
6,
127
],
[
127,
128
],
[
152,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
137,
142
],
[
131,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
129,
147
],
[
147,
148
],
[
129,
149
],
[
149,
150
],
[
0,
151
],
[
151,
152
],
[
151,
153
]
] | [
"import java.util.*;\npublic class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"Main",
"/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"String input = s.nextLine();",
"input",
"s.nextLine()",
"s.nextLine",
"s",
"Integer number = Integer.parseInt(input.split(\" \")[0]);",
"number",
"Integer.parseInt(input.split(\" \")[0])",
"Integer.parseInt",
"Integer",
"input.split(\" \")[0]",
"input.split(\" \")",
"input.split",
"input",
"\" \"",
"0",
"Integer quantum = Integer.parseInt(input.split(\" \")[1]);",
"quantum",
"Integer.parseInt(input.split(\" \")[1])",
"Integer.parseInt",
"Integer",
"input.split(\" \")[1]",
"input.split(\" \")",
"input.split",
"input",
"\" \"",
"1",
"Integer current_time = 0;",
"current_time",
"0",
"ArrayList<String> queue = new ArrayList<String>();",
"queue",
"new ArrayList<String>()",
"while(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}",
"s.hasNext()",
"s.hasNext",
"s",
"{\n\t\t\tqueue.add(s.nextLine());\n\t\t}",
"queue.add(s.nextLine())",
"queue.add",
"queue",
"s.nextLine()",
"s.nextLine",
"s",
"s.close()",
"s.close",
"s",
"while(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}",
"String process = queue.remove(0);",
"process",
"queue.remove(0)",
"queue.remove",
"queue",
"0",
"Integer result = get_time(process, quantum);",
"result",
"get_time(process, quantum)",
"get_time",
"process",
"quantum",
"if(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}",
"result <= 0",
"result",
"0",
"{\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}",
"current_time = current_time + quantum + result",
"current_time",
"current_time + quantum + result",
"current_time + quantum + result",
"current_time",
"quantum",
"result",
"System.out.println(process.split(\" \")[0] + \" \" + current_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.split(\" \")[0] + \" \" + current_time",
"process.split(\" \")[0] + \" \" + current_time",
"process.split(\" \")[0]",
"process.split(\" \")",
"process.split",
"process",
"\" \"",
"0",
"\" \"",
"current_time",
"{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}",
"current_time += quantum",
"current_time",
"quantum",
"String process_result = process.split(\" \")[0] + \" \" + result.toString();",
"process_result",
"process.split(\" \")[0] + \" \" + result.toString()",
"process.split(\" \")[0] + \" \" + result.toString()",
"process.split(\" \")[0]",
"process.split(\" \")",
"process.split",
"process",
"\" \"",
"0",
"\" \"",
"result.toString()",
"result.toString",
"result",
"queue.add(process_result)",
"queue.add",
"queue",
"process_result",
"String[] args",
"args",
"private static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}",
"get_time",
"{\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}",
"Integer time = Integer.parseInt(process.split(\" \")[1]);",
"time",
"Integer.parseInt(process.split(\" \")[1])",
"Integer.parseInt",
"Integer",
"process.split(\" \")[1]",
"process.split(\" \")",
"process.split",
"process",
"\" \"",
"1",
"return time - quantum;",
"time - quantum",
"time",
"quantum",
"String process",
"process",
"Integer quantum",
"quantum",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\t\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\tSystem.out.println(process.split(\" \")[0] + \" \" + current_time);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t}\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String input = s.nextLine();
Integer number = Integer.parseInt(input.split(" ")[0]);
Integer quantum = Integer.parseInt(input.split(" ")[1]);
Integer current_time = 0;
ArrayList<String> queue = new ArrayList<String>();
while(s.hasNext()){
queue.add(s.nextLine());
}
s.close();
while(queue.size() > 0){
String process = queue.remove(0);
Integer result = get_time(process, quantum);
if(result <= 0){
current_time = current_time + quantum + result;
System.out.println(process.split(" ")[0] + " " + current_time);
}
else{
current_time += quantum;
String process_result = process.split(" ")[0] + " " + result.toString();
queue.add(process_result);
}
}
}
private static Integer get_time(String process, Integer quantum){
Integer time = Integer.parseInt(process.split(" ")[1]);
return time - quantum;
}
} |
[
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,
0,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
17,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
17,
17,
4,
18,
13,
20,
41,
13,
17,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
2,
2,
2,
4,
18,
13,
17,
13,
17,
30,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
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,
29,
18,
36,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
20,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
20,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
36,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
20,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
52,
57
],
[
20,
58
],
[
58,
59
],
[
58,
60
],
[
20,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
61,
66
],
[
66,
67
],
[
66,
68
],
[
61,
69
],
[
69,
70
],
[
70,
71
],
[
61,
72
],
[
73,
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
],
[
85,
88
],
[
73,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
97,
102
],
[
73,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
20,
107
],
[
107,
108
],
[
107,
109
],
[
20,
110
],
[
110,
111
],
[
110,
112
],
[
20,
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
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
141,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
141,
145
],
[
140,
146
],
[
141,
147
],
[
124,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
149,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
152,
156
],
[
148,
157
],
[
157,
158
],
[
157,
159
],
[
148,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
20,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
18,
170
],
[
170,
171
],
[
0,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
172,
176
],
[
176,
177
],
[
172,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
180,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
178,
191
],
[
191,
192
],
[
178,
193
],
[
193,
194
],
[
172,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
195,
203
],
[
203,
204
],
[
172,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
172,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
216,
218
],
[
215,
219
],
[
212,
220
],
[
220,
221
],
[
172,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
226,
228
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\nclass Main{\n public static void main(String[] args) throws IOException{\n\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\tString line;\n\n\tline = br.readLine();\n\tint n = Integer.parseInt(line.substring(0,line.indexOf(' ')));\n\tint q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\tDeque<Process> queue = new ArrayDeque<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}\n\tint elapse = 0;\n\tStringBuilder sb = new StringBuilder();\n\twhile (!queue.isEmpty()) {\n\t Process p = queue.poll();\n\t if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }\n\t}\n\tSystem.out.print(sb);\n }\n}\nclass Process{\n private String name;\n private int time;\n public Process(String name,int time){\n\tthis.name = name;\n\tthis.time = time;\n }\n public void setName(String name){\n\tthis.name = name;\n }\n public String getName(){\n\treturn this.name;\n }\n public void setTime(int time){\n\tthis.time = time;\n }\n public int getTime(){\n\treturn this.time; \n }\n}\n \n",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"class Main{\n public static void main(String[] args) throws IOException{\n\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\tString line;\n\n\tline = br.readLine();\n\tint n = Integer.parseInt(line.substring(0,line.indexOf(' ')));\n\tint q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\tDeque<Process> queue = new ArrayDeque<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}\n\tint elapse = 0;\n\tStringBuilder sb = new StringBuilder();\n\twhile (!queue.isEmpty()) {\n\t Process p = queue.poll();\n\t if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }\n\t}\n\tSystem.out.print(sb);\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\tString line;\n\n\tline = br.readLine();\n\tint n = Integer.parseInt(line.substring(0,line.indexOf(' ')));\n\tint q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\tDeque<Process> queue = new ArrayDeque<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}\n\tint elapse = 0;\n\tStringBuilder sb = new StringBuilder();\n\twhile (!queue.isEmpty()) {\n\t Process p = queue.poll();\n\t if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }\n\t}\n\tSystem.out.print(sb);\n }",
"main",
"{\n\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\tString line;\n\n\tline = br.readLine();\n\tint n = Integer.parseInt(line.substring(0,line.indexOf(' ')));\n\tint q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\tDeque<Process> queue = new ArrayDeque<Process>();\n\t\n\tfor(int i = 0;i < n;i++){\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}\n\tint elapse = 0;\n\tStringBuilder sb = new StringBuilder();\n\twhile (!queue.isEmpty()) {\n\t Process p = queue.poll();\n\t if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }\n\t}\n\tSystem.out.print(sb);\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String line;",
"line",
"line = br.readLine()",
"line",
"br.readLine()",
"br.readLine",
"br",
"int n = Integer.parseInt(line.substring(0,line.indexOf(' ')));",
"n",
"Integer.parseInt(line.substring(0,line.indexOf(' ')))",
"Integer.parseInt",
"Integer",
"line.substring(0,line.indexOf(' '))",
"line.substring",
"line",
"0",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"int q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));",
"q",
"Integer.parseInt(line.substring(line.indexOf(' ') + 1))",
"Integer.parseInt",
"Integer",
"line.substring(line.indexOf(' ') + 1)",
"line.substring",
"line",
"line.indexOf(' ') + 1",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"1",
"Deque<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for(int i = 0;i < n;i++){\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}",
"{\n\t line = br.readLine();\n\t String name = line.substring(0,line.indexOf(' '));\n\t int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));\n\t queue.offer(new Process(name,time));\n\t}",
"line = br.readLine()",
"line",
"br.readLine()",
"br.readLine",
"br",
"String name = line.substring(0,line.indexOf(' '));",
"name",
"line.substring(0,line.indexOf(' '))",
"line.substring",
"line",
"0",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));",
"time",
"Integer.parseInt(line.substring(line.indexOf(' ') + 1))",
"Integer.parseInt",
"Integer",
"line.substring(line.indexOf(' ') + 1)",
"line.substring",
"line",
"line.indexOf(' ') + 1",
"line.indexOf(' ')",
"line.indexOf",
"line",
"' '",
"1",
"queue.offer(new Process(name,time))",
"queue.offer",
"queue",
"new Process(name,time)",
"int elapse = 0;",
"elapse",
"0",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"while (!queue.isEmpty()) {\n\t Process p = queue.poll();\n\t if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }\n\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t Process p = queue.poll();\n\t if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }\n\t}",
"Process p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"if (p.getTime() <= q) {\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t } else {\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }",
"p.getTime() <= q",
"p.getTime()",
"p.getTime",
"p",
"q",
"{\n\t\telapse += p.getTime();\n\t\tsb.append(p.getName() + \" \" + elapse + \"\\n\");\n\t }",
"elapse += p.getTime()",
"elapse",
"p.getTime()",
"p.getTime",
"p",
"sb.append(p.getName() + \" \" + elapse + \"\\n\")",
"sb.append",
"sb",
"p.getName() + \" \" + elapse + \"\\n\"",
"elapse",
"p.getName() + \" \" + elapse + \"\\n\"",
"p.getName()",
"p.getName",
"p",
"\" \"",
"elapse",
"\"\\n\"",
"{\n\t\tp.setTime(p.getTime() - q);\n\t\telapse += q;\n\t\tqueue.offer(p);\n\t }",
"p.setTime(p.getTime() - q)",
"p.setTime",
"p",
"p.getTime() - q",
"p.getTime()",
"p.getTime",
"p",
"q",
"elapse += q",
"elapse",
"q",
"queue.offer(p)",
"queue.offer",
"queue",
"p",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"String[] args",
"args",
"class Process{\n private String name;\n private int time;\n public Process(String name,int time){\n\tthis.name = name;\n\tthis.time = time;\n }\n public void setName(String name){\n\tthis.name = name;\n }\n public String getName(){\n\treturn this.name;\n }\n public void setTime(int time){\n\tthis.time = time;\n }\n public int getTime(){\n\treturn this.time; \n }\n}",
"Process",
"private String name;",
"name",
"private int time;",
"time",
"public Process(String name,int time){\n\tthis.name = name;\n\tthis.time = time;\n }",
"Process",
"{\n\tthis.name = name;\n\tthis.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public void setName(String name){\n\tthis.name = name;\n }",
"setName",
"{\n\tthis.name = name;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"public String getName(){\n\treturn this.name;\n }",
"getName",
"{\n\treturn this.name;\n }",
"return this.name;",
"this.name",
"this",
"this.name",
"public void setTime(int time){\n\tthis.time = time;\n }",
"setTime",
"{\n\tthis.time = time;\n }",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"public int getTime(){\n\treturn this.time; \n }",
"getTime",
"{\n\treturn this.time; \n }",
"return this.time;",
"this.time",
"this",
"this.time"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
line = br.readLine();
int n = Integer.parseInt(line.substring(0,line.indexOf(' ')));
int q = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
Deque<Process> queue = new ArrayDeque<Process>();
for(int i = 0;i < n;i++){
line = br.readLine();
String name = line.substring(0,line.indexOf(' '));
int time = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
queue.offer(new Process(name,time));
}
int elapse = 0;
StringBuilder sb = new StringBuilder();
while (!queue.isEmpty()) {
Process p = queue.poll();
if (p.getTime() <= q) {
elapse += p.getTime();
sb.append(p.getName() + " " + elapse + "\n");
} else {
p.setTime(p.getTime() - q);
elapse += q;
queue.offer(p);
}
}
System.out.print(sb);
}
}
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 this.name;
}
public void setTime(int time){
this.time = time;
}
public int getTime(){
return this.time;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
18,
4,
18,
13,
17,
17,
41,
13,
4,
18,
13,
18,
4,
18,
13,
17,
17,
41,
13,
17,
41,
13,
20,
42,
4,
18,
13,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
17,
41,
13,
4,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
2,
13,
13,
13,
0,
13,
2,
2,
2,
2,
13,
18,
4,
18,
13,
17,
17,
17,
13,
17,
30,
0,
13,
13,
41,
13,
2,
2,
18,
4,
18,
13,
17,
17,
17,
4,
18,
13,
4,
18,
13,
13,
14,
2,
4,
18,
13,
17,
30,
4,
18,
18,
13,
13,
13,
0,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
4,
18,
13,
18,
4,
18,
13,
17,
17,
29,
2,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
178,
5
],
[
178,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
19,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
23,
26
],
[
22,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
33,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
33,
38
],
[
8,
39
],
[
39,
40
],
[
39,
41
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
8,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
45,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
8,
56
],
[
56,
57
],
[
57,
58
],
[
8,
59
],
[
59,
60
],
[
59,
61
],
[
8,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
68,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
77,
80
],
[
68,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
89,
89
],
[
89,
90
],
[
89,
91
],
[
89,
92
],
[
85,
93
],
[
93,
94
],
[
93,
95
],
[
98,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
100,
105
],
[
97,
106
],
[
96,
107
],
[
98,
108
],
[
81,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
116,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
117,
122
],
[
116,
123
],
[
116,
124
],
[
124,
125
],
[
125,
126
],
[
109,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
68,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
132,
136
],
[
131,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
138,
143
],
[
137,
144
],
[
144,
145
],
[
144,
146
],
[
8,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
147,
152
],
[
6,
153
],
[
153,
154
],
[
178,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
164,
167
],
[
163,
168
],
[
157,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
155,
173
],
[
173,
174
],
[
155,
175
],
[
175,
176
],
[
0,
177
],
[
177,
178
],
[
177,
179
]
] | [
"import java.util.*;\npublic class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\tString output = \"\";\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(output);\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\tString output = \"\";\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(output);\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"Main",
"/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\tString output = \"\";\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(output);\n\n\t}",
"main",
"{\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\tString output = \"\";\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(output);\n\n\t}",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"String input = s.nextLine();",
"input",
"s.nextLine()",
"s.nextLine",
"s",
"Integer number = Integer.parseInt(input.split(\" \")[0]);",
"number",
"Integer.parseInt(input.split(\" \")[0])",
"Integer.parseInt",
"Integer",
"input.split(\" \")[0]",
"input.split(\" \")",
"input.split",
"input",
"\" \"",
"0",
"Integer quantum = Integer.parseInt(input.split(\" \")[1]);",
"quantum",
"Integer.parseInt(input.split(\" \")[1])",
"Integer.parseInt",
"Integer",
"input.split(\" \")[1]",
"input.split(\" \")",
"input.split",
"input",
"\" \"",
"1",
"Integer current_time = 0;",
"current_time",
"0",
"ArrayList<String> queue = new ArrayList<String>();",
"queue",
"new ArrayList<String>()",
"while(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}",
"s.hasNext()",
"s.hasNext",
"s",
"{\n\t\t\tqueue.add(s.nextLine());\n\t\t}",
"queue.add(s.nextLine())",
"queue.add",
"queue",
"s.nextLine()",
"s.nextLine",
"s",
"s.close()",
"s.close",
"s",
"String output = \"\";",
"output",
"\"\"",
"while(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}",
"String process = queue.remove(0);",
"process",
"queue.remove(0)",
"queue.remove",
"queue",
"0",
"Integer result = get_time(process, quantum);",
"result",
"get_time(process, quantum)",
"get_time",
"process",
"quantum",
"if(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}",
"result <= 0",
"result",
"0",
"{\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}",
"current_time = current_time + quantum + result",
"current_time",
"current_time + quantum + result",
"current_time + quantum + result",
"current_time",
"quantum",
"result",
"output = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\"",
"output",
"output + process.split(\" \")[0] + \" \" + current_time + \"\\n\"",
"current_time",
"\" \"",
"output + process.split(\" \")[0] + \" \" + current_time + \"\\n\"",
"output",
"process.split(\" \")[0]",
"process.split(\" \")",
"process.split",
"process",
"\" \"",
"0",
"\" \"",
"current_time",
"\"\\n\"",
"{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}",
"current_time += quantum",
"current_time",
"quantum",
"String process_result = process.split(\" \")[0] + \" \" + result.toString();",
"process_result",
"process.split(\" \")[0] + \" \" + result.toString()",
"process.split(\" \")[0] + \" \" + result.toString()",
"process.split(\" \")[0]",
"process.split(\" \")",
"process.split",
"process",
"\" \"",
"0",
"\" \"",
"result.toString()",
"result.toString",
"result",
"queue.add(process_result)",
"queue.add",
"queue",
"process_result",
"if(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}",
"output.length() > 1000",
"output.length()",
"output.length",
"output",
"1000",
"{\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}",
"System.out.print(output)",
"System.out.print",
"System.out",
"System",
"System.out",
"output",
"output = \"\"",
"output",
"\"\"",
"System.out.print(output)",
"System.out.print",
"System.out",
"System",
"System.out",
"output",
"String[] args",
"args",
"private static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}",
"get_time",
"{\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}",
"Integer time = Integer.parseInt(process.split(\" \")[1]);",
"time",
"Integer.parseInt(process.split(\" \")[1])",
"Integer.parseInt",
"Integer",
"process.split(\" \")[1]",
"process.split(\" \")",
"process.split",
"process",
"\" \"",
"1",
"return time - quantum;",
"time - quantum",
"time",
"quantum",
"String process",
"process",
"Integer quantum",
"quantum",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\tString output = \"\";\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(output);\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"public class Main {\n\n\t/**\n\t * @param args\n\t */\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString input = s.nextLine();\n\t\tInteger number = Integer.parseInt(input.split(\" \")[0]);\n\t\tInteger quantum = Integer.parseInt(input.split(\" \")[1]);\n\t\tInteger current_time = 0;\n\t\tArrayList<String> queue = new ArrayList<String>();\n\t\twhile(s.hasNext()){\n\t\t\tqueue.add(s.nextLine());\n\t\t}\n\t\ts.close();\n\t\tString output = \"\";\n\t\twhile(queue.size() > 0){\n\t\t\tString process = queue.remove(0);\n\t\t\tInteger result = get_time(process, quantum);\n\t\t\tif(result <= 0){\n\t\t\t\tcurrent_time = current_time + quantum + result;\n\t\t\t\toutput = output + process.split(\" \")[0] + \" \" + current_time + \"\\n\";\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrent_time += quantum;\n\t\t\t\tString process_result = process.split(\" \")[0] + \" \" + result.toString();\n\t\t\t\tqueue.add(process_result);\n\t\t\t}\n\t\t\tif(output.length() > 1000){\n\t\t\t\tSystem.out.print(output);\n\t\t\t\toutput = \"\";\n\t\t\t}\n\t\t}\n\t\tSystem.out.print(output);\n\n\t}\n\t\n\tprivate static Integer get_time(String process, Integer quantum){\n\t\tInteger time = Integer.parseInt(process.split(\" \")[1]);\n\t\treturn time - quantum;\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String input = s.nextLine();
Integer number = Integer.parseInt(input.split(" ")[0]);
Integer quantum = Integer.parseInt(input.split(" ")[1]);
Integer current_time = 0;
ArrayList<String> queue = new ArrayList<String>();
while(s.hasNext()){
queue.add(s.nextLine());
}
s.close();
String output = "";
while(queue.size() > 0){
String process = queue.remove(0);
Integer result = get_time(process, quantum);
if(result <= 0){
current_time = current_time + quantum + result;
output = output + process.split(" ")[0] + " " + current_time + "\n";
}
else{
current_time += quantum;
String process_result = process.split(" ")[0] + " " + result.toString();
queue.add(process_result);
}
if(output.length() > 1000){
System.out.print(output);
output = "";
}
}
System.out.print(output);
}
private static Integer get_time(String process, Integer quantum){
Integer time = Integer.parseInt(process.split(" ")[1]);
return time - quantum;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
14,
2,
18,
4,
18,
13,
13,
13,
30,
0,
18,
4,
18,
13,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
30,
0,
13,
18,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
13,
17,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
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
],
[
164,
17
],
[
164,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
26,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
20,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
66,
71
],
[
63,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
20,
76
],
[
76,
77
],
[
76,
78
],
[
20,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
80,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
88,
92
],
[
87,
93
],
[
86,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
96,
100
],
[
95,
101
],
[
94,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
105,
106
],
[
106,
107
],
[
94,
108
],
[
108,
109
],
[
108,
110
],
[
86,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
114,
118
],
[
111,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
125,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
126,
130
],
[
125,
131
],
[
125,
132
],
[
111,
133
],
[
133,
134
],
[
134,
135
],
[
18,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
138,
142
],
[
142,
143
],
[
138,
144
],
[
144,
145
],
[
138,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
148,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
146,
159
],
[
159,
160
],
[
146,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"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 void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] strArray = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(strArray[0]);\n\t\tint q = Integer.parseInt(strArray[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}\n\t\t\n\t\tint currentTime = 0;\n\t\twhile(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}\n\nclass Process {\n\tString name;\n\tint remainTime;\n\tint finishedTime;\n\t\n\tpublic Process (String name, int time){\n\t\tthis.name = name;\n\t\tthis.remainTime = 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 void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] strArray = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(strArray[0]);\n\t\tint q = Integer.parseInt(strArray[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}\n\t\t\n\t\tint currentTime = 0;\n\t\twhile(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] strArray = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(strArray[0]);\n\t\tint q = Integer.parseInt(strArray[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}\n\t\t\n\t\tint currentTime = 0;\n\t\twhile(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}\n\t}",
"main",
"{\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] strArray = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(strArray[0]);\n\t\tint q = Integer.parseInt(strArray[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}\n\t\t\n\t\tint currentTime = 0;\n\t\twhile(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\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[] strArray = br.readLine().split(\" \");",
"strArray",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(strArray[0]);",
"n",
"Integer.parseInt(strArray[0])",
"Integer.parseInt",
"Integer",
"strArray[0]",
"strArray",
"0",
"int q = Integer.parseInt(strArray[1]);",
"q",
"Integer.parseInt(strArray[1])",
"Integer.parseInt",
"Integer",
"strArray[1]",
"strArray",
"1",
"Queue<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}",
"{\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}",
"strArray = br.readLine().split(\" \")",
"strArray",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"queue.add(new Process(strArray[0], Integer.parseInt(strArray[1])))",
"queue.add",
"queue",
"new Process(strArray[0], Integer.parseInt(strArray[1]))",
"int currentTime = 0;",
"currentTime",
"0",
"while(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}",
"if(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}",
"queue.element().remainTime > q",
"queue.element().remainTime",
"queue.element()",
"queue.element",
"queue",
"queue.element().remainTime",
"q",
"{\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}",
"queue.element().remainTime -= q",
"queue.element().remainTime",
"queue.element()",
"queue.element",
"queue",
"queue.element().remainTime",
"q",
"queue.add(queue.poll())",
"queue.add",
"queue",
"queue.poll()",
"queue.poll",
"queue",
"currentTime += q",
"currentTime",
"q",
"{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}",
"currentTime += queue.element().remainTime",
"currentTime",
"queue.element().remainTime",
"queue.element()",
"queue.element",
"queue",
"queue.element().remainTime",
"System.out.println(queue.element().name + \" \" + currentTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"queue.element().name + \" \" + currentTime",
"queue.element().name + \" \" + currentTime",
"queue.element().name",
"queue.element()",
"queue.element",
"queue",
"queue.element().name",
"\" \"",
"currentTime",
"queue.poll()",
"queue.poll",
"queue",
"String[] args",
"args",
"class Process {\n\tString name;\n\tint remainTime;\n\tint finishedTime;\n\t\n\tpublic Process (String name, int time){\n\t\tthis.name = name;\n\t\tthis.remainTime = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int remainTime;",
"remainTime",
"int finishedTime;",
"finishedTime",
"public Process (String name, int time){\n\t\tthis.name = name;\n\t\tthis.remainTime = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.remainTime = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.remainTime = time",
"this.remainTime",
"this",
"this.remainTime",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] strArray = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(strArray[0]);\n\t\tint q = Integer.parseInt(strArray[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}\n\t\t\n\t\tint currentTime = 0;\n\t\twhile(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] strArray = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(strArray[0]);\n\t\tint q = Integer.parseInt(strArray[1]);\n\t\t\n\t\tQueue<Process> queue = new ArrayDeque<Process>();\n\t\tfor(int i = 0; i < n ;i++){\n\t\t\tstrArray = br.readLine().split(\" \");\n\t\t\tqueue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));\n\t\t}\n\t\t\n\t\tint currentTime = 0;\n\t\twhile(queue.size() > 0){\n\t\t\tif(queue.element().remainTime > q){\n\t\t\t\tqueue.element().remainTime -= q;\n\t\t\t\tqueue.add(queue.poll());\n\t\t\t\tcurrentTime += q;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcurrentTime += queue.element().remainTime;\n\t\t\t\tSystem.out.println(queue.element().name + \" \" + currentTime);\n\t\t\t\tqueue.poll();\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;
public class Main {
public static void main(String[] args) throws IOException {
// TODO ?????????????????????????????????????????????
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] strArray = br.readLine().split(" ");
int n = Integer.parseInt(strArray[0]);
int q = Integer.parseInt(strArray[1]);
Queue<Process> queue = new ArrayDeque<Process>();
for(int i = 0; i < n ;i++){
strArray = br.readLine().split(" ");
queue.add(new Process(strArray[0], Integer.parseInt(strArray[1])));
}
int currentTime = 0;
while(queue.size() > 0){
if(queue.element().remainTime > q){
queue.element().remainTime -= q;
queue.add(queue.poll());
currentTime += q;
}
else{
currentTime += queue.element().remainTime;
System.out.println(queue.element().name + " " + currentTime);
queue.poll();
}
}
}
}
class Process {
String name;
int remainTime;
int finishedTime;
public Process (String name, int time){
this.name = name;
this.remainTime = 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,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
4,
18,
13,
13,
42,
2,
4,
18,
13,
17,
30,
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,
18,
36,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
13,
20,
0,
13,
17,
23,
13,
12,
13,
30,
14,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
37,
20,
30,
0,
13,
20,
29,
4,
18,
13,
12,
13,
30,
14,
2,
2,
13,
17,
40,
4,
18,
13,
30,
38,
5,
13,
30,
37,
20,
30,
29,
4,
18,
13,
29,
4,
18,
13,
17,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
253,
8
],
[
253,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
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
],
[
54,
56
],
[
43,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
11,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
62,
66
],
[
61,
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
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
86,
91
],
[
92,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
92,
96
],
[
92,
97
],
[
78,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
98,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
9,
110
],
[
110,
111
],
[
253,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
112,
116
],
[
116,
117
],
[
112,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
120,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
118,
131
],
[
131,
132
],
[
118,
133
],
[
133,
134
],
[
112,
135
],
[
135,
136
],
[
135,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
112,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
112,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
149,
157
],
[
157,
158
],
[
253,
159
],
[
159,
160
],
[
159,
161
],
[
161,
162
],
[
161,
163
],
[
159,
164
],
[
164,
165
],
[
164,
166
],
[
159,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
173,
174
],
[
173,
175
],
[
167,
176
],
[
176,
177
],
[
159,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
181,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
195,
196
],
[
191,
197
],
[
197,
198
],
[
198,
199
],
[
198,
200
],
[
180,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
159,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
210,
211
],
[
210,
212
],
[
209,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
208,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
221,
222
],
[
222,
223
],
[
218,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
227,
228
],
[
207,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
230,
233
],
[
159,
234
],
[
234,
235
],
[
234,
236
],
[
236,
237
],
[
237,
238
],
[
238,
239
],
[
239,
240
],
[
238,
241
],
[
241,
242
],
[
159,
243
],
[
243,
244
],
[
243,
245
],
[
245,
246
],
[
246,
247
],
[
247,
248
],
[
248,
249
],
[
247,
250
],
[
250,
251
],
[
0,
252
],
[
252,
253
],
[
252,
254
]
] | [
"import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int totalTime = 0;\n ArrayDeque<Process> queue = new ArrayDeque<Process>();\n for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }\n while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }\n\n }\n static class Process{\n private String name;\n private int time;\n public Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public int getTime(){\n return this.time;\n }\n public String getName(){\n return this.name;\n }\n public void reduceTime(int q){\n this.time -= q;\n }\n\n }\n\n static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}\n",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int totalTime = 0;\n ArrayDeque<Process> queue = new ArrayDeque<Process>();\n for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }\n while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }\n\n }\n static class Process{\n private String name;\n private int time;\n public Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public int getTime(){\n return this.time;\n }\n public String getName(){\n return this.name;\n }\n public void reduceTime(int q){\n this.time -= q;\n }\n\n }\n\n static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int totalTime = 0;\n ArrayDeque<Process> queue = new ArrayDeque<Process>();\n for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }\n while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }\n\n }",
"main",
"{\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int totalTime = 0;\n ArrayDeque<Process> queue = new ArrayDeque<Process>();\n for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }\n while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }\n\n }",
"FastScanner sc = new FastScanner(System.in);",
"sc",
"new FastScanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int totalTime = 0;",
"totalTime",
"0",
"ArrayDeque<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\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 Process process = new Process(name, time);\n queue.offerLast(process);\n }",
"{\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Process process = new Process(name, time);",
"process",
"new Process(name, time)",
"queue.offerLast(process)",
"queue.offerLast",
"queue",
"process",
"while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }",
"Process process = queue.pollFirst();",
"process",
"queue.pollFirst()",
"queue.pollFirst",
"queue",
"int time = process.getTime();",
"time",
"process.getTime()",
"process.getTime",
"process",
"if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }",
"time <= q",
"time",
"q",
"{\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }",
"totalTime += time",
"totalTime",
"time",
"System.out.println(process.getName() + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.getName() + \" \" + totalTime",
"process.getName() + \" \" + totalTime",
"process.getName()",
"process.getName",
"process",
"\" \"",
"totalTime",
"{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }",
"totalTime += q",
"totalTime",
"q",
"process.reduceTime(q)",
"process.reduceTime",
"process",
"q",
"queue.offerLast(process)",
"queue.offerLast",
"queue",
"process",
"String[] args",
"args",
"static class Process{\n private String name;\n private int time;\n public Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public int getTime(){\n return this.time;\n }\n public String getName(){\n return this.name;\n }\n public void reduceTime(int q){\n this.time -= q;\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 this.time;\n }",
"getTime",
"{\n return this.time;\n }",
"return this.time;",
"this.time",
"this",
"this.time",
"public String getName(){\n return this.name;\n }",
"getName",
"{\n return this.name;\n }",
"return this.name;",
"this.name",
"this",
"this.name",
"public void reduceTime(int q){\n this.time -= q;\n }",
"reduceTime",
"{\n this.time -= q;\n }",
"this.time -= q",
"this.time",
"this",
"this.time",
"q",
"int q",
"q",
"static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }",
"FastScanner",
"private BufferedReader reader = null;",
"reader",
"null",
"private StringTokenizer tokenizer = null;",
"tokenizer",
"null",
"public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }",
"FastScanner",
"{\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }",
"reader = new BufferedReader(new InputStreamReader(in))",
"reader",
"new BufferedReader(new InputStreamReader(in))",
"tokenizer = null",
"tokenizer",
"null",
"InputStream in",
"in",
"public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }",
"next",
"{\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }",
"if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }",
"tokenizer == null || !tokenizer.hasMoreTokens()",
"tokenizer == null",
"tokenizer",
"null",
"!tokenizer.hasMoreTokens()",
"tokenizer.hasMoreTokens()",
"tokenizer.hasMoreTokens",
"tokenizer",
"{\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }",
"try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }",
"catch (IOException e) {\n throw new RuntimeException(e);\n }",
"IOException e",
"{\n throw new RuntimeException(e);\n }",
"throw new RuntimeException(e);",
"new RuntimeException(e)",
"{\n tokenizer = new StringTokenizer(reader.readLine());\n }",
"tokenizer = new StringTokenizer(reader.readLine())",
"tokenizer",
"new StringTokenizer(reader.readLine())",
"return tokenizer.nextToken();",
"tokenizer.nextToken()",
"tokenizer.nextToken",
"tokenizer",
"public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }",
"nextLine",
"{\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }",
"if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }",
"tokenizer == null || !tokenizer.hasMoreTokens()",
"tokenizer == null",
"tokenizer",
"null",
"!tokenizer.hasMoreTokens()",
"tokenizer.hasMoreTokens()",
"tokenizer.hasMoreTokens",
"tokenizer",
"{\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }",
"try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }",
"catch (IOException e) {\n throw new RuntimeException(e);\n }",
"IOException e",
"{\n throw new RuntimeException(e);\n }",
"throw new RuntimeException(e);",
"new RuntimeException(e)",
"{\n return reader.readLine();\n }",
"return reader.readLine();",
"reader.readLine()",
"reader.readLine",
"reader",
"return tokenizer.nextToken(\"\\n\");",
"tokenizer.nextToken(\"\\n\")",
"tokenizer.nextToken",
"tokenizer",
"\"\\n\"",
"public long nextLong() {\n return Long.parseLong(next());\n }",
"nextLong",
"{\n return Long.parseLong(next());\n }",
"return Long.parseLong(next());",
"Long.parseLong(next())",
"Long.parseLong",
"Long",
"next()",
"next",
"public int nextInt() {\n return Integer.parseInt(next());\n }",
"nextInt",
"{\n return Integer.parseInt(next());\n }",
"return Integer.parseInt(next());",
"Integer.parseInt(next())",
"Integer.parseInt",
"Integer",
"next()",
"next",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int totalTime = 0;\n ArrayDeque<Process> queue = new ArrayDeque<Process>();\n for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }\n while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }\n\n }\n static class Process{\n private String name;\n private int time;\n public Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public int getTime(){\n return this.time;\n }\n public String getName(){\n return this.name;\n }\n public void reduceTime(int q){\n this.time -= q;\n }\n\n }\n\n static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}",
"public class Main {\n\n public static void main(String[] args) throws Exception {\n FastScanner sc = new FastScanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int totalTime = 0;\n ArrayDeque<Process> queue = new ArrayDeque<Process>();\n for (int i=0; i<n; i++){\n String name = sc.next();\n int time = sc.nextInt();\n Process process = new Process(name, time);\n queue.offerLast(process);\n }\n while(queue.size() > 0){\n Process process = queue.pollFirst();\n int time = process.getTime();\n if(time <= q){\n totalTime += time;\n System.out.println(process.getName() + \" \" + totalTime);\n }else{\n totalTime += q;\n process.reduceTime(q);\n queue.offerLast(process);\n }\n }\n\n }\n static class Process{\n private String name;\n private int time;\n public Process(String name, int time){\n this.name = name;\n this.time = time;\n }\n public int getTime(){\n return this.time;\n }\n public String getName(){\n return this.name;\n }\n public void reduceTime(int q){\n this.time -= q;\n }\n\n }\n\n static class FastScanner {\n private BufferedReader reader = null;\n private StringTokenizer tokenizer = null;\n\n public FastScanner(InputStream in) {\n reader = new BufferedReader(new InputStreamReader(in));\n tokenizer = null;\n }\n\n public String next() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n tokenizer = new StringTokenizer(reader.readLine());\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n return tokenizer.nextToken();\n }\n\n public String nextLine() {\n if (tokenizer == null || !tokenizer.hasMoreTokens()) {\n try {\n return reader.readLine();\n } catch (IOException e) {\n throw new RuntimeException(e);\n }\n }\n\n return tokenizer.nextToken(\"\\n\");\n }\n\n public long nextLong() {\n return Long.parseLong(next());\n }\n\n public int nextInt() {\n return Integer.parseInt(next());\n }\n\n }\n}",
"Main"
] | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
int totalTime = 0;
ArrayDeque<Process> queue = new ArrayDeque<Process>();
for (int i=0; i<n; i++){
String name = sc.next();
int time = sc.nextInt();
Process process = new Process(name, time);
queue.offerLast(process);
}
while(queue.size() > 0){
Process process = queue.pollFirst();
int time = process.getTime();
if(time <= q){
totalTime += time;
System.out.println(process.getName() + " " + totalTime);
}else{
totalTime += q;
process.reduceTime(q);
queue.offerLast(process);
}
}
}
static class Process{
private String name;
private int time;
public Process(String name, int time){
this.name = name;
this.time = time;
}
public int getTime(){
return this.time;
}
public String getName(){
return this.name;
}
public void reduceTime(int q){
this.time -= q;
}
}
static class FastScanner {
private BufferedReader reader = null;
private StringTokenizer tokenizer = null;
public FastScanner(InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
tokenizer = null;
}
public String next() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
return reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken("\n");
}
public long nextLong() {
return Long.parseLong(next());
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
|
[
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,
0,
13,
13,
14,
4,
18,
13,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
20,
17,
0,
18,
36,
13,
17,
0,
18,
36,
13,
17,
12,
13,
30,
0,
18,
18,
36,
13,
18,
36,
13,
13,
14,
2,
2,
18,
36,
13,
17,
17,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
23,
13,
12,
13,
30,
14,
4,
13,
37,
20,
41,
13,
18,
36,
13,
14,
2,
2,
13,
17,
17,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
29,
18,
18,
36,
13,
13,
12,
13,
30,
29,
2,
18,
36,
13,
18,
36,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
0,
13,
13,
29,
13,
41,
13,
13,
0,
13,
17,
29,
13,
12,
13,
30,
29,
2,
18,
36,
13,
17,
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
],
[
291,
11
],
[
291,
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
],
[
78,
89
],
[
89,
90
],
[
89,
91
],
[
78,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
92,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
103,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
103,
108
],
[
92,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
12,
114
],
[
114,
115
],
[
291,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
116,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
116,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
126,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
126,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
116,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
151,
152
],
[
151,
153
],
[
146,
154
],
[
145,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
156,
162
],
[
155,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
155,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
143,
174
],
[
174,
175
],
[
116,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
179,
182
],
[
182,
183
],
[
178,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
186,
188
],
[
178,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
189,
195
],
[
195,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
196,
200
],
[
189,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
203,
205
],
[
178,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
211
],
[
116,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
217,
219
],
[
216,
220
],
[
220,
221
],
[
220,
222
],
[
291,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
223,
227
],
[
227,
228
],
[
223,
229
],
[
229,
230
],
[
223,
231
],
[
231,
232
],
[
231,
233
],
[
233,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
234,
238
],
[
233,
239
],
[
239,
240
],
[
240,
241
],
[
240,
242
],
[
239,
243
],
[
233,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
231,
249
],
[
249,
250
],
[
231,
251
],
[
251,
252
],
[
231,
253
],
[
253,
254
],
[
223,
255
],
[
255,
256
],
[
255,
257
],
[
257,
258
],
[
258,
259
],
[
259,
260
],
[
259,
261
],
[
258,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
266
],
[
266,
267
],
[
257,
268
],
[
268,
269
],
[
268,
270
],
[
257,
271
],
[
271,
272
],
[
271,
273
],
[
257,
274
],
[
274,
275
],
[
223,
276
],
[
276,
277
],
[
276,
278
],
[
278,
279
],
[
279,
280
],
[
280,
281
],
[
281,
282
],
[
281,
283
],
[
280,
284
],
[
223,
285
],
[
285,
286
],
[
285,
287
],
[
287,
288
],
[
288,
289
],
[
0,
290
],
[
290,
291
],
[
290,
292
]
] | [
"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 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] nq = br.readLine().split(\" \");\n int n = Integer.parseInt(nq[0]);\n int quantime = Integer.parseInt(nq[1]);\n\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }\n }\n\n private static class MyQueue {\n private Process[] processes;\n private int head;\n private int tail;\n\n public MyQueue() {\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }\n\n public void enqueue(Process process) {\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Process dequeue() {\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }\n\n public boolean isEmpty() {\n return this.tail == this.head;\n }\n }\n\n private static class Process {\n private String name;\n private int restTime;\n private int quantime;\n\n public Process(String name, int restTime, int quantime) {\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }\n\n public int work() {\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }\n\n public boolean isDone() {\n return this.restTime == 0;\n }\n\n public String getName() {\n return name;\n }\n }\n}\n",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n\n public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] nq = br.readLine().split(\" \");\n int n = Integer.parseInt(nq[0]);\n int quantime = Integer.parseInt(nq[1]);\n\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }\n }\n\n private static class MyQueue {\n private Process[] processes;\n private int head;\n private int tail;\n\n public MyQueue() {\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }\n\n public void enqueue(Process process) {\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Process dequeue() {\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }\n\n public boolean isEmpty() {\n return this.tail == this.head;\n }\n }\n\n private static class Process {\n private String name;\n private int restTime;\n private int quantime;\n\n public Process(String name, int restTime, int quantime) {\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }\n\n public int work() {\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }\n\n public boolean isDone() {\n return this.restTime == 0;\n }\n\n public String getName() {\n return name;\n }\n }\n}",
"Main",
"public static void main(String[] args) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] nq = br.readLine().split(\" \");\n int n = Integer.parseInt(nq[0]);\n int quantime = Integer.parseInt(nq[1]);\n\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] nq = br.readLine().split(\" \");\n int n = Integer.parseInt(nq[0]);\n int quantime = Integer.parseInt(nq[1]);\n\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] nq = br.readLine().split(\" \");",
"nq",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(nq[0]);",
"n",
"Integer.parseInt(nq[0])",
"Integer.parseInt",
"Integer",
"nq[0]",
"nq",
"0",
"int quantime = Integer.parseInt(nq[1]);",
"quantime",
"Integer.parseInt(nq[1])",
"Integer.parseInt",
"Integer",
"nq[1]",
"nq",
"1",
"MyQueue queue = new MyQueue();",
"queue",
"new MyQueue()",
"for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }",
"{\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }",
"String[] processStr = br.readLine().split(\" \");",
"processStr",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime))",
"queue.enqueue",
"queue",
"new Process(processStr[0], Integer.parseInt(processStr[1]), quantime)",
"int sum = 0;",
"sum",
"0",
"while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }",
"Process process = queue.dequeue();",
"process",
"queue.dequeue()",
"queue.dequeue",
"queue",
"int consume = process.work();",
"consume",
"process.work()",
"process.work",
"process",
"sum += consume",
"sum",
"consume",
"if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }",
"process.isDone()",
"process.isDone",
"process",
"{\n System.out.println(process.getName() + \" \" + sum);\n }",
"System.out.println(process.getName() + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.getName() + \" \" + sum",
"process.getName() + \" \" + sum",
"process.getName()",
"process.getName",
"process",
"\" \"",
"sum",
"{\n queue.enqueue(process);\n }",
"queue.enqueue(process)",
"queue.enqueue",
"queue",
"process",
"String[] args",
"args",
"private static class MyQueue {\n private Process[] processes;\n private int head;\n private int tail;\n\n public MyQueue() {\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }\n\n public void enqueue(Process process) {\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Process dequeue() {\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }\n\n public boolean isEmpty() {\n return this.tail == this.head;\n }\n }",
"MyQueue",
"private Process[] processes;",
"processes",
"private int head;",
"head",
"private int tail;",
"tail",
"public MyQueue() {\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }",
"MyQueue",
"{\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }",
"this.processes = new Process[100000]",
"this.processes",
"this",
"this.processes",
"new Process[100000]",
"100000",
"this.head = 0",
"this.head",
"this",
"this.head",
"0",
"this.tail = 0",
"this.tail",
"this",
"this.tail",
"0",
"public void enqueue(Process process) {\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }",
"enqueue",
"{\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }",
"this.processes[this.tail] = process",
"this.processes[this.tail]",
"this.processes",
"this",
"this.processes",
"this.tail",
"this",
"this.tail",
"process",
"if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }",
"this.tail + 1 >= 100000",
"this.tail + 1",
"this.tail",
"this",
"this.tail",
"1",
"100000",
"{\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",
"Process process",
"process",
"public Process dequeue() {\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }",
"dequeue",
"{\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }",
"if (isEmpty()) throw new RuntimeException();",
"isEmpty()",
"isEmpty",
"throw new RuntimeException();",
"new RuntimeException()",
"int head = this.head;",
"head",
"this.head",
"this",
"this.head",
"if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }",
"head + 1 >= 100000",
"head + 1",
"head",
"1",
"100000",
"{\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 this.processes[head];",
"this.processes[head]",
"this.processes",
"this",
"this.processes",
"head",
"public boolean isEmpty() {\n return this.tail == this.head;\n }",
"isEmpty",
"{\n return this.tail == this.head;\n }",
"return this.tail == this.head;",
"this.tail == this.head",
"this.tail",
"this",
"this.tail",
"this.head",
"this",
"this.head",
"private static class Process {\n private String name;\n private int restTime;\n private int quantime;\n\n public Process(String name, int restTime, int quantime) {\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }\n\n public int work() {\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }\n\n public boolean isDone() {\n return this.restTime == 0;\n }\n\n public String getName() {\n return name;\n }\n }",
"Process",
"private String name;",
"name",
"private int restTime;",
"restTime",
"private int quantime;",
"quantime",
"public Process(String name, int restTime, int quantime) {\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }",
"Process",
"{\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.restTime = restTime",
"this.restTime",
"this",
"this.restTime",
"restTime",
"this.quantime = quantime",
"this.quantime",
"this",
"this.quantime",
"quantime",
"String name",
"name",
"int restTime",
"restTime",
"int quantime",
"quantime",
"public int work() {\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }",
"work",
"{\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }",
"if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }",
"quantime <= restTime",
"quantime",
"restTime",
"{\n restTime -= quantime;\n return quantime;\n }",
"restTime -= quantime",
"restTime",
"quantime",
"return quantime;",
"quantime",
"int consume = restTime;",
"consume",
"restTime",
"restTime = 0",
"restTime",
"0",
"return consume;",
"consume",
"public boolean isDone() {\n return this.restTime == 0;\n }",
"isDone",
"{\n return this.restTime == 0;\n }",
"return this.restTime == 0;",
"this.restTime == 0",
"this.restTime",
"this",
"this.restTime",
"0",
"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) throws IOException {\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] nq = br.readLine().split(\" \");\n int n = Integer.parseInt(nq[0]);\n int quantime = Integer.parseInt(nq[1]);\n\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }\n }\n\n private static class MyQueue {\n private Process[] processes;\n private int head;\n private int tail;\n\n public MyQueue() {\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }\n\n public void enqueue(Process process) {\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Process dequeue() {\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }\n\n public boolean isEmpty() {\n return this.tail == this.head;\n }\n }\n\n private static class Process {\n private String name;\n private int restTime;\n private int quantime;\n\n public Process(String name, int restTime, int quantime) {\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }\n\n public int work() {\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }\n\n public boolean isDone() {\n return this.restTime == 0;\n }\n\n public String getName() {\n return name;\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[] nq = br.readLine().split(\" \");\n int n = Integer.parseInt(nq[0]);\n int quantime = Integer.parseInt(nq[1]);\n\n MyQueue queue = new MyQueue();\n for (int i = 0; i < n; i++) {\n String[] processStr = br.readLine().split(\" \");\n queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));\n }\n\n int sum = 0;\n while (!queue.isEmpty()) {\n Process process = queue.dequeue();\n int consume = process.work();\n sum += consume;\n if (process.isDone()) {\n System.out.println(process.getName() + \" \" + sum);\n } else {\n queue.enqueue(process);\n }\n }\n }\n\n private static class MyQueue {\n private Process[] processes;\n private int head;\n private int tail;\n\n public MyQueue() {\n this.processes = new Process[100000];\n this.head = 0;\n this.tail = 0;\n }\n\n public void enqueue(Process process) {\n this.processes[this.tail] = process;\n if (this.tail + 1 >= 100000) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Process dequeue() {\n if (isEmpty()) throw new RuntimeException();\n\n int head = this.head;\n if (head + 1 >= 100000) {\n this.head = 0;\n } else {\n this.head++;\n }\n return this.processes[head];\n }\n\n public boolean isEmpty() {\n return this.tail == this.head;\n }\n }\n\n private static class Process {\n private String name;\n private int restTime;\n private int quantime;\n\n public Process(String name, int restTime, int quantime) {\n this.name = name;\n this.restTime = restTime;\n this.quantime = quantime;\n }\n\n public int work() {\n if (quantime <= restTime) {\n restTime -= quantime;\n return quantime;\n }\n int consume = restTime;\n restTime = 0;\n return consume;\n }\n\n public boolean isDone() {\n return this.restTime == 0;\n }\n\n public String getName() {\n return name;\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 {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] nq = br.readLine().split(" ");
int n = Integer.parseInt(nq[0]);
int quantime = Integer.parseInt(nq[1]);
MyQueue queue = new MyQueue();
for (int i = 0; i < n; i++) {
String[] processStr = br.readLine().split(" ");
queue.enqueue(new Process(processStr[0], Integer.parseInt(processStr[1]), quantime));
}
int sum = 0;
while (!queue.isEmpty()) {
Process process = queue.dequeue();
int consume = process.work();
sum += consume;
if (process.isDone()) {
System.out.println(process.getName() + " " + sum);
} else {
queue.enqueue(process);
}
}
}
private static class MyQueue {
private Process[] processes;
private int head;
private int tail;
public MyQueue() {
this.processes = new Process[100000];
this.head = 0;
this.tail = 0;
}
public void enqueue(Process process) {
this.processes[this.tail] = process;
if (this.tail + 1 >= 100000) {
this.tail = 0;
} else {
this.tail++;
}
}
public Process dequeue() {
if (isEmpty()) throw new RuntimeException();
int head = this.head;
if (head + 1 >= 100000) {
this.head = 0;
} else {
this.head++;
}
return this.processes[head];
}
public boolean isEmpty() {
return this.tail == this.head;
}
}
private static class Process {
private String name;
private int restTime;
private int quantime;
public Process(String name, int restTime, int quantime) {
this.name = name;
this.restTime = restTime;
this.quantime = quantime;
}
public int work() {
if (quantime <= restTime) {
restTime -= quantime;
return quantime;
}
int consume = restTime;
restTime = 0;
return consume;
}
public boolean isDone() {
return this.restTime == 0;
}
public String getName() {
return name;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
13,
13,
4,
18,
13,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
13,
30,
0,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
13,
13,
30,
0,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
13,
2,
4,
18,
13,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
4,
18,
13,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
0,
22
],
[
164,
23
],
[
164,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
26,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
26,
40
],
[
40,
41
],
[
40,
42
],
[
26,
43
],
[
43,
44
],
[
43,
45
],
[
26,
46
],
[
46,
47
],
[
46,
48
],
[
26,
49
],
[
49,
50
],
[
49,
51
],
[
26,
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
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
75,
79
],
[
64,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
26,
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
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
96,
101
],
[
95,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
102,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
112,
113
],
[
113,
114
],
[
102,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
115,
119
],
[
95,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
127,
128
],
[
128,
129
],
[
120,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
130,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
135,
138
],
[
134,
139
],
[
26,
140
],
[
140,
141
],
[
140,
142
],
[
140,
143
],
[
144,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
145,
150
],
[
151,
151
],
[
151,
152
],
[
151,
153
],
[
151,
154
],
[
154,
155
],
[
155,
156
],
[
154,
157
],
[
26,
158
],
[
158,
159
],
[
159,
160
],
[
24,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"import java.util.Queue;\nimport java.util.ArrayDeque;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt(); // プロセス数\n\t\tint Q = sc.nextInt(); // クオンタム\n\t\tMap<String, Integer> hmap = new HashMap<String, Integer>();\n\t\tQueue<String> queue = new ArrayDeque<String>(); // 主役\n\t\tList<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する\n\t\tint timestamp = 0;\n\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}\n\n\t\twhile(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}\n\n\t\tfor(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.Map;",
"Map",
"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\t\tint N = sc.nextInt(); // プロセス数\n\t\tint Q = sc.nextInt(); // クオンタム\n\t\tMap<String, Integer> hmap = new HashMap<String, Integer>();\n\t\tQueue<String> queue = new ArrayDeque<String>(); // 主役\n\t\tList<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する\n\t\tint timestamp = 0;\n\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}\n\n\t\twhile(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}\n\n\t\tfor(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt(); // プロセス数\n\t\tint Q = sc.nextInt(); // クオンタム\n\t\tMap<String, Integer> hmap = new HashMap<String, Integer>();\n\t\tQueue<String> queue = new ArrayDeque<String>(); // 主役\n\t\tList<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する\n\t\tint timestamp = 0;\n\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}\n\n\t\twhile(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}\n\n\t\tfor(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}\n\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt(); // プロセス数\n\t\tint Q = sc.nextInt(); // クオンタム\n\t\tMap<String, Integer> hmap = new HashMap<String, Integer>();\n\t\tQueue<String> queue = new ArrayDeque<String>(); // 主役\n\t\tList<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する\n\t\tint timestamp = 0;\n\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}\n\n\t\twhile(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}\n\n\t\tfor(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}\n\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int Q = sc.nextInt();",
"Q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Map<String, Integer> hmap = new HashMap<String, Integer>();",
"hmap",
"new HashMap<String, Integer>()",
"Queue<String> queue = new ArrayDeque<String>();",
"queue",
"new ArrayDeque<String>()",
"List<String> terminated = new ArrayList<String>();",
"terminated",
"new ArrayList<String>()",
"int timestamp = 0;",
"timestamp",
"0",
"for(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(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 time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"hmap.put(name, time)",
"hmap.put",
"hmap",
"name",
"time",
"queue.add(name)",
"queue.add",
"queue",
"name",
"while(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}",
"String p = queue.peek();",
"p",
"queue.peek()",
"queue.peek",
"queue",
"if(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}",
"hmap.get(p) <= Q",
"hmap.get(p)",
"hmap.get",
"hmap",
"p",
"Q",
"{ // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}",
"timestamp += hmap.get(p)",
"timestamp",
"hmap.get(p)",
"hmap.get",
"hmap",
"p",
"terminated.add(queue.poll())",
"terminated.add",
"terminated",
"queue.poll()",
"queue.poll",
"queue",
"hmap.put(p, timestamp)",
"hmap.put",
"hmap",
"p",
"timestamp",
"{ // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}",
"timestamp += Q",
"timestamp",
"Q",
"queue.add(queue.poll())",
"queue.add",
"queue",
"queue.poll()",
"queue.poll",
"queue",
"hmap.put(p, hmap.get(p) - Q)",
"hmap.put",
"hmap",
"p",
"hmap.get(p) - Q",
"hmap.get(p)",
"hmap.get",
"hmap",
"p",
"Q",
"for(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}",
"String p",
"terminated",
"{\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}",
"{\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}",
"System.out.println(p + \" \" + hmap.get(p))",
"System.out.println",
"System.out",
"System",
"System.out",
"p + \" \" + hmap.get(p)",
"p + \" \" + hmap.get(p)",
"p",
"\" \"",
"hmap.get(p)",
"hmap.get",
"hmap",
"p",
"sc.close()",
"sc.close",
"sc",
"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 = sc.nextInt(); // プロセス数\n\t\tint Q = sc.nextInt(); // クオンタム\n\t\tMap<String, Integer> hmap = new HashMap<String, Integer>();\n\t\tQueue<String> queue = new ArrayDeque<String>(); // 主役\n\t\tList<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する\n\t\tint timestamp = 0;\n\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}\n\n\t\twhile(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}\n\n\t\tfor(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint N = sc.nextInt(); // プロセス数\n\t\tint Q = sc.nextInt(); // クオンタム\n\t\tMap<String, Integer> hmap = new HashMap<String, Integer>();\n\t\tQueue<String> queue = new ArrayDeque<String>(); // 主役\n\t\tList<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する\n\t\tint timestamp = 0;\n\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint time = sc.nextInt();\n\t\t\thmap.put(name, time);\n\t\t\tqueue.add(name);\n\t\t}\n\n\t\twhile(!queue.isEmpty()) {\n\t\t\tString p = queue.peek();\n\t\t\tif(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合\n\t\t\t\ttimestamp += hmap.get(p);\n\t\t\t\tterminated.add(queue.poll());\n\t\t\t\thmap.put(p, timestamp); // プロセスpが終了した時刻を記録\n\t\t\t}else { // クオンタム以内にプロセスpが終わらない場合\n\t\t\t\ttimestamp += Q;\n\t\t\t\tqueue.add(queue.poll()); // プロセスを待ち行列の最後尾へ\n\t\t\t\thmap.put(p, hmap.get(p) - Q);\n\t\t\t}\n\t\t}\n\n\t\tfor(String p : terminated) {\n\t\t\tSystem.out.println(p + \" \" + hmap.get(p));\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"Main"
] | import java.util.Queue;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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(); // クオンタム
Map<String, Integer> hmap = new HashMap<String, Integer>();
Queue<String> queue = new ArrayDeque<String>(); // 主役
List<String> terminated = new ArrayList<String>(); // プロセスの名前を終わった順に格納する
int timestamp = 0;
for(int i = 0; i < N; i++) {
String name = sc.next();
int time = sc.nextInt();
hmap.put(name, time);
queue.add(name);
}
while(!queue.isEmpty()) {
String p = queue.peek();
if(hmap.get(p) <= Q) { // クオンタム以内にプロセスpが終了する場合
timestamp += hmap.get(p);
terminated.add(queue.poll());
hmap.put(p, timestamp); // プロセスpが終了した時刻を記録
}else { // クオンタム以内にプロセスpが終わらない場合
timestamp += Q;
queue.add(queue.poll()); // プロセスを待ち行列の最後尾へ
hmap.put(p, hmap.get(p) - Q);
}
}
for(String p : terminated) {
System.out.println(p + " " + hmap.get(p));
}
sc.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
17,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
0,
18,
36,
13,
13,
42,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
12,
13,
30,
20,
23,
13,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
12,
13,
30,
0,
13,
20,
2,
13,
17,
23,
13,
12,
13,
30,
0,
18,
13,
40,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
40,
13,
41,
13,
4,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
13,
13,
0,
13,
13,
29,
13,
12,
13,
30,
41,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
17,
29,
13,
23,
13,
12,
13,
30,
29,
2,
13,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
220,
8
],
[
220,
9
],
[
9,
10
],
[
220,
11
],
[
11,
12
],
[
11,
13
],
[
220,
14
],
[
14,
15
],
[
14,
16
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
16,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
16,
30
],
[
30,
31
],
[
30,
32
],
[
16,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
16,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
38,
42
],
[
42,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
42,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
42,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
16,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
57,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
81,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
81,
86
],
[
220,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
87,
91
],
[
91,
92
],
[
220,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
93,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
101,
102
],
[
93,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
109,
110
],
[
109,
111
],
[
103,
112
],
[
112,
113
],
[
93,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
117,
122
],
[
114,
123
],
[
123,
124
],
[
93,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
127,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
127,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
139,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
127,
149
],
[
149,
150
],
[
149,
151
],
[
127,
152
],
[
152,
153
],
[
93,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
156,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
159,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
159,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
177,
179
],
[
174,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
156,
185
],
[
185,
186
],
[
154,
187
],
[
187,
188
],
[
93,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
220,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
196,
200
],
[
200,
201
],
[
196,
202
],
[
202,
203
],
[
202,
204
],
[
204,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
205,
209
],
[
204,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
210,
214
],
[
202,
215
],
[
215,
216
],
[
202,
217
],
[
217,
218
],
[
0,
219
],
[
219,
220
],
[
219,
221
]
] | [
"import java.util.Arrays;\nimport java.util.Scanner;\n\npublic class Main {\n public static int quantum;\n public static int currentTime = 0;\n public Main() {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n Queue queue = new Queue(100000 + n);\n this.quantum = quantum;\n\n while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }\n while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }\n }\n\n public static void main(String[] args) {\n new Main();\n }\n\n private class Queue{\n private int head = 0;\n private int tail = 0;\n private Data queue[];\n\n public Queue(int size){\n queue = new Data[size*2];\n }\n\n public void enqueue(Data data){\n queue[tail++] = data;\n }\n\n public Data dequeue(){\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }\n\n public int expendedTime(Data data){\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n }\n\n private class Data{\n public String pName;\n public int time;\n\n public Data(String pName, int time){\n this.pName = pName;\n this.time = time;\n }\n }\n}",
"import java.util.Arrays;",
"Arrays",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static int quantum;\n public static int currentTime = 0;\n public Main() {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n Queue queue = new Queue(100000 + n);\n this.quantum = quantum;\n\n while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }\n while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }\n }\n\n public static void main(String[] args) {\n new Main();\n }\n\n private class Queue{\n private int head = 0;\n private int tail = 0;\n private Data queue[];\n\n public Queue(int size){\n queue = new Data[size*2];\n }\n\n public void enqueue(Data data){\n queue[tail++] = data;\n }\n\n public Data dequeue(){\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }\n\n public int expendedTime(Data data){\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n }\n\n private class Data{\n public String pName;\n public int time;\n\n public Data(String pName, int time){\n this.pName = pName;\n this.time = time;\n }\n }\n}",
"Main",
"public static int quantum;",
"quantum",
"public static int currentTime = 0;",
"currentTime",
"0",
"public Main() {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n Queue queue = new Queue(100000 + n);\n this.quantum = quantum;\n\n while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }\n while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }\n }",
"Main",
"{\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n Queue queue = new Queue(100000 + n);\n this.quantum = quantum;\n\n while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }\n while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\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 quantum = scan.nextInt();",
"quantum",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Queue queue = new Queue(100000 + n);",
"queue",
"new Queue(100000 + n)",
"this.quantum = quantum",
"this.quantum",
"this",
"this.quantum",
"quantum",
"while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }",
"scan.hasNext()",
"scan.hasNext",
"scan",
"{\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }",
"String pName = scan.next();",
"pName",
"scan.next()",
"scan.next",
"scan",
"int time = scan.nextInt();",
"time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"queue.enqueue(new Data(pName, time))",
"queue.enqueue",
"queue",
"new Data(pName, time)",
"while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }",
"Data data = queue.dequeue();",
"data",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }",
"data.time == 0",
"data.time",
"data",
"data.time",
"0",
"{\n System.out.println(data.pName + \" \" + currentTime);\n }",
"System.out.println(data.pName + \" \" + currentTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"data.pName + \" \" + currentTime",
"data.pName + \" \" + currentTime",
"data.pName",
"data",
"data.pName",
"\" \"",
"currentTime",
"public static void main(String[] args) {\n new Main();\n }",
"main",
"{\n new Main();\n }",
"new Main()",
"String[] args",
"args",
"private class Queue{\n private int head = 0;\n private int tail = 0;\n private Data queue[];\n\n public Queue(int size){\n queue = new Data[size*2];\n }\n\n public void enqueue(Data data){\n queue[tail++] = data;\n }\n\n public Data dequeue(){\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }\n\n public int expendedTime(Data data){\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n }",
"Queue",
"private int head = 0;",
"head",
"0",
"private int tail = 0;",
"tail",
"0",
"private Data queue[];",
"queue",
"public Queue(int size){\n queue = new Data[size*2];\n }",
"Queue",
"{\n queue = new Data[size*2];\n }",
"queue = new Data[size*2]",
"queue",
"new Data[size*2]",
"size*2",
"size",
"2",
"int size",
"size",
"public void enqueue(Data data){\n queue[tail++] = data;\n }",
"enqueue",
"{\n queue[tail++] = data;\n }",
"queue[tail++] = data",
"queue[tail++]",
"queue",
"tail++",
"tail",
"data",
"Data data",
"data",
"public Data dequeue(){\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }",
"dequeue",
"{\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }",
"Data data = queue[head++];",
"data",
"queue[head++]",
"queue",
"head++",
"head",
"int time = expendedTime(data);",
"time",
"expendedTime(data)",
"expendedTime",
"data",
"if(data.time != 0){\n enqueue(data);\n }",
"data.time != 0",
"data.time",
"data",
"data.time",
"0",
"{\n enqueue(data);\n }",
"enqueue(data)",
"enqueue",
"data",
"currentTime += time",
"currentTime",
"time",
"return data;",
"data",
"public int expendedTime(Data data){\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }",
"expendedTime",
"{\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }",
"int time;",
"time",
"if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }",
"data.time > quantum",
"data.time",
"data",
"data.time",
"quantum",
"{\n time = quantum;\n data.time -= quantum;\n }",
"time = quantum",
"time",
"quantum",
"data.time -= quantum",
"data.time",
"data",
"data.time",
"quantum",
"{\n time = data.time;\n data.time = 0;\n }",
"time = data.time",
"time",
"data.time",
"data",
"data.time",
"data.time = 0",
"data.time",
"data",
"data.time",
"0",
"return time;",
"time",
"Data data",
"data",
"public boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"private class Data{\n public String pName;\n public int time;\n\n public Data(String pName, int time){\n this.pName = pName;\n this.time = time;\n }\n }",
"Data",
"public String pName;",
"pName",
"public int time;",
"time",
"public Data(String pName, int time){\n this.pName = pName;\n this.time = time;\n }",
"Data",
"{\n this.pName = pName;\n this.time = time;\n }",
"this.pName = pName",
"this.pName",
"this",
"this.pName",
"pName",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String pName",
"pName",
"int time",
"time",
"public class Main {\n public static int quantum;\n public static int currentTime = 0;\n public Main() {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n Queue queue = new Queue(100000 + n);\n this.quantum = quantum;\n\n while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }\n while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }\n }\n\n public static void main(String[] args) {\n new Main();\n }\n\n private class Queue{\n private int head = 0;\n private int tail = 0;\n private Data queue[];\n\n public Queue(int size){\n queue = new Data[size*2];\n }\n\n public void enqueue(Data data){\n queue[tail++] = data;\n }\n\n public Data dequeue(){\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }\n\n public int expendedTime(Data data){\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n }\n\n private class Data{\n public String pName;\n public int time;\n\n public Data(String pName, int time){\n this.pName = pName;\n this.time = time;\n }\n }\n}",
"public class Main {\n public static int quantum;\n public static int currentTime = 0;\n public Main() {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int quantum = scan.nextInt();\n\n Queue queue = new Queue(100000 + n);\n this.quantum = quantum;\n\n while(scan.hasNext()){\n String pName = scan.next();\n int time = scan.nextInt();\n queue.enqueue(new Data(pName, time));\n }\n while(!queue.isEmpty()){\n Data data = queue.dequeue();\n if(data.time == 0){\n System.out.println(data.pName + \" \" + currentTime);\n }\n }\n }\n\n public static void main(String[] args) {\n new Main();\n }\n\n private class Queue{\n private int head = 0;\n private int tail = 0;\n private Data queue[];\n\n public Queue(int size){\n queue = new Data[size*2];\n }\n\n public void enqueue(Data data){\n queue[tail++] = data;\n }\n\n public Data dequeue(){\n Data data = queue[head++];\n int time = expendedTime(data);\n if(data.time != 0){\n enqueue(data);\n }\n currentTime += time;\n return data;\n }\n\n public int expendedTime(Data data){\n int time;\n if(data.time > quantum){\n time = quantum;\n data.time -= quantum;\n }else{\n time = data.time;\n data.time = 0;\n }\n return time;\n }\n\n public boolean isEmpty(){\n return head == tail;\n }\n\n }\n\n private class Data{\n public String pName;\n public int time;\n\n public Data(String pName, int time){\n this.pName = pName;\n this.time = time;\n }\n }\n}",
"Main"
] | import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static int quantum;
public static int currentTime = 0;
public Main() {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int quantum = scan.nextInt();
Queue queue = new Queue(100000 + n);
this.quantum = quantum;
while(scan.hasNext()){
String pName = scan.next();
int time = scan.nextInt();
queue.enqueue(new Data(pName, time));
}
while(!queue.isEmpty()){
Data data = queue.dequeue();
if(data.time == 0){
System.out.println(data.pName + " " + currentTime);
}
}
}
public static void main(String[] args) {
new Main();
}
private class Queue{
private int head = 0;
private int tail = 0;
private Data queue[];
public Queue(int size){
queue = new Data[size*2];
}
public void enqueue(Data data){
queue[tail++] = data;
}
public Data dequeue(){
Data data = queue[head++];
int time = expendedTime(data);
if(data.time != 0){
enqueue(data);
}
currentTime += time;
return data;
}
public int expendedTime(Data data){
int time;
if(data.time > quantum){
time = quantum;
data.time -= quantum;
}else{
time = data.time;
data.time = 0;
}
return time;
}
public boolean isEmpty(){
return head == tail;
}
}
private class Data{
public String pName;
public int time;
public Data(String pName, int time){
this.pName = pName;
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,
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,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
2,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
2,
13,
13,
13,
4,
18,
18,
13,
13,
2,
13,
17,
4,
18,
18,
13,
13,
13,
14,
4,
18,
13,
30,
3,
30,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
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
],
[
132,
11
],
[
132,
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
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
77,
79
],
[
64,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
80,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
88,
88
],
[
88,
89
],
[
88,
90
],
[
88,
91
],
[
84,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
97,
98
],
[
97,
99
],
[
84,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
84,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
106,
110
],
[
110,
111
],
[
80,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
115,
117
],
[
112,
118
],
[
118,
119
],
[
119,
120
],
[
118,
121
],
[
112,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
14,
126
],
[
126,
127
],
[
127,
128
],
[
12,
129
],
[
129,
130
],
[
0,
131
],
[
131,
132
],
[
131,
133
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint time = scanner.nextInt();\n\t\tint total=0;\n\t\tDeque<Integer> queue = new ArrayDeque<Integer>();\n\t\tDeque<String> name = new ArrayDeque<String>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}\n\t\twhile(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\t}\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\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint time = scanner.nextInt();\n\t\tint total=0;\n\t\tDeque<Integer> queue = new ArrayDeque<Integer>();\n\t\tDeque<String> name = new ArrayDeque<String>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}\n\t\twhile(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint time = scanner.nextInt();\n\t\tint total=0;\n\t\tDeque<Integer> queue = new ArrayDeque<Integer>();\n\t\tDeque<String> name = new ArrayDeque<String>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}\n\t\twhile(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\t}",
"main",
"{\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint time = scanner.nextInt();\n\t\tint total=0;\n\t\tDeque<Integer> queue = new ArrayDeque<Integer>();\n\t\tDeque<String> name = new ArrayDeque<String>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}\n\t\twhile(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\t}",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n = scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int time = scanner.nextInt();",
"time",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"int total=0;",
"total",
"0",
"Deque<Integer> queue = new ArrayDeque<Integer>();",
"queue",
"new ArrayDeque<Integer>()",
"Deque<String> name = new ArrayDeque<String>();",
"name",
"new ArrayDeque<String>()",
"for (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}",
"{\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}",
"name.add(scanner.next())",
"name.add",
"name",
"scanner.next()",
"scanner.next",
"scanner",
"queue.add(scanner.nextInt())",
"queue.add",
"queue",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"while(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}",
"int num=queue.poll();",
"num",
"queue.poll()",
"queue.poll",
"queue",
"String name1=name.poll();",
"name1",
"name.poll()",
"name.poll",
"name",
"num=num-time",
"num",
"num-time",
"num",
"time",
"if(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}",
"num<=0",
"num",
"0",
"{\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"total=total+time+num",
"total",
"total+time+num",
"total+time+num",
"total",
"time",
"num",
"System.out.print(name1+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"name1+\" \"",
"name1",
"\" \"",
"System.out.println(total)",
"System.out.println",
"System.out",
"System",
"System.out",
"total",
"if(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"name.isEmpty()",
"name.isEmpty",
"name",
"{\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"break;",
"{\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}",
"total=total+time",
"total",
"total+time",
"total",
"time",
"queue.add(num)",
"queue.add",
"queue",
"num",
"name.add(name1)",
"name.add",
"name",
"name1",
"scanner.close()",
"scanner.close",
"scanner",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint time = scanner.nextInt();\n\t\tint total=0;\n\t\tDeque<Integer> queue = new ArrayDeque<Integer>();\n\t\tDeque<String> name = new ArrayDeque<String>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}\n\t\twhile(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scanner = new Scanner(System.in);\n\t\tint n = scanner.nextInt();\n\t\tint time = scanner.nextInt();\n\t\tint total=0;\n\t\tDeque<Integer> queue = new ArrayDeque<Integer>();\n\t\tDeque<String> name = new ArrayDeque<String>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.add(scanner.next());\n\t\t\tqueue.add(scanner.nextInt());\n\t\t}\n\t\twhile(true) {\n\t\t\tint num=queue.poll();\n\t\t\tString name1=name.poll();\n\t\t\tnum=num-time;\n\t\t\tif(num<=0) {\n\t\t\t\ttotal=total+time+num;\n\t\t\t\tSystem.out.print(name1+\" \");\n\t\t\t\tSystem.out.println(total);\n\t\t\t\tif(name.isEmpty()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\ttotal=total+time;\n\t\t\t\tqueue.add(num);\n\t\t\t\tname.add(name1);\n\t\t\t}\n\t\t}\n\t\tscanner.close();\n\t}\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 scanner = new Scanner(System.in);
int n = scanner.nextInt();
int time = scanner.nextInt();
int total=0;
Deque<Integer> queue = new ArrayDeque<Integer>();
Deque<String> name = new ArrayDeque<String>();
for (int i = 0; i < n; i++) {
name.add(scanner.next());
queue.add(scanner.nextInt());
}
while(true) {
int num=queue.poll();
String name1=name.poll();
num=num-time;
if(num<=0) {
total=total+time+num;
System.out.print(name1+" ");
System.out.println(total);
if(name.isEmpty()) {
break;
}
}else {
total=total+time;
queue.add(num);
name.add(name1);
}
}
scanner.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
20,
12,
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,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
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,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
0,
13,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
186,
14
],
[
186,
15
],
[
15,
16
],
[
15,
17
],
[
186,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
20,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
20,
45
],
[
45,
46
],
[
45,
47
],
[
20,
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
],
[
83,
84
],
[
82,
85
],
[
20,
86
],
[
86,
87
],
[
86,
88
],
[
20,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
89,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
94,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
94,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
113,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
119,
123
],
[
119,
124
],
[
105,
125
],
[
125,
126
],
[
126,
127
],
[
126,
128
],
[
125,
129
],
[
129,
130
],
[
129,
131
],
[
125,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
125,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
18,
140
],
[
140,
141
],
[
0,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
142,
146
],
[
146,
147
],
[
142,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
150,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
148,
161
],
[
161,
162
],
[
148,
163
],
[
163,
164
],
[
142,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
142,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
142,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
175,
183
],
[
183,
184
],
[
0,
185
],
[
185,
186
],
[
185,
187
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\npublic class Main {\n\tprivate static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tString[] list = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(list[0]);\n\t\tint q = Integer.parseInt(list[1]);\n\t\t\n\t\tDeque<ALDS1_3_B_Process> deque = new ArrayDeque<>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\t\n\t\twhile(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}\n\nclass ALDS1_3_B_Process{\n\tprivate String name;\n\tprivate int time;\n\t\n\tpublic ALDS1_3_B_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\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.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"public class Main {\n\tprivate static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tString[] list = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(list[0]);\n\t\tint q = Integer.parseInt(list[1]);\n\t\t\n\t\tDeque<ALDS1_3_B_Process> deque = new ArrayDeque<>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\t\n\t\twhile(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main",
"private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"public static void main(String[] args) throws Exception {\n\t\tString[] list = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(list[0]);\n\t\tint q = Integer.parseInt(list[1]);\n\t\t\n\t\tDeque<ALDS1_3_B_Process> deque = new ArrayDeque<>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\t\n\t\twhile(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tString[] list = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(list[0]);\n\t\tint q = Integer.parseInt(list[1]);\n\t\t\n\t\tDeque<ALDS1_3_B_Process> deque = new ArrayDeque<>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\t\n\t\twhile(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"String[] list = br.readLine().split(\" \");",
"list",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(list[0]);",
"n",
"Integer.parseInt(list[0])",
"Integer.parseInt",
"Integer",
"list[0]",
"list",
"0",
"int q = Integer.parseInt(list[1]);",
"q",
"Integer.parseInt(list[1])",
"Integer.parseInt",
"Integer",
"list[1]",
"list",
"1",
"Deque<ALDS1_3_B_Process> deque = new ArrayDeque<>();",
"deque",
"new ArrayDeque<>()",
"for(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}",
"{\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}",
"list = br.readLine().split(\" \")",
"list",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"String name = list[0];",
"name",
"list[0]",
"list",
"0",
"int time = Integer.parseInt(list[1]);",
"time",
"Integer.parseInt(list[1])",
"Integer.parseInt",
"Integer",
"list[1]",
"list",
"1",
"deque.addLast(new ALDS1_3_B_Process(name, time))",
"deque.addLast",
"deque",
"new ALDS1_3_B_Process(name, time)",
"int timer = 0;",
"timer",
"0",
"while(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}",
"!deque.isEmpty()",
"deque.isEmpty()",
"deque.isEmpty",
"deque",
"{\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}",
"ALDS1_3_B_Process process = deque.pollFirst();",
"process",
"deque.pollFirst()",
"deque.pollFirst",
"deque",
"int time = process.getTime();",
"time",
"process.getTime()",
"process.getTime",
"process",
"if(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}",
"timer += time",
"timer",
"time",
"System.out.println(process.getName() + \" \" + timer)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.getName() + \" \" + timer",
"process.getName() + \" \" + timer",
"process.getName()",
"process.getName",
"process",
"\" \"",
"timer",
"{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}",
"timer += q",
"timer",
"q",
"time -= q",
"time",
"q",
"process.setTime(time)",
"process.setTime",
"process",
"time",
"deque.offerLast(process)",
"deque.offerLast",
"deque",
"process",
"String[] args",
"args",
"class ALDS1_3_B_Process{\n\tprivate String name;\n\tprivate int time;\n\t\n\tpublic ALDS1_3_B_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\t\n\tpublic void setTime(int time){\n\t\tthis.time = time;\n\t}\n}",
"ALDS1_3_B_Process",
"private String name;",
"name",
"private int time;",
"time",
"public ALDS1_3_B_Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"ALDS1_3_B_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\tprivate static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tString[] list = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(list[0]);\n\t\tint q = Integer.parseInt(list[1]);\n\t\t\n\t\tDeque<ALDS1_3_B_Process> deque = new ArrayDeque<>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\t\n\t\twhile(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"public class Main {\n\tprivate static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tString[] list = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(list[0]);\n\t\tint q = Integer.parseInt(list[1]);\n\t\t\n\t\tDeque<ALDS1_3_B_Process> deque = new ArrayDeque<>();\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tlist = br.readLine().split(\" \");\n\t\t\tString name = list[0];\n\t\t\tint time = Integer.parseInt(list[1]);\n\t\t\tdeque.addLast(new ALDS1_3_B_Process(name, time));\n\t\t}\n\t\t\n\t\tint timer = 0;\n\t\t\n\t\twhile(!deque.isEmpty()){\n\t\t\tALDS1_3_B_Process process = deque.pollFirst();\n\t\t\tint time = process.getTime();\n\t\t\tif(time <= q){\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(process.getName() + \" \" + timer);\n\t\t\t}else{\n\t\t\t\ttimer += q;\n\t\t\t\ttime -= q;\n\t\t\t\tprocess.setTime(time);\n\t\t\t\tdeque.offerLast(process);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws Exception {
String[] list = br.readLine().split(" ");
int n = Integer.parseInt(list[0]);
int q = Integer.parseInt(list[1]);
Deque<ALDS1_3_B_Process> deque = new ArrayDeque<>();
for(int i = 0; i < n; i++){
list = br.readLine().split(" ");
String name = list[0];
int time = Integer.parseInt(list[1]);
deque.addLast(new ALDS1_3_B_Process(name, time));
}
int timer = 0;
while(!deque.isEmpty()){
ALDS1_3_B_Process process = deque.pollFirst();
int time = process.getTime();
if(time <= q){
timer += time;
System.out.println(process.getName() + " " + timer);
}else{
timer += q;
time -= q;
process.setTime(time);
deque.offerLast(process);
}
}
}
}
class ALDS1_3_B_Process{
private String name;
private int time;
public ALDS1_3_B_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,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
20,
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,
2,
18,
13,
13,
13,
17,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
28,
13,
13,
30,
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
],
[
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
],
[
25,
27
],
[
8,
29
],
[
29,
30
],
[
29,
31
],
[
8,
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
],
[
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
],
[
8,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
71,
75
],
[
70,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
83,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
90,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
82,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
106,
108
],
[
103,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
103,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
8,
118
],
[
118,
119
],
[
118,
120
],
[
118,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
128,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
128,
133
],
[
133,
134
],
[
133,
135
],
[
6,
136
],
[
136,
137
],
[
0,
138
],
[
138,
139
],
[
138,
140
]
] | [
"import java.util.*;\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 int time = 0;\n int [] T = new int[n];\n String [] Name = new String[n];\n Queue<Integer> L = new ArrayDeque<>();\n ArrayList<Integer> opt = new ArrayList<>();\n for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }\n while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }\n for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);\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 n = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n int [] T = new int[n];\n String [] Name = new String[n];\n Queue<Integer> L = new ArrayDeque<>();\n ArrayList<Integer> opt = new ArrayList<>();\n for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }\n while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }\n for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);\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 int time = 0;\n int [] T = new int[n];\n String [] Name = new String[n];\n Queue<Integer> L = new ArrayDeque<>();\n ArrayList<Integer> opt = new ArrayList<>();\n for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }\n while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }\n for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n int [] T = new int[n];\n String [] Name = new String[n];\n Queue<Integer> L = new ArrayDeque<>();\n ArrayList<Integer> opt = new ArrayList<>();\n for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }\n while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }\n for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);\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 time = 0;",
"time",
"0",
"int [] T = new int[n];",
"T",
"new int[n]",
"n",
"String [] Name = new String[n];",
"Name",
"new String[n]",
"n",
"Queue<Integer> L = new ArrayDeque<>();",
"L",
"new ArrayDeque<>()",
"ArrayList<Integer> opt = new ArrayList<>();",
"opt",
"new ArrayList<>()",
"for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }",
"{\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }",
"Name[i] = sc.next()",
"Name[i]",
"Name",
"i",
"sc.next()",
"sc.next",
"sc",
"T[i] = sc.nextInt()",
"T[i]",
"T",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"L.add(i)",
"L.add",
"L",
"i",
"while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }",
"L.size()!=0",
"L.size()",
"L.size",
"L",
"0",
"{\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }",
"int p_num = L.poll();",
"p_num",
"L.poll()",
"L.poll",
"L",
"if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }",
"T[p_num]-q>0",
"T[p_num]-q",
"T[p_num]",
"T",
"p_num",
"q",
"0",
"{\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }",
"time+=q",
"time",
"q",
"T[p_num]-=q",
"T[p_num]",
"T",
"p_num",
"q",
"L.add(p_num)",
"L.add",
"L",
"p_num",
"{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }",
"time+=T[p_num]",
"time",
"T[p_num]",
"T",
"p_num",
"T[p_num]=time",
"T[p_num]",
"T",
"p_num",
"time",
"opt.add(p_num)",
"opt.add",
"opt",
"p_num",
"for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);",
"int i",
"opt",
"System.out.println(Name[i]+\" \"+T[i]);",
"System.out.println(Name[i]+\" \"+T[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"Name[i]+\" \"+T[i]",
"Name[i]+\" \"+T[i]",
"Name[i]",
"Name",
"i",
"\" \"",
"T[i]",
"T",
"i",
"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 int time = 0;\n int [] T = new int[n];\n String [] Name = new String[n];\n Queue<Integer> L = new ArrayDeque<>();\n ArrayList<Integer> opt = new ArrayList<>();\n for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }\n while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }\n for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);\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 int time = 0;\n int [] T = new int[n];\n String [] Name = new String[n];\n Queue<Integer> L = new ArrayDeque<>();\n ArrayList<Integer> opt = new ArrayList<>();\n for(int i=0;i<n;i++){\n Name[i] = sc.next();\n T[i] = sc.nextInt();\n L.add(i);\n }\n while(L.size()!=0){\n int p_num = L.poll();\n if(T[p_num]-q>0){\n time+=q;\n T[p_num]-=q;\n L.add(p_num);\n }\n else{\n time+=T[p_num];\n T[p_num]=time;\n opt.add(p_num);\n }\n }\n for(int i:opt) System.out.println(Name[i]+\" \"+T[i]);\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String [] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
int time = 0;
int [] T = new int[n];
String [] Name = new String[n];
Queue<Integer> L = new ArrayDeque<>();
ArrayList<Integer> opt = new ArrayList<>();
for(int i=0;i<n;i++){
Name[i] = sc.next();
T[i] = sc.nextInt();
L.add(i);
}
while(L.size()!=0){
int p_num = L.poll();
if(T[p_num]-q>0){
time+=q;
T[p_num]-=q;
L.add(p_num);
}
else{
time+=T[p_num];
T[p_num]=time;
opt.add(p_num);
}
}
for(int i:opt) System.out.println(Name[i]+" "+T[i]);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
6,
13,
41,
13,
17,
41,
13,
41,
13,
41,
13,
20,
13,
12,
13,
30,
0,
13,
17,
0,
13,
17,
29,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
2,
2,
13,
17,
13,
13,
12,
13,
30,
14,
4,
13,
4,
18,
18,
13,
13,
17,
0,
18,
13,
13,
20,
0,
18,
18,
13,
13,
13,
13,
0,
18,
18,
13,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
23,
13,
12,
13,
30,
14,
4,
13,
4,
18,
18,
13,
13,
17,
41,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
18,
13,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
13,
13,
13,
42,
40,
4,
13,
30,
41,
13,
20,
0,
13,
4,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
4,
13,
18,
13,
13,
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
] | [
[
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
],
[
0,
19
],
[
19,
20
],
[
19,
21
],
[
21,
22
],
[
21,
23
],
[
19,
24
],
[
24,
25
],
[
19,
26
],
[
26,
27
],
[
19,
28
],
[
28,
29
],
[
28,
30
],
[
19,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
38,
40
],
[
34,
41
],
[
19,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
19,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
53,
59
],
[
19,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
66,
71
],
[
62,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
72,
76
],
[
62,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
77,
83
],
[
62,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
84,
90
],
[
62,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
60,
98
],
[
98,
99
],
[
60,
100
],
[
100,
101
],
[
19,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
104,
114
],
[
114,
115
],
[
114,
116
],
[
104,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
104,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
19,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
130,
139
],
[
139,
140
],
[
139,
141
],
[
141,
142
],
[
142,
143
],
[
130,
144
],
[
144,
145
],
[
144,
146
],
[
130,
147
],
[
147,
148
],
[
130,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
154,
155
],
[
154,
156
],
[
149,
157
],
[
157,
158
],
[
158,
159
],
[
149,
160
],
[
161,
161
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
161,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
161,
172
],
[
172,
173
],
[
172,
174
],
[
172,
175
],
[
130,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
176,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
180,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
189,
193
],
[
188,
194
],
[
194,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
199
],
[
194,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
202,
204
],
[
200,
205
],
[
205,
206
],
[
205,
207
],
[
194,
208
],
[
208,
209
],
[
208,
210
],
[
188,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
214,
216
],
[
211,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
219,
221
],
[
217,
222
],
[
223,
223
],
[
223,
224
],
[
224,
225
],
[
224,
226
],
[
223,
227
],
[
223,
228
],
[
128,
229
],
[
229,
230
]
] | [
"import java.util.Scanner;\nimport java.lang.Math;\nimport java.lang.System;\nimport java.io.*;\nclass Process{\n String n;\n int t;\n}\nclass Main{\n private static int max = 100005;\n private static int head, tail;\n private static Process[] q=new Process[max];\n\n public static void initialize(){\n head = 0;\n tail = 0;\n return;\n }\n\n public static boolean isEmpty(){\n return head==tail;\n }\n\n public static boolean isFull(){\n return ((tail+1)%max==head);\n }\n\n public static void enqueue(String n, int t){\n if(isFull()) System.out.println(\"Error\");\n q[tail]=new Process();\n q[tail].n=n;\n q[tail].t=t;\n //System.out.println(tail);\n tail=(tail+1)%max;\n //System.out.println(tail);\n }\n\n public static Process dequeue(){\n if(isEmpty()) System.out.println(\"Error\");\n int x=head;\n head=(head+1)%max;\n return q[x];\n }\n\n public static void main(String args[]) throws Exception{\n Scanner stdIn=new Scanner(System.in);\n int namecnt=stdIn.nextInt();\n int quantum=stdIn.nextInt();\n int total=0;\n\n // InputStreamReader isr=new InputStreamReader(System.in);\n // BufferedReader br=new BufferedReader(isr);\n String line;\n for(int i=0;i<namecnt;i++){\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }\n\n while(!isEmpty()){\n Process temp=new Process();\n temp=dequeue();\n //System.out.println(temp.n+temp.t);\n if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }\n }\n }\n}\n\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.lang.Math;",
"Math",
"java.lang",
"import java.lang.System;",
"System",
"java.lang",
"import java.io.*;",
"io.*",
"java",
"class Process{\n String n;\n int t;\n}",
"Process",
"String n;",
"n",
"int t;",
"t",
"class Main{\n private static int max = 100005;\n private static int head, tail;\n private static Process[] q=new Process[max];\n\n public static void initialize(){\n head = 0;\n tail = 0;\n return;\n }\n\n public static boolean isEmpty(){\n return head==tail;\n }\n\n public static boolean isFull(){\n return ((tail+1)%max==head);\n }\n\n public static void enqueue(String n, int t){\n if(isFull()) System.out.println(\"Error\");\n q[tail]=new Process();\n q[tail].n=n;\n q[tail].t=t;\n //System.out.println(tail);\n tail=(tail+1)%max;\n //System.out.println(tail);\n }\n\n public static Process dequeue(){\n if(isEmpty()) System.out.println(\"Error\");\n int x=head;\n head=(head+1)%max;\n return q[x];\n }\n\n public static void main(String args[]) throws Exception{\n Scanner stdIn=new Scanner(System.in);\n int namecnt=stdIn.nextInt();\n int quantum=stdIn.nextInt();\n int total=0;\n\n // InputStreamReader isr=new InputStreamReader(System.in);\n // BufferedReader br=new BufferedReader(isr);\n String line;\n for(int i=0;i<namecnt;i++){\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }\n\n while(!isEmpty()){\n Process temp=new Process();\n temp=dequeue();\n //System.out.println(temp.n+temp.t);\n if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }\n }\n }\n}",
"Main",
"private static int max = 100005;",
"max",
"100005",
"private static int head",
"head",
"tail;",
"tail",
"private static Process[] q=new Process[max];",
"q",
"new Process[max]",
"max",
"public static void initialize(){\n head = 0;\n tail = 0;\n return;\n }",
"initialize",
"{\n head = 0;\n tail = 0;\n return;\n }",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"return;",
"public static boolean isEmpty(){\n return head==tail;\n }",
"isEmpty",
"{\n return head==tail;\n }",
"return head==tail;",
"head==tail",
"head",
"tail",
"public static boolean isFull(){\n return ((tail+1)%max==head);\n }",
"isFull",
"{\n return ((tail+1)%max==head);\n }",
"return ((tail+1)%max==head);",
"((tail+1)%max==head)",
"(tail+1)%max",
"(tail+1)",
"tail",
"1",
"max",
"head",
"public static void enqueue(String n, int t){\n if(isFull()) System.out.println(\"Error\");\n q[tail]=new Process();\n q[tail].n=n;\n q[tail].t=t;\n //System.out.println(tail);\n tail=(tail+1)%max;\n //System.out.println(tail);\n }",
"enqueue",
"{\n if(isFull()) System.out.println(\"Error\");\n q[tail]=new Process();\n q[tail].n=n;\n q[tail].t=t;\n //System.out.println(tail);\n tail=(tail+1)%max;\n //System.out.println(tail);\n }",
"if(isFull()) System.out.println(\"Error\");",
"isFull()",
"isFull",
"System.out.println(\"Error\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"Error\"",
"q[tail]=new Process()",
"q[tail]",
"q",
"tail",
"new Process()",
"q[tail].n=n",
"q[tail].n",
"q[tail]",
"q",
"tail",
"q[tail].n",
"n",
"q[tail].t=t",
"q[tail].t",
"q[tail]",
"q",
"tail",
"q[tail].t",
"t",
"tail=(tail+1)%max",
"tail",
"(tail+1)%max",
"(tail+1)",
"tail",
"1",
"max",
"String n",
"n",
"int t",
"t",
"public static Process dequeue(){\n if(isEmpty()) System.out.println(\"Error\");\n int x=head;\n head=(head+1)%max;\n return q[x];\n }",
"dequeue",
"{\n if(isEmpty()) System.out.println(\"Error\");\n int x=head;\n head=(head+1)%max;\n return q[x];\n }",
"if(isEmpty()) System.out.println(\"Error\");",
"isEmpty()",
"isEmpty",
"System.out.println(\"Error\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"Error\"",
"int x=head;",
"x",
"head",
"head=(head+1)%max",
"head",
"(head+1)%max",
"(head+1)",
"head",
"1",
"max",
"return q[x];",
"q[x]",
"q",
"x",
"public static void main(String args[]) throws Exception{\n Scanner stdIn=new Scanner(System.in);\n int namecnt=stdIn.nextInt();\n int quantum=stdIn.nextInt();\n int total=0;\n\n // InputStreamReader isr=new InputStreamReader(System.in);\n // BufferedReader br=new BufferedReader(isr);\n String line;\n for(int i=0;i<namecnt;i++){\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }\n\n while(!isEmpty()){\n Process temp=new Process();\n temp=dequeue();\n //System.out.println(temp.n+temp.t);\n if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }\n }\n }",
"main",
"{\n Scanner stdIn=new Scanner(System.in);\n int namecnt=stdIn.nextInt();\n int quantum=stdIn.nextInt();\n int total=0;\n\n // InputStreamReader isr=new InputStreamReader(System.in);\n // BufferedReader br=new BufferedReader(isr);\n String line;\n for(int i=0;i<namecnt;i++){\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }\n\n while(!isEmpty()){\n Process temp=new Process();\n temp=dequeue();\n //System.out.println(temp.n+temp.t);\n if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }\n }\n }",
"Scanner stdIn=new Scanner(System.in);",
"stdIn",
"new Scanner(System.in)",
"int namecnt=stdIn.nextInt();",
"namecnt",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int quantum=stdIn.nextInt();",
"quantum",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"int total=0;",
"total",
"0",
"String line;",
"line",
"for(int i=0;i<namecnt;i++){\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<namecnt",
"i",
"namecnt",
"i++",
"i++",
"i",
"{\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }",
"{\n String n=stdIn.next();\n int t=stdIn.nextInt();\n enqueue(n,t);\n //String[] str=line.split(\" \");\n // enqueue(str[0],Integer.parseInt(str[1]));\n\n //System.out.println(line);\n }",
"String n=stdIn.next();",
"n",
"stdIn.next()",
"stdIn.next",
"stdIn",
"int t=stdIn.nextInt();",
"t",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"enqueue(n,t)",
"enqueue",
"n",
"t",
"while(!isEmpty()){\n Process temp=new Process();\n temp=dequeue();\n //System.out.println(temp.n+temp.t);\n if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }\n }",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n Process temp=new Process();\n temp=dequeue();\n //System.out.println(temp.n+temp.t);\n if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }\n }",
"Process temp=new Process();",
"temp",
"new Process()",
"temp=dequeue()",
"temp",
"dequeue()",
"dequeue",
"if(temp.t>quantum){\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }\n else{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }",
"temp.t>quantum",
"temp.t",
"temp",
"temp.t",
"quantum",
"{\n temp.t-=quantum;\n enqueue(temp.n,temp.t);\n total+=quantum;\n }",
"temp.t-=quantum",
"temp.t",
"temp",
"temp.t",
"quantum",
"enqueue(temp.n,temp.t)",
"enqueue",
"temp.n",
"temp",
"temp.n",
"temp.t",
"temp",
"temp.t",
"total+=quantum",
"total",
"quantum",
"{\n total+=temp.t;\n System.out.println(temp.n+\" \"+total);\n }",
"total+=temp.t",
"total",
"temp.t",
"temp",
"temp.t",
"System.out.println(temp.n+\" \"+total)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.n+\" \"+total",
"temp.n+\" \"+total",
"temp.n",
"temp",
"temp.n",
"\" \"",
"total",
"String args[]",
"args"
] | import java.util.Scanner;
import java.lang.Math;
import java.lang.System;
import java.io.*;
class Process{
String n;
int t;
}
class Main{
private static int max = 100005;
private static int head, tail;
private static Process[] q=new Process[max];
public static void initialize(){
head = 0;
tail = 0;
return;
}
public static boolean isEmpty(){
return head==tail;
}
public static boolean isFull(){
return ((tail+1)%max==head);
}
public static void enqueue(String n, int t){
if(isFull()) System.out.println("Error");
q[tail]=new Process();
q[tail].n=n;
q[tail].t=t;
//System.out.println(tail);
tail=(tail+1)%max;
//System.out.println(tail);
}
public static Process dequeue(){
if(isEmpty()) System.out.println("Error");
int x=head;
head=(head+1)%max;
return q[x];
}
public static void main(String args[]) throws Exception{
Scanner stdIn=new Scanner(System.in);
int namecnt=stdIn.nextInt();
int quantum=stdIn.nextInt();
int total=0;
// InputStreamReader isr=new InputStreamReader(System.in);
// BufferedReader br=new BufferedReader(isr);
String line;
for(int i=0;i<namecnt;i++){
String n=stdIn.next();
int t=stdIn.nextInt();
enqueue(n,t);
//String[] str=line.split(" ");
// enqueue(str[0],Integer.parseInt(str[1]));
//System.out.println(line);
}
while(!isEmpty()){
Process temp=new Process();
temp=dequeue();
//System.out.println(temp.n+temp.t);
if(temp.t>quantum){
temp.t-=quantum;
enqueue(temp.n,temp.t);
total+=quantum;
}
else{
total+=temp.t;
System.out.println(temp.n+" "+total);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
0,
13,
17,
42,
40,
4,
18,
13,
30,
0,
13,
4,
18,
13,
14,
40,
4,
18,
13,
13,
4,
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,
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,
41,
13,
20,
4,
18,
13,
13,
4,
18,
13,
4,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
13,
29,
17,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
29,
17,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
164,
11
],
[
164,
12
],
[
12,
13
],
[
12,
14
],
[
164,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
17,
20
],
[
20,
21
],
[
20,
22
],
[
17,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
28,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
28,
34
],
[
34,
35
],
[
35,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
34,
40
],
[
40,
41
],
[
41,
42
],
[
40,
43
],
[
15,
44
],
[
44,
45
],
[
15,
46
],
[
46,
47
],
[
164,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
50,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
50,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
50,
64
],
[
64,
65
],
[
64,
66
],
[
50,
67
],
[
67,
68
],
[
50,
69
],
[
69,
70
],
[
50,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
71,
76
],
[
76,
77
],
[
76,
78
],
[
71,
79
],
[
79,
80
],
[
80,
81
],
[
71,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
83,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
83,
94
],
[
94,
95
],
[
94,
96
],
[
83,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
50,
101
],
[
101,
102
],
[
102,
103
],
[
50,
104
],
[
104,
105
],
[
104,
106
],
[
104,
107
],
[
48,
108
],
[
108,
109
],
[
164,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
110,
114
],
[
114,
115
],
[
110,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
122,
123
],
[
122,
124
],
[
116,
125
],
[
125,
126
],
[
116,
127
],
[
127,
128
],
[
110,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
140,
142
],
[
136,
143
],
[
143,
144
],
[
132,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
155,
155
],
[
155,
156
],
[
155,
157
],
[
155,
158
],
[
145,
159
],
[
159,
160
],
[
129,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"import java.util.Scanner;\nimport java.util.Queue;\nimport java.util.LinkedList;\n\npublic class Main{\n\tprivate static int timer = 0;\n\n\tpublic static void processor(Queue<Process> p, int q){\n\t\tProcess x;\n\t\ttimer = 0;\n\t\twhile(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}\n\t}\t\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\n\t\tQueue<Process> p = new LinkedList<Process>();\n\t\tString name;\n\t\tint time;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}\n\n\t\tsc.close();\n\n\t\tprocessor(p,quantum);\n\t}\n\n\tprivate static class Process{\n\t\tString name;\n\t\tint time; //remaining time\n\n\t\tpublic Process(String n, int t){\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}\n\n\t\t//return if it ends\n\t\tpublic boolean handle(int q){\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"public class Main{\n\tprivate static int timer = 0;\n\n\tpublic static void processor(Queue<Process> p, int q){\n\t\tProcess x;\n\t\ttimer = 0;\n\t\twhile(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}\n\t}\t\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\n\t\tQueue<Process> p = new LinkedList<Process>();\n\t\tString name;\n\t\tint time;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}\n\n\t\tsc.close();\n\n\t\tprocessor(p,quantum);\n\t}\n\n\tprivate static class Process{\n\t\tString name;\n\t\tint time; //remaining time\n\n\t\tpublic Process(String n, int t){\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}\n\n\t\t//return if it ends\n\t\tpublic boolean handle(int q){\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"private static int timer = 0;",
"timer",
"0",
"public static void processor(Queue<Process> p, int q){\n\t\tProcess x;\n\t\ttimer = 0;\n\t\twhile(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}\n\t}",
"processor",
"{\n\t\tProcess x;\n\t\ttimer = 0;\n\t\twhile(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}\n\t}",
"Process x;",
"x",
"timer = 0",
"timer",
"0",
"while(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}",
"!p.isEmpty()",
"p.isEmpty()",
"p.isEmpty",
"p",
"{\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}",
"x = p.remove()",
"x",
"p.remove()",
"p.remove",
"p",
"if(!x.handle(q)) p.add(x);",
"!x.handle(q)",
"x.handle(q)",
"x.handle",
"x",
"q",
"p.add(x)",
"p.add",
"p",
"x",
"Queue<Process> p",
"p",
"int q",
"q",
"public static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\n\t\tQueue<Process> p = new LinkedList<Process>();\n\t\tString name;\n\t\tint time;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}\n\n\t\tsc.close();\n\n\t\tprocessor(p,quantum);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\n\t\tQueue<Process> p = new LinkedList<Process>();\n\t\tString name;\n\t\tint time;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}\n\n\t\tsc.close();\n\n\t\tprocessor(p,quantum);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int quantum = sc.nextInt();",
"quantum",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Process> p = new LinkedList<Process>();",
"p",
"new LinkedList<Process>()",
"String name;",
"name",
"int time;",
"time",
"for(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}",
"{\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}",
"name = sc.next()",
"name",
"sc.next()",
"sc.next",
"sc",
"time = sc.nextInt()",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Process x = new Process(name, time);",
"x",
"new Process(name, time)",
"p.add(x)",
"p.add",
"p",
"x",
"sc.close()",
"sc.close",
"sc",
"processor(p,quantum)",
"processor",
"p",
"quantum",
"String[] args",
"args",
"private static class Process{\n\t\tString name;\n\t\tint time; //remaining time\n\n\t\tpublic Process(String n, int t){\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}\n\n\t\t//return if it ends\n\t\tpublic boolean handle(int q){\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}\n\t}",
"Process",
"String name;",
"name",
"int time; //remaining time",
"time",
"public Process(String n, int t){\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}",
"Process",
"{\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}",
"name = n",
"name",
"n",
"time = t",
"time",
"t",
"String n",
"n",
"int t",
"t",
"//return if it ends\n\t\tpublic boolean handle(int q){\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}",
"handle",
"{\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}",
"if(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}",
"q<time",
"q",
"time",
"{\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\n\t\t\t}",
"time -= q",
"time",
"q",
"timer +=q",
"timer",
"q",
"return false;",
"false",
"{\n\t\t\t\ttimer += time;\n\t\t\t\tSystem.out.println(name+\" \"+timer);\n\t\t\t\treturn true;\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",
"return true;",
"true",
"int q",
"q",
"public class Main{\n\tprivate static int timer = 0;\n\n\tpublic static void processor(Queue<Process> p, int q){\n\t\tProcess x;\n\t\ttimer = 0;\n\t\twhile(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}\n\t}\t\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\n\t\tQueue<Process> p = new LinkedList<Process>();\n\t\tString name;\n\t\tint time;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}\n\n\t\tsc.close();\n\n\t\tprocessor(p,quantum);\n\t}\n\n\tprivate static class Process{\n\t\tString name;\n\t\tint time; //remaining time\n\n\t\tpublic Process(String n, int t){\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}\n\n\t\t//return if it ends\n\t\tpublic boolean handle(int q){\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main{\n\tprivate static int timer = 0;\n\n\tpublic static void processor(Queue<Process> p, int q){\n\t\tProcess x;\n\t\ttimer = 0;\n\t\twhile(!p.isEmpty()){\n\t\t\tx = p.remove();\n\t\t\tif(!x.handle(q)) p.add(x);\n\t\t}\n\t}\t\n\n\tpublic static void main(String[] args){\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint quantum = sc.nextInt();\n\n\t\tQueue<Process> p = new LinkedList<Process>();\n\t\tString name;\n\t\tint time;\n\t\tfor(int i=0; i<n; i++){\n\t\t\tname = sc.next();\n\t\t\ttime = sc.nextInt();\n\t\t\tProcess x = new Process(name, time);\n\t\t\tp.add(x);\n\t\t}\n\n\t\tsc.close();\n\n\t\tprocessor(p,quantum);\n\t}\n\n\tprivate static class Process{\n\t\tString name;\n\t\tint time; //remaining time\n\n\t\tpublic Process(String n, int t){\n\t\t\tname = n;\n\t\t\ttime = t;\n\t\t}\n\n\t\t//return if it ends\n\t\tpublic boolean handle(int q){\n\t\t\tif(q<time){\n\t\t\t\ttime -= q;\n\t\t\t\ttimer +=q;\n\t\t\t\treturn false;\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\treturn true;\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;
public class Main{
private static int timer = 0;
public static void processor(Queue<Process> p, int q){
Process x;
timer = 0;
while(!p.isEmpty()){
x = p.remove();
if(!x.handle(q)) p.add(x);
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int quantum = sc.nextInt();
Queue<Process> p = new LinkedList<Process>();
String name;
int time;
for(int i=0; i<n; i++){
name = sc.next();
time = sc.nextInt();
Process x = new Process(name, time);
p.add(x);
}
sc.close();
processor(p,quantum);
}
private static class Process{
String name;
int time; //remaining time
public Process(String n, int t){
name = n;
time = t;
}
//return if it ends
public boolean handle(int q){
if(q<time){
time -= q;
timer +=q;
return false;
}
else{
timer += time;
System.out.println(name+" "+timer);
return true;
}
}
}
}
|
[
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,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
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,
35
],
[
35,
36
],
[
35,
37
],
[
14,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
52,
56
],
[
56,
57
],
[
57,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
63,
64
],
[
64,
65
],
[
51,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
14,
70
],
[
70,
71
],
[
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
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
90,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
96,
101
],
[
102,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
102,
107
],
[
84,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
108,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
12,
121
],
[
121,
122
]
] | [
"import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Queue;\n\nclass Main{\n public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n Queue<Integer> queue = new ArrayDeque<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String name[] = new String[n];\n int time[] = new int[n];\n for(int i = 0; i < n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n \n int x = 0;\n while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }\n }\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 Scanner sc = new Scanner(System.in);\n Queue<Integer> queue = new ArrayDeque<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String name[] = new String[n];\n int time[] = new int[n];\n for(int i = 0; i < n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n \n int x = 0;\n while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }\n }\n}",
"Main",
"public static void main(String args[]){\n Scanner sc = new Scanner(System.in);\n Queue<Integer> queue = new ArrayDeque<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String name[] = new String[n];\n int time[] = new int[n];\n for(int i = 0; i < n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n \n int x = 0;\n while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n Queue<Integer> queue = new ArrayDeque<>();\n \n int n = sc.nextInt();\n int q = sc.nextInt();\n String name[] = new String[n];\n int time[] = new int[n];\n for(int i = 0; i < n; i++){\n name[i] = sc.next();\n time[i] = sc.nextInt();\n queue.add(i);\n }\n \n int x = 0;\n while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<Integer> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"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 queue.add(i);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name[i] = sc.next();\n time[i] = sc.nextInt();\n 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 x = 0;",
"x",
"0",
"while(!queue.isEmpty()){\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n int y = queue.poll();\n if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }\n }",
"int y = queue.poll();",
"y",
"queue.poll()",
"queue.poll",
"queue",
"if(time[y] <= q){\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }else{\n x += q;\n time[y] -= q;\n queue.add(y);\n }",
"time[y] <= q",
"time[y]",
"time",
"y",
"q",
"{\n x += time[y];\n System.out.println(name[y]+\" \"+x);\n }",
"x += time[y]",
"x",
"time[y]",
"time",
"y",
"System.out.println(name[y]+\" \"+x)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[y]+\" \"+x",
"name[y]+\" \"+x",
"name[y]",
"name",
"y",
"\" \"",
"x",
"{\n x += q;\n time[y] -= q;\n queue.add(y);\n }",
"x += q",
"x",
"q",
"time[y] -= q",
"time[y]",
"time",
"y",
"q",
"queue.add(y)",
"queue.add",
"queue",
"y",
"String args[]",
"args"
] | import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
Queue<Integer> queue = new ArrayDeque<>();
int n = sc.nextInt();
int q = sc.nextInt();
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();
queue.add(i);
}
int x = 0;
while(!queue.isEmpty()){
int y = queue.poll();
if(time[y] <= q){
x += time[y];
System.out.println(name[y]+" "+x);
}else{
x += q;
time[y] -= q;
queue.add(y);
}
}
}
}
|
[
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,
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,
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,
11,
1,
41,
13,
17,
2,
4,
18,
13,
17,
1,
40,
13,
30,
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
],
[
17,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
43,
46
],
[
46,
47
],
[
46,
48
],
[
17,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
54,
55
],
[
54,
56
],
[
17,
57
],
[
57,
58
],
[
57,
59
],
[
17,
60
],
[
60,
61
],
[
60,
62
],
[
17,
64
],
[
64,
65
],
[
64,
66
],
[
17,
67
],
[
67,
68
],
[
67,
69
],
[
17,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
70,
75
],
[
75,
76
],
[
75,
77
],
[
70,
78
],
[
78,
79
],
[
79,
80
],
[
70,
81
],
[
82,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
85,
86
],
[
86,
87
],
[
82,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
82,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
97,
98
],
[
97,
99
],
[
82,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
103,
104
],
[
104,
105
],
[
103,
106
],
[
106,
107
],
[
106,
108
],
[
17,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
109,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
114,
118
],
[
109,
119
],
[
119,
120
],
[
120,
121
],
[
109,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
123,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
123,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
142,
143
],
[
142,
144
],
[
138,
145
],
[
145,
146
],
[
146,
147
],
[
145,
148
],
[
138,
149
],
[
149,
150
],
[
149,
151
],
[
134,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
162,
162
],
[
162,
163
],
[
162,
164
],
[
162,
165
],
[
15,
166
],
[
166,
167
]
] | [
"/* 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 count = 0;\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\tint[] array = new int[n];\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\tfor(int i=0;queue.isEmpty()!=true;i++){\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 count = 0;\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\tint[] array = new int[n];\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\tfor(int i=0;queue.isEmpty()!=true;i++){\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 count = 0;\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\tint[] array = new int[n];\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\tfor(int i=0;queue.isEmpty()!=true;i++){\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 count = 0;\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\tint[] array = new int[n];\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\tfor(int i=0;queue.isEmpty()!=true;i++){\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 count = 0;",
"count",
"0",
"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()",
"int[] array = new int[n];",
"array",
"new int[n]",
"n",
"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",
"for(int i=0;queue.isEmpty()!=true;i++){\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}",
"int i=0;",
"int i=0;",
"i",
"0",
"queue.isEmpty()!=true",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"true",
"i++",
"i++",
"i",
"{\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\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 count = 0;
long timer = 0;
int time = 0;
int n = Integer.parseInt(str[0]);
int q = Integer.parseInt(str[1]);
String name = new String();
int[] array = new int[n];
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]));
}
for(int i=0;queue.isEmpty()!=true;i++){
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,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
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,
13,
13,
4,
18,
13,
13,
41,
13,
17,
41,
13,
20,
41,
13,
20,
42,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
0,
13,
4,
18,
13,
13,
13,
0,
13,
4,
18,
13,
17,
2,
13,
13,
4,
18,
13,
13,
13,
14,
2,
13,
17,
30,
4,
18,
13,
13,
4,
18,
13,
13,
13,
14,
2,
4,
18,
13,
13,
3,
30,
4,
18,
13,
13,
11,
1,
41,
13,
17,
2,
13,
4,
18,
13,
1,
40,
13,
30,
30,
4,
18,
13,
2,
2,
4,
18,
13,
13,
17,
4,
18,
13,
4,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
20,
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
],
[
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
],
[
83,
84
],
[
82,
85
],
[
82,
86
],
[
60,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
11,
91
],
[
91,
92
],
[
91,
93
],
[
11,
94
],
[
94,
95
],
[
94,
96
],
[
11,
97
],
[
97,
98
],
[
97,
99
],
[
11,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
102,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
102,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
116,
120
],
[
102,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
123,
127
],
[
127,
128
],
[
127,
129
],
[
102,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
130,
134
],
[
102,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
140,
143
],
[
139,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
144,
148
],
[
139,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
150,
154
],
[
149,
155
],
[
135,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
157,
160
],
[
11,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
161,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
161,
171
],
[
171,
172
],
[
172,
173
],
[
161,
174
],
[
175,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
176,
179
],
[
180,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
181,
184
],
[
180,
185
],
[
180,
186
],
[
186,
187
],
[
187,
188
],
[
186,
189
],
[
189,
190
],
[
190,
191
],
[
189,
192
],
[
9,
193
],
[
193,
194
]
] | [
"import java.util.*;\nimport java.io.*;\nclass Main{\n\tpublic static void main(String[]args){\n\t\tScanner in=new Scanner(System.in);\n\t\tPrintWriter out=new PrintWriter(System.out, true);\n\t\tString str[]=in.nextLine().split(\" \");\n\t\tint n=Integer.parseInt(str[0]);\n\t\tint q=Integer.parseInt(str[1]);\n\t\tHashMap<String, Integer> map=new HashMap<>();\n\t\tQueue<String> queue=new LinkedList<>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}\n\t\tint time=0;\n\t\tArrayList<String> list=new ArrayList<>();\n\t\tHashMap<String, Integer> map_2=new HashMap<>();\n\t\t\n\t\twhile(true){\n\t\t String pid=queue.poll();\n\t\t int ptime=map.get(pid);\n\t\t time+=Math.min(q, ptime);\n\t\t ptime=Math.max(0, ptime-q);\n\t\t map.put(pid, ptime);\n\t\t if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }\n\t\t}\n\t\tfor(int i=0;i<list.size();i++){\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}\n\t}\n\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"class Main{\n\tpublic static void main(String[]args){\n\t\tScanner in=new Scanner(System.in);\n\t\tPrintWriter out=new PrintWriter(System.out, true);\n\t\tString str[]=in.nextLine().split(\" \");\n\t\tint n=Integer.parseInt(str[0]);\n\t\tint q=Integer.parseInt(str[1]);\n\t\tHashMap<String, Integer> map=new HashMap<>();\n\t\tQueue<String> queue=new LinkedList<>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}\n\t\tint time=0;\n\t\tArrayList<String> list=new ArrayList<>();\n\t\tHashMap<String, Integer> map_2=new HashMap<>();\n\t\t\n\t\twhile(true){\n\t\t String pid=queue.poll();\n\t\t int ptime=map.get(pid);\n\t\t time+=Math.min(q, ptime);\n\t\t ptime=Math.max(0, ptime-q);\n\t\t map.put(pid, ptime);\n\t\t if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }\n\t\t}\n\t\tfor(int i=0;i<list.size();i++){\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[]args){\n\t\tScanner in=new Scanner(System.in);\n\t\tPrintWriter out=new PrintWriter(System.out, true);\n\t\tString str[]=in.nextLine().split(\" \");\n\t\tint n=Integer.parseInt(str[0]);\n\t\tint q=Integer.parseInt(str[1]);\n\t\tHashMap<String, Integer> map=new HashMap<>();\n\t\tQueue<String> queue=new LinkedList<>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}\n\t\tint time=0;\n\t\tArrayList<String> list=new ArrayList<>();\n\t\tHashMap<String, Integer> map_2=new HashMap<>();\n\t\t\n\t\twhile(true){\n\t\t String pid=queue.poll();\n\t\t int ptime=map.get(pid);\n\t\t time+=Math.min(q, ptime);\n\t\t ptime=Math.max(0, ptime-q);\n\t\t map.put(pid, ptime);\n\t\t if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }\n\t\t}\n\t\tfor(int i=0;i<list.size();i++){\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}\n\t}",
"main",
"{\n\t\tScanner in=new Scanner(System.in);\n\t\tPrintWriter out=new PrintWriter(System.out, true);\n\t\tString str[]=in.nextLine().split(\" \");\n\t\tint n=Integer.parseInt(str[0]);\n\t\tint q=Integer.parseInt(str[1]);\n\t\tHashMap<String, Integer> map=new HashMap<>();\n\t\tQueue<String> queue=new LinkedList<>();\n\t\tfor(int i=0;i<n;i++){\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}\n\t\tint time=0;\n\t\tArrayList<String> list=new ArrayList<>();\n\t\tHashMap<String, Integer> map_2=new HashMap<>();\n\t\t\n\t\twhile(true){\n\t\t String pid=queue.poll();\n\t\t int ptime=map.get(pid);\n\t\t time+=Math.min(q, ptime);\n\t\t ptime=Math.max(0, ptime-q);\n\t\t map.put(pid, ptime);\n\t\t if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }\n\t\t}\n\t\tfor(int i=0;i<list.size();i++){\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}\n\t}",
"Scanner in=new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"PrintWriter out=new PrintWriter(System.out, true);",
"out",
"new PrintWriter(System.out, true)",
"String str[]=in.nextLine().split(\" \");",
"str",
"in.nextLine().split(\" \")",
"in.nextLine().split",
"in.nextLine()",
"in.nextLine",
"in",
"\" \"",
"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",
"HashMap<String, Integer> map=new HashMap<>();",
"map",
"new HashMap<>()",
"Queue<String> queue=new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for(int i=0;i<n;i++){\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}",
"{\n\t\t\tstr=in.nextLine().split(\" \");\n\t\t\tString pid=str[0];\n\t\t\tint ptime=Integer.parseInt(str[1]);\n\t\t\tmap.put(pid, ptime);\n\t\t\tqueue.add(pid);\n\t\t}",
"str=in.nextLine().split(\" \")",
"str",
"in.nextLine().split(\" \")",
"in.nextLine().split",
"in.nextLine()",
"in.nextLine",
"in",
"\" \"",
"String pid=str[0];",
"pid",
"str[0]",
"str",
"0",
"int ptime=Integer.parseInt(str[1]);",
"ptime",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"map.put(pid, ptime)",
"map.put",
"map",
"pid",
"ptime",
"queue.add(pid)",
"queue.add",
"queue",
"pid",
"int time=0;",
"time",
"0",
"ArrayList<String> list=new ArrayList<>();",
"list",
"new ArrayList<>()",
"HashMap<String, Integer> map_2=new HashMap<>();",
"map_2",
"new HashMap<>()",
"while(true){\n\t\t String pid=queue.poll();\n\t\t int ptime=map.get(pid);\n\t\t time+=Math.min(q, ptime);\n\t\t ptime=Math.max(0, ptime-q);\n\t\t map.put(pid, ptime);\n\t\t if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }\n\t\t}",
"true",
"{\n\t\t String pid=queue.poll();\n\t\t int ptime=map.get(pid);\n\t\t time+=Math.min(q, ptime);\n\t\t ptime=Math.max(0, ptime-q);\n\t\t map.put(pid, ptime);\n\t\t if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }\n\t\t}",
"String pid=queue.poll();",
"pid",
"queue.poll()",
"queue.poll",
"queue",
"int ptime=map.get(pid);",
"ptime",
"map.get(pid)",
"map.get",
"map",
"pid",
"time+=Math.min(q, ptime)",
"time",
"Math.min(q, ptime)",
"Math.min",
"Math",
"q",
"ptime",
"ptime=Math.max(0, ptime-q)",
"ptime",
"Math.max(0, ptime-q)",
"Math.max",
"Math",
"0",
"ptime-q",
"ptime",
"q",
"map.put(pid, ptime)",
"map.put",
"map",
"pid",
"ptime",
"if(ptime==0){\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }else{\n\t\t\t queue.add(pid);\n\t\t }",
"ptime==0",
"ptime",
"0",
"{\n\t\t\t list.add(pid);\n\t\t\t map_2.put(pid, time);\n\t\t\t if(list.size()==n)\n\t\t\t\t break;\n\t\t }",
"list.add(pid)",
"list.add",
"list",
"pid",
"map_2.put(pid, time)",
"map_2.put",
"map_2",
"pid",
"time",
"if(list.size()==n)\n\t\t\t\t break;",
"list.size()==n",
"list.size()",
"list.size",
"list",
"n",
"break;",
"{\n\t\t\t queue.add(pid);\n\t\t }",
"queue.add(pid)",
"queue.add",
"queue",
"pid",
"for(int i=0;i<list.size();i++){\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<list.size()",
"i",
"list.size()",
"list.size",
"list",
"i++",
"i++",
"i",
"{\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}",
"{\n\t\t\tout.println(list.get(i)+\" \"+map_2.get(list.get(i)));\n\t\t}",
"out.println(list.get(i)+\" \"+map_2.get(list.get(i)))",
"out.println",
"out",
"list.get(i)+\" \"+map_2.get(list.get(i))",
"list.get(i)+\" \"+map_2.get(list.get(i))",
"list.get(i)",
"list.get",
"list",
"i",
"\" \"",
"map_2.get(list.get(i))",
"map_2.get",
"map_2",
"list.get(i)",
"list.get",
"list",
"i",
"String[]args",
"args"
] | import java.util.*;
import java.io.*;
class Main{
public static void main(String[]args){
Scanner in=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out, true);
String str[]=in.nextLine().split(" ");
int n=Integer.parseInt(str[0]);
int q=Integer.parseInt(str[1]);
HashMap<String, Integer> map=new HashMap<>();
Queue<String> queue=new LinkedList<>();
for(int i=0;i<n;i++){
str=in.nextLine().split(" ");
String pid=str[0];
int ptime=Integer.parseInt(str[1]);
map.put(pid, ptime);
queue.add(pid);
}
int time=0;
ArrayList<String> list=new ArrayList<>();
HashMap<String, Integer> map_2=new HashMap<>();
while(true){
String pid=queue.poll();
int ptime=map.get(pid);
time+=Math.min(q, ptime);
ptime=Math.max(0, ptime-q);
map.put(pid, ptime);
if(ptime==0){
list.add(pid);
map_2.put(pid, time);
if(list.size()==n)
break;
}else{
queue.add(pid);
}
}
for(int i=0;i<list.size();i++){
out.println(list.get(i)+" "+map_2.get(list.get(i)));
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
14,
2,
2,
4,
18,
13,
13,
17,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
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
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
25
],
[
25,
26
],
[
25,
27
],
[
8,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
48,
49
],
[
43,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
8,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
64,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
76,
77
],
[
71,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
81,
85
],
[
71,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
63,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
97,
98
],
[
91,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
105,
109
],
[
105,
110
],
[
6,
111
],
[
111,
112
]
] | [
"import java.util.*;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<String> qProcess = new LinkedList<String>();\n\t\tQueue<Integer> qTime = new LinkedList<Integer>();\n\t\t\n\t\tint totalTime = 0;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (qProcess.size()>0) {\n\t\t\tif (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<String> qProcess = new LinkedList<String>();\n\t\tQueue<Integer> qTime = new LinkedList<Integer>();\n\t\t\n\t\tint totalTime = 0;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (qProcess.size()>0) {\n\t\t\tif (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<String> qProcess = new LinkedList<String>();\n\t\tQueue<Integer> qTime = new LinkedList<Integer>();\n\t\t\n\t\tint totalTime = 0;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (qProcess.size()>0) {\n\t\t\tif (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\t\n\t\tQueue<String> qProcess = new LinkedList<String>();\n\t\tQueue<Integer> qTime = new LinkedList<Integer>();\n\t\t\n\t\tint totalTime = 0;\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}\n\t\t\n\t\twhile (qProcess.size()>0) {\n\t\t\tif (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<String> qProcess = new LinkedList<String>();",
"qProcess",
"new LinkedList<String>()",
"Queue<Integer> qTime = new LinkedList<Integer>();",
"qTime",
"new LinkedList<Integer>()",
"int totalTime = 0;",
"totalTime",
"0",
"for (int i = 0; i < n; i++) {\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tqProcess.add(sc.next());\n\t\t\tqTime.add(sc.nextInt());\n\t\t}",
"qProcess.add(sc.next())",
"qProcess.add",
"qProcess",
"sc.next()",
"sc.next",
"sc",
"qTime.add(sc.nextInt())",
"qTime.add",
"qTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while (qProcess.size()>0) {\n\t\t\tif (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}\n\t\t}",
"qProcess.size()>0",
"qProcess.size()",
"qProcess.size",
"qProcess",
"0",
"{\n\t\t\tif (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}\n\t\t}",
"if (qTime.peek() - q > 0) {\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t} else {\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}",
"qTime.peek() - q > 0",
"qTime.peek() - q",
"qTime.peek()",
"qTime.peek",
"qTime",
"q",
"0",
"{\n\t\t\t\tqProcess.add(qProcess.poll());\n\t\t\t\tqTime.add(qTime.poll()-q);\n\t\t\t\ttotalTime = totalTime + q;\n\t\t\t}",
"qProcess.add(qProcess.poll())",
"qProcess.add",
"qProcess",
"qProcess.poll()",
"qProcess.poll",
"qProcess",
"qTime.add(qTime.poll()-q)",
"qTime.add",
"qTime",
"qTime.poll()-q",
"qTime.poll()",
"qTime.poll",
"qTime",
"q",
"totalTime = totalTime + q",
"totalTime",
"totalTime + q",
"totalTime",
"q",
"{\n\t\t\t\ttotalTime = totalTime + qTime.poll();\n\t\t\t\tSystem.out.println(qProcess.poll() + ' ' + totalTime);\n\t\t\t}",
"totalTime = totalTime + qTime.poll()",
"totalTime",
"totalTime + qTime.poll()",
"totalTime",
"qTime.poll()",
"qTime.poll",
"qTime",
"System.out.println(qProcess.poll() + ' ' + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"qProcess.poll() + ' ' + totalTime",
"qProcess.poll() + ' ' + totalTime",
"qProcess.poll()",
"qProcess.poll",
"qProcess",
"' '",
"totalTime",
"String[] args",
"args"
] | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Queue<String> qProcess = new LinkedList<String>();
Queue<Integer> qTime = new LinkedList<Integer>();
int totalTime = 0;
for (int i = 0; i < n; i++) {
qProcess.add(sc.next());
qTime.add(sc.nextInt());
}
while (qProcess.size()>0) {
if (qTime.peek() - q > 0) {
qProcess.add(qProcess.poll());
qTime.add(qTime.poll()-q);
totalTime = totalTime + q;
} else {
totalTime = totalTime + qTime.poll();
System.out.println(qProcess.poll() + ' ' + totalTime);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
20,
38,
5,
13,
30,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
41,
13,
20,
41,
13,
41,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
4,
18,
13,
13,
42,
2,
18,
13,
13,
17,
30,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
17,
0,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
0,
13,
13,
4,
18,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
0,
13,
0,
13,
17,
0,
13,
20,
13,
23,
13,
12,
13,
30,
0,
18,
13,
40,
13,
13,
40,
13,
14,
2,
13,
13,
0,
13,
17,
23,
13,
12,
13,
30,
41,
13,
18,
13,
40,
13,
40,
13,
14,
2,
13,
13,
0,
13,
17,
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
],
[
224,
11
],
[
224,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
17,
19
],
[
14,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
24,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
32,
35
],
[
24,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
41,
42
],
[
41,
43
],
[
24,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
49,
51
],
[
24,
52
],
[
52,
53
],
[
52,
54
],
[
24,
55
],
[
55,
56
],
[
55,
57
],
[
24,
58
],
[
58,
59
],
[
24,
60
],
[
60,
61
],
[
24,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
62,
67
],
[
67,
68
],
[
67,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
62,
73
],
[
74,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
74,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
24,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
84,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
90,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
90,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
90,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
112,
113
],
[
112,
114
],
[
90,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
122,
124
],
[
119,
125
],
[
125,
126
],
[
125,
127
],
[
119,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
132,
132
],
[
132,
133
],
[
132,
134
],
[
132,
135
],
[
115,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
140,
145
],
[
146,
146
],
[
146,
147
],
[
146,
148
],
[
146,
149
],
[
12,
150
],
[
150,
151
],
[
0,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
152,
156
],
[
156,
157
],
[
152,
158
],
[
158,
159
],
[
152,
160
],
[
160,
161
],
[
152,
162
],
[
162,
163
],
[
152,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
166,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
174,
176
],
[
166,
177
],
[
177,
178
],
[
177,
179
],
[
164,
181
],
[
181,
182
],
[
152,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
186,
191
],
[
185,
192
],
[
192,
193
],
[
185,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
194,
198
],
[
198,
199
],
[
198,
200
],
[
183,
201
],
[
201,
202
],
[
152,
203
],
[
203,
204
],
[
203,
205
],
[
205,
206
],
[
206,
207
],
[
206,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
205,
212
],
[
212,
213
],
[
205,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
214,
218
],
[
218,
219
],
[
218,
220
],
[
205,
221
],
[
221,
222
],
[
0,
223
],
[
223,
224
],
[
223,
225
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main{\n\n\n\n\n\tpublic static void main(String[] args){\n\n\t\tString array[];\n\n\t\tBufferedReader reader=new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}\n\n\t}//main\n}\n\nclass Queue{\n\tint max;\n\tint num;\n\tString[] array;\n\tint front, rear;\n\n\tQueue(int capacity){//?????????????????????\n\t\tmax=capacity;\n\t\tnum=rear=front=0;\n\t\tarray=new String[max];\n\t}\n\tpublic void enqueue(String str){\n\t\tarray[rear++]=str;\n\t\tnum++;\n\t\tif(rear==max)rear=0;\n\t}\n\n\tpublic String dequeue(){\n\t\tString str=array[front++];\n\t\tnum--;\n\t\tif(front==max)front=0;\n\n\t\treturn str;\n\t}\n\n}//stack?????????",
"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\n\n\n\tpublic static void main(String[] args){\n\n\t\tString array[];\n\n\t\tBufferedReader reader=new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}\n\n\t}//main\n}",
"Main",
"public static void main(String[] args){\n\n\t\tString array[];\n\n\t\tBufferedReader reader=new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}\n\n\t}//main",
"main",
"{\n\n\t\tString array[];\n\n\t\tBufferedReader reader=new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}\n\n\t}",
"String array[];",
"array",
"BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));",
"reader",
"new BufferedReader(new InputStreamReader(System.in))",
"try{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}",
"catch(IOException e){\n\n\t\t}",
"IOException e",
"{\n\n\t\t}",
"{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}",
"String str=reader.readLine();",
"str",
"reader.readLine()",
"reader.readLine",
"reader",
"array=str.split(\" \")",
"array",
"str.split(\" \")",
"str.split",
"str",
"\" \"",
"int num=Integer.parseInt(array[0]);",
"num",
"Integer.parseInt(array[0])",
"Integer.parseInt",
"Integer",
"array[0]",
"array",
"0",
"int q=Integer.parseInt(array[1]);",
"q",
"Integer.parseInt(array[1])",
"Integer.parseInt",
"Integer",
"array[1]",
"array",
"1",
"int sum=0;",
"sum",
"0",
"Queue queue=new Queue(num);",
"queue",
"new Queue(num)",
"String x;",
"x",
"int y;",
"y",
"for(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}",
"{\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}",
"str=reader.readLine()",
"str",
"reader.readLine()",
"reader.readLine",
"reader",
"queue.enqueue(str)",
"queue.enqueue",
"queue",
"str",
"while(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}",
"queue.num!=0",
"queue.num",
"queue",
"queue.num",
"0",
"{\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}",
"str=queue.dequeue()",
"str",
"queue.dequeue()",
"queue.dequeue",
"queue",
"array=str.split(\" \")",
"array",
"str.split(\" \")",
"str.split",
"str",
"\" \"",
"x=array[0]",
"x",
"array[0]",
"array",
"0",
"y=Integer.parseInt(array[1])",
"y",
"Integer.parseInt(array[1])",
"Integer.parseInt",
"Integer",
"array[1]",
"array",
"1",
"if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }",
"y>q",
"y",
"q",
"{\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t}",
"y=y-q",
"y",
"y-q",
"y",
"q",
"sum+=q",
"sum",
"q",
"queue.enqueue(x+\" \"+y)",
"queue.enqueue",
"queue",
"x+\" \"+y",
"x+\" \"+y",
"x",
"\" \"",
"y",
"{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }",
"sum+=y",
"sum",
"y",
"System.out.println(x+\" \"+sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"x+\" \"+sum",
"x+\" \"+sum",
"x",
"\" \"",
"sum",
"String[] args",
"args",
"class Queue{\n\tint max;\n\tint num;\n\tString[] array;\n\tint front, rear;\n\n\tQueue(int capacity){//?????????????????????\n\t\tmax=capacity;\n\t\tnum=rear=front=0;\n\t\tarray=new String[max];\n\t}\n\tpublic void enqueue(String str){\n\t\tarray[rear++]=str;\n\t\tnum++;\n\t\tif(rear==max)rear=0;\n\t}\n\n\tpublic String dequeue(){\n\t\tString str=array[front++];\n\t\tnum--;\n\t\tif(front==max)front=0;\n\n\t\treturn str;\n\t}\n\n}//stack?????????",
"Queue",
"int max;",
"max",
"int num;",
"num",
"String[] array;",
"array",
"int front",
"front",
"rear;",
"rear",
"Queue(int capacity){//?????????????????????\n\t\tmax=capacity;\n\t\tnum=rear=front=0;\n\t\tarray=new String[max];\n\t}",
"Queue",
"{//?????????????????????\n\t\tmax=capacity;\n\t\tnum=rear=front=0;\n\t\tarray=new String[max];\n\t}",
"max=capacity",
"max",
"capacity",
"num=rear=front=0",
"num",
"rear=front=0",
"rear",
"front=0",
"front",
"0",
"array=new String[max]",
"array",
"new String[max]",
"max",
"int capacity",
"capacity",
"public void enqueue(String str){\n\t\tarray[rear++]=str;\n\t\tnum++;\n\t\tif(rear==max)rear=0;\n\t}",
"enqueue",
"{\n\t\tarray[rear++]=str;\n\t\tnum++;\n\t\tif(rear==max)rear=0;\n\t}",
"array[rear++]=str",
"array[rear++]",
"array",
"rear++",
"rear",
"str",
"num++",
"num",
"if(rear==max)rear=0;",
"rear==max",
"rear",
"max",
"rear=0",
"rear",
"0",
"String str",
"str",
"public String dequeue(){\n\t\tString str=array[front++];\n\t\tnum--;\n\t\tif(front==max)front=0;\n\n\t\treturn str;\n\t}",
"dequeue",
"{\n\t\tString str=array[front++];\n\t\tnum--;\n\t\tif(front==max)front=0;\n\n\t\treturn str;\n\t}",
"String str=array[front++];",
"str",
"array[front++]",
"array",
"front++",
"front",
"num--",
"num",
"if(front==max)front=0;",
"front==max",
"front",
"max",
"front=0",
"front",
"0",
"return str;",
"str",
"public class Main{\n\n\n\n\n\tpublic static void main(String[] args){\n\n\t\tString array[];\n\n\t\tBufferedReader reader=new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}\n\n\t}//main\n}",
"public class Main{\n\n\n\n\n\tpublic static void main(String[] args){\n\n\t\tString array[];\n\n\t\tBufferedReader reader=new BufferedReader(new InputStreamReader(System.in));\n\n\t\ttry{\n\t\tString str=reader.readLine();\n\t\tarray=str.split(\" \");\n\t\tint num=Integer.parseInt(array[0]);\n\t\tint q=Integer.parseInt(array[1]);\n\t\tint sum=0;\n\t\tQueue queue=new Queue(num);\n\n\t\tString x;\n\t\tint y;\n\n\n\n\t\tfor(int i=0;i<num;i++){\n\t\t\tstr=reader.readLine();\n\t\t\tqueue.enqueue(str);\n\t\t}\n\n\t\twhile(queue.num!=0){\n\t\t\tstr=queue.dequeue();\n\t\t\t array=str.split(\" \");\n\t\t\t x=array[0];\n\t\t\t\ty=Integer.parseInt(array[1]);\n\n\t\t\t if(y>q){\n\t\t\t \ty=y-q;\n\t\t\t \tsum+=q;\n\t\t\t \tqueue.enqueue(x+\" \"+y);\n\t\t\t \t} else{\n\n\t\t\t \tsum+=y;\n\t\t\t System.out.println(x+\" \"+sum);\n\t\t\t }\n\t\t}\n\n\n\n\n\n\n\t\t}catch(IOException e){\n\n\t\t}\n\n\t}//main\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args){
String array[];
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
try{
String str=reader.readLine();
array=str.split(" ");
int num=Integer.parseInt(array[0]);
int q=Integer.parseInt(array[1]);
int sum=0;
Queue queue=new Queue(num);
String x;
int y;
for(int i=0;i<num;i++){
str=reader.readLine();
queue.enqueue(str);
}
while(queue.num!=0){
str=queue.dequeue();
array=str.split(" ");
x=array[0];
y=Integer.parseInt(array[1]);
if(y>q){
y=y-q;
sum+=q;
queue.enqueue(x+" "+y);
} else{
sum+=y;
System.out.println(x+" "+sum);
}
}
}catch(IOException e){
}
}//main
}
class Queue{
int max;
int num;
String[] array;
int front, rear;
Queue(int capacity){//?????????????????????
max=capacity;
num=rear=front=0;
array=new String[max];
}
public void enqueue(String str){
array[rear++]=str;
num++;
if(rear==max)rear=0;
}
public String dequeue(){
String str=array[front++];
num--;
if(front==max)front=0;
return str;
}
}//stack????????? |
[
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,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
17,
4,
18,
13,
13,
4,
18,
18,
13,
13,
17,
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,
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,
29,
18,
36,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
194,
11
],
[
194,
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
],
[
76,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
88,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
100,
104
],
[
93,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
87,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
115,
124
],
[
109,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
125,
130
],
[
14,
131
],
[
131,
132
],
[
132,
133
],
[
12,
134
],
[
134,
135
],
[
0,
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
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
159,
167
],
[
167,
168
],
[
136,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
136,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
176,
184
],
[
184,
185
],
[
136,
186
],
[
186,
187
],
[
186,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
0,
193
],
[
193,
194
],
[
193,
195
]
] | [
"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 sc = new Scanner(System.in);\n\n\t\tString[] S = sc.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(S[0]);\n\t\tint quantum = Integer.parseInt(S[1]);\n\n\t\tQueue<Node> queue = new ArrayDeque<Node>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}\n\n\t\tlong count = 0;\n\n\t\twhile (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n}\n\nclass Node {\n\tprivate String name;\n\tprivate int time;\n\n\tpublic Node(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic String getName() {\n\t\treturn this.name;\n\t}\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\n\tpublic int getTime() {\n\t\treturn this.time;\n\t}\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString[] S = sc.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(S[0]);\n\t\tint quantum = Integer.parseInt(S[1]);\n\n\t\tQueue<Node> queue = new ArrayDeque<Node>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}\n\n\t\tlong count = 0;\n\n\t\twhile (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString[] S = sc.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(S[0]);\n\t\tint quantum = Integer.parseInt(S[1]);\n\n\t\tQueue<Node> queue = new ArrayDeque<Node>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}\n\n\t\tlong count = 0;\n\n\t\twhile (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString[] S = sc.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(S[0]);\n\t\tint quantum = Integer.parseInt(S[1]);\n\n\t\tQueue<Node> queue = new ArrayDeque<Node>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}\n\n\t\tlong count = 0;\n\n\t\twhile (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"String[] S = sc.nextLine().split(\" \");",
"S",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"int n = Integer.parseInt(S[0]);",
"n",
"Integer.parseInt(S[0])",
"Integer.parseInt",
"Integer",
"S[0]",
"S",
"0",
"int quantum = Integer.parseInt(S[1]);",
"quantum",
"Integer.parseInt(S[1])",
"Integer.parseInt",
"Integer",
"S[1]",
"S",
"1",
"Queue<Node> queue = new ArrayDeque<Node>();",
"queue",
"new ArrayDeque<Node>()",
"for (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}",
"{\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}",
"S = sc.nextLine().split(\" \")",
"S",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"Node node = new Node(S[0], Integer.parseInt(S[1]));",
"node",
"new Node(S[0], Integer.parseInt(S[1]))",
"queue.offer(node)",
"queue.offer",
"queue",
"node",
"long count = 0;",
"count",
"0",
"while (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}",
"Node tmp = queue.poll();",
"tmp",
"queue.poll()",
"queue.poll",
"queue",
"if (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}",
"tmp.getTime() > quantum",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"quantum",
"{\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t}",
"count += quantum",
"count",
"quantum",
"tmp.setTime(tmp.getTime() - quantum)",
"tmp.setTime",
"tmp",
"tmp.getTime() - quantum",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"quantum",
"queue.offer(tmp)",
"queue.offer",
"queue",
"tmp",
"{\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}",
"count += tmp.getTime()",
"count",
"tmp.getTime()",
"tmp.getTime",
"tmp",
"System.out.printf(\"%s %d\", tmp.getName(), count)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\"",
"tmp.getName()",
"tmp.getName",
"tmp",
"count",
"System.out.println(\"\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\"\"",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"class Node {\n\tprivate String name;\n\tprivate int time;\n\n\tpublic Node(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic String getName() {\n\t\treturn this.name;\n\t}\n\n\tpublic void setTime(int time) {\n\t\tthis.time = time;\n\t}\n\n\tpublic int getTime() {\n\t\treturn this.time;\n\t}\n}",
"Node",
"private String name;",
"name",
"private 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 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 String getName() {\n\t\treturn this.name;\n\t}",
"getName",
"{\n\t\treturn this.name;\n\t}",
"return this.name;",
"this.name",
"this",
"this.name",
"public 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 int getTime() {\n\t\treturn this.time;\n\t}",
"getTime",
"{\n\t\treturn this.time;\n\t}",
"return this.time;",
"this.time",
"this",
"this.time",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString[] S = sc.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(S[0]);\n\t\tint quantum = Integer.parseInt(S[1]);\n\n\t\tQueue<Node> queue = new ArrayDeque<Node>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}\n\n\t\tlong count = 0;\n\n\t\twhile (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tString[] S = sc.nextLine().split(\" \");\n\t\tint n = Integer.parseInt(S[0]);\n\t\tint quantum = Integer.parseInt(S[1]);\n\n\t\tQueue<Node> queue = new ArrayDeque<Node>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tS = sc.nextLine().split(\" \");\n\t\t\tNode node = new Node(S[0], Integer.parseInt(S[1]));\n\t\t\tqueue.offer(node);\n\t\t}\n\n\t\tlong count = 0;\n\n\t\twhile (!queue.isEmpty()) {\n\t\t\tNode tmp = queue.poll();\n\t\t\tif (tmp.getTime() > quantum) {\n\t\t\t\tcount += quantum;\n\t\t\t\ttmp.setTime(tmp.getTime() - quantum);\n\t\t\t\tqueue.offer(tmp);\n\t\t\t} else {\n\t\t\t\tcount += tmp.getTime();\n\t\t\t\tSystem.out.printf(\"%s %d\", tmp.getName(), count);\n\t\t\t\tSystem.out.println(\"\");\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\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 sc = new Scanner(System.in);
String[] S = sc.nextLine().split(" ");
int n = Integer.parseInt(S[0]);
int quantum = Integer.parseInt(S[1]);
Queue<Node> queue = new ArrayDeque<Node>();
for (int i = 0; i < n; i++) {
S = sc.nextLine().split(" ");
Node node = new Node(S[0], Integer.parseInt(S[1]));
queue.offer(node);
}
long count = 0;
while (!queue.isEmpty()) {
Node tmp = queue.poll();
if (tmp.getTime() > quantum) {
count += quantum;
tmp.setTime(tmp.getTime() - quantum);
queue.offer(tmp);
} else {
count += tmp.getTime();
System.out.printf("%s %d", tmp.getName(), count);
System.out.println("");
}
}
sc.close();
}
}
class Node {
private String name;
private int time;
public Node(String name, int time) {
this.name = name;
this.time = time;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setTime(int time) {
this.time = time;
}
public int getTime() {
return this.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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
41,
13,
17,
42,
4,
18,
13,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
18,
13,
13,
13,
14,
2,
18,
13,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
4,
18,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
14,
2,
18,
13,
13,
17,
30,
0,
18,
18,
13,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
18,
13,
13,
29,
13,
12,
13,
30,
29,
2,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
205,
5
],
[
205,
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
],
[
39,
40
],
[
38,
41
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
8,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
45,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
49,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
60,
62
],
[
57,
63
],
[
49,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
71,
76
],
[
77,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
77,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
64,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
6,
96
],
[
96,
97
],
[
205,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
98,
102
],
[
102,
103
],
[
98,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
106,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
104,
117
],
[
117,
118
],
[
104,
119
],
[
119,
120
],
[
205,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
121,
125
],
[
125,
126
],
[
121,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
133,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
140,
146
],
[
129,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
127,
155
],
[
155,
156
],
[
121,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
162,
164
],
[
159,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
167,
169
],
[
159,
170
],
[
170,
171
],
[
121,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
121,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
179,
183
],
[
183,
184
],
[
179,
185
],
[
185,
186
],
[
179,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
191,
193
],
[
190,
194
],
[
189,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
199
],
[
187,
200
],
[
200,
201
],
[
187,
202
],
[
202,
203
],
[
0,
204
],
[
204,
205
],
[
204,
206
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n Queue queue = new Queue();\n for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }\n int t = 0;\n while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }\n }\n\n private static class Process {\n private String name;\n private int time;\n\n private Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n\n private static class Queue {\n private static class Node {\n private Process process;\n private Node next;\n private Node prev;\n\n private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }\n }\n\n private Node first;\n private Node last;\n\n private void enqueue(Process process) {\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }\n\n private Process dequeue() {\n Process process = first.process;\n first = first.prev;\n return process;\n }\n\n private boolean hasNode() {\n return first != null;\n }\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n Queue queue = new Queue();\n for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }\n int t = 0;\n while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }\n }\n\n private static class Process {\n private String name;\n private int time;\n\n private Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n\n private static class Queue {\n private static class Node {\n private Process process;\n private Node next;\n private Node prev;\n\n private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }\n }\n\n private Node first;\n private Node last;\n\n private void enqueue(Process process) {\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }\n\n private Process dequeue() {\n Process process = first.process;\n first = first.prev;\n return process;\n }\n\n private boolean hasNode() {\n return first != null;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n Queue queue = new Queue();\n for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }\n int t = 0;\n while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n Queue queue = new Queue();\n for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }\n int t = 0;\n while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }\n }",
"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 queue = new Queue();",
"queue",
"new Queue()",
"for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }",
"{\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }",
"queue.enqueue(new Process(scanner.next(), scanner.nextInt()))",
"queue.enqueue",
"queue",
"new Process(scanner.next(), scanner.nextInt())",
"int t = 0;",
"t",
"0",
"while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }",
"queue.hasNode()",
"queue.hasNode",
"queue",
"{\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }",
"Process process = queue.dequeue();",
"process",
"queue.dequeue()",
"queue.dequeue",
"queue",
"t += Math.min(process.time, q)",
"t",
"Math.min(process.time, q)",
"Math.min",
"Math",
"process.time",
"process",
"process.time",
"q",
"if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }",
"process.time <= q",
"process.time",
"process",
"process.time",
"q",
"{\n System.out.println(process.name + \" \" + String.valueOf(t));\n }",
"System.out.println(process.name + \" \" + String.valueOf(t))",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + String.valueOf(t)",
"process.name + \" \" + String.valueOf(t)",
"process.name",
"process",
"process.name",
"\" \"",
"String.valueOf(t)",
"String.valueOf",
"String",
"t",
"{\n process.time -= q;\n queue.enqueue(process);\n }",
"process.time -= q",
"process.time",
"process",
"process.time",
"q",
"queue.enqueue(process)",
"queue.enqueue",
"queue",
"process",
"String[] args",
"args",
"private static class Process {\n private String name;\n private int time;\n\n private Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }",
"Process",
"private String name;",
"name",
"private int time;",
"time",
"private 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",
"private static class Queue {\n private static class Node {\n private Process process;\n private Node next;\n private Node prev;\n\n private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }\n }\n\n private Node first;\n private Node last;\n\n private void enqueue(Process process) {\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }\n\n private Process dequeue() {\n Process process = first.process;\n first = first.prev;\n return process;\n }\n\n private boolean hasNode() {\n return first != null;\n }\n }",
"Queue",
"private Node first;",
"first",
"private Node last;",
"last",
"private void enqueue(Process process) {\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }",
"enqueue",
"{\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }",
"last = new Node(process, last)",
"last",
"new Node(process, last)",
"if (last.next != null) {\n last.next.prev = last;\n }",
"last.next != null",
"last.next",
"last",
"last.next",
"null",
"{\n last.next.prev = last;\n }",
"last.next.prev = last",
"last.next.prev",
"last.next",
"last",
"last.next",
"last.next.prev",
"last",
"if (first == null) {\n first = last;\n }",
"first == null",
"first",
"null",
"{\n first = last;\n }",
"first = last",
"first",
"last",
"Process process",
"process",
"private Process dequeue() {\n Process process = first.process;\n first = first.prev;\n return process;\n }",
"dequeue",
"{\n Process process = first.process;\n first = first.prev;\n return process;\n }",
"Process process = first.process;",
"process",
"first.process",
"first",
"first.process",
"first = first.prev",
"first",
"first.prev",
"first",
"first.prev",
"return process;",
"process",
"private boolean hasNode() {\n return first != null;\n }",
"hasNode",
"{\n return first != null;\n }",
"return first != null;",
"first != null",
"first",
"null",
"private static class Node {\n private Process process;\n private Node next;\n private Node prev;\n\n private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }\n }",
"Node",
"private Process process;",
"process",
"private Node next;",
"next",
"private Node prev;",
"prev",
"private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }",
"Node",
"{\n this.process = process;\n this.next = next;\n }",
"this.process = process",
"this.process",
"this",
"this.process",
"process",
"this.next = next",
"this.next",
"this",
"this.next",
"next",
"Process process",
"process",
"Node next",
"next",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n Queue queue = new Queue();\n for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }\n int t = 0;\n while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }\n }\n\n private static class Process {\n private String name;\n private int time;\n\n private Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n\n private static class Queue {\n private static class Node {\n private Process process;\n private Node next;\n private Node prev;\n\n private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }\n }\n\n private Node first;\n private Node last;\n\n private void enqueue(Process process) {\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }\n\n private Process dequeue() {\n Process process = first.process;\n first = first.prev;\n return process;\n }\n\n private boolean hasNode() {\n return first != null;\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n int n = scanner.nextInt();\n int q = scanner.nextInt();\n Queue queue = new Queue();\n for (int i = 0; i < n; i++) {\n queue.enqueue(new Process(scanner.next(), scanner.nextInt()));\n }\n int t = 0;\n while (queue.hasNode()) {\n Process process = queue.dequeue();\n t += Math.min(process.time, q);\n if (process.time <= q) {\n System.out.println(process.name + \" \" + String.valueOf(t));\n } else {\n process.time -= q;\n queue.enqueue(process);\n }\n }\n }\n\n private static class Process {\n private String name;\n private int time;\n\n private Process(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n\n private static class Queue {\n private static class Node {\n private Process process;\n private Node next;\n private Node prev;\n\n private Node(Process process, Node next) {\n this.process = process;\n this.next = next;\n }\n }\n\n private Node first;\n private Node last;\n\n private void enqueue(Process process) {\n last = new Node(process, last);\n if (last.next != null) {\n last.next.prev = last;\n }\n if (first == null) {\n first = last;\n }\n }\n\n private Process dequeue() {\n Process process = first.process;\n first = first.prev;\n return process;\n }\n\n private boolean hasNode() {\n return first != null;\n }\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int q = scanner.nextInt();
Queue queue = new Queue();
for (int i = 0; i < n; i++) {
queue.enqueue(new Process(scanner.next(), scanner.nextInt()));
}
int t = 0;
while (queue.hasNode()) {
Process process = queue.dequeue();
t += Math.min(process.time, q);
if (process.time <= q) {
System.out.println(process.name + " " + String.valueOf(t));
} else {
process.time -= q;
queue.enqueue(process);
}
}
}
private static class Process {
private String name;
private int time;
private Process(String name, int time) {
this.name = name;
this.time = time;
}
}
private static class Queue {
private static class Node {
private Process process;
private Node next;
private Node prev;
private Node(Process process, Node next) {
this.process = process;
this.next = next;
}
}
private Node first;
private Node last;
private void enqueue(Process process) {
last = new Node(process, last);
if (last.next != null) {
last.next.prev = last;
}
if (first == null) {
first = last;
}
}
private Process dequeue() {
Process process = first.process;
first = first.prev;
return process;
}
private boolean hasNode() {
return first != null;
}
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
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,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
151,
5
],
[
151,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
37,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
48,
49
],
[
48,
50
],
[
37,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
8,
55
],
[
55,
56
],
[
55,
57
],
[
8,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
58,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
63,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
70,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
79,
83
],
[
75,
84
],
[
84,
85
],
[
84,
86
],
[
75,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
69,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
103,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
103,
108
],
[
6,
109
],
[
109,
110
],
[
0,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
111,
115
],
[
115,
116
],
[
111,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
123,
124
],
[
123,
125
],
[
117,
126
],
[
126,
127
],
[
117,
128
],
[
128,
129
],
[
111,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
130,
138
],
[
138,
139
],
[
111,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
111,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
0,
150
],
[
150,
151
],
[
150,
152
]
] | [
"\n\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tQueue<ItemPair> list = new LinkedList<ItemPair>();\n\t\tScanner k = new Scanner(System.in);\n\t\t\n\t\tint processes = k.nextInt();\n\t\tint quantum = k.nextInt();\n\t\t\n\t\t//Fill the queue\n\t\tfor(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}\n\t\t\n\t\tint timeStart = 0;\n\t\twhile(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}\n\n//Each node in the queue will have these properties\nclass ItemPair {\n\tString name;\n\tint time;\n\t\n\tpublic ItemPair(int x, String y) {\n\t\ttime = x;\n\t\tname = y;\n\t}\n\tpublic void set_time(int newTime) {\n\t\tthis.time = newTime;\n\t}\n\tpublic int send_time() {\n\t\treturn time;\n\t}\n\tpublic String send_name() {\n\t\treturn name;\n\t}\n\t\n\t\n\t\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tQueue<ItemPair> list = new LinkedList<ItemPair>();\n\t\tScanner k = new Scanner(System.in);\n\t\t\n\t\tint processes = k.nextInt();\n\t\tint quantum = k.nextInt();\n\t\t\n\t\t//Fill the queue\n\t\tfor(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}\n\t\t\n\t\tint timeStart = 0;\n\t\twhile(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tQueue<ItemPair> list = new LinkedList<ItemPair>();\n\t\tScanner k = new Scanner(System.in);\n\t\t\n\t\tint processes = k.nextInt();\n\t\tint quantum = k.nextInt();\n\t\t\n\t\t//Fill the queue\n\t\tfor(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}\n\t\t\n\t\tint timeStart = 0;\n\t\twhile(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tQueue<ItemPair> list = new LinkedList<ItemPair>();\n\t\tScanner k = new Scanner(System.in);\n\t\t\n\t\tint processes = k.nextInt();\n\t\tint quantum = k.nextInt();\n\t\t\n\t\t//Fill the queue\n\t\tfor(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}\n\t\t\n\t\tint timeStart = 0;\n\t\twhile(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"Queue<ItemPair> list = new LinkedList<ItemPair>();",
"list",
"new LinkedList<ItemPair>()",
"Scanner k = new Scanner(System.in);",
"k",
"new Scanner(System.in)",
"int processes = k.nextInt();",
"processes",
"k.nextInt()",
"k.nextInt",
"k",
"int quantum = k.nextInt();",
"quantum",
"k.nextInt()",
"k.nextInt",
"k",
"for(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}",
"int x = 0;",
"int x = 0;",
"x",
"0",
"x < processes",
"x",
"processes",
"x++",
"x++",
"x",
"{\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}",
"{\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}",
"String inputName = k.next();",
"inputName",
"k.next()",
"k.next",
"k",
"int inputTime = k.nextInt();",
"inputTime",
"k.nextInt()",
"k.nextInt",
"k",
"ItemPair itemPair = new ItemPair(inputTime, inputName);",
"itemPair",
"new ItemPair(inputTime, inputName)",
"list.add(itemPair)",
"list.add",
"list",
"itemPair",
"int timeStart = 0;",
"timeStart",
"0",
"while(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}",
"!list.isEmpty()",
"list.isEmpty()",
"list.isEmpty",
"list",
"{\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}",
"ItemPair temp = list.poll();",
"temp",
"list.poll()",
"list.poll",
"list",
"if(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}",
"temp.send_time() > quantum",
"temp.send_time()",
"temp.send_time",
"temp",
"quantum",
"{\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t}",
"temp.set_time(temp.send_time() - quantum)",
"temp.set_time",
"temp",
"temp.send_time() - quantum",
"temp.send_time()",
"temp.send_time",
"temp",
"quantum",
"timeStart += quantum",
"timeStart",
"quantum",
"list.add(temp)",
"list.add",
"list",
"temp",
"{\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}",
"timeStart += temp.send_time()",
"timeStart",
"temp.send_time()",
"temp.send_time",
"temp",
"System.out.println(temp.send_name() + \" \" + timeStart)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.send_name() + \" \" + timeStart",
"temp.send_name() + \" \" + timeStart",
"temp.send_name()",
"temp.send_name",
"temp",
"\" \"",
"timeStart",
"String args[]",
"args",
"class ItemPair {\n\tString name;\n\tint time;\n\t\n\tpublic ItemPair(int x, String y) {\n\t\ttime = x;\n\t\tname = y;\n\t}\n\tpublic void set_time(int newTime) {\n\t\tthis.time = newTime;\n\t}\n\tpublic int send_time() {\n\t\treturn time;\n\t}\n\tpublic String send_name() {\n\t\treturn name;\n\t}\n\t\n\t\n\t\n}",
"ItemPair",
"String name;",
"name",
"int time;",
"time",
"public ItemPair(int x, String y) {\n\t\ttime = x;\n\t\tname = y;\n\t}",
"ItemPair",
"{\n\t\ttime = x;\n\t\tname = y;\n\t}",
"time = x",
"time",
"x",
"name = y",
"name",
"y",
"int x",
"x",
"String y",
"y",
"public void set_time(int newTime) {\n\t\tthis.time = newTime;\n\t}",
"set_time",
"{\n\t\tthis.time = newTime;\n\t}",
"this.time = newTime",
"this.time",
"this",
"this.time",
"newTime",
"int newTime",
"newTime",
"public int send_time() {\n\t\treturn time;\n\t}",
"send_time",
"{\n\t\treturn time;\n\t}",
"return time;",
"time",
"public String send_name() {\n\t\treturn name;\n\t}",
"send_name",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tQueue<ItemPair> list = new LinkedList<ItemPair>();\n\t\tScanner k = new Scanner(System.in);\n\t\t\n\t\tint processes = k.nextInt();\n\t\tint quantum = k.nextInt();\n\t\t\n\t\t//Fill the queue\n\t\tfor(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}\n\t\t\n\t\tint timeStart = 0;\n\t\twhile(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\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\tQueue<ItemPair> list = new LinkedList<ItemPair>();\n\t\tScanner k = new Scanner(System.in);\n\t\t\n\t\tint processes = k.nextInt();\n\t\tint quantum = k.nextInt();\n\t\t\n\t\t//Fill the queue\n\t\tfor(int x = 0; x < processes; x++) {\n\t\t\tString inputName = k.next();\n\t\t\tint inputTime = k.nextInt();\n\t\t\t\n\t\t\tItemPair itemPair = new ItemPair(inputTime, inputName);\n\t\t\tlist.add(itemPair);\n\t\t}\n\t\t\n\t\tint timeStart = 0;\n\t\twhile(!list.isEmpty()) {\n\t\t\t\n\t\t\tItemPair temp = list.poll();\n\t\t\t\n\t\t\tif(temp.send_time() > quantum) {\n\t\t\t\ttemp.set_time(temp.send_time() - quantum);\n\t\t\t\ttimeStart += quantum;\n\t\t\t\tlist.add(temp);\n\t\t\t} else {\n\t\t\t\ttimeStart += temp.send_time();\n\t\t\t\tSystem.out.println(temp.send_name() + \" \" + timeStart);\n\t\t\t}\n\t\t}\n\t\t\n\t}\n}",
"Main"
] |
import java.util.*;
public class Main {
public static void main(String args[]) {
Queue<ItemPair> list = new LinkedList<ItemPair>();
Scanner k = new Scanner(System.in);
int processes = k.nextInt();
int quantum = k.nextInt();
//Fill the queue
for(int x = 0; x < processes; x++) {
String inputName = k.next();
int inputTime = k.nextInt();
ItemPair itemPair = new ItemPair(inputTime, inputName);
list.add(itemPair);
}
int timeStart = 0;
while(!list.isEmpty()) {
ItemPair temp = list.poll();
if(temp.send_time() > quantum) {
temp.set_time(temp.send_time() - quantum);
timeStart += quantum;
list.add(temp);
} else {
timeStart += temp.send_time();
System.out.println(temp.send_name() + " " + timeStart);
}
}
}
}
//Each node in the queue will have these properties
class ItemPair {
String name;
int time;
public ItemPair(int x, String y) {
time = x;
name = y;
}
public void set_time(int newTime) {
this.time = newTime;
}
public int send_time() {
return time;
}
public String send_name() {
return name;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
4,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
17,
30,
14,
4,
18,
13,
3,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
4,
18,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
17,
18,
13,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
10,
14
],
[
14,
15
],
[
10,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
19,
20
],
[
18,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
18,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
26,
30
],
[
16,
31
],
[
31,
32
],
[
16,
33
],
[
33,
34
],
[
10,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
35,
43
],
[
43,
44
],
[
0,
45
],
[
150,
46
],
[
150,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
49,
53
],
[
53,
54
],
[
53,
55
],
[
55,
56
],
[
56,
57
],
[
49,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
49,
63
],
[
63,
64
],
[
64,
65
],
[
49,
66
],
[
66,
67
],
[
66,
68
],
[
49,
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
],
[
86,
87
],
[
87,
88
],
[
84,
89
],
[
81,
90
],
[
90,
91
],
[
90,
92
],
[
81,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
49,
97
],
[
97,
98
],
[
97,
99
],
[
49,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
102,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
111,
112
],
[
102,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
113,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
119,
124
],
[
124,
125
],
[
124,
126
],
[
119,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
113,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
131,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
137,
143
],
[
143,
144
],
[
143,
145
],
[
137,
146
],
[
47,
147
],
[
147,
148
],
[
0,
149
],
[
149,
150
],
[
149,
151
]
] | [
"import java.util.LinkedList;\nimport java.util.Queue;\nimport java.util.Scanner;\n\nclass Process {\n\tString name;\n\tint time;\n\n\tpublic Process(String name, int time) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic void proceed(int q) {\n\t\tthis.time -= q;\n\t}\n\n}\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tQueue<Process> queue = new LinkedList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}\n\n\t\tint passedTime = 0;\n\t\twhile(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Process {\n\tString name;\n\tint time;\n\n\tpublic Process(String name, int time) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n\tpublic void proceed(int q) {\n\t\tthis.time -= q;\n\t}\n\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\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 void proceed(int q) {\n\t\tthis.time -= q;\n\t}",
"proceed",
"{\n\t\tthis.time -= q;\n\t}",
"this.time -= q",
"this.time",
"this",
"this.time",
"q",
"int q",
"q",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tQueue<Process> queue = new LinkedList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}\n\n\t\tint passedTime = 0;\n\t\twhile(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tQueue<Process> queue = new LinkedList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}\n\n\t\tint passedTime = 0;\n\t\twhile(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tQueue<Process> queue = new LinkedList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}\n\n\t\tint passedTime = 0;\n\t\twhile(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.nextLine()",
"sc.nextLine",
"sc",
"Queue<Process> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}",
"{\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}",
"String[] input = sc.nextLine().split(\" \");",
"input",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"Process p = new Process(input[0], Integer.parseInt(input[1]));",
"p",
"new Process(input[0], Integer.parseInt(input[1]))",
"queue.add(p)",
"queue.add",
"queue",
"p",
"int passedTime = 0;",
"passedTime",
"0",
"while(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}",
"true",
"{\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}",
"if(queue.isEmpty()) break;",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"break;",
"Process now = queue.poll();",
"now",
"queue.poll()",
"queue.poll",
"queue",
"if(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}",
"now.time > q",
"now.time",
"now",
"now.time",
"q",
"{\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t}",
"now.proceed(q)",
"now.proceed",
"now",
"q",
"passedTime += q",
"passedTime",
"q",
"queue.add(now)",
"queue.add",
"queue",
"now",
"{\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}",
"passedTime += now.time",
"passedTime",
"now.time",
"now",
"now.time",
"System.out.printf(\"%s %d\\n\", now.name, passedTime)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"now.name",
"now",
"now.name",
"passedTime",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tQueue<Process> queue = new LinkedList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}\n\n\t\tint passedTime = 0;\n\t\twhile(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tQueue<Process> queue = new LinkedList<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] input = sc.nextLine().split(\" \");\n\t\t\tProcess p = new Process(input[0], Integer.parseInt(input[1]));\n\t\t\tqueue.add(p);\n\t\t}\n\n\t\tint passedTime = 0;\n\t\twhile(true) {\n\n\t\t\tif(queue.isEmpty()) break;\n\n\t\t\tProcess now = queue.poll();\n\t\t\tif(now.time > q) {\n\t\t\t\tnow.proceed(q);\n\t\t\t\tpassedTime += q;\n\t\t\t\tqueue.add(now);\n\t\t\t} else {\n\t\t\t\tpassedTime += now.time;\n\t\t\t\tSystem.out.printf(\"%s %d\\n\", now.name, passedTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
class Process {
String name;
int time;
public Process(String name, int time) {
super();
this.name = name;
this.time = time;
}
public void proceed(int q) {
this.time -= q;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
sc.nextLine();
Queue<Process> queue = new LinkedList<>();
for (int i = 0; i < n; i++) {
String[] input = sc.nextLine().split(" ");
Process p = new Process(input[0], Integer.parseInt(input[1]));
queue.add(p);
}
int passedTime = 0;
while(true) {
if(queue.isEmpty()) break;
Process now = queue.poll();
if(now.time > q) {
now.proceed(q);
passedTime += q;
queue.add(now);
} else {
passedTime += now.time;
System.out.printf("%s %d\n", now.name, passedTime);
}
}
}
} |
[
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,
42,
2,
13,
17,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
40,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
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
],
[
8,
34
],
[
34,
35
],
[
35,
36
],
[
35,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
43,
44
],
[
38,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
49,
50
],
[
38,
51
],
[
51,
52
],
[
8,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
53,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
58,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
58,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
77,
82
],
[
83,
83
],
[
83,
84
],
[
83,
85
],
[
83,
86
],
[
69,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
90,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
87,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
87,
101
],
[
101,
102
],
[
101,
103
],
[
6,
104
],
[
104,
105
],
[
0,
106
],
[
106,
107
],
[
106,
108
]
] | [
"import java.util.*;\n\npublic class Main{\n\tpublic static void main(String args[]) {\n\t\tQueue<String> p = new LinkedList<>();\n\t\tQueue<Integer> values = new LinkedList<>();\n\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\t\t\n\t\t\n\t\tint time = 0;\n\t\t\n\t\tin.nextLine();\n\t\twhile(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\twhile (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t\n\t\t\n\t\t\n\t\n\t\n\t}\n\t\n\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n\tpublic static void main(String args[]) {\n\t\tQueue<String> p = new LinkedList<>();\n\t\tQueue<Integer> values = new LinkedList<>();\n\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\t\t\n\t\t\n\t\tint time = 0;\n\t\t\n\t\tin.nextLine();\n\t\twhile(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\twhile (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t\n\t\t\n\t\t\n\t\n\t\n\t}\n\t\n\n}",
"Main",
"public static void main(String args[]) {\n\t\tQueue<String> p = new LinkedList<>();\n\t\tQueue<Integer> values = new LinkedList<>();\n\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\t\t\n\t\t\n\t\tint time = 0;\n\t\t\n\t\tin.nextLine();\n\t\twhile(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\twhile (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t\n\t\t\n\t\t\n\t\n\t\n\t}",
"main",
"{\n\t\tQueue<String> p = new LinkedList<>();\n\t\tQueue<Integer> values = new LinkedList<>();\n\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\t\t\n\t\t\n\t\tint time = 0;\n\t\t\n\t\tin.nextLine();\n\t\twhile(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\twhile (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t\n\t\t\n\t\t\n\t\n\t\n\t}",
"Queue<String> p = new LinkedList<>();",
"p",
"new LinkedList<>()",
"Queue<Integer> values = new LinkedList<>();",
"values",
"new LinkedList<>()",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int q = in.nextInt();",
"q",
"in.nextInt()",
"in.nextInt",
"in",
"int time = 0;",
"time",
"0",
"in.nextLine()",
"in.nextLine",
"in",
"while(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}",
"n > 0",
"n",
"0",
"{\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}",
"p.add(in.next())",
"p.add",
"p",
"in.next()",
"in.next",
"in",
"values.add(in.nextInt())",
"values.add",
"values",
"in.nextInt()",
"in.nextInt",
"in",
"n--",
"n",
"while (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"!p.isEmpty()",
"p.isEmpty()",
"p.isEmpty",
"p",
"{\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}",
"String pr = p.poll();",
"pr",
"p.poll()",
"p.poll",
"p",
"Integer ti = values.poll();",
"ti",
"values.poll()",
"values.poll",
"values",
"if (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}",
"ti <= q",
"ti",
"q",
"{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}",
"time += ti",
"time",
"ti",
"System.out.println(pr + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"pr + \" \" + time",
"pr + \" \" + time",
"pr",
"\" \"",
"time",
"{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}",
"ti = ti - q",
"ti",
"ti - q",
"ti",
"q",
"p.add(pr)",
"p.add",
"p",
"pr",
"values.add(ti)",
"values.add",
"values",
"ti",
"time += q",
"time",
"q",
"String args[]",
"args",
"public class Main{\n\tpublic static void main(String args[]) {\n\t\tQueue<String> p = new LinkedList<>();\n\t\tQueue<Integer> values = new LinkedList<>();\n\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\t\t\n\t\t\n\t\tint time = 0;\n\t\t\n\t\tin.nextLine();\n\t\twhile(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\twhile (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t\n\t\t\n\t\t\n\t\n\t\n\t}\n\t\n\n}",
"public class Main{\n\tpublic static void main(String args[]) {\n\t\tQueue<String> p = new LinkedList<>();\n\t\tQueue<Integer> values = new LinkedList<>();\n\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\t\t\n\t\t\n\t\tint time = 0;\n\t\t\n\t\tin.nextLine();\n\t\twhile(n > 0) {\n\t\t\tp.add(in.next());\n\t\t\tvalues.add(in.nextInt());\n\t\t\tn--;\n\t\t\t\n\t\t\t\n\t\t}\n\t\t\n\t\twhile (!p.isEmpty()) {\n\t\t\tString pr = p.poll();\n\t\t\tInteger ti = values.poll();\n\t\t\t\n\t\t\tif (ti <= q)\n\t\t\t{\n\t\t\t\ttime += ti;\n\t\t\t\tSystem.out.println(pr + \" \" + time);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tti = ti - q;\n\t\t\t\tp.add(pr);\n\t\t\t\tvalues.add(ti);\n\t\t\t\ttime += q;\n\t\t\t}\n\t\t}\n\t\n\t\t\n\t\t\n\t\n\t\n\t}\n\t\n\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String args[]) {
Queue<String> p = new LinkedList<>();
Queue<Integer> values = new LinkedList<>();
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int q = in.nextInt();
int time = 0;
in.nextLine();
while(n > 0) {
p.add(in.next());
values.add(in.nextInt());
n--;
}
while (!p.isEmpty()) {
String pr = p.poll();
Integer ti = values.poll();
if (ti <= q)
{
time += ti;
System.out.println(pr + " " + time);
}
else
{
ti = ti - q;
p.add(pr);
values.add(ti);
time += q;
}
}
}
}
|
[
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,
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
],
[
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
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
35,
43
],
[
43,
44
],
[
7,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
0,
50
],
[
158,
51
],
[
158,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
54,
63
],
[
63,
64
],
[
63,
65
],
[
65,
66
],
[
66,
67
],
[
54,
68
],
[
68,
69
],
[
68,
70
],
[
54,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
73,
75
],
[
71,
76
],
[
76,
77
],
[
76,
78
],
[
71,
79
],
[
79,
80
],
[
80,
81
],
[
71,
82
],
[
83,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
83,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
83,
94
],
[
94,
95
],
[
94,
96
],
[
83,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
54,
101
],
[
101,
102
],
[
101,
103
],
[
54,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
104,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
112,
113
],
[
113,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
116,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
125,
129
],
[
121,
130
],
[
130,
131
],
[
130,
132
],
[
121,
133
],
[
133,
134
],
[
134,
135
],
[
133,
136
],
[
115,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
141,
142
],
[
137,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
149,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
149,
153
],
[
149,
154
],
[
52,
155
],
[
155,
156
],
[
0,
157
],
[
157,
158
],
[
157,
159
]
] | [
"import java.io.*;\nimport 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 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 in = new Scanner(System.in);\n int inputProcesses = in.nextInt();\n int quantum = in.nextInt();\n\n Queue<Process> processes = new LinkedList<Process>();\n\n for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }\n int currTime = 0;\n while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }\n }\n}",
"import java.io.*;",
"io.*",
"java",
"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 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 in = new Scanner(System.in);\n int inputProcesses = in.nextInt();\n int quantum = in.nextInt();\n\n Queue<Process> processes = new LinkedList<Process>();\n\n for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }\n int currTime = 0;\n while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n\n Scanner in = new Scanner(System.in);\n int inputProcesses = in.nextInt();\n int quantum = in.nextInt();\n\n Queue<Process> processes = new LinkedList<Process>();\n\n for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }\n int currTime = 0;\n while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }\n }",
"main",
"{\n\n Scanner in = new Scanner(System.in);\n int inputProcesses = in.nextInt();\n int quantum = in.nextInt();\n\n Queue<Process> processes = new LinkedList<Process>();\n\n for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }\n int currTime = 0;\n while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int inputProcesses = in.nextInt();",
"inputProcesses",
"in.nextInt()",
"in.nextInt",
"in",
"int quantum = in.nextInt();",
"quantum",
"in.nextInt()",
"in.nextInt",
"in",
"Queue<Process> processes = new LinkedList<Process>();",
"processes",
"new LinkedList<Process>()",
"for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < inputProcesses",
"i",
"inputProcesses",
"i++",
"i++",
"i",
"{\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }",
"{\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }",
"String nameIndex = in.next();",
"nameIndex",
"in.next()",
"in.next",
"in",
"int timeIndex = in.nextInt();",
"timeIndex",
"in.nextInt()",
"in.nextInt",
"in",
"Process processIndex = new Process(nameIndex, timeIndex);",
"processIndex",
"new Process(nameIndex, timeIndex)",
"processes.add(processIndex)",
"processes.add",
"processes",
"processIndex",
"int currTime = 0;",
"currTime",
"0",
"while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }",
"!processes.isEmpty()",
"processes.isEmpty()",
"processes.isEmpty",
"processes",
"{\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }",
"Process head = processes.poll();",
"head",
"processes.poll()",
"processes.poll",
"processes",
"if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }",
"head.getTime() > quantum",
"head.getTime()",
"head.getTime",
"head",
"quantum",
"{\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }",
"head.setTime(head.getTime() - quantum)",
"head.setTime",
"head",
"head.getTime() - quantum",
"head.getTime()",
"head.getTime",
"head",
"quantum",
"currTime += quantum",
"currTime",
"quantum",
"processes.add(head)",
"processes.add",
"processes",
"head",
"{\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }",
"currTime += head.getTime()",
"currTime",
"head.getTime()",
"head.getTime",
"head",
"System.out.println(head.getName() + \" \" + currTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"head.getName() + \" \" + currTime",
"head.getName() + \" \" + currTime",
"head.getName()",
"head.getName",
"head",
"\" \"",
"currTime",
"String[] args",
"args",
"public class Main {\n\n public static void main(String[] args) {\n\n Scanner in = new Scanner(System.in);\n int inputProcesses = in.nextInt();\n int quantum = in.nextInt();\n\n Queue<Process> processes = new LinkedList<Process>();\n\n for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }\n int currTime = 0;\n while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n\n Scanner in = new Scanner(System.in);\n int inputProcesses = in.nextInt();\n int quantum = in.nextInt();\n\n Queue<Process> processes = new LinkedList<Process>();\n\n for (int i = 0; i < inputProcesses; i++) {\n String nameIndex = in.next();\n int timeIndex = in.nextInt();\n \n Process processIndex = new Process(nameIndex, timeIndex);\n processes.add(processIndex);\n }\n int currTime = 0;\n while(!processes.isEmpty()) {\n Process head = processes.poll();\n if (head.getTime() > quantum) {\n \t head.setTime(head.getTime() - quantum);\n currTime += quantum;\n processes.add(head);\n }\n else {\n currTime += head.getTime();\n System.out.println(head.getName() + \" \" + currTime);\n }\n }\n }\n}",
"Main"
] | import java.io.*;
import java.util.*;
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 in = new Scanner(System.in);
int inputProcesses = in.nextInt();
int quantum = in.nextInt();
Queue<Process> processes = new LinkedList<Process>();
for (int i = 0; i < inputProcesses; i++) {
String nameIndex = in.next();
int timeIndex = in.nextInt();
Process processIndex = new Process(nameIndex, timeIndex);
processes.add(processIndex);
}
int currTime = 0;
while(!processes.isEmpty()) {
Process head = processes.poll();
if (head.getTime() > quantum) {
head.setTime(head.getTime() - quantum);
currTime += quantum;
processes.add(head);
}
else {
currTime += head.getTime();
System.out.println(head.getName() + " " + currTime);
}
}
}
}
|
[
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,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
17,
0,
13,
4,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
13,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
29,
13,
23,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
6,
13,
41,
13,
20,
12,
13,
30,
4,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
4,
18,
13,
17,
29,
4,
18,
13,
18,
13,
17,
29,
17,
12,
13,
30,
41,
13,
20,
38,
5,
13,
30,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
4,
18,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
18,
13,
13,
29,
13,
29,
17,
12,
13,
30,
38,
5,
13,
30,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
13,
29,
13,
29,
17
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
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
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
32,
35
],
[
35,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
40,
42
],
[
32,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
32,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
32,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
56,
59
],
[
32,
60
],
[
60,
61
],
[
60,
62
],
[
32,
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
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
75,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
99,
100
],
[
100,
101
],
[
99,
102
],
[
99,
103
],
[
32,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
105,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
114,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
125,
127
],
[
122,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
134,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
134,
139
],
[
116,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
140,
148
],
[
148,
149
],
[
149,
150
],
[
148,
151
],
[
30,
152
],
[
152,
153
],
[
0,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
154,
158
],
[
158,
159
],
[
154,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
162,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
160,
173
],
[
173,
174
],
[
160,
175
],
[
175,
176
],
[
154,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
183,
184
],
[
177,
185
],
[
185,
186
],
[
177,
187
],
[
187,
188
],
[
154,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
189,
197
],
[
197,
198
],
[
0,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
201,
203
],
[
199,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
199,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
212,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
222,
223
],
[
223,
224
],
[
224,
225
],
[
225,
226
],
[
226,
227
],
[
227,
228
],
[
222,
229
],
[
219,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
231,
234
],
[
234,
235
],
[
234,
236
],
[
211,
237
],
[
237,
238
],
[
199,
239
],
[
239,
240
],
[
239,
241
],
[
241,
242
],
[
242,
243
],
[
242,
244
],
[
241,
245
],
[
245,
246
],
[
246,
247
],
[
246,
248
],
[
248,
249
],
[
249,
250
],
[
250,
251
],
[
245,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
255,
256
],
[
256,
257
],
[
257,
258
],
[
258,
259
],
[
259,
260
],
[
260,
261
],
[
255,
262
],
[
252,
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
],
[
278,
281
],
[
281,
282
],
[
282,
283
],
[
281,
284
],
[
284,
285
],
[
284,
286
],
[
252,
287
],
[
287,
288
],
[
241,
289
],
[
289,
290
],
[
199,
291
],
[
291,
292
],
[
291,
293
],
[
293,
294
],
[
294,
295
],
[
295,
296
],
[
295,
297
],
[
297,
298
],
[
298,
299
],
[
299,
300
],
[
294,
301
],
[
301,
302
],
[
302,
303
],
[
302,
304
],
[
304,
305
],
[
305,
306
],
[
306,
307
],
[
307,
308
],
[
308,
309
],
[
309,
310
],
[
304,
311
],
[
301,
312
],
[
312,
313
],
[
312,
314
],
[
314,
315
],
[
315,
316
],
[
314,
317
],
[
301,
318
],
[
318,
319
],
[
293,
320
],
[
320,
321
]
] | [
"import java.util.Deque;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nclass Main {\n\n\tpublic static void main(String[] args) {\n\t\tint n,q;\n\t\tint time = 0;\n\n\t\tInput stdIn = new Input();\n\t\tList<Integer> firstline = stdIn.getLineInteger();\n\t\tn = firstline.get(0);\n\t\tq = firstline.get(1);\n\n\t\tDeque<Process> queue = new LinkedList<>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}\n\n\t\twhile(queue.size() > 0) {\n\t\t\tProcess temp = queue.pop();\n\t\t\tif(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process {\n\tString name;\n\tint time;\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tpublic static Process createProcess(String name, int time) {\n\t\tProcess p = new Process(name, time);\n\t\treturn p;\n\t}\n\tpublic void decTime(int q) {\n\t\tthis.time -= q;\n\t}\n}\nclass Input {\n\n\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\tInput() {\n\t\tsuper();\n\t}\n\n\tpublic Integer getLineValue() {\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\treturn Integer.parseInt(s[0]);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic List<Integer> getLineInteger() {\n\t\tList<Integer> values = new ArrayList<>();\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tfor(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\tpublic List<String> getLineString() {\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tList<String> values = Arrays.asList(s);\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n}",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"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.Arrays;",
"Arrays",
"java.util",
"import java.util.List;",
"List",
"java.util",
"class Main {\n\n\tpublic static void main(String[] args) {\n\t\tint n,q;\n\t\tint time = 0;\n\n\t\tInput stdIn = new Input();\n\t\tList<Integer> firstline = stdIn.getLineInteger();\n\t\tn = firstline.get(0);\n\t\tq = firstline.get(1);\n\n\t\tDeque<Process> queue = new LinkedList<>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}\n\n\t\twhile(queue.size() > 0) {\n\t\t\tProcess temp = queue.pop();\n\t\t\tif(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tint n,q;\n\t\tint time = 0;\n\n\t\tInput stdIn = new Input();\n\t\tList<Integer> firstline = stdIn.getLineInteger();\n\t\tn = firstline.get(0);\n\t\tq = firstline.get(1);\n\n\t\tDeque<Process> queue = new LinkedList<>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}\n\n\t\twhile(queue.size() > 0) {\n\t\t\tProcess temp = queue.pop();\n\t\t\tif(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tint n,q;\n\t\tint time = 0;\n\n\t\tInput stdIn = new Input();\n\t\tList<Integer> firstline = stdIn.getLineInteger();\n\t\tn = firstline.get(0);\n\t\tq = firstline.get(1);\n\n\t\tDeque<Process> queue = new LinkedList<>();\n\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}\n\n\t\twhile(queue.size() > 0) {\n\t\t\tProcess temp = queue.pop();\n\t\t\tif(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}\n\t\t}\n\t}",
"int n",
"n",
"q;",
"q",
"int time = 0;",
"time",
"0",
"Input stdIn = new Input();",
"stdIn",
"new Input()",
"List<Integer> firstline = stdIn.getLineInteger();",
"firstline",
"stdIn.getLineInteger()",
"stdIn.getLineInteger",
"stdIn",
"n = firstline.get(0)",
"n",
"firstline.get(0)",
"firstline.get",
"firstline",
"0",
"q = firstline.get(1)",
"q",
"firstline.get(1)",
"firstline.get",
"firstline",
"1",
"Deque<Process> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"for(int i = 0; i < n; i++) {\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}",
"{\n\t\t\tList<String> line = stdIn.getLineString();\n\t\t\tString name = line.get(0);\n\t\t\tint t = Integer.parseInt(line.get(1));\n\t\t\tqueue.add(Process.createProcess(name, t));\n\t\t}",
"List<String> line = stdIn.getLineString();",
"line",
"stdIn.getLineString()",
"stdIn.getLineString",
"stdIn",
"String name = line.get(0);",
"name",
"line.get(0)",
"line.get",
"line",
"0",
"int t = Integer.parseInt(line.get(1));",
"t",
"Integer.parseInt(line.get(1))",
"Integer.parseInt",
"Integer",
"line.get(1)",
"line.get",
"line",
"1",
"queue.add(Process.createProcess(name, t))",
"queue.add",
"queue",
"Process.createProcess(name, t)",
"Process.createProcess",
"Process",
"name",
"t",
"while(queue.size() > 0) {\n\t\t\tProcess temp = queue.pop();\n\t\t\tif(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tProcess temp = queue.pop();\n\t\t\tif(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}\n\t\t}",
"Process temp = queue.pop();",
"temp",
"queue.pop()",
"queue.pop",
"queue",
"if(temp.time <= q) {\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}",
"temp.time <= q",
"temp.time",
"temp",
"temp.time",
"q",
"{\n\t\t\t\ttime += temp.time;\n\t\t\t\tSystem.out.println(temp.name + \" \" + time);\n\t\t\t}",
"time += temp.time",
"time",
"temp.time",
"temp",
"temp.time",
"System.out.println(temp.name + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.name + \" \" + time",
"temp.name + \" \" + time",
"temp.name",
"temp",
"temp.name",
"\" \"",
"time",
"{\n\t\t\t\ttime += q;\n\t\t\t\ttemp.decTime(q);\n\t\t\t\tqueue.add(temp);\n\t\t\t}",
"time += q",
"time",
"q",
"temp.decTime(q)",
"temp.decTime",
"temp",
"q",
"queue.add(temp)",
"queue.add",
"queue",
"temp",
"String[] args",
"args",
"class Process {\n\tString name;\n\tint time;\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tpublic static Process createProcess(String name, int time) {\n\t\tProcess p = new Process(name, time);\n\t\treturn p;\n\t}\n\tpublic void decTime(int q) {\n\t\tthis.time -= q;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public static Process createProcess(String name, int time) {\n\t\tProcess p = new Process(name, time);\n\t\treturn p;\n\t}",
"createProcess",
"{\n\t\tProcess p = new Process(name, time);\n\t\treturn p;\n\t}",
"Process p = new Process(name, time);",
"p",
"new Process(name, time)",
"return p;",
"p",
"String name",
"name",
"int time",
"time",
"public void decTime(int q) {\n\t\tthis.time -= q;\n\t}",
"decTime",
"{\n\t\tthis.time -= q;\n\t}",
"this.time -= q",
"this.time",
"this",
"this.time",
"q",
"int q",
"q",
"class Input {\n\n\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\tInput() {\n\t\tsuper();\n\t}\n\n\tpublic Integer getLineValue() {\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\treturn Integer.parseInt(s[0]);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\n\tpublic List<Integer> getLineInteger() {\n\t\tList<Integer> values = new ArrayList<>();\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tfor(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n\tpublic List<String> getLineString() {\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tList<String> values = Arrays.asList(s);\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}\n}",
"Input",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"Input() {\n\t\tsuper();\n\t}",
"Input",
"{\n\t\tsuper();\n\t}",
"super()",
"super",
"public Integer getLineValue() {\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\treturn Integer.parseInt(s[0]);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}",
"getLineValue",
"{\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\treturn Integer.parseInt(s[0]);\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}",
"try {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\treturn Integer.parseInt(s[0]);\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[] s = br.readLine().trim().split(\" \");\n\t\t\treturn Integer.parseInt(s[0]);\n\t\t}",
"String[] s = br.readLine().trim().split(\" \");",
"s",
"br.readLine().trim().split(\" \")",
"br.readLine().trim().split",
"br.readLine().trim()",
"br.readLine().trim",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"return Integer.parseInt(s[0]);",
"Integer.parseInt(s[0])",
"Integer.parseInt",
"Integer",
"s[0]",
"s",
"0",
"return null;",
"null",
"public List<Integer> getLineInteger() {\n\t\tList<Integer> values = new ArrayList<>();\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tfor(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}",
"getLineInteger",
"{\n\t\tList<Integer> values = new ArrayList<>();\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tfor(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}",
"List<Integer> values = new ArrayList<>();",
"values",
"new ArrayList<>()",
"try {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tfor(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}\n\t\t\treturn values;\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[] s = br.readLine().trim().split(\" \");\n\t\t\tfor(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}\n\t\t\treturn values;\n\t\t}",
"String[] s = br.readLine().trim().split(\" \");",
"s",
"br.readLine().trim().split(\" \")",
"br.readLine().trim().split",
"br.readLine().trim()",
"br.readLine().trim",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"for(int i = 0; i < s.length; i++) {\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < s.length",
"i",
"s.length",
"s",
"s.length",
"i++",
"i++",
"i",
"{\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}",
"{\n\t\t\t\tvalues.add(Integer.parseInt(s[i]));\n\t\t\t}",
"values.add(Integer.parseInt(s[i]))",
"values.add",
"values",
"Integer.parseInt(s[i])",
"Integer.parseInt",
"Integer",
"s[i]",
"s",
"i",
"return values;",
"values",
"return null;",
"null",
"public List<String> getLineString() {\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tList<String> values = Arrays.asList(s);\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}",
"getLineString",
"{\n\t\ttry {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tList<String> values = Arrays.asList(s);\n\t\t\treturn values;\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn null;\n\t}",
"try {\n\t\t\tString[] s = br.readLine().trim().split(\" \");\n\t\t\tList<String> values = Arrays.asList(s);\n\t\t\treturn values;\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[] s = br.readLine().trim().split(\" \");\n\t\t\tList<String> values = Arrays.asList(s);\n\t\t\treturn values;\n\t\t}",
"String[] s = br.readLine().trim().split(\" \");",
"s",
"br.readLine().trim().split(\" \")",
"br.readLine().trim().split",
"br.readLine().trim()",
"br.readLine().trim",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"List<String> values = Arrays.asList(s);",
"values",
"Arrays.asList(s)",
"Arrays.asList",
"Arrays",
"s",
"return values;",
"values",
"return null;",
"null"
] | import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
class Main {
public static void main(String[] args) {
int n,q;
int time = 0;
Input stdIn = new Input();
List<Integer> firstline = stdIn.getLineInteger();
n = firstline.get(0);
q = firstline.get(1);
Deque<Process> queue = new LinkedList<>();
for(int i = 0; i < n; i++) {
List<String> line = stdIn.getLineString();
String name = line.get(0);
int t = Integer.parseInt(line.get(1));
queue.add(Process.createProcess(name, t));
}
while(queue.size() > 0) {
Process temp = queue.pop();
if(temp.time <= q) {
time += temp.time;
System.out.println(temp.name + " " + time);
} else {
time += q;
temp.decTime(q);
queue.add(temp);
}
}
}
}
class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
public static Process createProcess(String name, int time) {
Process p = new Process(name, time);
return p;
}
public void decTime(int q) {
this.time -= q;
}
}
class Input {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Input() {
super();
}
public Integer getLineValue() {
try {
String[] s = br.readLine().trim().split(" ");
return Integer.parseInt(s[0]);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public List<Integer> getLineInteger() {
List<Integer> values = new ArrayList<>();
try {
String[] s = br.readLine().trim().split(" ");
for(int i = 0; i < s.length; i++) {
values.add(Integer.parseInt(s[i]));
}
return values;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public List<String> getLineString() {
try {
String[] s = br.readLine().trim().split(" ");
List<String> values = Arrays.asList(s);
return values;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
} |
[
7,
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,
12,
13,
30,
0,
18,
36,
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,
20,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
2,
13,
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,
17,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
17,
4,
18,
13,
13,
0,
18,
13,
40,
13,
13,
14,
2,
40,
13,
13,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
18,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
18,
13,
13,
13,
17,
18,
18,
13,
13,
13,
12,
13,
30,
4,
18,
20,
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
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
14,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
12,
25
],
[
25,
26
],
[
12,
27
],
[
27,
28
],
[
4,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
32,
36
],
[
29,
37
],
[
37,
38
],
[
0,
39
],
[
206,
40
],
[
206,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
50,
51
],
[
43,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
43,
57
],
[
57,
58
],
[
57,
59
],
[
43,
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
],
[
84,
85
],
[
83,
86
],
[
43,
87
],
[
87,
88
],
[
87,
89
],
[
43,
91
],
[
91,
92
],
[
91,
93
],
[
43,
94
],
[
94,
95
],
[
94,
96
],
[
43,
97
],
[
97,
98
],
[
97,
99
],
[
43,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
116,
122
],
[
122,
123
],
[
122,
124
],
[
116,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
110,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
138,
140
],
[
135,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
135,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
135,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
150,
155
],
[
104,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
157,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
43,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
171,
173
],
[
164,
174
],
[
174,
175
],
[
175,
176
],
[
164,
177
],
[
178,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
179,
184
],
[
185,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
185,
191
],
[
185,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
206,
197
],
[
197,
198
],
[
197,
199
],
[
199,
200
],
[
200,
201
],
[
201,
202
],
[
197,
203
],
[
203,
204
],
[
0,
205
],
[
205,
206
],
[
205,
207
]
] | [
"/*\n * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp\n */\nimport java.util.*;\n\nclass Task {\n\tString name;\n\tint time;\n\tint endTime;\n\tTask(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tvoid setEndTime(int x) {\n\t\tthis.endTime = x;\n\t}\n}\n\npublic class Main {\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\t//Task[] tasks = new Task[n];\n\t\tLinkedList<Task> tasks = new LinkedList<Task>();\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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}\n\n\t\tTask[] result = new Task[n];\n\t\tint topOfResult = 0;\n\t\t\n\t\tint time = 0;\n\t\tint idx = 0;\n\t\twhile (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"class Task {\n\tString name;\n\tint time;\n\tint endTime;\n\tTask(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\tvoid setEndTime(int x) {\n\t\tthis.endTime = x;\n\t}\n}",
"Task",
"String name;",
"name",
"int time;",
"time",
"int endTime;",
"endTime",
"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",
"void setEndTime(int x) {\n\t\tthis.endTime = x;\n\t}",
"setEndTime",
"{\n\t\tthis.endTime = x;\n\t}",
"this.endTime = x",
"this.endTime",
"this",
"this.endTime",
"x",
"int x",
"x",
"public class Main {\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\t//Task[] tasks = new Task[n];\n\t\tLinkedList<Task> tasks = new LinkedList<Task>();\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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}\n\n\t\tTask[] result = new Task[n];\n\t\tint topOfResult = 0;\n\t\t\n\t\tint time = 0;\n\t\tint idx = 0;\n\t\twhile (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\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\t//Task[] tasks = new Task[n];\n\t\tLinkedList<Task> tasks = new LinkedList<Task>();\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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}\n\n\t\tTask[] result = new Task[n];\n\t\tint topOfResult = 0;\n\t\t\n\t\tint time = 0;\n\t\tint idx = 0;\n\t\twhile (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\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\t//Task[] tasks = new Task[n];\n\t\tLinkedList<Task> tasks = new LinkedList<Task>();\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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}\n\n\t\tTask[] result = new Task[n];\n\t\tint topOfResult = 0;\n\t\t\n\t\tint time = 0;\n\t\tint idx = 0;\n\t\twhile (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\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",
"LinkedList<Task> tasks = new LinkedList<Task>();",
"tasks",
"new LinkedList<Task>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}",
"{\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(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",
"tasks.add(new Task(name, time))",
"tasks.add",
"tasks",
"new Task(name, time)",
"Task[] result = new Task[n];",
"result",
"new Task[n]",
"n",
"int topOfResult = 0;",
"topOfResult",
"0",
"int time = 0;",
"time",
"0",
"int idx = 0;",
"idx",
"0",
"while (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}",
"topOfResult < n",
"topOfResult",
"n",
"{\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}",
"Task task = tasks.pop();",
"task",
"tasks.pop()",
"tasks.pop",
"tasks",
"if (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}",
"task.time > q",
"task.time",
"task",
"task.time",
"q",
"{\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t}",
"task.time -= q",
"task.time",
"task",
"task.time",
"q",
"time += q",
"time",
"q",
"tasks.add(task)",
"tasks.add",
"tasks",
"task",
"if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}",
"task.time > 0",
"task.time",
"task",
"task.time",
"0",
"{\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}",
"time += task.time",
"time",
"task.time",
"task",
"task.time",
"task.time = 0",
"task.time",
"task",
"task.time",
"0",
"task.setEndTime(time)",
"task.setEndTime",
"task",
"time",
"result[topOfResult++] = task",
"result[topOfResult++]",
"result",
"topOfResult++",
"topOfResult",
"task",
"if (++idx >= n) idx = 0;",
"++idx >= n",
"++idx",
"idx",
"n",
"idx = 0",
"idx",
"0",
"for (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < result.length",
"i",
"result.length",
"result",
"result.length",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}",
"{\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}",
"System.out.println(result[i].name + \" \" + result[i].endTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"result[i].name + \" \" + result[i].endTime",
"result[i].name + \" \" + result[i].endTime",
"result[i].name",
"result[i]",
"result",
"i",
"result[i].name",
"\" \"",
"result[i].endTime",
"result[i]",
"result",
"i",
"result[i].endTime",
"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\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\t//Task[] tasks = new Task[n];\n\t\tLinkedList<Task> tasks = new LinkedList<Task>();\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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}\n\n\t\tTask[] result = new Task[n];\n\t\tint topOfResult = 0;\n\t\t\n\t\tint time = 0;\n\t\tint idx = 0;\n\t\twhile (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n}",
"public class Main {\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\t//Task[] tasks = new Task[n];\n\t\tLinkedList<Task> tasks = new LinkedList<Task>();\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\t//tasks[i] = new Task(name, time);\n\t\t\ttasks.add(new Task(name, time));\n\t\t}\n\n\t\tTask[] result = new Task[n];\n\t\tint topOfResult = 0;\n\t\t\n\t\tint time = 0;\n\t\tint idx = 0;\n\t\twhile (topOfResult < n) {\n\t\t\tTask task = tasks.pop();\n\t\t\tif (task.time > q) {\n\t\t\t\ttask.time -= q;\n\t\t\t\ttime += q;\n\t\t\t\ttasks.add(task);\n\t\t\t} else if (task.time > 0) {\n\t\t\t\ttime += task.time;\n\t\t\t\ttask.time = 0;\n\t\t\t\ttask.setEndTime(time);\n\t\t\t\tresult[topOfResult++] = task;\n\t\t\t}\n\t\t\tif (++idx >= n) idx = 0;\n\t\t}\n\t\t\n\t\tfor (int i = 0; i < result.length; i++) {\n\t\t\tSystem.out.println(result[i].name + \" \" + result[i].endTime);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n}",
"Main"
] | /*
* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp
*/
import java.util.*;
class Task {
String name;
int time;
int endTime;
Task(String name, int time) {
this.name = name;
this.time = time;
}
void setEndTime(int x) {
this.endTime = x;
}
}
public class Main {
void run() {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int q = scan.nextInt();
//Task[] tasks = new Task[n];
LinkedList<Task> tasks = new LinkedList<Task>();
for (int i = 0; i < n; i++) {
String name = scan.next();
int time = scan.nextInt();
//tasks[i] = new Task(name, time);
tasks.add(new Task(name, time));
}
Task[] result = new Task[n];
int topOfResult = 0;
int time = 0;
int idx = 0;
while (topOfResult < n) {
Task task = tasks.pop();
if (task.time > q) {
task.time -= q;
time += q;
tasks.add(task);
} else if (task.time > 0) {
time += task.time;
task.time = 0;
task.setEndTime(time);
result[topOfResult++] = task;
}
if (++idx >= n) idx = 0;
}
for (int i = 0; i < result.length; i++) {
System.out.println(result[i].name + " " + result[i].endTime);
}
}
public static void main(String[] args) {
new Main().run();
}
}
|
[
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,
4,
18,
13,
17,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
17,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
13,
41,
13,
4,
18,
13,
17,
4,
18,
13,
17,
41,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
17,
17,
4,
18,
13,
20,
41,
13,
17,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
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
],
[
201,
17
],
[
201,
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
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
34,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
20,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
50,
55
],
[
20,
56
],
[
56,
57
],
[
56,
58
],
[
20,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
59,
67
],
[
67,
68
],
[
68,
69
],
[
59,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
79,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
71,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
95,
100
],
[
71,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
20,
105
],
[
105,
106
],
[
105,
107
],
[
20,
108
],
[
108,
109
],
[
108,
110
],
[
20,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
111,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
119,
120
],
[
120,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
122,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
128,
134
],
[
134,
135
],
[
134,
136
],
[
128,
137
],
[
137,
138
],
[
138,
139
],
[
137,
140
],
[
122,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
141,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
141,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
20,
156
],
[
156,
157
],
[
156,
158
],
[
156,
159
],
[
160,
160
],
[
160,
161
],
[
161,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
161,
166
],
[
167,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
167,
171
],
[
167,
172
],
[
172,
173
],
[
172,
174
],
[
18,
175
],
[
175,
176
],
[
0,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
177,
181
],
[
181,
182
],
[
177,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
187,
189
],
[
186,
190
],
[
185,
191
],
[
191,
192
],
[
192,
193
],
[
192,
194
],
[
191,
195
],
[
183,
196
],
[
196,
197
],
[
183,
198
],
[
198,
199
],
[
0,
200
],
[
200,
201
],
[
200,
202
]
] | [
"\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\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 line = br.readLine();\n int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));\n int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n Deque<Process> deque = new ArrayDeque<Process>();\n\n for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }\n\n int maxTime = 0;\n Deque<Process> resultDeque = new ArrayDeque<Process>();\n while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }\n\n for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }\n\n\n }\n}\n\nclass Process{\n\tString name;\n\tint time;\n\n\tProcess(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\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",
"public class Main{\n\n public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));\n int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n Deque<Process> deque = new ArrayDeque<Process>();\n\n for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }\n\n int maxTime = 0;\n Deque<Process> resultDeque = new ArrayDeque<Process>();\n while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }\n\n for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }\n\n\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));\n int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n Deque<Process> deque = new ArrayDeque<Process>();\n\n for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }\n\n int maxTime = 0;\n Deque<Process> resultDeque = new ArrayDeque<Process>();\n while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }\n\n for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }\n\n\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));\n int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n Deque<Process> deque = new ArrayDeque<Process>();\n\n for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }\n\n int maxTime = 0;\n Deque<Process> resultDeque = new ArrayDeque<Process>();\n while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }\n\n for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }\n\n\n }",
"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",
"int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));",
"num",
"Integer.parseInt(line.substring(0, line.indexOf(\" \")))",
"Integer.parseInt",
"Integer",
"line.substring(0, line.indexOf(\" \"))",
"line.substring",
"line",
"0",
"line.indexOf(\" \")",
"line.indexOf",
"line",
"\" \"",
"int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));",
"q",
"Integer.parseInt(line.substring(line.indexOf(\" \") + 1))",
"Integer.parseInt",
"Integer",
"line.substring(line.indexOf(\" \") + 1)",
"line.substring",
"line",
"line.indexOf(\" \") + 1",
"line.indexOf(\" \")",
"line.indexOf",
"line",
"\" \"",
"1",
"Deque<Process> deque = new ArrayDeque<Process>();",
"deque",
"new ArrayDeque<Process>()",
"for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }",
"{\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }",
"line = br.readLine()",
"line",
"br.readLine()",
"br.readLine",
"br",
"String name = line.substring(0, line.indexOf(\" \"));",
"name",
"line.substring(0, line.indexOf(\" \"))",
"line.substring",
"line",
"0",
"line.indexOf(\" \")",
"line.indexOf",
"line",
"\" \"",
"int time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));",
"time",
"Integer.parseInt(line.substring(line.indexOf(\" \") + 1))",
"Integer.parseInt",
"Integer",
"line.substring(line.indexOf(\" \") + 1)",
"line.substring",
"line",
"line.indexOf(\" \") + 1",
"line.indexOf(\" \")",
"line.indexOf",
"line",
"\" \"",
"1",
"deque.addLast(new Process(name, time))",
"deque.addLast",
"deque",
"new Process(name, time)",
"int maxTime = 0;",
"maxTime",
"0",
"Deque<Process> resultDeque = new ArrayDeque<Process>();",
"resultDeque",
"new ArrayDeque<Process>()",
"while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }",
"!deque.isEmpty()",
"deque.isEmpty()",
"deque.isEmpty",
"deque",
"{\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }",
"Process p = deque.pollFirst();",
"p",
"deque.pollFirst()",
"deque.pollFirst",
"deque",
"if(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"maxTime += q",
"maxTime",
"q",
"deque.addLast(p)",
"deque.addLast",
"deque",
"p",
"{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}",
"maxTime += p.time",
"maxTime",
"p.time",
"p",
"p.time",
"p.time = maxTime",
"p.time",
"p",
"p.time",
"maxTime",
"resultDeque.addLast(p)",
"resultDeque.addLast",
"resultDeque",
"p",
"for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }",
"Process result",
"resultDeque",
"{\n \tSystem.out.println(result.name + \" \" + result.time);\n }",
"{\n \tSystem.out.println(result.name + \" \" + result.time);\n }",
"System.out.println(result.name + \" \" + result.time)",
"System.out.println",
"System.out",
"System",
"System.out",
"result.name + \" \" + result.time",
"result.name + \" \" + result.time",
"result.name",
"result",
"result.name",
"\" \"",
"result.time",
"result",
"result.time",
"String[] args",
"args",
"class Process{\n\tString name;\n\tint time;\n\n\tProcess(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main{\n\n public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String line = br.readLine();\n int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));\n int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n Deque<Process> deque = new ArrayDeque<Process>();\n\n for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }\n\n int maxTime = 0;\n Deque<Process> resultDeque = new ArrayDeque<Process>();\n while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }\n\n for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }\n\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 line = br.readLine();\n int num = Integer.parseInt(line.substring(0, line.indexOf(\" \")));\n int q = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n Deque<Process> deque = new ArrayDeque<Process>();\n\n for(int i = 0; i < num; i++){\n \tline = br.readLine();\n \tString name = line.substring(0, line.indexOf(\" \"));\n \tint time = Integer.parseInt(line.substring(line.indexOf(\" \") + 1));\n \tdeque.addLast(new Process(name, time));\n }\n\n int maxTime = 0;\n Deque<Process> resultDeque = new ArrayDeque<Process>();\n while(!deque.isEmpty()){\n \tProcess p = deque.pollFirst();\n \tif(p.time > q){\n \t\tp.time -= q;\n \t\tmaxTime += q;\n \t\tdeque.addLast(p);\n \t}else{\n \t\tmaxTime += p.time;\n \t\tp.time = maxTime;\n \t\tresultDeque.addLast(p);\n \t}\n }\n\n for(Process result: resultDeque){\n \tSystem.out.println(result.name + \" \" + result.time);\n }\n\n\n }\n}",
"Main"
] |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int num = Integer.parseInt(line.substring(0, line.indexOf(" ")));
int q = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
Deque<Process> deque = new ArrayDeque<Process>();
for(int i = 0; i < num; i++){
line = br.readLine();
String name = line.substring(0, line.indexOf(" "));
int time = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
deque.addLast(new Process(name, time));
}
int maxTime = 0;
Deque<Process> resultDeque = new ArrayDeque<Process>();
while(!deque.isEmpty()){
Process p = deque.pollFirst();
if(p.time > q){
p.time -= q;
maxTime += q;
deque.addLast(p);
}else{
maxTime += p.time;
p.time = maxTime;
resultDeque.addLast(p);
}
}
for(Process result: resultDeque){
System.out.println(result.name + " " + result.time);
}
}
}
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,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
13,
14,
2,
18,
13,
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,
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,
18,
36,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
14,
2,
2,
18,
36,
13,
13,
17,
30,
0,
18,
36,
13,
17,
30,
0,
18,
36,
13,
2,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
163,
5
],
[
163,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
8,
42
],
[
42,
43
],
[
43,
44
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
8,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
48,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
53,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
53,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
69,
73
],
[
68,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
78,
83
],
[
84,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
84,
88
],
[
84,
89
],
[
68,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
6,
98
],
[
98,
99
],
[
163,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
100,
104
],
[
104,
105
],
[
100,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
112,
114
],
[
106,
115
],
[
115,
116
],
[
106,
117
],
[
117,
118
],
[
100,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
100,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
100,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
137,
143
],
[
136,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
136,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
133,
160
],
[
160,
161
],
[
0,
162
],
[
162,
163
],
[
162,
164
]
] | [
"import java.util.*;\npublic class Main\n{\n\tpublic static class process\n\t{\n\t\tString name;\n\t\tint time;\n\t\tpublic process(String n, int t)\n\t\t{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}\n\t\tpublic String getName()\n\t\t{\n\t\t\treturn this.name;\n\t\t}\n\t\t\n\t\tpublic int getTime()\n\t\t{\n\t\t\treturn this.time;\n\t\t}\n\t\t\n\t\tpublic void run(int t)\n\t\t{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args)\n\t{\n\t\tQueue<process> q = new LinkedList<process>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint procs = in.nextInt();\n\t\tint lot = in.nextInt();\n\t\tfor(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}\n\t\tin.close();\n\t\t\n\t\t//start of algorithm\n\t\tint runTime = 0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main\n{\n\tpublic static class process\n\t{\n\t\tString name;\n\t\tint time;\n\t\tpublic process(String n, int t)\n\t\t{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}\n\t\tpublic String getName()\n\t\t{\n\t\t\treturn this.name;\n\t\t}\n\t\t\n\t\tpublic int getTime()\n\t\t{\n\t\t\treturn this.time;\n\t\t}\n\t\t\n\t\tpublic void run(int t)\n\t\t{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args)\n\t{\n\t\tQueue<process> q = new LinkedList<process>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint procs = in.nextInt();\n\t\tint lot = in.nextInt();\n\t\tfor(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}\n\t\tin.close();\n\t\t\n\t\t//start of algorithm\n\t\tint runTime = 0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args)\n\t{\n\t\tQueue<process> q = new LinkedList<process>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint procs = in.nextInt();\n\t\tint lot = in.nextInt();\n\t\tfor(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}\n\t\tin.close();\n\t\t\n\t\t//start of algorithm\n\t\tint runTime = 0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tQueue<process> q = new LinkedList<process>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint procs = in.nextInt();\n\t\tint lot = in.nextInt();\n\t\tfor(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}\n\t\tin.close();\n\t\t\n\t\t//start of algorithm\n\t\tint runTime = 0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}\n\t}",
"Queue<process> q = new LinkedList<process>();",
"q",
"new LinkedList<process>()",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int procs = in.nextInt();",
"procs",
"in.nextInt()",
"in.nextInt",
"in",
"int lot = in.nextInt();",
"lot",
"in.nextInt()",
"in.nextInt",
"in",
"for(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}",
"int c = 0;",
"int c = 0;",
"c",
"0",
"c < procs",
"c",
"procs",
"c++",
"c++",
"c",
"{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}",
"{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}",
"q.add(new process(in.next(),in.nextInt()))",
"q.add",
"q",
"new process(in.next(),in.nextInt())",
"in.close()",
"in.close",
"in",
"int runTime = 0;",
"runTime",
"0",
"while(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}",
"process p = q.poll();",
"p",
"q.poll()",
"q.poll",
"q",
"int remainingPTime = p.getTime();",
"remainingPTime",
"p.getTime()",
"p.getTime",
"p",
"p.run(lot)",
"p.run",
"p",
"lot",
"if(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}",
"p.time == 0",
"p.time",
"p",
"p.time",
"0",
"{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}",
"runTime+= remainingPTime",
"runTime",
"remainingPTime",
"System.out.println(p.getName()+\" \"+runTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getName()+\" \"+runTime",
"p.getName()+\" \"+runTime",
"p.getName()",
"p.getName",
"p",
"\" \"",
"runTime",
"{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}",
"runTime+=lot",
"runTime",
"lot",
"q.add(p)",
"q.add",
"q",
"p",
"String[] args",
"args",
"public static class process\n\t{\n\t\tString name;\n\t\tint time;\n\t\tpublic process(String n, int t)\n\t\t{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}\n\t\tpublic String getName()\n\t\t{\n\t\t\treturn this.name;\n\t\t}\n\t\t\n\t\tpublic int getTime()\n\t\t{\n\t\t\treturn this.time;\n\t\t}\n\t\t\n\t\tpublic void run(int t)\n\t\t{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}\n\t}",
"process",
"String name;",
"name",
"int time;",
"time",
"public process(String n, int t)\n\t\t{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}",
"process",
"{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}",
"name=n",
"name",
"n",
"time=t",
"time",
"t",
"String n",
"n",
"int t",
"t",
"public String getName()\n\t\t{\n\t\t\treturn this.name;\n\t\t}",
"getName",
"{\n\t\t\treturn this.name;\n\t\t}",
"return this.name;",
"this.name",
"this",
"this.name",
"public int getTime()\n\t\t{\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 run(int t)\n\t\t{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}",
"run",
"{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}",
"if(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}",
"this.time-t<0",
"this.time-t",
"this.time",
"this",
"this.time",
"t",
"0",
"{\n\t\t\t\tthis.time=0;\n\t\t\t}",
"this.time=0",
"this.time",
"this",
"this.time",
"0",
"{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}",
"this.time = this.time - t",
"this.time",
"this",
"this.time",
"this.time - t",
"this.time",
"this",
"this.time",
"t",
"int t",
"t",
"public class Main\n{\n\tpublic static class process\n\t{\n\t\tString name;\n\t\tint time;\n\t\tpublic process(String n, int t)\n\t\t{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}\n\t\tpublic String getName()\n\t\t{\n\t\t\treturn this.name;\n\t\t}\n\t\t\n\t\tpublic int getTime()\n\t\t{\n\t\t\treturn this.time;\n\t\t}\n\t\t\n\t\tpublic void run(int t)\n\t\t{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args)\n\t{\n\t\tQueue<process> q = new LinkedList<process>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint procs = in.nextInt();\n\t\tint lot = in.nextInt();\n\t\tfor(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}\n\t\tin.close();\n\t\t\n\t\t//start of algorithm\n\t\tint runTime = 0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main\n{\n\tpublic static class process\n\t{\n\t\tString name;\n\t\tint time;\n\t\tpublic process(String n, int t)\n\t\t{\n\t\t\tname=n;\n\t\t\ttime=t;\n\t\t}\n\t\tpublic String getName()\n\t\t{\n\t\t\treturn this.name;\n\t\t}\n\t\t\n\t\tpublic int getTime()\n\t\t{\n\t\t\treturn this.time;\n\t\t}\n\t\t\n\t\tpublic void run(int t)\n\t\t{\n\t\t\tif(this.time-t<0)\n\t\t\t{\n\t\t\t\tthis.time=0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.time = this.time - t;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tpublic static void main(String[] args)\n\t{\n\t\tQueue<process> q = new LinkedList<process>();\n\t\tScanner in = new Scanner(System.in);\n\t\tint procs = in.nextInt();\n\t\tint lot = in.nextInt();\n\t\tfor(int c = 0; c < procs ; c++)\n\t\t{\n\t\t\tq.add(new process(in.next(),in.nextInt()));\n\t\t}\n\t\tin.close();\n\t\t\n\t\t//start of algorithm\n\t\tint runTime = 0;\n\t\twhile(!q.isEmpty())\n\t\t{\n\t\t\tprocess p = q.poll();\n\t\t\tint remainingPTime = p.getTime();\n\t\t\tp.run(lot);\n\t\t\tif(p.time == 0)\n\t\t\t{\n\t\t\t\trunTime+= remainingPTime;\n\t\t\t\tSystem.out.println(p.getName()+\" \"+runTime);\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\trunTime+=lot;\n\t\t\t\tq.add(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
public class Main
{
public static class process
{
String name;
int time;
public process(String n, int t)
{
name=n;
time=t;
}
public String getName()
{
return this.name;
}
public int getTime()
{
return this.time;
}
public void run(int t)
{
if(this.time-t<0)
{
this.time=0;
}
else
{
this.time = this.time - t;
}
}
}
public static void main(String[] args)
{
Queue<process> q = new LinkedList<process>();
Scanner in = new Scanner(System.in);
int procs = in.nextInt();
int lot = in.nextInt();
for(int c = 0; c < procs ; c++)
{
q.add(new process(in.next(),in.nextInt()));
}
in.close();
//start of algorithm
int runTime = 0;
while(!q.isEmpty())
{
process p = q.poll();
int remainingPTime = p.getTime();
p.run(lot);
if(p.time == 0)
{
runTime+= remainingPTime;
System.out.println(p.getName()+" "+runTime);
}
else
{
runTime+=lot;
q.add(p);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
2,
18,
13,
13,
13,
17,
30,
41,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
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
] | [
[
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
],
[
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,
37
],
[
37,
38
],
[
37,
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
],
[
55,
56
],
[
56,
57
],
[
52,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
64,
65
],
[
52,
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
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
85,
91
],
[
84,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
92,
103
],
[
103,
104
],
[
103,
105
],
[
92,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
84,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
110,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
110,
120
],
[
120,
121
],
[
120,
122
],
[
14,
123
],
[
123,
124
],
[
123,
125
],
[
123,
126
],
[
127,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
128,
133
],
[
134,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
134,
139
],
[
139,
140
],
[
139,
141
],
[
12,
142
],
[
142,
143
],
[
0,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
144,
148
],
[
148,
149
],
[
144,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
152,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
150,
163
],
[
163,
164
],
[
150,
165
],
[
165,
166
]
] | [
"import java.io.*;\nimport java.util.*;\nimport java.lang.*;\n\nclass Main{\n public static void main(String[] args) throws IOException{\n Scanner scan=new Scanner(System.in);\n int n=Integer.parseInt(scan.next());\n int q=Integer.parseInt(scan.next());\n int sumTime=0;\n Queue<Process> queue=new ArrayDeque<Process>();\n\n for(int i=0;i<n;i++){\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }\n\n Queue<Process> ans=new ArrayDeque<>();\n while(!queue.isEmpty()){\n Process buf=queue.remove();\n if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }\n }\n for(Process p:ans){\n System.out.println(p.name+\" \"+p.pTime);\n }\n }\n}\nclass Process{\n String name;\n int pTime;\n\n public Process(String name,int pTime){\n this.name=name;\n this.pTime=pTime;\n }\n}\n",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"class Main{\n public static void main(String[] args) throws IOException{\n Scanner scan=new Scanner(System.in);\n int n=Integer.parseInt(scan.next());\n int q=Integer.parseInt(scan.next());\n int sumTime=0;\n Queue<Process> queue=new ArrayDeque<Process>();\n\n for(int i=0;i<n;i++){\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }\n\n Queue<Process> ans=new ArrayDeque<>();\n while(!queue.isEmpty()){\n Process buf=queue.remove();\n if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }\n }\n for(Process p:ans){\n System.out.println(p.name+\" \"+p.pTime);\n }\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n Scanner scan=new Scanner(System.in);\n int n=Integer.parseInt(scan.next());\n int q=Integer.parseInt(scan.next());\n int sumTime=0;\n Queue<Process> queue=new ArrayDeque<Process>();\n\n for(int i=0;i<n;i++){\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }\n\n Queue<Process> ans=new ArrayDeque<>();\n while(!queue.isEmpty()){\n Process buf=queue.remove();\n if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }\n }\n for(Process p:ans){\n System.out.println(p.name+\" \"+p.pTime);\n }\n }",
"main",
"{\n Scanner scan=new Scanner(System.in);\n int n=Integer.parseInt(scan.next());\n int q=Integer.parseInt(scan.next());\n int sumTime=0;\n Queue<Process> queue=new ArrayDeque<Process>();\n\n for(int i=0;i<n;i++){\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }\n\n Queue<Process> ans=new ArrayDeque<>();\n while(!queue.isEmpty()){\n Process buf=queue.remove();\n if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }\n }\n for(Process p:ans){\n System.out.println(p.name+\" \"+p.pTime);\n }\n }",
"Scanner scan=new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"int n=Integer.parseInt(scan.next());",
"n",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"int q=Integer.parseInt(scan.next());",
"q",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"int sumTime=0;",
"sumTime",
"0",
"Queue<Process> queue=new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for(int i=0;i<n;i++){\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }",
"{\n String namae=scan.next();\n int Time=Integer.parseInt(scan.next());\n queue.add(new Process(namae,Time));\n }",
"String namae=scan.next();",
"namae",
"scan.next()",
"scan.next",
"scan",
"int Time=Integer.parseInt(scan.next());",
"Time",
"Integer.parseInt(scan.next())",
"Integer.parseInt",
"Integer",
"scan.next()",
"scan.next",
"scan",
"queue.add(new Process(namae,Time))",
"queue.add",
"queue",
"new Process(namae,Time)",
"Queue<Process> ans=new ArrayDeque<>();",
"ans",
"new ArrayDeque<>()",
"while(!queue.isEmpty()){\n Process buf=queue.remove();\n if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process buf=queue.remove();\n if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }\n }",
"Process buf=queue.remove();",
"buf",
"queue.remove()",
"queue.remove",
"queue",
"if(buf.pTime-q<=0){\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }else {\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }",
"buf.pTime-q<=0",
"buf.pTime-q",
"buf.pTime",
"buf",
"buf.pTime",
"q",
"0",
"{\n int buf2=buf.pTime;\n buf.pTime+=sumTime;\n sumTime+=buf2;\n ans.add(buf);\n }",
"int buf2=buf.pTime;",
"buf2",
"buf.pTime",
"buf",
"buf.pTime",
"buf.pTime+=sumTime",
"buf.pTime",
"buf",
"buf.pTime",
"sumTime",
"sumTime+=buf2",
"sumTime",
"buf2",
"ans.add(buf)",
"ans.add",
"ans",
"buf",
"{\n buf.pTime-=q;\n queue.add(buf);\n sumTime+=q;\n }",
"buf.pTime-=q",
"buf.pTime",
"buf",
"buf.pTime",
"q",
"queue.add(buf)",
"queue.add",
"queue",
"buf",
"sumTime+=q",
"sumTime",
"q",
"for(Process p:ans){\n System.out.println(p.name+\" \"+p.pTime);\n }",
"Process p",
"ans",
"{\n System.out.println(p.name+\" \"+p.pTime);\n }",
"{\n System.out.println(p.name+\" \"+p.pTime);\n }",
"System.out.println(p.name+\" \"+p.pTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name+\" \"+p.pTime",
"p.name+\" \"+p.pTime",
"p.name",
"p",
"p.name",
"\" \"",
"p.pTime",
"p",
"p.pTime",
"String[] args",
"args",
"class Process{\n String name;\n int pTime;\n\n public Process(String name,int pTime){\n this.name=name;\n this.pTime=pTime;\n }\n}",
"Process",
"String name;",
"name",
"int pTime;",
"pTime",
"public Process(String name,int pTime){\n this.name=name;\n this.pTime=pTime;\n }",
"Process",
"{\n this.name=name;\n this.pTime=pTime;\n }",
"this.name=name",
"this.name",
"this",
"this.name",
"name",
"this.pTime=pTime",
"this.pTime",
"this",
"this.pTime",
"pTime",
"String name",
"name",
"int pTime",
"pTime"
] | import java.io.*;
import java.util.*;
import java.lang.*;
class Main{
public static void main(String[] args) throws IOException{
Scanner scan=new Scanner(System.in);
int n=Integer.parseInt(scan.next());
int q=Integer.parseInt(scan.next());
int sumTime=0;
Queue<Process> queue=new ArrayDeque<Process>();
for(int i=0;i<n;i++){
String namae=scan.next();
int Time=Integer.parseInt(scan.next());
queue.add(new Process(namae,Time));
}
Queue<Process> ans=new ArrayDeque<>();
while(!queue.isEmpty()){
Process buf=queue.remove();
if(buf.pTime-q<=0){
int buf2=buf.pTime;
buf.pTime+=sumTime;
sumTime+=buf2;
ans.add(buf);
}else {
buf.pTime-=q;
queue.add(buf);
sumTime+=q;
}
}
for(Process p:ans){
System.out.println(p.name+" "+p.pTime);
}
}
}
class Process{
String name;
int pTime;
public Process(String name,int pTime){
this.name=name;
this.pTime=pTime;
}
}
|
[
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,
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,
14,
4,
13,
30,
4,
18,
18,
13,
13,
17,
29,
0,
18,
13,
13,
20,
0,
13,
2,
2,
13,
17,
13,
23,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
4,
18,
18,
13,
13,
17,
29,
17,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
29,
2,
13,
13,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
18,
13,
18,
13,
17,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
18,
13,
13,
2,
18,
13,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
10,
14
],
[
14,
15
],
[
10,
16
],
[
16,
17
],
[
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
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
35,
37
],
[
33,
38
],
[
38,
39
],
[
33,
40
],
[
40,
41
],
[
33,
42
],
[
42,
43
],
[
33,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
46,
54
],
[
54,
55
],
[
54,
56
],
[
33,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
64,
69
],
[
63,
70
],
[
59,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
71,
75
],
[
59,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
57,
83
],
[
83,
84
],
[
57,
85
],
[
85,
86
],
[
33,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
94,
99
],
[
93,
100
],
[
100,
101
],
[
89,
102
],
[
102,
103
],
[
102,
104
],
[
104,
105
],
[
104,
106
],
[
89,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
89,
114
],
[
114,
115
],
[
33,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
33,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
0,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
144,
149
],
[
138,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
152,
155
],
[
155,
156
],
[
155,
157
],
[
138,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
163,
164
],
[
163,
165
],
[
138,
166
],
[
166,
167
],
[
166,
168
],
[
138,
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
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
184,
189
],
[
181,
190
],
[
190,
191
],
[
191,
192
],
[
190,
193
],
[
193,
194
],
[
193,
195
],
[
190,
196
],
[
196,
197
],
[
197,
198
],
[
196,
199
],
[
199,
200
],
[
199,
201
],
[
138,
202
],
[
202,
203
],
[
202,
204
],
[
138,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
205,
210
],
[
210,
211
],
[
211,
212
],
[
211,
213
],
[
213,
214
],
[
214,
215
],
[
210,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
218,
220
],
[
217,
221
],
[
216,
222
],
[
222,
223
],
[
223,
224
],
[
223,
225
],
[
225,
226
],
[
225,
227
],
[
222,
228
],
[
228,
229
],
[
229,
230
],
[
230,
231
],
[
230,
232
],
[
228,
233
],
[
234,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
234,
238
],
[
234,
239
],
[
216,
240
],
[
240,
241
],
[
241,
242
],
[
241,
243
],
[
240,
244
],
[
244,
245
],
[
245,
246
],
[
244,
247
],
[
247,
248
],
[
247,
249
],
[
244,
250
],
[
250,
251
],
[
251,
252
],
[
251,
253
],
[
250,
254
],
[
136,
255
],
[
255,
256
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nclass Tuple{\n String name;\n int time;\n Tuple(String name, int time){\n this.name = name;\n this.time = time;\n }\n}\n\nclass myQueue{\n int size = 100000;\n Tuple[] data;\n int head;\n int tail;\n\n myQueue(){\n data = new Tuple[size];\n head = 0;\n tail = 0;\n }\n\n void enqueue(String n, int t){\n if(isFull()){\n System.err.println(\"queue is full\");\n return;\n }\n data[tail] = new Tuple(n,t);\n tail = (tail + 1) % size;\n }\n\n Tuple dequeue(){\n if(isEmpty()){\n System.err.println(\"queue is empty\");\n return null;\n }\n Tuple answer = data[head];\n head = (head + 1) % size;\n return answer;\n }\n \n boolean isFull(){\n return head == (tail + 1) % size;\n }\n\n boolean isEmpty(){\n return head == tail;\n }\n}\nclass Main{\n public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n \n myQueue mq = new myQueue();\n for(int i = 0; i < n; i++){\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }\n\n int now = 0;\n while(!mq.isEmpty()){\n Tuple process = mq.dequeue();\n if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }\n }\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"class Tuple{\n String name;\n int time;\n Tuple(String name, int time){\n this.name = name;\n this.time = time;\n }\n}",
"Tuple",
"String name;",
"name",
"int time;",
"time",
"Tuple(String name, int time){\n this.name = name;\n this.time = time;\n }",
"Tuple",
"{\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",
"class myQueue{\n int size = 100000;\n Tuple[] data;\n int head;\n int tail;\n\n myQueue(){\n data = new Tuple[size];\n head = 0;\n tail = 0;\n }\n\n void enqueue(String n, int t){\n if(isFull()){\n System.err.println(\"queue is full\");\n return;\n }\n data[tail] = new Tuple(n,t);\n tail = (tail + 1) % size;\n }\n\n Tuple dequeue(){\n if(isEmpty()){\n System.err.println(\"queue is empty\");\n return null;\n }\n Tuple answer = data[head];\n head = (head + 1) % size;\n return answer;\n }\n \n boolean isFull(){\n return head == (tail + 1) % size;\n }\n\n boolean isEmpty(){\n return head == tail;\n }\n}",
"myQueue",
"int size = 100000;",
"size",
"100000",
"Tuple[] data;",
"data",
"int head;",
"head",
"int tail;",
"tail",
"myQueue(){\n data = new Tuple[size];\n head = 0;\n tail = 0;\n }",
"myQueue",
"{\n data = new Tuple[size];\n head = 0;\n tail = 0;\n }",
"data = new Tuple[size]",
"data",
"new Tuple[size]",
"size",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"void enqueue(String n, int t){\n if(isFull()){\n System.err.println(\"queue is full\");\n return;\n }\n data[tail] = new Tuple(n,t);\n tail = (tail + 1) % size;\n }",
"enqueue",
"{\n if(isFull()){\n System.err.println(\"queue is full\");\n return;\n }\n data[tail] = new Tuple(n,t);\n tail = (tail + 1) % size;\n }",
"if(isFull()){\n System.err.println(\"queue is full\");\n return;\n }",
"isFull()",
"isFull",
"{\n System.err.println(\"queue is full\");\n return;\n }",
"System.err.println(\"queue is full\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"queue is full\"",
"return;",
"data[tail] = new Tuple(n,t)",
"data[tail]",
"data",
"tail",
"new Tuple(n,t)",
"tail = (tail + 1) % size",
"tail",
"(tail + 1) % size",
"(tail + 1)",
"tail",
"1",
"size",
"String n",
"n",
"int t",
"t",
"Tuple dequeue(){\n if(isEmpty()){\n System.err.println(\"queue is empty\");\n return null;\n }\n Tuple answer = data[head];\n head = (head + 1) % size;\n return answer;\n }",
"dequeue",
"{\n if(isEmpty()){\n System.err.println(\"queue is empty\");\n return null;\n }\n Tuple answer = data[head];\n head = (head + 1) % size;\n return answer;\n }",
"if(isEmpty()){\n System.err.println(\"queue is empty\");\n return null;\n }",
"isEmpty()",
"isEmpty",
"{\n System.err.println(\"queue is empty\");\n return null;\n }",
"System.err.println(\"queue is empty\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"queue is empty\"",
"return null;",
"null",
"Tuple answer = data[head];",
"answer",
"data[head]",
"data",
"head",
"head = (head + 1) % size",
"head",
"(head + 1) % size",
"(head + 1)",
"head",
"1",
"size",
"return answer;",
"answer",
"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",
"boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"class Main{\n public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n \n myQueue mq = new myQueue();\n for(int i = 0; i < n; i++){\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }\n\n int now = 0;\n while(!mq.isEmpty()){\n Tuple process = mq.dequeue();\n if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n \n myQueue mq = new myQueue();\n for(int i = 0; i < n; i++){\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }\n\n int now = 0;\n while(!mq.isEmpty()){\n Tuple process = mq.dequeue();\n if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }\n }\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n String[] input = br.readLine().split(\" \");\n int n = Integer.parseInt(input[0]);\n int q = Integer.parseInt(input[1]);\n \n myQueue mq = new myQueue();\n for(int i = 0; i < n; i++){\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }\n\n int now = 0;\n while(!mq.isEmpty()){\n Tuple process = mq.dequeue();\n if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }\n }\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] input = br.readLine().split(\" \");",
"input",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(input[0]);",
"n",
"Integer.parseInt(input[0])",
"Integer.parseInt",
"Integer",
"input[0]",
"input",
"0",
"int q = Integer.parseInt(input[1]);",
"q",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"myQueue mq = new myQueue();",
"mq",
"new myQueue()",
"for(int i = 0; i < n; i++){\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }",
"{\n String[] line = br.readLine().split(\" \");\n mq.enqueue(line[0], Integer.parseInt(line[1]));\n }",
"String[] line = br.readLine().split(\" \");",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"mq.enqueue(line[0], Integer.parseInt(line[1]))",
"mq.enqueue",
"mq",
"line[0]",
"line",
"0",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"int now = 0;",
"now",
"0",
"while(!mq.isEmpty()){\n Tuple process = mq.dequeue();\n if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }\n }",
"!mq.isEmpty()",
"mq.isEmpty()",
"mq.isEmpty",
"mq",
"{\n Tuple process = mq.dequeue();\n if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }\n }",
"Tuple process = mq.dequeue();",
"process",
"mq.dequeue()",
"mq.dequeue",
"mq",
"if(process.time <= q){\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }else{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }",
"process.time <= q",
"process.time",
"process",
"process.time",
"q",
"{\n now += process.time;\n System.out.println(process.name + \" \" + now);\n }",
"now += process.time",
"now",
"process.time",
"process",
"process.time",
"System.out.println(process.name + \" \" + now)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + now",
"process.name + \" \" + now",
"process.name",
"process",
"process.name",
"\" \"",
"now",
"{\n now += q;\n mq.enqueue(process.name, process.time - q);\n }",
"now += q",
"now",
"q",
"mq.enqueue(process.name, process.time - q)",
"mq.enqueue",
"mq",
"process.name",
"process",
"process.name",
"process.time - q",
"process.time",
"process",
"process.time",
"q",
"String[] args",
"args"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Tuple{
String name;
int time;
Tuple(String name, int time){
this.name = name;
this.time = time;
}
}
class myQueue{
int size = 100000;
Tuple[] data;
int head;
int tail;
myQueue(){
data = new Tuple[size];
head = 0;
tail = 0;
}
void enqueue(String n, int t){
if(isFull()){
System.err.println("queue is full");
return;
}
data[tail] = new Tuple(n,t);
tail = (tail + 1) % size;
}
Tuple dequeue(){
if(isEmpty()){
System.err.println("queue is empty");
return null;
}
Tuple answer = data[head];
head = (head + 1) % size;
return answer;
}
boolean isFull(){
return head == (tail + 1) % size;
}
boolean isEmpty(){
return head == tail;
}
}
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] input = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int q = Integer.parseInt(input[1]);
myQueue mq = new myQueue();
for(int i = 0; i < n; i++){
String[] line = br.readLine().split(" ");
mq.enqueue(line[0], Integer.parseInt(line[1]));
}
int now = 0;
while(!mq.isEmpty()){
Tuple process = mq.dequeue();
if(process.time <= q){
now += process.time;
System.out.println(process.name + " " + now);
}else{
now += q;
mq.enqueue(process.name, process.time - q);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
18,
13,
13,
20,
4,
18,
13,
18,
13,
13,
41,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
4,
18,
13,
20,
0,
13,
4,
18,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
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,
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
],
[
207,
17
],
[
207,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
20,
37
],
[
37,
38
],
[
37,
39
],
[
20,
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
],
[
53,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
53,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
72,
73
],
[
72,
74
],
[
20,
75
],
[
75,
76
],
[
75,
77
],
[
20,
78
],
[
78,
79
],
[
78,
80
],
[
20,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
82,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
94,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
103,
107
],
[
99,
108
],
[
108,
109
],
[
109,
110
],
[
108,
111
],
[
99,
112
],
[
112,
113
],
[
112,
114
],
[
93,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
116,
119
],
[
115,
120
],
[
120,
121
],
[
120,
122
],
[
122,
123
],
[
123,
124
],
[
20,
125
],
[
125,
126
],
[
125,
127
],
[
125,
128
],
[
129,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
130,
135
],
[
136,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
136,
141
],
[
141,
142
],
[
141,
143
],
[
20,
144
],
[
144,
145
],
[
145,
146
],
[
18,
147
],
[
147,
148
],
[
207,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
149,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
157,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
155,
168
],
[
168,
169
],
[
155,
170
],
[
170,
171
],
[
149,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
149,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
179,
187
],
[
187,
188
],
[
149,
189
],
[
189,
190
],
[
189,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
149,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
199,
203
],
[
196,
204
],
[
204,
205
],
[
0,
206
],
[
206,
207
],
[
206,
208
]
] | [
"import java.util.ArrayList;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main\n{\n static class Process {\n private String name;\n private int time;\n\n public Process(String name, int time)\n {\n this.name = name;\n this.time = time;\n }\n\n public String getName()\n {\n return this.name;\n }\n public void setName(String name)\n {\n this.name = name;\n }\n public int getTime()\n {\n return this.time;\n }\n public void setTime(int time)\n {\n this.time = time;\n }\n }\n\n public static void main(String[] args)\n {\n Scanner scan = new Scanner(System.in);\n Queue<Process> queue = new LinkedList<Process>();\n int n = scan.nextInt();\n int q = scan.nextInt();\n\n Process[] p = new Process[n];\n\n for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }\n\n List<Process> finishProcesses = new ArrayList<Main.Process>();\n\n int currentTime = 0;\n while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }\n\n for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }\n\n scan.close();\n }\n\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main\n{\n static class Process {\n private String name;\n private int time;\n\n public Process(String name, int time)\n {\n this.name = name;\n this.time = time;\n }\n\n public String getName()\n {\n return this.name;\n }\n public void setName(String name)\n {\n this.name = name;\n }\n public int getTime()\n {\n return this.time;\n }\n public void setTime(int time)\n {\n this.time = time;\n }\n }\n\n public static void main(String[] args)\n {\n Scanner scan = new Scanner(System.in);\n Queue<Process> queue = new LinkedList<Process>();\n int n = scan.nextInt();\n int q = scan.nextInt();\n\n Process[] p = new Process[n];\n\n for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }\n\n List<Process> finishProcesses = new ArrayList<Main.Process>();\n\n int currentTime = 0;\n while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }\n\n for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }\n\n scan.close();\n }\n\n}",
"Main",
"public static void main(String[] args)\n {\n Scanner scan = new Scanner(System.in);\n Queue<Process> queue = new LinkedList<Process>();\n int n = scan.nextInt();\n int q = scan.nextInt();\n\n Process[] p = new Process[n];\n\n for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }\n\n List<Process> finishProcesses = new ArrayList<Main.Process>();\n\n int currentTime = 0;\n while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }\n\n for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }\n\n scan.close();\n }",
"main",
"{\n Scanner scan = new Scanner(System.in);\n Queue<Process> queue = new LinkedList<Process>();\n int n = scan.nextInt();\n int q = scan.nextInt();\n\n Process[] p = new Process[n];\n\n for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }\n\n List<Process> finishProcesses = new ArrayList<Main.Process>();\n\n int currentTime = 0;\n while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }\n\n for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }\n\n scan.close();\n }",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"Queue<Process> queue = new LinkedList<Process>();",
"queue",
"new LinkedList<Process>()",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Process[] p = new Process[n];",
"p",
"new Process[n]",
"n",
"for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }",
"{\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }",
"String name = scan.next();",
"name",
"scan.next()",
"scan.next",
"scan",
"int time = scan.nextInt();",
"time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"p[i] = new Process(name, time)",
"p[i]",
"p",
"i",
"new Process(name, time)",
"queue.offer(p[i])",
"queue.offer",
"queue",
"p[i]",
"p",
"i",
"List<Process> finishProcesses = new ArrayList<Main.Process>();",
"finishProcesses",
"new ArrayList<Main.Process>()",
"int currentTime = 0;",
"currentTime",
"0",
"while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }",
"Process current = queue.poll();",
"current",
"queue.poll()",
"queue.poll",
"queue",
"if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }",
"current.getTime() > q",
"current.getTime()",
"current.getTime",
"current",
"q",
"{\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }",
"current.setTime(current.getTime() - q)",
"current.setTime",
"current",
"current.getTime() - q",
"current.getTime()",
"current.getTime",
"current",
"q",
"queue.offer(current)",
"queue.offer",
"queue",
"current",
"currentTime += q",
"currentTime",
"q",
"{\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }",
"finishProcesses.add(new Process(current.name, currentTime + current.getTime()))",
"finishProcesses.add",
"finishProcesses",
"new Process(current.name, currentTime + current.getTime())",
"currentTime += current.getTime()",
"currentTime",
"current.getTime()",
"current.getTime",
"current",
"for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }",
"Process process",
"finishProcesses",
"{\n System.out.println(process.name + \" \" + process.time);\n }",
"{\n System.out.println(process.name + \" \" + process.time);\n }",
"System.out.println(process.name + \" \" + process.time)",
"System.out.println",
"System.out",
"System",
"System.out",
"process.name + \" \" + process.time",
"process.name + \" \" + process.time",
"process.name",
"process",
"process.name",
"\" \"",
"process.time",
"process",
"process.time",
"scan.close()",
"scan.close",
"scan",
"String[] args",
"args",
"static class Process {\n private String name;\n private int time;\n\n public Process(String name, int time)\n {\n this.name = name;\n this.time = time;\n }\n\n public String getName()\n {\n return this.name;\n }\n public void setName(String name)\n {\n this.name = name;\n }\n public int getTime()\n {\n return this.time;\n }\n public void setTime(int time)\n {\n this.time = time;\n }\n }",
"Process",
"private String name;",
"name",
"private int time;",
"time",
"public Process(String name, int time)\n {\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 {\n return this.name;\n }",
"getName",
"{\n return this.name;\n }",
"return this.name;",
"this.name",
"this",
"this.name",
"public void setName(String name)\n {\n this.name = name;\n }",
"setName",
"{\n this.name = name;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"public int getTime()\n {\n return this.time;\n }",
"getTime",
"{\n return this.time;\n }",
"return this.time;",
"this.time",
"this",
"this.time",
"public void setTime(int time)\n {\n this.time = time;\n }",
"setTime",
"{\n this.time = time;\n }",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"int time",
"time",
"public class Main\n{\n static class Process {\n private String name;\n private int time;\n\n public Process(String name, int time)\n {\n this.name = name;\n this.time = time;\n }\n\n public String getName()\n {\n return this.name;\n }\n public void setName(String name)\n {\n this.name = name;\n }\n public int getTime()\n {\n return this.time;\n }\n public void setTime(int time)\n {\n this.time = time;\n }\n }\n\n public static void main(String[] args)\n {\n Scanner scan = new Scanner(System.in);\n Queue<Process> queue = new LinkedList<Process>();\n int n = scan.nextInt();\n int q = scan.nextInt();\n\n Process[] p = new Process[n];\n\n for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }\n\n List<Process> finishProcesses = new ArrayList<Main.Process>();\n\n int currentTime = 0;\n while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }\n\n for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }\n\n scan.close();\n }\n\n}",
"public class Main\n{\n static class Process {\n private String name;\n private int time;\n\n public Process(String name, int time)\n {\n this.name = name;\n this.time = time;\n }\n\n public String getName()\n {\n return this.name;\n }\n public void setName(String name)\n {\n this.name = name;\n }\n public int getTime()\n {\n return this.time;\n }\n public void setTime(int time)\n {\n this.time = time;\n }\n }\n\n public static void main(String[] args)\n {\n Scanner scan = new Scanner(System.in);\n Queue<Process> queue = new LinkedList<Process>();\n int n = scan.nextInt();\n int q = scan.nextInt();\n\n Process[] p = new Process[n];\n\n for (int i = 0; i < n; i++)\n {\n String name = scan.next();\n int time = scan.nextInt();\n p[i] = new Process(name, time);\n queue.offer(p[i]);\n }\n\n List<Process> finishProcesses = new ArrayList<Main.Process>();\n\n int currentTime = 0;\n while (queue.size() > 0) {\n Process current = queue.poll();\n if (current.getTime() > q) {\n current.setTime(current.getTime() - q);\n queue.offer(current);\n currentTime += q;\n }\n else {\n finishProcesses.add(new Process(current.name, currentTime + current.getTime()));\n currentTime += current.getTime();\n }\n }\n\n for (Process process : finishProcesses)\n {\n System.out.println(process.name + \" \" + process.time);\n }\n\n scan.close();\n }\n\n}",
"Main"
] | import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;
public class Main
{
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 this.name;
}
public void setName(String name)
{
this.name = name;
}
public int getTime()
{
return this.time;
}
public void setTime(int time)
{
this.time = time;
}
}
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Queue<Process> queue = new LinkedList<Process>();
int n = scan.nextInt();
int q = scan.nextInt();
Process[] p = new Process[n];
for (int i = 0; i < n; i++)
{
String name = scan.next();
int time = scan.nextInt();
p[i] = new Process(name, time);
queue.offer(p[i]);
}
List<Process> finishProcesses = new ArrayList<Main.Process>();
int currentTime = 0;
while (queue.size() > 0) {
Process current = queue.poll();
if (current.getTime() > q) {
current.setTime(current.getTime() - q);
queue.offer(current);
currentTime += q;
}
else {
finishProcesses.add(new Process(current.name, currentTime + current.getTime()));
currentTime += current.getTime();
}
}
for (Process process : finishProcesses)
{
System.out.println(process.name + " " + process.time);
}
scan.close();
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
4,
18,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
13,
0,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
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
],
[
179,
17
],
[
179,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
24,
31
],
[
31,
32
],
[
32,
33
],
[
32,
34
],
[
31,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
37,
42
],
[
31,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
48,
50
],
[
31,
51
],
[
51,
52
],
[
51,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
56,
57
],
[
56,
58
],
[
31,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
64,
65
],
[
64,
66
],
[
59,
67
],
[
67,
68
],
[
68,
69
],
[
59,
70
],
[
71,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
74,
79
],
[
71,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
71,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
90,
91
],
[
90,
92
],
[
71,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
31,
97
],
[
97,
98
],
[
97,
99
],
[
31,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
101,
105
],
[
100,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
106,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
106,
121
],
[
121,
122
],
[
121,
123
],
[
106,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
106,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
131,
133
],
[
130,
134
],
[
129,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
129,
140
],
[
140,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
147,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
147,
152
],
[
18,
153
],
[
153,
154
],
[
0,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
155,
159
],
[
159,
160
],
[
155,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
163,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
161,
174
],
[
174,
175
],
[
161,
176
],
[
176,
177
],
[
0,
178
],
[
178,
179
],
[
178,
180
]
] | [
"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\tpublic static void main(String[] args) {\n\n\t\t// Queueはインターフェースなので、実装クラスのArrayDequeで実装\n\t\tQueue<Process> queue = new ArrayDeque<>();\n\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n}\n\n// プロセスの情報\nclass Process {\n\tString name;// プロセス名\n\tint time;// 処理時間\n\n\tpublic Process(String name, int time) {\n\t\tthis.time = time;\n\t\tthis.name = name;\n\n\t}\n\n}\n",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\t// Queueはインターフェースなので、実装クラスのArrayDequeで実装\n\t\tQueue<Process> queue = new ArrayDeque<>();\n\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\n\t\t// Queueはインターフェースなので、実装クラスのArrayDequeで実装\n\t\tQueue<Process> queue = new ArrayDeque<>();\n\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}",
"main",
"{\n\n\t\t// Queueはインターフェースなので、実装クラスのArrayDequeで実装\n\t\tQueue<Process> queue = new ArrayDeque<>();\n\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}",
"Queue<Process> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\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[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] str = br.readLine().split(\" \");",
"str",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"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",
"for (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}",
"{\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}",
"String[] tmp = br.readLine().split(\" \");",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"String name = tmp[0];",
"name",
"tmp[0]",
"tmp",
"0",
"int time = Integer.parseInt(tmp[1]);",
"time",
"Integer.parseInt(tmp[1])",
"Integer.parseInt",
"Integer",
"tmp[1]",
"tmp",
"1",
"queue.add(new Process(name, time))",
"queue.add",
"queue",
"new Process(name, time)",
"int total = 0;",
"total",
"0",
"while (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}",
"queue.peek() != null",
"queue.peek()",
"queue.peek",
"queue",
"null",
"{\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}",
"Process curPrcs = queue.remove();",
"curPrcs",
"queue.remove()",
"queue.remove",
"queue",
"int curTime = Math.min(q, curPrcs.time);",
"curTime",
"Math.min(q, curPrcs.time)",
"Math.min",
"Math",
"q",
"curPrcs.time",
"curPrcs",
"curPrcs.time",
"total += curTime",
"total",
"curTime",
"curPrcs.time -= curTime",
"curPrcs.time",
"curPrcs",
"curPrcs.time",
"curTime",
"if (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}",
"curPrcs.time > 0",
"curPrcs.time",
"curPrcs",
"curPrcs.time",
"0",
"{\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t}",
"queue.add(curPrcs)",
"queue.add",
"queue",
"curPrcs",
"{\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}",
"System.out.println(curPrcs.name + \" \" + total)",
"System.out.println",
"System.out",
"System",
"System.out",
"curPrcs.name + \" \" + total",
"curPrcs.name + \" \" + total",
"curPrcs.name",
"curPrcs",
"curPrcs.name",
"\" \"",
"total",
"String[] args",
"args",
"class Process {\n\tString name;// プロセス名\n\tint time;// 処理時間\n\n\tpublic Process(String name, int time) {\n\t\tthis.time = time;\n\t\tthis.name = name;\n\n\t}\n\n}",
"Process",
"String name;// プロセス名",
"name",
"int time;// 処理時間",
"time",
"public Process(String name, int time) {\n\t\tthis.time = time;\n\t\tthis.name = name;\n\n\t}",
"Process",
"{\n\t\tthis.time = time;\n\t\tthis.name = name;\n\n\t}",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"int time",
"time",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\t// Queueはインターフェースなので、実装クラスのArrayDequeで実装\n\t\tQueue<Process> queue = new ArrayDeque<>();\n\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\t// Queueはインターフェースなので、実装クラスのArrayDequeで実装\n\t\tQueue<Process> queue = new ArrayDeque<>();\n\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {\n\t\t\tString[] str = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(str[0]);// プロセス数\n\t\t\tint q = Integer.parseInt(str[1]);// クオンタム\n\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];// プロセス名\n\t\t\t\tint time = Integer.parseInt(tmp[1]);// 処理時間\n\t\t\t\t// キューに追加\n\t\t\t\tqueue.add(new Process(name, time));\n\t\t\t}\n\n\t\t\tint total = 0;// 終了時刻\n\t\t\t// peek()メソッドは要素がなくても例外はスローせずnullを返す\n\t\t\twhile (queue.peek() != null) {\n\t\t\t\t// キューから取り出し\n\t\t\t\tProcess curPrcs = queue.remove();\n\t\t\t\tint curTime = Math.min(q, curPrcs.time);\n\t\t\t\ttotal += curTime;\n\t\t\t\tcurPrcs.time -= curTime;\n\t\t\t\tif (curPrcs.time > 0) {\n\t\t\t\t\t// キューに追加\n\t\t\t\t\tqueue.add(curPrcs);\n\t\t\t\t} else {\n\t\t\t\t\tSystem.out.println(curPrcs.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;
public class Main {
public static void main(String[] args) {
// Queueはインターフェースなので、実装クラスのArrayDequeで実装
Queue<Process> queue = new ArrayDeque<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
String[] str = br.readLine().split(" ");
int n = Integer.parseInt(str[0]);// プロセス数
int q = Integer.parseInt(str[1]);// クオンタム
for (int i = 0; i < n; i++) {
String[] tmp = br.readLine().split(" ");
String name = tmp[0];// プロセス名
int time = Integer.parseInt(tmp[1]);// 処理時間
// キューに追加
queue.add(new Process(name, time));
}
int total = 0;// 終了時刻
// peek()メソッドは要素がなくても例外はスローせずnullを返す
while (queue.peek() != null) {
// キューから取り出し
Process curPrcs = queue.remove();
int curTime = Math.min(q, curPrcs.time);
total += curTime;
curPrcs.time -= curTime;
if (curPrcs.time > 0) {
// キューに追加
queue.add(curPrcs);
} else {
System.out.println(curPrcs.name + " " + total);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
// プロセスの情報
class Process {
String name;// プロセス名
int time;// 処理時間
public Process(String name, int time) {
this.time = time;
this.name = name;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
14,
4,
18,
13,
30,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
30,
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,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
2,
18,
36,
13,
17,
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,
4,
18,
13,
29,
13,
12,
13,
30,
29,
2,
4,
18,
13,
17,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
213,
8
],
[
213,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
11,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
30,
32
],
[
28,
33
],
[
33,
34
],
[
33,
35
],
[
28,
36
],
[
36,
37
],
[
37,
38
],
[
28,
39
],
[
40,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
43,
44
],
[
44,
45
],
[
40,
46
],
[
46,
47
],
[
46,
48
],
[
48,
49
],
[
49,
50
],
[
40,
51
],
[
51,
52
],
[
51,
53
],
[
40,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
11,
58
],
[
58,
59
],
[
59,
60
],
[
11,
61
],
[
61,
62
],
[
61,
63
],
[
11,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
64,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
69,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
81,
82
],
[
77,
83
],
[
69,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
87,
91
],
[
69,
92
],
[
92,
93
],
[
92,
94
],
[
69,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
95,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
106,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
106,
110
],
[
106,
111
],
[
95,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
9,
117
],
[
117,
118
],
[
0,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
119,
123
],
[
123,
124
],
[
119,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
125,
138
],
[
138,
139
],
[
125,
140
],
[
140,
141
],
[
119,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
119,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
119,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
152,
160
],
[
160,
161
],
[
119,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
166,
170
],
[
0,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
171,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
171,
181
],
[
181,
182
],
[
181,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
184,
187
],
[
181,
188
],
[
188,
189
],
[
171,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
192,
198
],
[
198,
199
],
[
199,
200
],
[
192,
201
],
[
201,
202
],
[
171,
203
],
[
203,
204
],
[
203,
205
],
[
205,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
209,
210
],
[
207,
211
],
[
0,
212
],
[
212,
213
],
[
212,
214
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue queue = new Queue();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}\n\t\tsc.close();\n\n\t\tint totalTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process {\n\tprivate String name;\n\tprivate int cpuTime;\n\tpublic Process(String name, int cpuTime) {\n\t\tthis.name = name;\n\t\tthis.cpuTime = cpuTime;\n\t}\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic int getCpuTime() {\n\t\treturn cpuTime;\n\t}\n\tpublic void setCpuTime(int cpuTime) {\n\t\tthis.cpuTime = cpuTime;\n\t}\n\tpublic boolean isFinished() {\n\t\treturn this.cpuTime <= 0;\n\t}\n}\n\nclass Queue {\n\tprivate LinkedList<Process> queue;\n\tpublic Queue() {\n\t\tqueue = new LinkedList<Process>();\n\t}\n\tpublic void enqueue(Process p) {\n\t\tqueue.addLast(p);\n\t}\n\tpublic Process dequeue() {\n\t\tProcess ret = queue.getFirst();\n\t\tqueue.removeFirst();\n\t\treturn ret;\n\t}\n\tpublic boolean isEmpty() {\n\t\treturn queue.size() <= 0;\n\t}\n}",
"import java.util.LinkedList;",
"LinkedList",
"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\t\tQueue queue = new Queue();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}\n\t\tsc.close();\n\n\t\tint totalTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue queue = new Queue();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}\n\t\tsc.close();\n\n\t\tint totalTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue queue = new Queue();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}\n\t\tsc.close();\n\n\t\tint totalTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue 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\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int cpuTime = sc.nextInt();",
"cpuTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Process p = new Process(name, cpuTime);",
"p",
"new Process(name, cpuTime)",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"sc.close()",
"sc.close",
"sc",
"int totalTime = 0;",
"totalTime",
"0",
"while (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}",
"Process p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"int time = Math.min(p.getCpuTime(), q);",
"time",
"Math.min(p.getCpuTime(), q)",
"Math.min",
"Math",
"p.getCpuTime()",
"p.getCpuTime",
"p",
"q",
"p.setCpuTime(p.getCpuTime() - time)",
"p.setCpuTime",
"p",
"p.getCpuTime() - time",
"p.getCpuTime()",
"p.getCpuTime",
"p",
"time",
"totalTime += time",
"totalTime",
"time",
"if (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}",
"p.isFinished()",
"p.isFinished",
"p",
"{\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t}",
"System.out.println(p.getName() + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getName() + \" \" + totalTime",
"p.getName() + \" \" + totalTime",
"p.getName()",
"p.getName",
"p",
"\" \"",
"totalTime",
"{\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"String[] args",
"args",
"class Process {\n\tprivate String name;\n\tprivate int cpuTime;\n\tpublic Process(String name, int cpuTime) {\n\t\tthis.name = name;\n\t\tthis.cpuTime = cpuTime;\n\t}\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic int getCpuTime() {\n\t\treturn cpuTime;\n\t}\n\tpublic void setCpuTime(int cpuTime) {\n\t\tthis.cpuTime = cpuTime;\n\t}\n\tpublic boolean isFinished() {\n\t\treturn this.cpuTime <= 0;\n\t}\n}",
"Process",
"private String name;",
"name",
"private int cpuTime;",
"cpuTime",
"public Process(String name, int cpuTime) {\n\t\tthis.name = name;\n\t\tthis.cpuTime = cpuTime;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.cpuTime = cpuTime;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.cpuTime = cpuTime",
"this.cpuTime",
"this",
"this.cpuTime",
"cpuTime",
"String name",
"name",
"int cpuTime",
"cpuTime",
"public String getName() {\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public int getCpuTime() {\n\t\treturn cpuTime;\n\t}",
"getCpuTime",
"{\n\t\treturn cpuTime;\n\t}",
"return cpuTime;",
"cpuTime",
"public void setCpuTime(int cpuTime) {\n\t\tthis.cpuTime = cpuTime;\n\t}",
"setCpuTime",
"{\n\t\tthis.cpuTime = cpuTime;\n\t}",
"this.cpuTime = cpuTime",
"this.cpuTime",
"this",
"this.cpuTime",
"cpuTime",
"int cpuTime",
"cpuTime",
"public boolean isFinished() {\n\t\treturn this.cpuTime <= 0;\n\t}",
"isFinished",
"{\n\t\treturn this.cpuTime <= 0;\n\t}",
"return this.cpuTime <= 0;",
"this.cpuTime <= 0",
"this.cpuTime",
"this",
"this.cpuTime",
"0",
"class Queue {\n\tprivate LinkedList<Process> queue;\n\tpublic Queue() {\n\t\tqueue = new LinkedList<Process>();\n\t}\n\tpublic void enqueue(Process p) {\n\t\tqueue.addLast(p);\n\t}\n\tpublic Process dequeue() {\n\t\tProcess ret = queue.getFirst();\n\t\tqueue.removeFirst();\n\t\treturn ret;\n\t}\n\tpublic boolean isEmpty() {\n\t\treturn queue.size() <= 0;\n\t}\n}",
"Queue",
"private LinkedList<Process> queue;",
"queue",
"public Queue() {\n\t\tqueue = new LinkedList<Process>();\n\t}",
"Queue",
"{\n\t\tqueue = new LinkedList<Process>();\n\t}",
"queue = new LinkedList<Process>()",
"queue",
"new LinkedList<Process>()",
"public void enqueue(Process p) {\n\t\tqueue.addLast(p);\n\t}",
"enqueue",
"{\n\t\tqueue.addLast(p);\n\t}",
"queue.addLast(p)",
"queue.addLast",
"queue",
"p",
"Process p",
"p",
"public Process dequeue() {\n\t\tProcess ret = queue.getFirst();\n\t\tqueue.removeFirst();\n\t\treturn ret;\n\t}",
"dequeue",
"{\n\t\tProcess ret = queue.getFirst();\n\t\tqueue.removeFirst();\n\t\treturn ret;\n\t}",
"Process ret = queue.getFirst();",
"ret",
"queue.getFirst()",
"queue.getFirst",
"queue",
"queue.removeFirst()",
"queue.removeFirst",
"queue",
"return ret;",
"ret",
"public boolean isEmpty() {\n\t\treturn queue.size() <= 0;\n\t}",
"isEmpty",
"{\n\t\treturn queue.size() <= 0;\n\t}",
"return queue.size() <= 0;",
"queue.size() <= 0",
"queue.size()",
"queue.size",
"queue",
"0",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue queue = new Queue();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}\n\t\tsc.close();\n\n\t\tint totalTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tQueue queue = new Queue();\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint cpuTime = sc.nextInt();\n\t\t\tProcess p = new Process(name, cpuTime);\n\t\t\tqueue.enqueue(p);\n\t\t}\n\t\tsc.close();\n\n\t\tint totalTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tProcess p = queue.dequeue();\n\t\t\tint time = Math.min(p.getCpuTime(), q);\n\t\t\tp.setCpuTime(p.getCpuTime() - time);\n\t\t\ttotalTime += time;\n\t\t\tif (p.isFinished()) {\n\t\t\t\tSystem.out.println(p.getName() + \" \" + totalTime);\n\t\t\t} else {\n\t\t\t\tqueue.enqueue(p);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Queue queue = new Queue();
int n = sc.nextInt();
int q = sc.nextInt();
for (int i = 0; i < n; i++) {
String name = sc.next();
int cpuTime = sc.nextInt();
Process p = new Process(name, cpuTime);
queue.enqueue(p);
}
sc.close();
int totalTime = 0;
while (!queue.isEmpty()) {
Process p = queue.dequeue();
int time = Math.min(p.getCpuTime(), q);
p.setCpuTime(p.getCpuTime() - time);
totalTime += time;
if (p.isFinished()) {
System.out.println(p.getName() + " " + totalTime);
} else {
queue.enqueue(p);
}
}
}
}
class Process {
private String name;
private int cpuTime;
public Process(String name, int cpuTime) {
this.name = name;
this.cpuTime = cpuTime;
}
public String getName() {
return name;
}
public int getCpuTime() {
return cpuTime;
}
public void setCpuTime(int cpuTime) {
this.cpuTime = cpuTime;
}
public boolean isFinished() {
return this.cpuTime <= 0;
}
}
class Queue {
private LinkedList<Process> queue;
public Queue() {
queue = new LinkedList<Process>();
}
public void enqueue(Process p) {
queue.addLast(p);
}
public Process dequeue() {
Process ret = queue.getFirst();
queue.removeFirst();
return ret;
}
public boolean isEmpty() {
return queue.size() <= 0;
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
0,
13,
2,
4,
18,
13,
17,
0,
13,
4,
18,
13,
0,
13,
20,
17,
0,
13,
20,
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,
4,
18,
13,
4,
13,
12,
13,
30,
42,
2,
13,
13,
30,
41,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
2,
13,
17,
17,
13,
30,
0,
13,
13,
4,
13,
2,
13,
13,
12,
13,
30,
29,
18,
13,
40,
13,
12,
13,
30,
0,
18,
13,
40,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
13,
23,
13,
6,
13,
12,
13,
30,
41,
13,
20,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
4,
9
],
[
9,
10
],
[
9,
11
],
[
4,
12
],
[
12,
13
],
[
4,
14
],
[
14,
15
],
[
4,
16
],
[
16,
17
],
[
4,
18
],
[
18,
19
],
[
4,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
22,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
28,
32
],
[
22,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
22,
38
],
[
38,
39
],
[
38,
40
],
[
22,
42
],
[
42,
43
],
[
42,
44
],
[
22,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
46,
51
],
[
51,
52
],
[
51,
53
],
[
46,
54
],
[
54,
55
],
[
55,
56
],
[
46,
57
],
[
58,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
63,
64
],
[
64,
65
],
[
58,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
66,
70
],
[
70,
71
],
[
71,
72
],
[
22,
73
],
[
73,
74
],
[
74,
75
],
[
22,
76
],
[
76,
77
],
[
4,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
85,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
104,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
107,
109
],
[
104,
110
],
[
104,
111
],
[
90,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
4,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
4,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
135,
136
],
[
132,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
131,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
142,
146
],
[
129,
147
],
[
147,
148
],
[
0,
149
],
[
163,
150
],
[
163,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
157,
158
],
[
158,
159
],
[
151,
160
],
[
160,
161
],
[
0,
162
],
[
162,
163
],
[
162,
164
]
] | [
"import java.util.*;\n\nclass Queue {\n static int top = 0;\n static int time = 0;\n static int n, q;\n static String[] label;\n static int[] value;\n public static void main() {\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt()-1;\n q = sc.nextInt();\n label = new String[1000000];\n value = new int[1000000];\n for (int i = 0; i <= n; i++) {\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }\n sc.close();\n process(); \n }\n\n static void process() {\n while (top <= n) {\n int topItem = pop();\n if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }\n }\n }\n \n static int pop() {\n return value[top++];\n }\n\n static void push(int x) {\n label[++n] = label[top-1];\n value[n] = x;\n }\n}\n\npublic class Main {\n public static void main(String[] args) {\n Queue que = new Queue();\n que.main();\n }\n}",
"import java.util.*;",
"util.*",
"java",
"class Queue {\n static int top = 0;\n static int time = 0;\n static int n, q;\n static String[] label;\n static int[] value;\n public static void main() {\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt()-1;\n q = sc.nextInt();\n label = new String[1000000];\n value = new int[1000000];\n for (int i = 0; i <= n; i++) {\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }\n sc.close();\n process(); \n }\n\n static void process() {\n while (top <= n) {\n int topItem = pop();\n if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }\n }\n }\n \n static int pop() {\n return value[top++];\n }\n\n static void push(int x) {\n label[++n] = label[top-1];\n value[n] = x;\n }\n}",
"Queue",
"static int top = 0;",
"top",
"0",
"static int time = 0;",
"time",
"0",
"static int n",
"n",
"q;",
"q",
"static String[] label;",
"label",
"static int[] value;",
"value",
"public static void main() {\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt()-1;\n q = sc.nextInt();\n label = new String[1000000];\n value = new int[1000000];\n for (int i = 0; i <= n; i++) {\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }\n sc.close();\n process(); \n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n n = sc.nextInt()-1;\n q = sc.nextInt();\n label = new String[1000000];\n value = new int[1000000];\n for (int i = 0; i <= n; i++) {\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }\n sc.close();\n process(); \n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"n = sc.nextInt()-1",
"n",
"sc.nextInt()-1",
"sc.nextInt()",
"sc.nextInt",
"sc",
"1",
"q = sc.nextInt()",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"label = new String[1000000]",
"label",
"new String[1000000]",
"1000000",
"value = new int[1000000]",
"value",
"new int[1000000]",
"1000000",
"for (int i = 0; i <= n; i++) {\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i <= n",
"i",
"n",
"i++",
"i++",
"i",
"{\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }",
"{\n label[i] = sc.next();\n value[i] = sc.nextInt();\n }",
"label[i] = sc.next()",
"label[i]",
"label",
"i",
"sc.next()",
"sc.next",
"sc",
"value[i] = sc.nextInt()",
"value[i]",
"value",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.close()",
"sc.close",
"sc",
"process()",
"process",
"static void process() {\n while (top <= n) {\n int topItem = pop();\n if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }\n }\n }",
"process",
"{\n while (top <= n) {\n int topItem = pop();\n if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }\n }\n }",
"while (top <= n) {\n int topItem = pop();\n if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }\n }",
"top <= n",
"top",
"n",
"{\n int topItem = pop();\n if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }\n }",
"int topItem = pop();",
"topItem",
"pop()",
"pop",
"if (topItem <= q) {\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n } else {\n time += q;\n push(topItem - q);\n }",
"topItem <= q",
"topItem",
"q",
"{\n time += topItem;\n System.out.println(label[top-1] + \" \" + time);\n }",
"time += topItem",
"time",
"topItem",
"System.out.println(label[top-1] + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"label[top-1] + \" \" + time",
"label[top-1] + \" \" + time",
"label[top-1]",
"label",
"top-1",
"top",
"1",
"\" \"",
"time",
"{\n time += q;\n push(topItem - q);\n }",
"time += q",
"time",
"q",
"push(topItem - q)",
"push",
"topItem - q",
"topItem",
"q",
"static int pop() {\n return value[top++];\n }",
"pop",
"{\n return value[top++];\n }",
"return value[top++];",
"value[top++]",
"value",
"top++",
"top",
"static void push(int x) {\n label[++n] = label[top-1];\n value[n] = x;\n }",
"push",
"{\n label[++n] = label[top-1];\n value[n] = x;\n }",
"label[++n] = label[top-1]",
"label[++n]",
"label",
"++n",
"n",
"label[top-1]",
"label",
"top-1",
"top",
"1",
"value[n] = x",
"value[n]",
"value",
"n",
"x",
"int x",
"x",
"public class Main {\n public static void main(String[] args) {\n Queue que = new Queue();\n que.main();\n }\n}",
"Main",
"public static void main(String[] args) {\n Queue que = new Queue();\n que.main();\n }",
"main",
"{\n Queue que = new Queue();\n que.main();\n }",
"Queue que = new Queue();",
"que",
"new Queue()",
"que.main()",
"que.main",
"que",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Queue que = new Queue();\n que.main();\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Queue que = new Queue();\n que.main();\n }\n}",
"Main"
] | import java.util.*;
class Queue {
static int top = 0;
static int time = 0;
static int n, q;
static String[] label;
static int[] value;
public static void main() {
Scanner sc = new Scanner(System.in);
n = sc.nextInt()-1;
q = sc.nextInt();
label = new String[1000000];
value = new int[1000000];
for (int i = 0; i <= n; i++) {
label[i] = sc.next();
value[i] = sc.nextInt();
}
sc.close();
process();
}
static void process() {
while (top <= n) {
int topItem = pop();
if (topItem <= q) {
time += topItem;
System.out.println(label[top-1] + " " + time);
} else {
time += q;
push(topItem - q);
}
}
}
static int pop() {
return value[top++];
}
static void push(int x) {
label[++n] = label[top-1];
value[n] = x;
}
}
public class Main {
public static void main(String[] args) {
Queue que = new Queue();
que.main();
}
}
|
[
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,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
41,
13,
17,
42,
2,
18,
13,
13,
18,
13,
13,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
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,
17,
12,
13,
30,
0,
18,
36,
13,
0,
18,
36,
13,
17,
0,
18,
36,
13,
20,
18,
36,
13,
12,
13,
30,
29,
2,
18,
36,
13,
2,
2,
18,
36,
13,
17,
18,
36,
13,
12,
13,
30,
29,
2,
18,
36,
13,
18,
36,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
0,
18,
18,
36,
13,
18,
36,
13,
13,
14,
2,
2,
18,
36,
13,
17,
18,
36,
13,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
23,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
41,
13,
18,
18,
36,
13,
18,
36,
13,
14,
2,
2,
18,
36,
13,
17,
18,
36,
13,
30,
0,
18,
36,
13,
17,
30,
40,
18,
36,
13,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
284,
5
],
[
284,
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,
29
],
[
29,
30
],
[
30,
31
],
[
8,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
32,
37
],
[
37,
38
],
[
37,
39
],
[
32,
40
],
[
40,
41
],
[
41,
42
],
[
32,
43
],
[
44,
44
],
[
44,
45
],
[
45,
46
],
[
46,
47
],
[
46,
48
],
[
45,
49
],
[
49,
50
],
[
50,
51
],
[
44,
52
],
[
52,
53
],
[
53,
54
],
[
52,
55
],
[
8,
56
],
[
56,
57
],
[
56,
58
],
[
8,
59
],
[
59,
60
],
[
59,
61
],
[
8,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
67,
68
],
[
67,
69
],
[
62,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
70,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
78,
82
],
[
82,
83
],
[
82,
84
],
[
70,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
70,
90
],
[
90,
91
],
[
90,
92
],
[
70,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
94,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
93,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
111,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
111,
115
],
[
111,
116
],
[
6,
117
],
[
117,
118
],
[
0,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
119,
123
],
[
123,
124
],
[
119,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
125,
138
],
[
138,
139
],
[
125,
140
],
[
140,
141
],
[
0,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
142,
146
],
[
146,
147
],
[
142,
148
],
[
148,
149
],
[
142,
150
],
[
150,
151
],
[
150,
152
],
[
142,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
155,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
170,
171
],
[
170,
172
],
[
142,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
177,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
181,
187
],
[
187,
188
],
[
187,
189
],
[
142,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
194,
198
],
[
198,
199
],
[
198,
200
],
[
142,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
204,
207
],
[
207,
208
],
[
208,
209
],
[
203,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
212,
214
],
[
211,
215
],
[
215,
216
],
[
215,
217
],
[
210,
218
],
[
203,
219
],
[
219,
220
],
[
220,
221
],
[
221,
222
],
[
222,
223
],
[
222,
224
],
[
221,
225
],
[
220,
226
],
[
226,
227
],
[
226,
228
],
[
219,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
230,
234
],
[
219,
235
],
[
235,
236
],
[
236,
237
],
[
237,
238
],
[
237,
239
],
[
201,
240
],
[
240,
241
],
[
142,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
246,
247
],
[
245,
248
],
[
248,
249
],
[
249,
250
],
[
244,
251
],
[
251,
252
],
[
251,
253
],
[
253,
254
],
[
254,
255
],
[
254,
256
],
[
253,
257
],
[
257,
258
],
[
257,
259
],
[
244,
260
],
[
260,
261
],
[
261,
262
],
[
262,
263
],
[
263,
264
],
[
263,
265
],
[
262,
266
],
[
261,
267
],
[
267,
268
],
[
267,
269
],
[
260,
270
],
[
270,
271
],
[
271,
272
],
[
272,
273
],
[
272,
274
],
[
271,
275
],
[
260,
276
],
[
276,
277
],
[
277,
278
],
[
278,
279
],
[
278,
280
],
[
244,
281
],
[
281,
282
],
[
0,
283
],
[
283,
284
],
[
283,
285
]
] | [
"import java.util.*;\n\npublic class Main {\n public static void main(String[] args) throws Exception {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int q = in.nextInt();\n String[] line = new String[n];\n Queue tasks = new Queue();\n in.nextLine();\n for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }\n int costTime = 0;\n int totalTime = 0;\n while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }\n }\n}\n\nclass Task {\n public String name;\n public int time;\n\n public Task(String name, int time) {\n this.name = name;\n this.time = time;\n }\n}\n\nclass Queue {\n public int head;\n public int tail;\n private Task[] queue;\n private int len = 1000001;\n\n public Queue() {\n this.head = this.tail = 0;\n this.queue = new Task[this.len];\n }\n\n public boolean isFull() {\n return (this.head == (this.tail + 1) % (this.len));\n }\n\n public boolean isEmpty() {\n return (this.head == this.tail);\n }\n\n public void enqueue(Task task) throws Exception {\n if (isFull()) {\n throw (new Exception(\"上溢出\"));\n }\n this.queue[this.tail] = task;\n if (this.tail + 1 == this.len) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Task dequeue() throws Exception {\n if (isEmpty()) {\n throw (new Exception(\"下溢出\"));\n }\n Task task = this.queue[this.head];\n if (this.head + 1 == this.len) {\n this.head = 0;\n } else {\n this.head++;\n }\n return task;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int q = in.nextInt();\n String[] line = new String[n];\n Queue tasks = new Queue();\n in.nextLine();\n for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }\n int costTime = 0;\n int totalTime = 0;\n while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int q = in.nextInt();\n String[] line = new String[n];\n Queue tasks = new Queue();\n in.nextLine();\n for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }\n int costTime = 0;\n int totalTime = 0;\n while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }\n }",
"main",
"{\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int q = in.nextInt();\n String[] line = new String[n];\n Queue tasks = new Queue();\n in.nextLine();\n for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }\n int costTime = 0;\n int totalTime = 0;\n while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int q = in.nextInt();",
"q",
"in.nextInt()",
"in.nextInt",
"in",
"String[] line = new String[n];",
"line",
"new String[n]",
"n",
"Queue tasks = new Queue();",
"tasks",
"new Queue()",
"in.nextLine()",
"in.nextLine",
"in",
"for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }",
"{\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }",
"line[i] = in.nextLine()",
"line[i]",
"line",
"i",
"in.nextLine()",
"in.nextLine",
"in",
"tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])))",
"tasks.enqueue",
"tasks",
"new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1]))",
"int costTime = 0;",
"costTime",
"0",
"int totalTime = 0;",
"totalTime",
"0",
"while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }",
"tasks.head != tasks.tail",
"tasks.head",
"tasks",
"tasks.head",
"tasks.tail",
"tasks",
"tasks.tail",
"{\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }",
"Task current = tasks.dequeue();",
"current",
"tasks.dequeue()",
"tasks.dequeue",
"tasks",
"costTime = Math.min(q, current.time)",
"costTime",
"Math.min(q, current.time)",
"Math.min",
"Math",
"q",
"current.time",
"current",
"current.time",
"current.time -= costTime",
"current.time",
"current",
"current.time",
"costTime",
"totalTime += costTime",
"totalTime",
"costTime",
"if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }",
"current.time > 0",
"current.time",
"current",
"current.time",
"0",
"{\n tasks.enqueue(current);\n }",
"tasks.enqueue(current)",
"tasks.enqueue",
"tasks",
"current",
"{\n System.out.println(current.name + \" \" + totalTime);\n }",
"System.out.println(current.name + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"current.name + \" \" + totalTime",
"current.name + \" \" + totalTime",
"current.name",
"current",
"current.name",
"\" \"",
"totalTime",
"String[] args",
"args",
"class Task {\n public String name;\n public int time;\n\n public Task(String name, int time) {\n this.name = name;\n this.time = time;\n }\n}",
"Task",
"public String name;",
"name",
"public int time;",
"time",
"public Task(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Task",
"{\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",
"class Queue {\n public int head;\n public int tail;\n private Task[] queue;\n private int len = 1000001;\n\n public Queue() {\n this.head = this.tail = 0;\n this.queue = new Task[this.len];\n }\n\n public boolean isFull() {\n return (this.head == (this.tail + 1) % (this.len));\n }\n\n public boolean isEmpty() {\n return (this.head == this.tail);\n }\n\n public void enqueue(Task task) throws Exception {\n if (isFull()) {\n throw (new Exception(\"上溢出\"));\n }\n this.queue[this.tail] = task;\n if (this.tail + 1 == this.len) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }\n\n public Task dequeue() throws Exception {\n if (isEmpty()) {\n throw (new Exception(\"下溢出\"));\n }\n Task task = this.queue[this.head];\n if (this.head + 1 == this.len) {\n this.head = 0;\n } else {\n this.head++;\n }\n return task;\n }\n}",
"Queue",
"public int head;",
"head",
"public int tail;",
"tail",
"private Task[] queue;",
"queue",
"private int len = 1000001;",
"len",
"1000001",
"public Queue() {\n this.head = this.tail = 0;\n this.queue = new Task[this.len];\n }",
"Queue",
"{\n this.head = this.tail = 0;\n this.queue = new Task[this.len];\n }",
"this.head = this.tail = 0",
"this.head",
"this",
"this.head",
"this.tail = 0",
"this.tail",
"this",
"this.tail",
"0",
"this.queue = new Task[this.len]",
"this.queue",
"this",
"this.queue",
"new Task[this.len]",
"this.len",
"this",
"this.len",
"public boolean isFull() {\n return (this.head == (this.tail + 1) % (this.len));\n }",
"isFull",
"{\n return (this.head == (this.tail + 1) % (this.len));\n }",
"return (this.head == (this.tail + 1) % (this.len));",
"(this.head == (this.tail + 1) % (this.len))",
"this.head",
"this",
"this.head",
"(this.tail + 1) % (this.len)",
"(this.tail + 1)",
"this.tail",
"this",
"this.tail",
"1",
"(this.len)",
"this",
"this.len",
"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 void enqueue(Task task) throws Exception {\n if (isFull()) {\n throw (new Exception(\"上溢出\"));\n }\n this.queue[this.tail] = task;\n if (this.tail + 1 == this.len) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }",
"enqueue",
"{\n if (isFull()) {\n throw (new Exception(\"上溢出\"));\n }\n this.queue[this.tail] = task;\n if (this.tail + 1 == this.len) {\n this.tail = 0;\n } else {\n this.tail++;\n }\n }",
"if (isFull()) {\n throw (new Exception(\"上溢出\"));\n }",
"isFull()",
"isFull",
"{\n throw (new Exception(\"上溢出\"));\n }",
"throw (new Exception(\"上溢出\"));",
"(new Exception(\"上溢出\"))",
"this.queue[this.tail] = task",
"this.queue[this.tail]",
"this.queue",
"this",
"this.queue",
"this.tail",
"this",
"this.tail",
"task",
"if (this.tail + 1 == this.len) {\n this.tail = 0;\n } else {\n this.tail++;\n }",
"this.tail + 1 == this.len",
"this.tail + 1",
"this.tail",
"this",
"this.tail",
"1",
"this.len",
"this",
"this.len",
"{\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",
"Task task",
"task",
"public Task dequeue() throws Exception {\n if (isEmpty()) {\n throw (new Exception(\"下溢出\"));\n }\n Task task = this.queue[this.head];\n if (this.head + 1 == this.len) {\n this.head = 0;\n } else {\n this.head++;\n }\n return task;\n }",
"dequeue",
"{\n if (isEmpty()) {\n throw (new Exception(\"下溢出\"));\n }\n Task task = this.queue[this.head];\n if (this.head + 1 == this.len) {\n this.head = 0;\n } else {\n this.head++;\n }\n return task;\n }",
"if (isEmpty()) {\n throw (new Exception(\"下溢出\"));\n }",
"isEmpty()",
"isEmpty",
"{\n throw (new Exception(\"下溢出\"));\n }",
"throw (new Exception(\"下溢出\"));",
"(new Exception(\"下溢出\"))",
"Task task = this.queue[this.head];",
"task",
"this.queue[this.head]",
"this.queue",
"this",
"this.queue",
"this.head",
"this",
"this.head",
"if (this.head + 1 == this.len) {\n this.head = 0;\n } else {\n this.head++;\n }",
"this.head + 1 == this.len",
"this.head + 1",
"this.head",
"this",
"this.head",
"1",
"this.len",
"this",
"this.len",
"{\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 task;",
"task",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int q = in.nextInt();\n String[] line = new String[n];\n Queue tasks = new Queue();\n in.nextLine();\n for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }\n int costTime = 0;\n int totalTime = 0;\n while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] args) throws Exception {\n Scanner in = new Scanner(System.in);\n int n = in.nextInt();\n int q = in.nextInt();\n String[] line = new String[n];\n Queue tasks = new Queue();\n in.nextLine();\n for (int i = 0; i < n; i++) {\n line[i] = in.nextLine();\n tasks.enqueue(new Task(line[i].split(\" \")[0], Integer.parseInt(line[i].split(\" \")[1])));\n }\n int costTime = 0;\n int totalTime = 0;\n while (tasks.head != tasks.tail) {\n Task current = tasks.dequeue();\n costTime = Math.min(q, current.time);\n current.time -= costTime; // 计算剩余的所需时间\n totalTime += costTime; // 累计已经过的时间\n if(current.time > 0) {\n tasks.enqueue(current);\n }\n else {\n System.out.println(current.name + \" \" + totalTime);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int q = in.nextInt();
String[] line = new String[n];
Queue tasks = new Queue();
in.nextLine();
for (int i = 0; i < n; i++) {
line[i] = in.nextLine();
tasks.enqueue(new Task(line[i].split(" ")[0], Integer.parseInt(line[i].split(" ")[1])));
}
int costTime = 0;
int totalTime = 0;
while (tasks.head != tasks.tail) {
Task current = tasks.dequeue();
costTime = Math.min(q, current.time);
current.time -= costTime; // 计算剩余的所需时间
totalTime += costTime; // 累计已经过的时间
if(current.time > 0) {
tasks.enqueue(current);
}
else {
System.out.println(current.name + " " + totalTime);
}
}
}
}
class Task {
public String name;
public int time;
public Task(String name, int time) {
this.name = name;
this.time = time;
}
}
class Queue {
public int head;
public int tail;
private Task[] queue;
private int len = 1000001;
public Queue() {
this.head = this.tail = 0;
this.queue = new Task[this.len];
}
public boolean isFull() {
return (this.head == (this.tail + 1) % (this.len));
}
public boolean isEmpty() {
return (this.head == this.tail);
}
public void enqueue(Task task) throws Exception {
if (isFull()) {
throw (new Exception("上溢出"));
}
this.queue[this.tail] = task;
if (this.tail + 1 == this.len) {
this.tail = 0;
} else {
this.tail++;
}
}
public Task dequeue() throws Exception {
if (isEmpty()) {
throw (new Exception("下溢出"));
}
Task task = this.queue[this.head];
if (this.head + 1 == this.len) {
this.head = 0;
} else {
this.head++;
}
return task;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
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,
2,
13,
13,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
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
],
[
118,
8
],
[
118,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
11,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
11,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
47,
48
],
[
48,
49
],
[
43,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
53,
54
],
[
54,
55
],
[
11,
56
],
[
56,
57
],
[
56,
58
],
[
11,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
60,
64
],
[
59,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
65,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
65,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
80,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
80,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
80,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
76,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
102,
104
],
[
99,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
111,
111
],
[
111,
112
],
[
111,
113
],
[
111,
114
],
[
9,
115
],
[
115,
116
],
[
0,
117
],
[
117,
118
],
[
117,
119
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\n\n\n\npublic class Main{\n\tpublic static void main(String[] args)\n\t{\n\t\tScanner in = new Scanner(System.in);\n\t\tLinkedList<String> qName = new LinkedList<>();\n\t\tLinkedList<Integer> qTime = new LinkedList<>();\n\t\t\n\t\tint amount = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tfor(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\n\t\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\tpublic static void main(String[] args)\n\t{\n\t\tScanner in = new Scanner(System.in);\n\t\tLinkedList<String> qName = new LinkedList<>();\n\t\tLinkedList<Integer> qTime = new LinkedList<>();\n\t\t\n\t\tint amount = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tfor(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\n\t\n}",
"Main",
"public static void main(String[] args)\n\t{\n\t\tScanner in = new Scanner(System.in);\n\t\tLinkedList<String> qName = new LinkedList<>();\n\t\tLinkedList<Integer> qTime = new LinkedList<>();\n\t\t\n\t\tint amount = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tfor(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tLinkedList<String> qName = new LinkedList<>();\n\t\tLinkedList<Integer> qTime = new LinkedList<>();\n\t\t\n\t\tint amount = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tfor(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"LinkedList<String> qName = new LinkedList<>();",
"qName",
"new LinkedList<>()",
"LinkedList<Integer> qTime = new LinkedList<>();",
"qTime",
"new LinkedList<>()",
"int amount = in.nextInt();",
"amount",
"in.nextInt()",
"in.nextInt",
"in",
"int quantum = in.nextInt();",
"quantum",
"in.nextInt()",
"in.nextInt",
"in",
"for(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}",
"int i= 0;",
"int i= 0;",
"i",
"0",
"i < amount",
"i",
"amount",
"i++",
"i++",
"i",
"{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}",
"{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}",
"qName.addLast(in.next())",
"qName.addLast",
"qName",
"in.next()",
"in.next",
"in",
"qTime.addLast(in.nextInt())",
"qTime.addLast",
"qTime",
"in.nextInt()",
"in.nextInt",
"in",
"int time = 0;",
"time",
"0",
"while(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}",
"qName.size() != 0",
"qName.size()",
"qName.size",
"qName",
"0",
"{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}",
"String cName = qName.removeFirst();",
"cName",
"qName.removeFirst()",
"qName.removeFirst",
"qName",
"int cTime = qTime.removeFirst();",
"cTime",
"qTime.removeFirst()",
"qTime.removeFirst",
"qTime",
"if(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}",
"cTime > quantum",
"cTime",
"quantum",
"{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}",
"time = time + quantum",
"time",
"time + quantum",
"time",
"quantum",
"cTime = cTime - quantum",
"cTime",
"cTime - quantum",
"cTime",
"quantum",
"qName.addLast(cName)",
"qName.addLast",
"qName",
"cName",
"qTime.addLast(cTime)",
"qTime.addLast",
"qTime",
"cTime",
"{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}",
"time = time + cTime",
"time",
"time + cTime",
"time",
"cTime",
"System.out.println(cName + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"cName + \" \" + time",
"cName + \" \" + time",
"cName",
"\" \"",
"time",
"String[] args",
"args",
"public class Main{\n\tpublic static void main(String[] args)\n\t{\n\t\tScanner in = new Scanner(System.in);\n\t\tLinkedList<String> qName = new LinkedList<>();\n\t\tLinkedList<Integer> qTime = new LinkedList<>();\n\t\t\n\t\tint amount = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tfor(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\n\t\n}",
"public class Main{\n\tpublic static void main(String[] args)\n\t{\n\t\tScanner in = new Scanner(System.in);\n\t\tLinkedList<String> qName = new LinkedList<>();\n\t\tLinkedList<Integer> qTime = new LinkedList<>();\n\t\t\n\t\tint amount = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\tfor(int i= 0; i < amount; i++) \n\t\t{\n\t\t\tqName.addLast(in.next());\n\t\t\tqTime.addLast(in.nextInt());\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(qName.size() != 0)\n\t\t{\n\t\t\tString cName = qName.removeFirst();\n\t\t\tint cTime = qTime.removeFirst();\n\t\t\tif(cTime > quantum)\n\t\t\t{\n\t\t\t\ttime = time + quantum;\n\t\t\t\tcTime = cTime - quantum;\n\t\t\t\t\n\t\t\t\tqName.addLast(cName);\n\t\t\t\tqTime.addLast(cTime);\n\t\t\t}else\n\t\t\t{\n\t\t\t\ttime = time + cTime;\n\t\t\t\tSystem.out.println(cName + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n\n\t\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
public class Main{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
LinkedList<String> qName = new LinkedList<>();
LinkedList<Integer> qTime = new LinkedList<>();
int amount = in.nextInt();
int quantum = in.nextInt();
for(int i= 0; i < amount; i++)
{
qName.addLast(in.next());
qTime.addLast(in.nextInt());
}
int time = 0;
while(qName.size() != 0)
{
String cName = qName.removeFirst();
int cTime = qTime.removeFirst();
if(cTime > quantum)
{
time = time + quantum;
cTime = cTime - quantum;
qName.addLast(cName);
qTime.addLast(cTime);
}else
{
time = time + cTime;
System.out.println(cName + " " + time);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
40,
17,
41,
13,
20,
17,
12,
13,
30,
41,
13,
20,
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,
0,
18,
13,
13,
20,
4,
18,
13,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
4,
18,
18,
13,
13,
30,
0,
13,
13,
41,
13,
20,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
17,
41,
13,
20,
13,
12,
13,
30,
0,
13,
17,
12,
13,
30,
29,
2,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
14,
4,
13,
29,
40,
13,
0,
18,
13,
13,
13,
23,
13,
12,
13,
30,
14,
4,
13,
29,
40,
17,
40,
13,
29,
18,
13,
2,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
213,
11
],
[
213,
12
],
[
12,
13
],
[
12,
14
],
[
213,
15
],
[
15,
16
],
[
15,
17
],
[
213,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
213,
22
],
[
22,
23
],
[
22,
24
],
[
213,
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,
46
],
[
46,
47
],
[
46,
48
],
[
28,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
51,
53
],
[
49,
54
],
[
54,
55
],
[
54,
56
],
[
49,
57
],
[
57,
58
],
[
58,
59
],
[
49,
60
],
[
61,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
70,
71
],
[
70,
72
],
[
28,
73
],
[
73,
74
],
[
73,
75
],
[
28,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
76,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
93,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
99,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
105,
110
],
[
93,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
87,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
120,
121
],
[
120,
122
],
[
116,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
26,
127
],
[
127,
128
],
[
0,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
129,
133
],
[
133,
134
],
[
133,
135
],
[
129,
136
],
[
136,
137
],
[
136,
138
],
[
129,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
129,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
129,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
129,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
162,
167
],
[
167,
168
],
[
162,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
160,
174
],
[
174,
175
],
[
129,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
179,
182
],
[
182,
183
],
[
183,
184
],
[
178,
185
],
[
185,
186
],
[
178,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
190,
191
],
[
190,
192
],
[
0,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
193,
197
],
[
197,
198
],
[
193,
199
],
[
199,
200
],
[
199,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
201,
205
],
[
205,
206
],
[
205,
207
],
[
199,
208
],
[
208,
209
],
[
199,
210
],
[
210,
211
],
[
0,
212
],
[
212,
213
],
[
212,
214
]
] | [
"\nimport javax.xml.crypto.Data;\nimport java.util.*;\nimport java.io.*;\n\npublic class Main {\n public static int SENTINEL = 100000007;\n public static int MAX = 10007;\n public static int NIL = -1;\n\n public static int[] dp = new int[100];\n\n\n public static void main(String[] args) throws IOException {\n\n //??\\???\n /*\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] str = br.readLine().split(\" \");\n */\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n P[] PP = new P[n];\n Queue<P> Q = new ArrayDeque<P>();\n\n for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }\n\n int T = 0;\n while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }\n }\n\n}\n\nclass Stack {\n int top;\n int MAX = 100007;\n int[] S = new int[MAX];\n\n Stack() {\n top = 0;\n }\n boolean isEmpty() {\n return top == 0;\n }\n boolean isFull() {\n return top > MAX;\n }\n void push(int x) {\n if(isFull()) return;\n top++;\n S[top] = x;\n }\n int pop() {\n if(isEmpty()) return -1;\n top--;\n return S[top + 1];\n }\n}\n\n\nclass P {\n String name;\n int time;\n P(String n, int t) {\n name = n;\n time = t;\n }\n}",
"import javax.xml.crypto.Data;",
"Data",
"javax.xml.crypto",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"public class Main {\n public static int SENTINEL = 100000007;\n public static int MAX = 10007;\n public static int NIL = -1;\n\n public static int[] dp = new int[100];\n\n\n public static void main(String[] args) throws IOException {\n\n //??\\???\n /*\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] str = br.readLine().split(\" \");\n */\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n P[] PP = new P[n];\n Queue<P> Q = new ArrayDeque<P>();\n\n for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }\n\n int T = 0;\n while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }\n }\n\n}",
"Main",
"public static int SENTINEL = 100000007;",
"SENTINEL",
"100000007",
"public static int MAX = 10007;",
"MAX",
"10007",
"public static int NIL = -1;",
"NIL",
"-1",
"1",
"public static int[] dp = new int[100];",
"dp",
"new int[100]",
"100",
"public static void main(String[] args) throws IOException {\n\n //??\\???\n /*\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] str = br.readLine().split(\" \");\n */\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n P[] PP = new P[n];\n Queue<P> Q = new ArrayDeque<P>();\n\n for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }\n\n int T = 0;\n while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }\n }",
"main",
"{\n\n //??\\???\n /*\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] str = br.readLine().split(\" \");\n */\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n P[] PP = new P[n];\n Queue<P> Q = new ArrayDeque<P>();\n\n for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }\n\n int T = 0;\n while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\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",
"P[] PP = new P[n];",
"PP",
"new P[n]",
"n",
"Queue<P> Q = new ArrayDeque<P>();",
"Q",
"new ArrayDeque<P>()",
"for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }",
"{\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }",
"PP[i] = new P(sc.next(), sc.nextInt())",
"PP[i]",
"PP",
"i",
"new P(sc.next(), sc.nextInt())",
"Q.offer(PP[i])",
"Q.offer",
"Q",
"PP[i]",
"PP",
"i",
"int T = 0;",
"T",
"0",
"while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }",
"!Q.isEmpty()",
"Q.isEmpty()",
"Q.isEmpty",
"Q",
"{\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }",
"P Process = Q.poll();",
"Process",
"Q.poll()",
"Q.poll",
"Q",
"if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }",
"Process.time <= q",
"Process.time",
"Process",
"Process.time",
"q",
"{\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }",
"T += Process.time",
"T",
"Process.time",
"Process",
"Process.time",
"System.out.print(Process.name + \" \" + T)",
"System.out.print",
"System.out",
"System",
"System.out",
"Process.name + \" \" + T",
"Process.name + \" \" + T",
"Process.name",
"Process",
"Process.name",
"\" \"",
"T",
"System.out.println()",
"System.out.println",
"System.out",
"System",
"System.out",
"{\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }",
"T += q",
"T",
"q",
"P newProcess = new P(Process.name, Process.time - q);",
"newProcess",
"new P(Process.name, Process.time - q)",
"Q.offer(newProcess)",
"Q.offer",
"Q",
"newProcess",
"String[] args",
"args",
"class Stack {\n int top;\n int MAX = 100007;\n int[] S = new int[MAX];\n\n Stack() {\n top = 0;\n }\n boolean isEmpty() {\n return top == 0;\n }\n boolean isFull() {\n return top > MAX;\n }\n void push(int x) {\n if(isFull()) return;\n top++;\n S[top] = x;\n }\n int pop() {\n if(isEmpty()) return -1;\n top--;\n return S[top + 1];\n }\n}",
"Stack",
"int top;",
"top",
"int MAX = 100007;",
"MAX",
"100007",
"int[] S = new int[MAX];",
"S",
"new int[MAX]",
"MAX",
"Stack() {\n top = 0;\n }",
"Stack",
"{\n top = 0;\n }",
"top = 0",
"top",
"0",
"boolean isEmpty() {\n return top == 0;\n }",
"isEmpty",
"{\n return top == 0;\n }",
"return top == 0;",
"top == 0",
"top",
"0",
"boolean isFull() {\n return top > MAX;\n }",
"isFull",
"{\n return top > MAX;\n }",
"return top > MAX;",
"top > MAX",
"top",
"MAX",
"void push(int x) {\n if(isFull()) return;\n top++;\n S[top] = x;\n }",
"push",
"{\n if(isFull()) return;\n top++;\n S[top] = x;\n }",
"if(isFull()) return;",
"isFull()",
"isFull",
"return;",
"top++",
"top",
"S[top] = x",
"S[top]",
"S",
"top",
"x",
"int x",
"x",
"int pop() {\n if(isEmpty()) return -1;\n top--;\n return S[top + 1];\n }",
"pop",
"{\n if(isEmpty()) return -1;\n top--;\n return S[top + 1];\n }",
"if(isEmpty()) return -1;",
"isEmpty()",
"isEmpty",
"return -1;",
"-1",
"1",
"top--",
"top",
"return S[top + 1];",
"S[top + 1]",
"S",
"top + 1",
"top",
"1",
"class P {\n String name;\n int time;\n P(String n, int t) {\n name = n;\n time = t;\n }\n}",
"P",
"String name;",
"name",
"int time;",
"time",
"P(String n, int t) {\n name = n;\n time = t;\n }",
"P",
"{\n name = n;\n time = t;\n }",
"name = n",
"name",
"n",
"time = t",
"time",
"t",
"String n",
"n",
"int t",
"t",
"public class Main {\n public static int SENTINEL = 100000007;\n public static int MAX = 10007;\n public static int NIL = -1;\n\n public static int[] dp = new int[100];\n\n\n public static void main(String[] args) throws IOException {\n\n //??\\???\n /*\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] str = br.readLine().split(\" \");\n */\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n P[] PP = new P[n];\n Queue<P> Q = new ArrayDeque<P>();\n\n for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }\n\n int T = 0;\n while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }\n }\n\n}",
"public class Main {\n public static int SENTINEL = 100000007;\n public static int MAX = 10007;\n public static int NIL = -1;\n\n public static int[] dp = new int[100];\n\n\n public static void main(String[] args) throws IOException {\n\n //??\\???\n /*\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] str = br.readLine().split(\" \");\n */\n\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n P[] PP = new P[n];\n Queue<P> Q = new ArrayDeque<P>();\n\n for(int i = 0; i < n; i++) {\n PP[i] = new P(sc.next(), sc.nextInt());\n Q.offer(PP[i]);\n }\n\n int T = 0;\n while(!Q.isEmpty()) {\n P Process = Q.poll();\n if(Process.time <= q) {\n T += Process.time;\n System.out.print(Process.name + \" \" + T);\n System.out.println();\n }\n else {\n T += q;\n P newProcess = new P(Process.name, Process.time - q);\n Q.offer(newProcess);\n }\n }\n }\n\n}",
"Main"
] |
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;
public class Main {
public static int SENTINEL = 100000007;
public static int MAX = 10007;
public static int NIL = -1;
public static int[] dp = new int[100];
public static void main(String[] args) throws IOException {
//??\???
/*
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] str = br.readLine().split(" ");
*/
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
P[] PP = new P[n];
Queue<P> Q = new ArrayDeque<P>();
for(int i = 0; i < n; i++) {
PP[i] = new P(sc.next(), sc.nextInt());
Q.offer(PP[i]);
}
int T = 0;
while(!Q.isEmpty()) {
P Process = Q.poll();
if(Process.time <= q) {
T += Process.time;
System.out.print(Process.name + " " + T);
System.out.println();
}
else {
T += q;
P newProcess = new P(Process.name, Process.time - q);
Q.offer(newProcess);
}
}
}
}
class Stack {
int top;
int MAX = 100007;
int[] S = new int[MAX];
Stack() {
top = 0;
}
boolean isEmpty() {
return top == 0;
}
boolean isFull() {
return top > MAX;
}
void push(int x) {
if(isFull()) return;
top++;
S[top] = x;
}
int pop() {
if(isEmpty()) return -1;
top--;
return S[top + 1];
}
}
class P {
String name;
int time;
P(String n, int t) {
name = n;
time = t;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
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,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
2,
13,
13,
0,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
113,
5
],
[
113,
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
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
60,
64
],
[
59,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
65,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
65,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
76,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
80,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
88,
89
],
[
88,
90
],
[
80,
91
],
[
91,
92
],
[
91,
93
],
[
76,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
101,
101
],
[
101,
102
],
[
101,
103
],
[
101,
104
],
[
104,
105
],
[
104,
106
],
[
94,
107
],
[
107,
108
],
[
107,
109
],
[
6,
110
],
[
110,
111
],
[
0,
112
],
[
112,
113
],
[
112,
114
]
] | [
"\nimport java.util.*;\n\n/**\n * B\n */\npublic class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n Queue<String> name_array = new ArrayDeque<String>();\n Queue<Integer> time_array = new ArrayDeque<Integer>();\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n \n int sum_time = 0;\n\n for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }\n\n sc.close();\n\n while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n Queue<String> name_array = new ArrayDeque<String>();\n Queue<Integer> time_array = new ArrayDeque<Integer>();\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n \n int sum_time = 0;\n\n for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }\n\n sc.close();\n\n while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n Queue<String> name_array = new ArrayDeque<String>();\n Queue<Integer> time_array = new ArrayDeque<Integer>();\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n \n int sum_time = 0;\n\n for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }\n\n sc.close();\n\n while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }\n }",
"main",
"{\n\n Scanner sc = new Scanner(System.in);\n Queue<String> name_array = new ArrayDeque<String>();\n Queue<Integer> time_array = new ArrayDeque<Integer>();\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n \n int sum_time = 0;\n\n for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }\n\n sc.close();\n\n while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"Queue<String> name_array = new ArrayDeque<String>();",
"name_array",
"new ArrayDeque<String>()",
"Queue<Integer> time_array = new ArrayDeque<Integer>();",
"time_array",
"new ArrayDeque<Integer>()",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int sum_time = 0;",
"sum_time",
"0",
"for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }",
"{\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }",
"name_array.add(sc.next())",
"name_array.add",
"name_array",
"sc.next()",
"sc.next",
"sc",
"time_array.add(sc.nextInt())",
"time_array.add",
"time_array",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.close()",
"sc.close",
"sc",
"while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }",
"name_array.peek() != null",
"name_array.peek()",
"name_array.peek",
"name_array",
"null",
"{\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }",
"String str = name_array.remove();",
"str",
"name_array.remove()",
"name_array.remove",
"name_array",
"int tmp = time_array.remove();",
"tmp",
"time_array.remove()",
"time_array.remove",
"time_array",
"if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }",
"tmp > q",
"tmp",
"q",
"{\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n }",
"name_array.add(str)",
"name_array.add",
"name_array",
"str",
"time_array.add(tmp - q)",
"time_array.add",
"time_array",
"tmp - q",
"tmp",
"q",
"sum_time += q",
"sum_time",
"q",
"{\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }",
"System.out.println(str + \" \" + (sum_time + tmp))",
"System.out.println",
"System.out",
"System",
"System.out",
"str + \" \" + (sum_time + tmp)",
"str + \" \" + (sum_time + tmp)",
"str",
"\" \"",
"(sum_time + tmp)",
"sum_time",
"tmp",
"sum_time += tmp",
"sum_time",
"tmp",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n Queue<String> name_array = new ArrayDeque<String>();\n Queue<Integer> time_array = new ArrayDeque<Integer>();\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n \n int sum_time = 0;\n\n for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }\n\n sc.close();\n\n while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n\n Scanner sc = new Scanner(System.in);\n Queue<String> name_array = new ArrayDeque<String>();\n Queue<Integer> time_array = new ArrayDeque<Integer>();\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n \n int sum_time = 0;\n\n for (int i = 0; i < n; i++) {\n name_array.add(sc.next());\n time_array.add(sc.nextInt());\n }\n\n sc.close();\n\n while (name_array.peek() != null) {\n\n String str = name_array.remove();\n int tmp = time_array.remove();\n\n if(tmp > q) {\n name_array.add(str);\n time_array.add(tmp - q);\n sum_time += q;\n } else {\n System.out.println(str + \" \" + (sum_time + tmp));\n sum_time += tmp;\n }\n\n }\n }\n}",
"Main"
] |
import java.util.*;
/**
* B
*/
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Queue<String> name_array = new ArrayDeque<String>();
Queue<Integer> time_array = new ArrayDeque<Integer>();
int n = sc.nextInt();
int q = sc.nextInt();
int sum_time = 0;
for (int i = 0; i < n; i++) {
name_array.add(sc.next());
time_array.add(sc.nextInt());
}
sc.close();
while (name_array.peek() != null) {
String str = name_array.remove();
int tmp = time_array.remove();
if(tmp > q) {
name_array.add(str);
time_array.add(tmp - q);
sum_time += q;
} else {
System.out.println(str + " " + (sum_time + tmp));
sum_time += tmp;
}
}
}
}
|
[
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,
20,
41,
13,
20,
41,
13,
17,
41,
13,
4,
18,
13,
41,
13,
17,
42,
2,
13,
13,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
40,
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
],
[
116,
17
],
[
116,
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
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
20,
35
],
[
35,
36
],
[
35,
37
],
[
20,
38
],
[
38,
39
],
[
38,
40
],
[
40,
41
],
[
41,
42
],
[
20,
43
],
[
43,
44
],
[
43,
45
],
[
20,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
51,
54
],
[
54,
55
],
[
55,
56
],
[
50,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
61,
62
],
[
50,
63
],
[
63,
64
],
[
20,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
66,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
75,
79
],
[
71,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
83,
84
],
[
84,
85
],
[
71,
86
],
[
86,
87
],
[
86,
88
],
[
71,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
90,
94
],
[
89,
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
],
[
18,
113
],
[
113,
114
],
[
0,
115
],
[
115,
116
],
[
115,
117
]
] | [
"import java.util.Deque;\nimport java.util.LinkedList;\nimport java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sca = new Scanner(System.in);\n int n = sca.nextInt();\n Deque<Integer> quu = new LinkedList<>();\n Deque<String> name = new LinkedList<>();\n int hour = 0;\n \n int qa = sca.nextInt();\n int K = 0;\n while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }\n while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }\n }\n}",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n Scanner sca = new Scanner(System.in);\n int n = sca.nextInt();\n Deque<Integer> quu = new LinkedList<>();\n Deque<String> name = new LinkedList<>();\n int hour = 0;\n \n int qa = sca.nextInt();\n int K = 0;\n while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }\n while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sca = new Scanner(System.in);\n int n = sca.nextInt();\n Deque<Integer> quu = new LinkedList<>();\n Deque<String> name = new LinkedList<>();\n int hour = 0;\n \n int qa = sca.nextInt();\n int K = 0;\n while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }\n while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }\n }",
"main",
"{\n Scanner sca = new Scanner(System.in);\n int n = sca.nextInt();\n Deque<Integer> quu = new LinkedList<>();\n Deque<String> name = new LinkedList<>();\n int hour = 0;\n \n int qa = sca.nextInt();\n int K = 0;\n while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }\n while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }\n }",
"Scanner sca = new Scanner(System.in);",
"sca",
"new Scanner(System.in)",
"int n = sca.nextInt();",
"n",
"sca.nextInt()",
"sca.nextInt",
"sca",
"Deque<Integer> quu = new LinkedList<>();",
"quu",
"new LinkedList<>()",
"Deque<String> name = new LinkedList<>();",
"name",
"new LinkedList<>()",
"int hour = 0;",
"hour",
"0",
"int qa = sca.nextInt();",
"qa",
"sca.nextInt()",
"sca.nextInt",
"sca",
"int K = 0;",
"K",
"0",
"while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }",
"K < n",
"K",
"n",
"{\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }",
"name.add(sca.next())",
"name.add",
"name",
"sca.next()",
"sca.next",
"sca",
"quu.add(sca.nextInt())",
"quu.add",
"quu",
"sca.nextInt()",
"sca.nextInt",
"sca",
"++K",
"K",
"while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }",
"quu.size() > 0",
"quu.size()",
"quu.size",
"quu",
"0",
"{\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }",
"quu.addLast(quu.poll() - qa)",
"quu.addLast",
"quu",
"quu.poll() - qa",
"quu.poll()",
"quu.poll",
"quu",
"qa",
"name.addLast(name.poll())",
"name.addLast",
"name",
"name.poll()",
"name.poll",
"name",
"hour += qa",
"hour",
"qa",
"if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }",
"quu.peekLast() <= 0",
"quu.peekLast()",
"quu.peekLast",
"quu",
"0",
"{\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }",
"hour += quu.pollLast()",
"hour",
"quu.pollLast()",
"quu.pollLast",
"quu",
"System.out.println(name.pollLast() + \" \" + hour)",
"System.out.println",
"System.out",
"System",
"System.out",
"name.pollLast() + \" \" + hour",
"name.pollLast() + \" \" + hour",
"name.pollLast()",
"name.pollLast",
"name",
"\" \"",
"hour",
"String[] args",
"args",
"public class Main {\n public static void main(String[] args) {\n Scanner sca = new Scanner(System.in);\n int n = sca.nextInt();\n Deque<Integer> quu = new LinkedList<>();\n Deque<String> name = new LinkedList<>();\n int hour = 0;\n \n int qa = sca.nextInt();\n int K = 0;\n while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }\n while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sca = new Scanner(System.in);\n int n = sca.nextInt();\n Deque<Integer> quu = new LinkedList<>();\n Deque<String> name = new LinkedList<>();\n int hour = 0;\n \n int qa = sca.nextInt();\n int K = 0;\n while (K < n) {\n name.add(sca.next());\n quu.add(sca.nextInt());\n ++K;\n }\n while (quu.size() > 0) {\n \n quu.addLast(quu.poll() - qa);\n name.addLast(name.poll());\n hour += qa;\n \n if (quu.peekLast() <= 0) {\n hour += quu.pollLast();;\n System.out.println(name.pollLast() + \" \" + hour);\n }\n }\n }\n}",
"Main"
] | import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
int n = sca.nextInt();
Deque<Integer> quu = new LinkedList<>();
Deque<String> name = new LinkedList<>();
int hour = 0;
int qa = sca.nextInt();
int K = 0;
while (K < n) {
name.add(sca.next());
quu.add(sca.nextInt());
++K;
}
while (quu.size() > 0) {
quu.addLast(quu.poll() - qa);
name.addLast(name.poll());
hour += qa;
if (quu.peekLast() <= 0) {
hour += quu.pollLast();;
System.out.println(name.pollLast() + " " + hour);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
4,
18,
20,
23,
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,
2,
40,
4,
18,
13,
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,
4,
18,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
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
],
[
132,
11
],
[
132,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
12,
18
],
[
18,
19
],
[
132,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
22,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
22,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
22,
36
],
[
36,
37
],
[
36,
38
],
[
22,
39
],
[
39,
40
],
[
39,
41
],
[
22,
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
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
59,
60
],
[
54,
61
],
[
61,
62
],
[
62,
63
],
[
61,
64
],
[
64,
65
],
[
65,
66
],
[
22,
67
],
[
67,
68
],
[
67,
69
],
[
22,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
71,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
70,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
80,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
80,
91
],
[
91,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
107,
109
],
[
107,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
91,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
114,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
122,
123
],
[
122,
124
],
[
114,
125
],
[
125,
126
],
[
125,
127
],
[
22,
128
],
[
128,
129
],
[
129,
130
],
[
0,
131
],
[
131,
132
],
[
131,
133
]
] | [
"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\tnew Main().run();\n\t}\n\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tDeque<String> nameQueue = new ArrayDeque<String>();\n\t\tDeque<Integer> timeQueue = new ArrayDeque<Integer>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}\n\t\tint nowTime = 0;\n\n\t\twhile (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}\n\n\t\tsc.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\tnew Main().run();\n\t}\n\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tDeque<String> nameQueue = new ArrayDeque<String>();\n\t\tDeque<Integer> timeQueue = new ArrayDeque<Integer>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}\n\t\tint nowTime = 0;\n\n\t\twhile (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\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",
"void run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tDeque<String> nameQueue = new ArrayDeque<String>();\n\t\tDeque<Integer> timeQueue = new ArrayDeque<Integer>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}\n\t\tint nowTime = 0;\n\n\t\twhile (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"run",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tDeque<String> nameQueue = new ArrayDeque<String>();\n\t\tDeque<Integer> timeQueue = new ArrayDeque<Integer>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}\n\t\tint nowTime = 0;\n\n\t\twhile (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Deque<String> nameQueue = new ArrayDeque<String>();",
"nameQueue",
"new ArrayDeque<String>()",
"Deque<Integer> timeQueue = new ArrayDeque<Integer>();",
"timeQueue",
"new ArrayDeque<Integer>()",
"for (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}",
"{\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}",
"nameQueue.offer(sc.next())",
"nameQueue.offer",
"nameQueue",
"sc.next()",
"sc.next",
"sc",
"timeQueue.offer(sc.nextInt())",
"timeQueue.offer",
"timeQueue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int nowTime = 0;",
"nowTime",
"0",
"while (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}",
"!nameQueue.isEmpty() && !timeQueue.isEmpty()",
"!nameQueue.isEmpty()",
"nameQueue.isEmpty()",
"nameQueue.isEmpty",
"nameQueue",
"!timeQueue.isEmpty()",
"timeQueue.isEmpty()",
"timeQueue.isEmpty",
"timeQueue",
"{\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}",
"String p = nameQueue.poll();",
"p",
"nameQueue.poll()",
"nameQueue.poll",
"nameQueue",
"int t = timeQueue.poll();",
"t",
"timeQueue.poll()",
"timeQueue.poll",
"timeQueue",
"if (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}",
"t - q <= 0",
"t - q",
"t",
"q",
"0",
"{\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t}",
"nowTime += t",
"nowTime",
"t",
"System.out.println(p + \" \" + String.valueOf(nowTime))",
"System.out.println",
"System.out",
"System",
"System.out",
"p + \" \" + String.valueOf(nowTime)",
"p + \" \" + String.valueOf(nowTime)",
"p",
"\" \"",
"String.valueOf(nowTime)",
"String.valueOf",
"String",
"nowTime",
"{\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}",
"nameQueue.offer(p)",
"nameQueue.offer",
"nameQueue",
"p",
"timeQueue.offer(t - q)",
"timeQueue.offer",
"timeQueue",
"t - q",
"t",
"q",
"nowTime += q",
"nowTime",
"q",
"sc.close()",
"sc.close",
"sc",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tDeque<String> nameQueue = new ArrayDeque<String>();\n\t\tDeque<Integer> timeQueue = new ArrayDeque<Integer>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}\n\t\tint nowTime = 0;\n\n\t\twhile (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\tnew Main().run();\n\t}\n\n\tvoid run() {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tDeque<String> nameQueue = new ArrayDeque<String>();\n\t\tDeque<Integer> timeQueue = new ArrayDeque<Integer>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnameQueue.offer(sc.next());\n\t\t\ttimeQueue.offer(sc.nextInt());\n\t\t}\n\t\tint nowTime = 0;\n\n\t\twhile (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {\n\t\t\tString p = nameQueue.poll();\n\t\t\tint t = timeQueue.poll();\n\t\t\tif (t - q <= 0) {\n\t\t\t\tnowTime += t;\n\t\t\t\tSystem.out.println(p + \" \" + String.valueOf(nowTime));\n\t\t\t} else {\n\t\t\t\tnameQueue.offer(p);\n\t\t\t\ttimeQueue.offer(t - q);\n\t\t\t\tnowTime += q;\n\t\t\t}\n\t\t}\n\n\t\tsc.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) {
new Main().run();
}
void run() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Deque<String> nameQueue = new ArrayDeque<String>();
Deque<Integer> timeQueue = new ArrayDeque<Integer>();
for (int i = 0; i < n; i++) {
nameQueue.offer(sc.next());
timeQueue.offer(sc.nextInt());
}
int nowTime = 0;
while (!nameQueue.isEmpty() && !timeQueue.isEmpty()) {
String p = nameQueue.poll();
int t = timeQueue.poll();
if (t - q <= 0) {
nowTime += t;
System.out.println(p + " " + String.valueOf(nowTime));
} else {
nameQueue.offer(p);
timeQueue.offer(t - q);
nowTime += q;
}
}
sc.close();
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
0,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
2,
13,
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
],
[
124,
11
],
[
124,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
14,
17
],
[
17,
18
],
[
14,
19
],
[
19,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
29
],
[
29,
30
],
[
29,
31
],
[
14,
32
],
[
32,
33
],
[
32,
34
],
[
14,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
14,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
14,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
61,
62
],
[
62,
63
],
[
57,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
67,
68
],
[
68,
69
],
[
14,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
71,
75
],
[
70,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
86,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
101,
101
],
[
101,
102
],
[
101,
103
],
[
101,
104
],
[
82,
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
],
[
12,
121
],
[
121,
122
],
[
0,
123
],
[
123,
124
],
[
123,
125
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tint n, q, t;\n\t\tint t_sum = 0;\n\t\tString pros;\n\t\tDeque<String> name = new ArrayDeque<>();\n\t\tDeque<Integer> time = new ArrayDeque<>();\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}\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\tpublic static void main(String args[]) {\n\t\tint n, q, t;\n\t\tint t_sum = 0;\n\t\tString pros;\n\t\tDeque<String> name = new ArrayDeque<>();\n\t\tDeque<Integer> time = new ArrayDeque<>();\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tint n, q, t;\n\t\tint t_sum = 0;\n\t\tString pros;\n\t\tDeque<String> name = new ArrayDeque<>();\n\t\tDeque<Integer> time = new ArrayDeque<>();\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tint n, q, t;\n\t\tint t_sum = 0;\n\t\tString pros;\n\t\tDeque<String> name = new ArrayDeque<>();\n\t\tDeque<Integer> time = new ArrayDeque<>();\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}\n\t}",
"int n",
"n",
"q",
"q",
"t;",
"t",
"int t_sum = 0;",
"t_sum",
"0",
"String pros;",
"pros",
"Deque<String> name = new ArrayDeque<>();",
"name",
"new ArrayDeque<>()",
"Deque<Integer> time = new ArrayDeque<>();",
"time",
"new ArrayDeque<>()",
"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",
"for (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}",
"{\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}",
"name.offerLast(sc.next())",
"name.offerLast",
"name",
"sc.next()",
"sc.next",
"sc",
"time.offerLast(sc.nextInt())",
"time.offerLast",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}",
"time.size() != 0",
"time.size()",
"time.size",
"time",
"0",
"{\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}",
"t = time.poll()",
"t",
"time.poll()",
"time.poll",
"time",
"if (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}",
"t <= q",
"t",
"q",
"{\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t}",
"t_sum += t",
"t_sum",
"t",
"pros = name.poll()",
"pros",
"name.poll()",
"name.poll",
"name",
"System.out.println(pros + \" \" + t_sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"pros + \" \" + t_sum",
"pros + \" \" + t_sum",
"pros",
"\" \"",
"t_sum",
"{\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}",
"t_sum += q",
"t_sum",
"q",
"time.offerLast(t - q)",
"time.offerLast",
"time",
"t - q",
"t",
"q",
"name.offerLast(name.poll())",
"name.offerLast",
"name",
"name.poll()",
"name.poll",
"name",
"String args[]",
"args",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tint n, q, t;\n\t\tint t_sum = 0;\n\t\tString pros;\n\t\tDeque<String> name = new ArrayDeque<>();\n\t\tDeque<Integer> time = new ArrayDeque<>();\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tint n, q, t;\n\t\tint t_sum = 0;\n\t\tString pros;\n\t\tDeque<String> name = new ArrayDeque<>();\n\t\tDeque<Integer> time = new ArrayDeque<>();\n\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tn = sc.nextInt();\n\t\tq = sc.nextInt();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tname.offerLast(sc.next());\n\t\t\ttime.offerLast(sc.nextInt());\n\t\t}\n\n\t\twhile (time.size() != 0) {\n\t\t\tt = time.poll();\n\t\t\tif (t <= q) {\n\t\t\t\tt_sum += t;\n\t\t\t\tpros = name.poll();\n\t\t\t\tSystem.out.println(pros + \" \" + t_sum);\n\t\t\t} else {\n\t\t\t\tt_sum += q;\n\t\t\t\ttime.offerLast(t - q);\n\t\t\t\tname.offerLast(name.poll());\n\t\t\t}\n\t\t}\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[]) {
int n, q, t;
int t_sum = 0;
String pros;
Deque<String> name = new ArrayDeque<>();
Deque<Integer> time = new ArrayDeque<>();
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
q = sc.nextInt();
for (int i = 0; i < n; i++) {
name.offerLast(sc.next());
time.offerLast(sc.nextInt());
}
while (time.size() != 0) {
t = time.poll();
if (t <= q) {
t_sum += t;
pros = name.poll();
System.out.println(pros + " " + t_sum);
} else {
t_sum += q;
time.offerLast(t - q);
name.offerLast(name.poll());
}
}
}
} |
[
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,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
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,
18,
13,
13,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
4,
18,
13,
17,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
17,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
181,
8
],
[
181,
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
],
[
49,
50
],
[
50,
51
],
[
46,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
57,
58
],
[
58,
59
],
[
46,
60
],
[
60,
61
],
[
60,
62
],
[
46,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
11,
67
],
[
67,
68
],
[
67,
69
],
[
11,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
71,
75
],
[
70,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
76,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
84,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
100,
104
],
[
89,
105
],
[
105,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
105,
110
],
[
89,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
83,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
122,
126
],
[
115,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
115,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
9,
135
],
[
135,
136
],
[
0,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
137,
141
],
[
141,
142
],
[
137,
143
],
[
143,
144
],
[
143,
145
],
[
145,
146
],
[
146,
147
],
[
147,
148
],
[
147,
149
],
[
146,
150
],
[
145,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
143,
156
],
[
156,
157
],
[
143,
158
],
[
158,
159
],
[
137,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
137,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
137,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
170,
178
],
[
178,
179
],
[
0,
180
],
[
180,
181
],
[
180,
182
]
] | [
"import java.util.ArrayList;\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\tArrayList<Task> tasks = new ArrayList<>();\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}\n\t\tint time = 0;\n\t\twhile (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nclass Task {\n\tString name;\n\tint second;\n\n\tpublic Task(String name, int second) {\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getSecond() {\n\t\treturn second;\n\t}\n\n\tpublic void setSecond(int second) {\n\t\tthis.second = second;\n\t}\n}",
"import java.util.ArrayList;",
"ArrayList",
"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\tArrayList<Task> tasks = new ArrayList<>();\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}\n\t\tint time = 0;\n\t\twhile (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tArrayList<Task> tasks = new ArrayList<>();\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}\n\t\tint time = 0;\n\t\twhile (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}\n\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tArrayList<Task> tasks = new ArrayList<>();\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}\n\t\tint time = 0;\n\t\twhile (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}\n\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"ArrayList<Task> tasks = new ArrayList<>();",
"tasks",
"new ArrayList<>()",
"int n = Integer.parseInt(sc.next());",
"n",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int q = Integer.parseInt(sc.next());",
"q",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"for (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}",
"{\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int second = Integer.parseInt(sc.next());",
"second",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"Task task = new Task(name, second);",
"task",
"new Task(name, second)",
"tasks.add(task)",
"tasks.add",
"tasks",
"task",
"int time = 0;",
"time",
"0",
"while (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}",
"tasks.size() != 0",
"tasks.size()",
"tasks.size",
"tasks",
"0",
"{\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}",
"Task task = tasks.get(0);",
"task",
"tasks.get(0)",
"tasks.get",
"tasks",
"0",
"if (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}",
"task.getSecond() <= q",
"task.getSecond()",
"task.getSecond",
"task",
"q",
"{\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t}",
"time += task.getSecond()",
"time",
"task.getSecond()",
"task.getSecond",
"task",
"System.out.print(task.getName() + \" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"task.getName() + \" \"",
"task.getName()",
"task.getName",
"task",
"\" \"",
"System.out.println(time)",
"System.out.println",
"System.out",
"System",
"System.out",
"time",
"tasks.remove(0)",
"tasks.remove",
"tasks",
"0",
"{\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}",
"time += q",
"time",
"q",
"task.setSecond(task.getSecond() - q)",
"task.setSecond",
"task",
"task.getSecond() - q",
"task.getSecond()",
"task.getSecond",
"task",
"q",
"tasks.add(task)",
"tasks.add",
"tasks",
"task",
"tasks.remove(0)",
"tasks.remove",
"tasks",
"0",
"String[] args",
"args",
"class Task {\n\tString name;\n\tint second;\n\n\tpublic Task(String name, int second) {\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic int getSecond() {\n\t\treturn second;\n\t}\n\n\tpublic void setSecond(int second) {\n\t\tthis.second = second;\n\t}\n}",
"Task",
"String name;",
"name",
"int second;",
"second",
"public Task(String name, int second) {\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}",
"Task",
"{\n\t\tthis.name = name;\n\t\tthis.second = second;\n\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.second = second",
"this.second",
"this",
"this.second",
"second",
"String name",
"name",
"int second",
"second",
"public String getName() {\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public int getSecond() {\n\t\treturn second;\n\t}",
"getSecond",
"{\n\t\treturn second;\n\t}",
"return second;",
"second",
"public void setSecond(int second) {\n\t\tthis.second = second;\n\t}",
"setSecond",
"{\n\t\tthis.second = second;\n\t}",
"this.second = second",
"this.second",
"this",
"this.second",
"second",
"int second",
"second",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tArrayList<Task> tasks = new ArrayList<>();\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}\n\t\tint time = 0;\n\t\twhile (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}",
"public class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tArrayList<Task> tasks = new ArrayList<>();\n\n\t\tint n = Integer.parseInt(sc.next());\n\t\tint q = Integer.parseInt(sc.next());\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString name = sc.next();\n\t\t\tint second = Integer.parseInt(sc.next());\n\t\t\tTask task = new Task(name, second);\n\t\t\ttasks.add(task);\n\t\t}\n\t\tint time = 0;\n\t\twhile (tasks.size() != 0) {\n\t\t\tTask task = tasks.get(0);\n\t\t\tif (task.getSecond() <= q) {\n\t\t\t\ttime += task.getSecond();\n\t\t\t\tSystem.out.print(task.getName() + \" \");\n\t\t\t\tSystem.out.println(time);\n\t\t\t\ttasks.remove(0);\n\n\t\t\t} else {\n\t\t\t\ttime += q;\n\t\t\t\ttask.setSecond(task.getSecond() - q);\n\t\t\t\ttasks.add(task);\n\t\t\t\ttasks.remove(0);\n\t\t\t}\n\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) {
Scanner sc = new Scanner(System.in);
ArrayList<Task> tasks = new ArrayList<>();
int n = Integer.parseInt(sc.next());
int q = Integer.parseInt(sc.next());
for (int i = 0; i < n; i++) {
String name = sc.next();
int second = Integer.parseInt(sc.next());
Task task = new Task(name, second);
tasks.add(task);
}
int time = 0;
while (tasks.size() != 0) {
Task task = tasks.get(0);
if (task.getSecond() <= q) {
time += task.getSecond();
System.out.print(task.getName() + " ");
System.out.println(time);
tasks.remove(0);
} else {
time += q;
task.setSecond(task.getSecond() - q);
tasks.add(task);
tasks.remove(0);
}
}
}
}
class Task {
String name;
int second;
public Task(String name, int second) {
this.name = name;
this.second = second;
}
public String getName() {
return name;
}
public int getSecond() {
return second;
}
public void setSecond(int second) {
this.second = second;
}
} |
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
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,
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
],
[
110,
5
],
[
110,
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
],
[
57,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
65,
69
],
[
64,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
76,
77
],
[
71,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
81,
85
],
[
71,
86
],
[
86,
87
],
[
86,
88
],
[
63,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
95,
100
],
[
101,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
101,
105
],
[
101,
106
],
[
6,
107
],
[
107,
108
],
[
0,
109
],
[
109,
110
],
[
109,
111
]
] | [
"import java.util.*;\n\npublic class Main{\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> name = new LinkedList<>();\n Queue<Integer> time = new LinkedList<>();\n int a = in.nextInt();\n int b = in.nextInt();\n int timer = 0;\n\n for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }\n while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> name = new LinkedList<>();\n Queue<Integer> time = new LinkedList<>();\n int a = in.nextInt();\n int b = in.nextInt();\n int timer = 0;\n\n for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }\n while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> name = new LinkedList<>();\n Queue<Integer> time = new LinkedList<>();\n int a = in.nextInt();\n int b = in.nextInt();\n int timer = 0;\n\n for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }\n while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }\n }",
"main",
"{\n Scanner in = new Scanner(System.in);\n Queue<String> name = new LinkedList<>();\n Queue<Integer> time = new LinkedList<>();\n int a = in.nextInt();\n int b = in.nextInt();\n int timer = 0;\n\n for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }\n while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }\n }",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"Queue<String> name = new LinkedList<>();",
"name",
"new LinkedList<>()",
"Queue<Integer> time = new LinkedList<>();",
"time",
"new LinkedList<>()",
"int a = in.nextInt();",
"a",
"in.nextInt()",
"in.nextInt",
"in",
"int b = in.nextInt();",
"b",
"in.nextInt()",
"in.nextInt",
"in",
"int timer = 0;",
"timer",
"0",
"for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < a",
"i",
"a",
"i++",
"i++",
"i",
"{\n name.add(in.next());\n time.add(in.nextInt());\n }",
"{\n name.add(in.next());\n time.add(in.nextInt());\n }",
"name.add(in.next())",
"name.add",
"name",
"in.next()",
"in.next",
"in",
"time.add(in.nextInt())",
"time.add",
"time",
"in.nextInt()",
"in.nextInt",
"in",
"while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }",
"name.size() != 0",
"name.size()",
"name.size",
"name",
"0",
"{\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }",
"if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }",
"time.peek() - b > 0",
"time.peek() - b",
"time.peek()",
"time.peek",
"time",
"b",
"0",
"{\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n }",
"name.add(name.poll())",
"name.add",
"name",
"name.poll()",
"name.poll",
"name",
"time.add(time.poll() - b)",
"time.add",
"time",
"time.poll() - b",
"time.poll()",
"time.poll",
"time",
"b",
"timer += b",
"timer",
"b",
"{\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }",
"timer += time.poll()",
"timer",
"time.poll()",
"time.poll",
"time",
"System.out.println(name.poll() + \" \" + timer)",
"System.out.println",
"System.out",
"System",
"System.out",
"name.poll() + \" \" + timer",
"name.poll() + \" \" + timer",
"name.poll()",
"name.poll",
"name",
"\" \"",
"timer",
"String[] args",
"args",
"public class Main{\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> name = new LinkedList<>();\n Queue<Integer> time = new LinkedList<>();\n int a = in.nextInt();\n int b = in.nextInt();\n int timer = 0;\n\n for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }\n while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }\n }\n}",
"public class Main{\n public static void main(String[] args) {\n Scanner in = new Scanner(System.in);\n Queue<String> name = new LinkedList<>();\n Queue<Integer> time = new LinkedList<>();\n int a = in.nextInt();\n int b = in.nextInt();\n int timer = 0;\n\n for (int i = 0; i < a; i++) {\n name.add(in.next());\n time.add(in.nextInt());\n }\n while (name.size() != 0) {\n if (time.peek() - b > 0) {\n name.add(name.poll());\n time.add(time.poll() - b);\n timer += b;\n } else {\n timer += time.poll();\n System.out.println(name.poll() + \" \" + timer);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
Queue<String> name = new LinkedList<>();
Queue<Integer> time = new LinkedList<>();
int a = in.nextInt();
int b = in.nextInt();
int timer = 0;
for (int i = 0; i < a; i++) {
name.add(in.next());
time.add(in.nextInt());
}
while (name.size() != 0) {
if (time.peek() - b > 0) {
name.add(name.poll());
time.add(time.poll() - b);
timer += b;
} else {
timer += time.poll();
System.out.println(name.poll() + " " + timer);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
13,
29,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
17,
0,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
13,
17,
0,
13,
2,
13,
17,
41,
13,
17,
42,
2,
13,
13,
30,
41,
13,
4,
13,
14,
2,
2,
18,
13,
13,
13,
17,
30,
0,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
0,
10
],
[
181,
11
],
[
181,
12
],
[
12,
13
],
[
181,
14
],
[
14,
15
],
[
181,
16
],
[
16,
17
],
[
181,
18
],
[
18,
19
],
[
181,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
24,
26
],
[
23,
27
],
[
22,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
20,
35
],
[
35,
36
],
[
181,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
42,
44
],
[
39,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
48,
50
],
[
47,
51
],
[
39,
52
],
[
52,
53
],
[
181,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
56,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
56,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
56,
70
],
[
70,
71
],
[
70,
72
],
[
56,
73
],
[
73,
74
],
[
73,
75
],
[
56,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
77,
82
],
[
82,
83
],
[
82,
84
],
[
77,
85
],
[
85,
86
],
[
86,
87
],
[
77,
88
],
[
89,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
89,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
56,
113
],
[
113,
114
],
[
113,
115
],
[
56,
116
],
[
116,
117
],
[
116,
118
],
[
118,
119
],
[
118,
120
],
[
56,
121
],
[
121,
122
],
[
121,
123
],
[
56,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
128,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
134,
140
],
[
133,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
141,
154
],
[
154,
155
],
[
154,
156
],
[
133,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
160,
162
],
[
157,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
169,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
169,
174
],
[
56,
175
],
[
175,
176
],
[
176,
177
],
[
54,
178
],
[
178,
179
],
[
0,
180
],
[
180,
181
],
[
180,
182
]
] | [
"import java.util.Scanner;\n\nclass Pair {\n String name;\n int time;\n}\n\npublic class Main {\n static int LEN;\n static int head;\n static int tail;\n static Pair[] pairs;\n\n // データの追加\n public static void enqueue(Pair x) {\n pairs[tail] = x;\n tail = (tail + 1) % LEN;\n }\n\n // データを取り出す\n public static Pair dequeue() {\n Pair x = pairs[head];\n head = (head + 1) % LEN;\n return x;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); // n個のプロセス\n int q = sc.nextInt(); // 最大実行時間\n LEN = 100005;\n pairs = new Pair[LEN];\n for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n int now = 0;\n while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }\n sc.close();\n }\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Pair {\n String name;\n int time;\n}",
"Pair",
"String name;",
"name",
"int time;",
"time",
"public class Main {\n static int LEN;\n static int head;\n static int tail;\n static Pair[] pairs;\n\n // データの追加\n public static void enqueue(Pair x) {\n pairs[tail] = x;\n tail = (tail + 1) % LEN;\n }\n\n // データを取り出す\n public static Pair dequeue() {\n Pair x = pairs[head];\n head = (head + 1) % LEN;\n return x;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); // n個のプロセス\n int q = sc.nextInt(); // 最大実行時間\n LEN = 100005;\n pairs = new Pair[LEN];\n for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n int now = 0;\n while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }\n sc.close();\n }\n\n}",
"Main",
"static int LEN;",
"LEN",
"static int head;",
"head",
"static int tail;",
"tail",
"static Pair[] pairs;",
"pairs",
"// データの追加\n public static void enqueue(Pair x) {\n pairs[tail] = x;\n tail = (tail + 1) % LEN;\n }",
"enqueue",
"{\n pairs[tail] = x;\n tail = (tail + 1) % LEN;\n }",
"pairs[tail] = x",
"pairs[tail]",
"pairs",
"tail",
"x",
"tail = (tail + 1) % LEN",
"tail",
"(tail + 1) % LEN",
"(tail + 1)",
"tail",
"1",
"LEN",
"Pair x",
"x",
"// データを取り出す\n public static Pair dequeue() {\n Pair x = pairs[head];\n head = (head + 1) % LEN;\n return x;\n }",
"dequeue",
"{\n Pair x = pairs[head];\n head = (head + 1) % LEN;\n return x;\n }",
"Pair x = pairs[head];",
"x",
"pairs[head]",
"pairs",
"head",
"head = (head + 1) % LEN",
"head",
"(head + 1) % LEN",
"(head + 1)",
"head",
"1",
"LEN",
"return x;",
"x",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); // n個のプロセス\n int q = sc.nextInt(); // 最大実行時間\n LEN = 100005;\n pairs = new Pair[LEN];\n for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n int now = 0;\n while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }\n sc.close();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); // n個のプロセス\n int q = sc.nextInt(); // 最大実行時間\n LEN = 100005;\n pairs = new Pair[LEN];\n for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n int now = 0;\n while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\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 q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"LEN = 100005",
"LEN",
"100005",
"pairs = new Pair[LEN]",
"pairs",
"new Pair[LEN]",
"LEN",
"for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= n",
"i",
"n",
"i++",
"i++",
"i",
"{\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }",
"{\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }",
"pairs[i] = new Pair()",
"pairs[i]",
"pairs",
"i",
"new Pair()",
"pairs[i].name = sc.next()",
"pairs[i].name",
"pairs[i]",
"pairs",
"i",
"pairs[i].name",
"sc.next()",
"sc.next",
"sc",
"pairs[i].time = sc.nextInt()",
"pairs[i].time",
"pairs[i]",
"pairs",
"i",
"pairs[i].time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"head = 1",
"head",
"1",
"tail = n + 1",
"tail",
"n + 1",
"n",
"1",
"int now = 0;",
"now",
"0",
"while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }",
"tail != head",
"tail",
"head",
"{\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }",
"Pair u = dequeue();",
"u",
"dequeue()",
"dequeue",
"if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }",
"u.time - q > 0",
"u.time - q",
"u.time",
"u",
"u.time",
"q",
"0",
"{\n now += q;\n u.time = u.time - q;\n enqueue(u);\n }",
"now += q",
"now",
"q",
"u.time = u.time - q",
"u.time",
"u",
"u.time",
"u.time - q",
"u.time",
"u",
"u.time",
"q",
"enqueue(u)",
"enqueue",
"u",
"{\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }",
"now += u.time",
"now",
"u.time",
"u",
"u.time",
"System.out.println(u.name + \" \" + now)",
"System.out.println",
"System.out",
"System",
"System.out",
"u.name + \" \" + now",
"u.name + \" \" + now",
"u.name",
"u",
"u.name",
"\" \"",
"now",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"public class Main {\n static int LEN;\n static int head;\n static int tail;\n static Pair[] pairs;\n\n // データの追加\n public static void enqueue(Pair x) {\n pairs[tail] = x;\n tail = (tail + 1) % LEN;\n }\n\n // データを取り出す\n public static Pair dequeue() {\n Pair x = pairs[head];\n head = (head + 1) % LEN;\n return x;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); // n個のプロセス\n int q = sc.nextInt(); // 最大実行時間\n LEN = 100005;\n pairs = new Pair[LEN];\n for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n int now = 0;\n while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }\n sc.close();\n }\n\n}",
"public class Main {\n static int LEN;\n static int head;\n static int tail;\n static Pair[] pairs;\n\n // データの追加\n public static void enqueue(Pair x) {\n pairs[tail] = x;\n tail = (tail + 1) % LEN;\n }\n\n // データを取り出す\n public static Pair dequeue() {\n Pair x = pairs[head];\n head = (head + 1) % LEN;\n return x;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt(); // n個のプロセス\n int q = sc.nextInt(); // 最大実行時間\n LEN = 100005;\n pairs = new Pair[LEN];\n for (int i = 1; i <= n; i++) {\n pairs[i] = new Pair();\n pairs[i].name = sc.next();\n pairs[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n int now = 0;\n while (tail != head) {\n Pair u = dequeue();\n if (u.time - q > 0) {\n now += q;\n u.time = u.time - q;\n enqueue(u);\n } else {\n now += u.time;\n System.out.println(u.name + \" \" + now);\n }\n }\n sc.close();\n }\n\n}",
"Main"
] | import java.util.Scanner;
class Pair {
String name;
int time;
}
public class Main {
static int LEN;
static int head;
static int tail;
static Pair[] pairs;
// データの追加
public static void enqueue(Pair x) {
pairs[tail] = x;
tail = (tail + 1) % LEN;
}
// データを取り出す
public static Pair dequeue() {
Pair x = pairs[head];
head = (head + 1) % LEN;
return x;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); // n個のプロセス
int q = sc.nextInt(); // 最大実行時間
LEN = 100005;
pairs = new Pair[LEN];
for (int i = 1; i <= n; i++) {
pairs[i] = new Pair();
pairs[i].name = sc.next();
pairs[i].time = sc.nextInt();
}
head = 1;
tail = n + 1;
int now = 0;
while (tail != head) {
Pair u = dequeue();
if (u.time - q > 0) {
now += q;
u.time = u.time - q;
enqueue(u);
} else {
now += u.time;
System.out.println(u.name + " " + now);
}
}
sc.close();
}
}
|
[
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,
20,
4,
18,
13,
13,
41,
13,
17,
41,
13,
17,
41,
13,
20,
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,
0,
18,
13,
13,
2,
2,
18,
13,
13,
17,
4,
18,
13,
13,
40,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
145,
5
],
[
145,
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
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
8,
48
],
[
48,
49
],
[
48,
50
],
[
8,
51
],
[
51,
52
],
[
51,
53
],
[
8,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
56,
60
],
[
55,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
67,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
73,
83
],
[
83,
84
],
[
83,
85
],
[
67,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
101
],
[
97,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
86,
106
],
[
106,
107
],
[
8,
108
],
[
108,
109
],
[
108,
110
],
[
108,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
113,
118
],
[
6,
119
],
[
119,
120
],
[
0,
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.*;\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 Queue<Process> queue = new ArrayDeque<Process>();\n for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }\n int pTime = 0;\n int b = 0;\n String[] result = new String[n];\n while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }\n for(String s:result) {\n System.out.println(s);\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}\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 n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> queue = new ArrayDeque<Process>();\n for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }\n int pTime = 0;\n int b = 0;\n String[] result = new String[n];\n while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }\n for(String s:result) {\n System.out.println(s);\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> queue = new ArrayDeque<Process>();\n for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }\n int pTime = 0;\n int b = 0;\n String[] result = new String[n];\n while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }\n for(String s:result) {\n System.out.println(s);\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> queue = new ArrayDeque<Process>();\n for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }\n int pTime = 0;\n int b = 0;\n String[] result = new String[n];\n while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }\n for(String s:result) {\n System.out.println(s);\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }",
"{\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }",
"Process p = new Process(sc.next(),sc.nextInt());",
"p",
"new Process(sc.next(),sc.nextInt())",
"queue.add(p)",
"queue.add",
"queue",
"p",
"int pTime = 0;",
"pTime",
"0",
"int b = 0;",
"b",
"0",
"String[] result = new String[n];",
"result",
"new String[n]",
"n",
"while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }",
"queue.size()>0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }",
"Process pro = queue.poll();",
"pro",
"queue.poll()",
"queue.poll",
"queue",
"if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }",
"pro.time>q",
"pro.time",
"pro",
"pro.time",
"q",
"{\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n }",
"pro.time -= q",
"pro.time",
"pro",
"pro.time",
"q",
"queue.add(pro)",
"queue.add",
"queue",
"pro",
"pTime += q",
"pTime",
"q",
"{\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }",
"pTime += pro.time",
"pTime",
"pro.time",
"pro",
"pro.time",
"result[b] = pro.name+\" \"+Integer.toString(pTime)",
"result[b]",
"result",
"b",
"pro.name+\" \"+Integer.toString(pTime)",
"pro.name+\" \"+Integer.toString(pTime)",
"pro.name",
"pro",
"pro.name",
"\" \"",
"Integer.toString(pTime)",
"Integer.toString",
"Integer",
"pTime",
"b++",
"b",
"for(String s:result) {\n System.out.println(s);\n }",
"String s",
"result",
"{\n System.out.println(s);\n }",
"{\n System.out.println(s);\n }",
"System.out.println(s)",
"System.out.println",
"System.out",
"System",
"System.out",
"s",
"String[] args",
"args",
"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",
"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) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Queue<Process> queue = new ArrayDeque<Process>();\n for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }\n int pTime = 0;\n int b = 0;\n String[] result = new String[n];\n while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }\n for(String s:result) {\n System.out.println(s);\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 Queue<Process> queue = new ArrayDeque<Process>();\n for(int i=0; i<n; i++) {\n Process p = new Process(sc.next(),sc.nextInt());\n queue.add(p);\n }\n int pTime = 0;\n int b = 0;\n String[] result = new String[n];\n while(queue.size()>0) {\n Process pro = queue.poll();\n if(pro.time>q) {\n pro.time -= q;\n queue.add(pro);\n pTime += q;\n } else {\n pTime += pro.time;\n result[b] = pro.name+\" \"+Integer.toString(pTime);\n b++;\n }\n }\n for(String s:result) {\n System.out.println(s);\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Queue<Process> queue = new ArrayDeque<Process>();
for(int i=0; i<n; i++) {
Process p = new Process(sc.next(),sc.nextInt());
queue.add(p);
}
int pTime = 0;
int b = 0;
String[] result = new String[n];
while(queue.size()>0) {
Process pro = queue.poll();
if(pro.time>q) {
pro.time -= q;
queue.add(pro);
pTime += q;
} else {
pTime += pro.time;
result[b] = pro.name+" "+Integer.toString(pTime);
b++;
}
}
for(String s:result) {
System.out.println(s);
}
}
}
class Process{
String name;
int time;
Process(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,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
4,
18,
13,
13,
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,
14,
2,
13,
13,
30,
0,
13,
13,
41,
13,
4,
18,
13,
2,
13,
13,
4,
18,
13,
2,
2,
18,
13,
17,
17,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
17,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
13,
12,
13,
30,
0,
13,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
4,
13,
30,
4,
18,
18,
13,
13,
17,
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,
4,
18,
18,
13,
13,
17,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
29,
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
],
[
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
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
14,
70
],
[
70,
71
],
[
70,
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
],
[
84,
85
],
[
85,
86
],
[
82,
87
],
[
79,
88
],
[
88,
89
],
[
88,
90
],
[
90,
91
],
[
91,
92
],
[
90,
93
],
[
93,
94
],
[
93,
95
],
[
79,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
109,
110
],
[
109,
111
],
[
100,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
116,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
116,
121
],
[
96,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
126,
131
],
[
132,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
132,
137
],
[
12,
138
],
[
138,
139
],
[
0,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
140,
144
],
[
144,
145
],
[
140,
146
],
[
146,
147
],
[
146,
148
],
[
140,
149
],
[
149,
150
],
[
149,
151
],
[
140,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
158,
160
],
[
140,
161
],
[
161,
162
],
[
161,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
140,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
174,
178
],
[
140,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
182,
183
],
[
183,
184
],
[
182,
185
],
[
185,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
186,
191
],
[
181,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
181,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
197,
203
],
[
203,
204
],
[
204,
205
],
[
204,
206
],
[
197,
207
],
[
207,
208
],
[
208,
209
],
[
179,
210
],
[
210,
211
],
[
140,
212
],
[
212,
213
],
[
212,
214
],
[
214,
215
],
[
215,
216
],
[
216,
217
],
[
215,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
221,
222
],
[
221,
223
],
[
219,
224
],
[
214,
225
],
[
225,
226
],
[
225,
227
],
[
227,
228
],
[
227,
229
],
[
214,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
231,
235
],
[
230,
236
],
[
236,
237
],
[
237,
238
],
[
237,
239
],
[
230,
240
],
[
240,
241
],
[
241,
242
],
[
214,
243
],
[
243,
244
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\nclass Main {\n\n public static void main(String args[]) throws IOException{\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t String[] string = br.readLine().split(\" \");\n int n = Integer.parseInt (string[0]);\n\t int Quantum = Integer.parseInt(string[1]);\n\n\t Queue queue = new Queue();\n\t queue.initialize();\n\n\t for(int i = 0;i < n; i++){\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }\n\n\t int pasttime = 0;\n\t while( queue.isEmpty() == false){\n String[] tmpstring = queue.dequeue().split(\" \");\n //System.out.println(tmpstring[0]+ \" \" + tmpstring[1]);\n int tmptime = Integer.parseInt(tmpstring[1]);\n\n if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }\n\t }\n\n }\n}\n\nclass Queue{\n int head , tail;\n int MAX = 100000;\n String[] Q = new String[MAX];\n\n\n void initialize(){\n \thead = tail = 0;\n }\n\n boolean isEmpty(){\n \treturn head == tail;\n }\n\n boolean isFull(){\n \treturn head == (tail + 1) % MAX;\n }\n\n void enqueue(String x){\n \tif( isFull() ){\n \t\tSystem.out.println(\" ??¨?????????????????????????????????\");\n \t}\n \t Q[tail] = x;\n\n \tif(tail + 1 == MAX){\n \t\t tail = 0;\n \t}else{\n \t\t tail++;\n \t}\n\n }\n\n String dequeue(){\n \tif( isEmpty() ){\n \t\tSystem.out.println(\" ??¨???????????¢?????????????????????\");\n \t}\n \tString x = Q[head];\n\n \tif(head + 1 == MAX){\n \t\thead = 0;\n \t }else{\n \t head++;\n \t }\n return x;\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"class Main {\n\n public static void main(String args[]) throws IOException{\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t String[] string = br.readLine().split(\" \");\n int n = Integer.parseInt (string[0]);\n\t int Quantum = Integer.parseInt(string[1]);\n\n\t Queue queue = new Queue();\n\t queue.initialize();\n\n\t for(int i = 0;i < n; i++){\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }\n\n\t int pasttime = 0;\n\t while( queue.isEmpty() == false){\n String[] tmpstring = queue.dequeue().split(\" \");\n //System.out.println(tmpstring[0]+ \" \" + tmpstring[1]);\n int tmptime = Integer.parseInt(tmpstring[1]);\n\n if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }\n\t }\n\n }\n}",
"Main",
"public static void main(String args[]) throws IOException{\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t String[] string = br.readLine().split(\" \");\n int n = Integer.parseInt (string[0]);\n\t int Quantum = Integer.parseInt(string[1]);\n\n\t Queue queue = new Queue();\n\t queue.initialize();\n\n\t for(int i = 0;i < n; i++){\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }\n\n\t int pasttime = 0;\n\t while( queue.isEmpty() == false){\n String[] tmpstring = queue.dequeue().split(\" \");\n //System.out.println(tmpstring[0]+ \" \" + tmpstring[1]);\n int tmptime = Integer.parseInt(tmpstring[1]);\n\n if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }\n\t }\n\n }",
"main",
"{\n\t BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t String[] string = br.readLine().split(\" \");\n int n = Integer.parseInt (string[0]);\n\t int Quantum = Integer.parseInt(string[1]);\n\n\t Queue queue = new Queue();\n\t queue.initialize();\n\n\t for(int i = 0;i < n; i++){\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }\n\n\t int pasttime = 0;\n\t while( queue.isEmpty() == false){\n String[] tmpstring = queue.dequeue().split(\" \");\n //System.out.println(tmpstring[0]+ \" \" + tmpstring[1]);\n int tmptime = Integer.parseInt(tmpstring[1]);\n\n if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }\n\t }\n\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] string = br.readLine().split(\" \");",
"string",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt (string[0]);",
"n",
"Integer.parseInt (string[0])",
"Integer.parseInt",
"Integer",
"string[0]",
"string",
"0",
"int Quantum = Integer.parseInt(string[1]);",
"Quantum",
"Integer.parseInt(string[1])",
"Integer.parseInt",
"Integer",
"string[1]",
"string",
"1",
"Queue queue = new Queue();",
"queue",
"new Queue()",
"queue.initialize()",
"queue.initialize",
"queue",
"for(int i = 0;i < n; i++){\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }",
"{\n\t\t String date = br.readLine();\n\t\t queue.enqueue(date);\n\t }",
"String date = br.readLine();",
"date",
"br.readLine()",
"br.readLine",
"br",
"queue.enqueue(date)",
"queue.enqueue",
"queue",
"date",
"int pasttime = 0;",
"pasttime",
"0",
"while( queue.isEmpty() == false){\n String[] tmpstring = queue.dequeue().split(\" \");\n //System.out.println(tmpstring[0]+ \" \" + tmpstring[1]);\n int tmptime = Integer.parseInt(tmpstring[1]);\n\n if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }\n\t }",
"queue.isEmpty() == false",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"false",
"{\n String[] tmpstring = queue.dequeue().split(\" \");\n //System.out.println(tmpstring[0]+ \" \" + tmpstring[1]);\n int tmptime = Integer.parseInt(tmpstring[1]);\n\n if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }\n\t }",
"String[] tmpstring = queue.dequeue().split(\" \");",
"tmpstring",
"queue.dequeue().split(\" \")",
"queue.dequeue().split",
"queue.dequeue()",
"queue.dequeue",
"queue",
"\" \"",
"int tmptime = Integer.parseInt(tmpstring[1]);",
"tmptime",
"Integer.parseInt(tmpstring[1])",
"Integer.parseInt",
"Integer",
"tmpstring[1]",
"tmpstring",
"1",
"if( tmptime > Quantum ){\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }\n else{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }",
"tmptime > Quantum",
"tmptime",
"Quantum",
"{\n pasttime += Quantum;\n String time = String.valueOf( tmptime - Quantum);\n queue.enqueue(tmpstring[0]+\" \"+time);\n\n }",
"pasttime += Quantum",
"pasttime",
"Quantum",
"String time = String.valueOf( tmptime - Quantum);",
"time",
"String.valueOf( tmptime - Quantum)",
"String.valueOf",
"String",
"tmptime - Quantum",
"tmptime",
"Quantum",
"queue.enqueue(tmpstring[0]+\" \"+time)",
"queue.enqueue",
"queue",
"tmpstring[0]+\" \"+time",
"tmpstring[0]+\" \"+time",
"tmpstring[0]",
"tmpstring",
"0",
"\" \"",
"time",
"{\n \t pasttime += tmptime;\n \t System.out.println(tmpstring[0]+\" \"+pasttime);\n }",
"pasttime += tmptime",
"pasttime",
"tmptime",
"System.out.println(tmpstring[0]+\" \"+pasttime)",
"System.out.println",
"System.out",
"System",
"System.out",
"tmpstring[0]+\" \"+pasttime",
"tmpstring[0]+\" \"+pasttime",
"tmpstring[0]",
"tmpstring",
"0",
"\" \"",
"pasttime",
"String args[]",
"args",
"class Queue{\n int head , tail;\n int MAX = 100000;\n String[] Q = new String[MAX];\n\n\n void initialize(){\n \thead = tail = 0;\n }\n\n boolean isEmpty(){\n \treturn head == tail;\n }\n\n boolean isFull(){\n \treturn head == (tail + 1) % MAX;\n }\n\n void enqueue(String x){\n \tif( isFull() ){\n \t\tSystem.out.println(\" ??¨?????????????????????????????????\");\n \t}\n \t Q[tail] = x;\n\n \tif(tail + 1 == MAX){\n \t\t tail = 0;\n \t}else{\n \t\t tail++;\n \t}\n\n }\n\n String dequeue(){\n \tif( isEmpty() ){\n \t\tSystem.out.println(\" ??¨???????????¢?????????????????????\");\n \t}\n \tString x = Q[head];\n\n \tif(head + 1 == MAX){\n \t\thead = 0;\n \t }else{\n \t head++;\n \t }\n return x;\n }\n}",
"Queue",
"int head",
"head",
"tail;",
"tail",
"int MAX = 100000;",
"MAX",
"100000",
"String[] Q = new String[MAX];",
"Q",
"new String[MAX]",
"MAX",
"void initialize(){\n \thead = tail = 0;\n }",
"initialize",
"{\n \thead = tail = 0;\n }",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"boolean isEmpty(){\n \treturn head == tail;\n }",
"isEmpty",
"{\n \treturn head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"boolean isFull(){\n \treturn head == (tail + 1) % MAX;\n }",
"isFull",
"{\n \treturn 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(String x){\n \tif( isFull() ){\n \t\tSystem.out.println(\" ??¨?????????????????????????????????\");\n \t}\n \t Q[tail] = x;\n\n \tif(tail + 1 == MAX){\n \t\t tail = 0;\n \t}else{\n \t\t tail++;\n \t}\n\n }",
"enqueue",
"{\n \tif( isFull() ){\n \t\tSystem.out.println(\" ??¨?????????????????????????????????\");\n \t}\n \t Q[tail] = x;\n\n \tif(tail + 1 == MAX){\n \t\t tail = 0;\n \t}else{\n \t\t tail++;\n \t}\n\n }",
"if( isFull() ){\n \t\tSystem.out.println(\" ??¨?????????????????????????????????\");\n \t}",
"isFull()",
"isFull",
"{\n \t\tSystem.out.println(\" ??¨?????????????????????????????????\");\n \t}",
"System.out.println(\" ??¨?????????????????????????????????\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\" ??¨?????????????????????????????????\"",
"Q[tail] = x",
"Q[tail]",
"Q",
"tail",
"x",
"if(tail + 1 == MAX){\n \t\t tail = 0;\n \t}else{\n \t\t tail++;\n \t}",
"tail + 1 == MAX",
"tail + 1",
"tail",
"1",
"MAX",
"{\n \t\t tail = 0;\n \t}",
"tail = 0",
"tail",
"0",
"{\n \t\t tail++;\n \t}",
"tail++",
"tail",
"String x",
"x",
"String dequeue(){\n \tif( isEmpty() ){\n \t\tSystem.out.println(\" ??¨???????????¢?????????????????????\");\n \t}\n \tString x = Q[head];\n\n \tif(head + 1 == MAX){\n \t\thead = 0;\n \t }else{\n \t head++;\n \t }\n return x;\n }",
"dequeue",
"{\n \tif( isEmpty() ){\n \t\tSystem.out.println(\" ??¨???????????¢?????????????????????\");\n \t}\n \tString x = Q[head];\n\n \tif(head + 1 == MAX){\n \t\thead = 0;\n \t }else{\n \t head++;\n \t }\n return x;\n }",
"if( isEmpty() ){\n \t\tSystem.out.println(\" ??¨???????????¢?????????????????????\");\n \t}",
"isEmpty()",
"isEmpty",
"{\n \t\tSystem.out.println(\" ??¨???????????¢?????????????????????\");\n \t}",
"System.out.println(\" ??¨???????????¢?????????????????????\")",
"System.out.println",
"System.out",
"System",
"System.out",
"\" ??¨???????????¢?????????????????????\"",
"String x = Q[head];",
"x",
"Q[head]",
"Q",
"head",
"if(head + 1 == MAX){\n \t\thead = 0;\n \t }else{\n \t head++;\n \t }",
"head + 1 == MAX",
"head + 1",
"head",
"1",
"MAX",
"{\n \t\thead = 0;\n \t }",
"head = 0",
"head",
"0",
"{\n \t head++;\n \t }",
"head++",
"head",
"return x;",
"x"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] string = br.readLine().split(" ");
int n = Integer.parseInt (string[0]);
int Quantum = Integer.parseInt(string[1]);
Queue queue = new Queue();
queue.initialize();
for(int i = 0;i < n; i++){
String date = br.readLine();
queue.enqueue(date);
}
int pasttime = 0;
while( queue.isEmpty() == false){
String[] tmpstring = queue.dequeue().split(" ");
//System.out.println(tmpstring[0]+ " " + tmpstring[1]);
int tmptime = Integer.parseInt(tmpstring[1]);
if( tmptime > Quantum ){
pasttime += Quantum;
String time = String.valueOf( tmptime - Quantum);
queue.enqueue(tmpstring[0]+" "+time);
}
else{
pasttime += tmptime;
System.out.println(tmpstring[0]+" "+pasttime);
}
}
}
}
class Queue{
int head , tail;
int MAX = 100000;
String[] Q = new String[MAX];
void initialize(){
head = tail = 0;
}
boolean isEmpty(){
return head == tail;
}
boolean isFull(){
return head == (tail + 1) % MAX;
}
void enqueue(String x){
if( isFull() ){
System.out.println(" ??¨?????????????????????????????????");
}
Q[tail] = x;
if(tail + 1 == MAX){
tail = 0;
}else{
tail++;
}
}
String dequeue(){
if( isEmpty() ){
System.out.println(" ??¨???????????¢?????????????????????");
}
String x = Q[head];
if(head + 1 == MAX){
head = 0;
}else{
head++;
}
return x;
}
} |
[
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,
4,
18,
13,
41,
13,
20,
41,
13,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
18,
13,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
131,
8
],
[
131,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
26,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
11,
35
],
[
35,
36
],
[
35,
37
],
[
11,
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
],
[
51,
70
],
[
70,
71
],
[
71,
72
],
[
11,
73
],
[
73,
74
],
[
73,
75
],
[
11,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
76,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
92,
94
],
[
89,
95
],
[
81,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
81,
101
],
[
101,
102
],
[
101,
103
],
[
81,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
111,
116
],
[
117,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
117,
122
],
[
104,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
9,
128
],
[
128,
129
],
[
0,
130
],
[
130,
131
],
[
130,
132
]
] | [
"import java.util.Scanner;\nimport java.util.LinkedList;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint nProcesses = input.nextInt();\n\t\tint quantum = input.nextInt();\n\t\tinput.nextLine(); // Clear \\n.\n\t\t\n\t\tLinkedList<Integer> queue = new LinkedList<>();\n\t\t\n\t\tString[] processes = new String[nProcesses];\n\t\tint[] times = new int[nProcesses];\n\t\t\n\t\tfor (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}\n\n\t\tint elapsedTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}\n\t\t\n\t}\t\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint nProcesses = input.nextInt();\n\t\tint quantum = input.nextInt();\n\t\tinput.nextLine(); // Clear \\n.\n\t\t\n\t\tLinkedList<Integer> queue = new LinkedList<>();\n\t\t\n\t\tString[] processes = new String[nProcesses];\n\t\tint[] times = new int[nProcesses];\n\t\t\n\t\tfor (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}\n\n\t\tint elapsedTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}\n\t\t\n\t}\t\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint nProcesses = input.nextInt();\n\t\tint quantum = input.nextInt();\n\t\tinput.nextLine(); // Clear \\n.\n\t\t\n\t\tLinkedList<Integer> queue = new LinkedList<>();\n\t\t\n\t\tString[] processes = new String[nProcesses];\n\t\tint[] times = new int[nProcesses];\n\t\t\n\t\tfor (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}\n\n\t\tint elapsedTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tScanner input = new Scanner(System.in);\n\t\tint nProcesses = input.nextInt();\n\t\tint quantum = input.nextInt();\n\t\tinput.nextLine(); // Clear \\n.\n\t\t\n\t\tLinkedList<Integer> queue = new LinkedList<>();\n\t\t\n\t\tString[] processes = new String[nProcesses];\n\t\tint[] times = new int[nProcesses];\n\t\t\n\t\tfor (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}\n\n\t\tint elapsedTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}\n\t\t\n\t}",
"Scanner input = new Scanner(System.in);",
"input",
"new Scanner(System.in)",
"int nProcesses = input.nextInt();",
"nProcesses",
"input.nextInt()",
"input.nextInt",
"input",
"int quantum = input.nextInt();",
"quantum",
"input.nextInt()",
"input.nextInt",
"input",
"input.nextLine()",
"input.nextLine",
"input",
"LinkedList<Integer> queue = new LinkedList<>();",
"queue",
"new LinkedList<>()",
"String[] processes = new String[nProcesses];",
"processes",
"new String[nProcesses]",
"nProcesses",
"int[] times = new int[nProcesses];",
"times",
"new int[nProcesses]",
"nProcesses",
"for (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < nProcesses",
"i",
"nProcesses",
"i++",
"i++",
"i",
"{\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}",
"{\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}",
"processes[i] = input.next()",
"processes[i]",
"processes",
"i",
"input.next()",
"input.next",
"input",
"times[i] = input.nextInt()",
"times[i]",
"times",
"i",
"input.nextInt()",
"input.nextInt",
"input",
"queue.add(i)",
"queue.add",
"queue",
"i",
"input.nextLine()",
"input.nextLine",
"input",
"int elapsedTime = 0;",
"elapsedTime",
"0",
"while (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}",
"int processID = queue.removeFirst();",
"processID",
"queue.removeFirst()",
"queue.removeFirst",
"queue",
"int timeSpent = Math.min(times[processID], quantum);",
"timeSpent",
"Math.min(times[processID], quantum)",
"Math.min",
"Math",
"times[processID]",
"times",
"processID",
"quantum",
"times[processID] -= timeSpent",
"times[processID]",
"times",
"processID",
"timeSpent",
"elapsedTime += timeSpent",
"elapsedTime",
"timeSpent",
"if (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}",
"times[processID] == 0",
"times[processID]",
"times",
"processID",
"0",
"{\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t}",
"System.out.println(processes[processID] + \" \" + elapsedTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"processes[processID] + \" \" + elapsedTime",
"processes[processID] + \" \" + elapsedTime",
"processes[processID]",
"processes",
"processID",
"\" \"",
"elapsedTime",
"{\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}",
"queue.addLast(processID)",
"queue.addLast",
"queue",
"processID",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint nProcesses = input.nextInt();\n\t\tint quantum = input.nextInt();\n\t\tinput.nextLine(); // Clear \\n.\n\t\t\n\t\tLinkedList<Integer> queue = new LinkedList<>();\n\t\t\n\t\tString[] processes = new String[nProcesses];\n\t\tint[] times = new int[nProcesses];\n\t\t\n\t\tfor (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}\n\n\t\tint elapsedTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}\n\t\t\n\t}\t\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\t\tint nProcesses = input.nextInt();\n\t\tint quantum = input.nextInt();\n\t\tinput.nextLine(); // Clear \\n.\n\t\t\n\t\tLinkedList<Integer> queue = new LinkedList<>();\n\t\t\n\t\tString[] processes = new String[nProcesses];\n\t\tint[] times = new int[nProcesses];\n\t\t\n\t\tfor (int i = 0; i < nProcesses; i++) {\n\t\t\tprocesses[i] = input.next();\n\t\t\ttimes[i] = input.nextInt();\n\t\t\tqueue.add(i); // Add process to queue.\n\t\t\tinput.nextLine(); // Clear \\n.\n\t\t}\n\n\t\tint elapsedTime = 0;\n\t\twhile (!queue.isEmpty()) {\n\t\t\tint processID = queue.removeFirst();\n\t\t\tint timeSpent = Math.min(times[processID], quantum);\n\t\t\ttimes[processID] -= timeSpent;\n\t\t\telapsedTime += timeSpent;\n\t\t\t\n\t\t\tif (times[processID] == 0) {\n\t\t\t\tSystem.out.println(processes[processID] + \" \" + elapsedTime);\n\t\t\t} else {\n\t\t\t\tqueue.addLast(processID);\n\t\t\t}\n\t\t}\n\t\t\n\t}\t\n}",
"Main"
] | import java.util.Scanner;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int nProcesses = input.nextInt();
int quantum = input.nextInt();
input.nextLine(); // Clear \n.
LinkedList<Integer> queue = new LinkedList<>();
String[] processes = new String[nProcesses];
int[] times = new int[nProcesses];
for (int i = 0; i < nProcesses; i++) {
processes[i] = input.next();
times[i] = input.nextInt();
queue.add(i); // Add process to queue.
input.nextLine(); // Clear \n.
}
int elapsedTime = 0;
while (!queue.isEmpty()) {
int processID = queue.removeFirst();
int timeSpent = Math.min(times[processID], quantum);
times[processID] -= timeSpent;
elapsedTime += timeSpent;
if (times[processID] == 0) {
System.out.println(processes[processID] + " " + elapsedTime);
} else {
queue.addLast(processID);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
41,
13,
6,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
20,
13,
12,
13,
30,
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,
0,
18,
13,
13,
20,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
13,
17,
0,
13,
2,
13,
17,
42,
2,
13,
13,
30,
41,
13,
4,
13,
41,
13,
4,
18,
13,
18,
13,
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,
13,
0,
13,
17,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
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,
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
],
[
6,
7
],
[
4,
8
],
[
8,
9
],
[
0,
10
],
[
215,
11
],
[
215,
12
],
[
12,
13
],
[
215,
14
],
[
14,
15
],
[
215,
16
],
[
16,
17
],
[
16,
18
],
[
215,
19
],
[
19,
20
],
[
19,
21
],
[
215,
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
],
[
39,
41
],
[
25,
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
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
54,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
54,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
25,
78
],
[
78,
79
],
[
78,
80
],
[
25,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
83,
85
],
[
25,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
90,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
100,
101
],
[
100,
102
],
[
97,
103
],
[
90,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
104,
108
],
[
90,
109
],
[
109,
110
],
[
109,
111
],
[
90,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
112,
118
],
[
118,
119
],
[
118,
120
],
[
112,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
122,
127
],
[
122,
128
],
[
128,
129
],
[
128,
130
],
[
122,
131
],
[
23,
132
],
[
132,
133
],
[
215,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
139,
141
],
[
215,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
215,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
215,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
164,
165
],
[
163,
166
],
[
166,
167
],
[
167,
168
],
[
162,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
162,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
174,
180
],
[
180,
181
],
[
180,
182
],
[
174,
183
],
[
183,
184
],
[
160,
185
],
[
185,
186
],
[
215,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
190,
193
],
[
193,
194
],
[
194,
195
],
[
189,
196
],
[
196,
197
],
[
196,
198
],
[
198,
199
],
[
198,
200
],
[
189,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
203,
205
],
[
202,
206
],
[
201,
207
],
[
207,
208
],
[
207,
209
],
[
201,
210
],
[
210,
211
],
[
189,
212
],
[
212,
213
],
[
0,
214
],
[
214,
215
],
[
214,
216
]
] | [
"import java.util.Scanner;\n\nclass Process {\n String name;\n int time;\n}\n\npublic class Main {\n private static int head, tail;\n private final static int MAX = 100000;\n private static Process[] Queue = new Process[MAX];\n\n public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int elaps = 0;\n for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }\n\n private static void initialize() {\n head = tail = 0;\n }\n\n private static boolean isEmpty() {\n return head == tail;\n }\n\n private static boolean isFull() {\n return head == (tail + 1) % MAX;\n // if (tail == MAX) {\n // return head == 0;\n // } else\n // return tail - 1 == head;\n }\n\n private static void enqueue(Process x) {\n if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }\n Queue[tail] = x;\n if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;\n }\n\n private static Process dequeue() {\n if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }\n Process x = Queue[head];\n if (head + 1 == MAX)\n head = 0;\n else\n head++;\n return x;\n }\n\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Process {\n String name;\n int time;\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public class Main {\n private static int head, tail;\n private final static int MAX = 100000;\n private static Process[] Queue = new Process[MAX];\n\n public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int elaps = 0;\n for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }\n\n private static void initialize() {\n head = tail = 0;\n }\n\n private static boolean isEmpty() {\n return head == tail;\n }\n\n private static boolean isFull() {\n return head == (tail + 1) % MAX;\n // if (tail == MAX) {\n // return head == 0;\n // } else\n // return tail - 1 == head;\n }\n\n private static void enqueue(Process x) {\n if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }\n Queue[tail] = x;\n if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;\n }\n\n private static Process dequeue() {\n if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }\n Process x = Queue[head];\n if (head + 1 == MAX)\n head = 0;\n else\n head++;\n return x;\n }\n\n}",
"Main",
"private static int head",
"head",
"tail;",
"tail",
"private final static int MAX = 100000;",
"MAX",
"100000",
"private static Process[] Queue = new Process[MAX];",
"Queue",
"new Process[MAX]",
"MAX",
"public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int elaps = 0;\n for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int elaps = 0;\n for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }",
"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 elaps = 0;",
"elaps",
"0",
"for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= n",
"i",
"n",
"i++",
"i++",
"i",
"{\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }",
"{\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }",
"Queue[i] = new Process()",
"Queue[i]",
"Queue",
"i",
"new Process()",
"Queue[i].name = sc.next()",
"Queue[i].name",
"Queue[i]",
"Queue",
"i",
"Queue[i].name",
"sc.next()",
"sc.next",
"sc",
"Queue[i].time = sc.nextInt()",
"Queue[i].time",
"Queue[i]",
"Queue",
"i",
"Queue[i].time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"head = 1",
"head",
"1",
"tail = n + 1",
"tail",
"n + 1",
"n",
"1",
"while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }",
"head != tail",
"head",
"tail",
"{\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }",
"Process p = dequeue();",
"p",
"dequeue()",
"dequeue",
"int time = Math.min(p.time, q);",
"time",
"Math.min(p.time, q)",
"Math.min",
"Math",
"p.time",
"p",
"p.time",
"q",
"p.time -= time",
"p.time",
"p",
"p.time",
"time",
"elaps += time",
"elaps",
"time",
"if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }",
"p.time > 0",
"p.time",
"p",
"p.time",
"0",
"enqueue(p)",
"enqueue",
"p",
"{\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }",
"System.out.printf(\"%s %d\\n\", p.name, elaps)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"p.name",
"p",
"p.name",
"elaps",
"final String[] args",
"args",
"private static void initialize() {\n head = tail = 0;\n }",
"initialize",
"{\n head = tail = 0;\n }",
"head = tail = 0",
"head",
"tail = 0",
"tail",
"0",
"private static boolean isEmpty() {\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"private static boolean isFull() {\n return head == (tail + 1) % MAX;\n // if (tail == MAX) {\n // return head == 0;\n // } else\n // return tail - 1 == head;\n }",
"isFull",
"{\n return head == (tail + 1) % MAX;\n // if (tail == MAX) {\n // return head == 0;\n // } else\n // return tail - 1 == head;\n }",
"return head == (tail + 1) % MAX;",
"head == (tail + 1) % MAX",
"head",
"(tail + 1) % MAX",
"(tail + 1)",
"tail",
"1",
"MAX",
"private static void enqueue(Process x) {\n if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }\n Queue[tail] = x;\n if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;\n }",
"enqueue",
"{\n if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }\n Queue[tail] = x;\n if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;\n }",
"if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }",
"isFull()",
"isFull",
"{\n throw new Error(\"Queue Over Flow\");\n }",
"throw new Error(\"Queue Over Flow\");",
"new Error(\"Queue Over Flow\")",
"Queue[tail] = x",
"Queue[tail]",
"Queue",
"tail",
"x",
"if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;",
"tail + 1 == MAX",
"tail + 1",
"tail",
"1",
"MAX",
"tail = 0",
"tail",
"0",
"tail++",
"tail",
"Process x",
"x",
"private static Process dequeue() {\n if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }\n Process x = Queue[head];\n if (head + 1 == MAX)\n head = 0;\n else\n head++;\n return x;\n }",
"dequeue",
"{\n if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }\n Process x = Queue[head];\n if (head + 1 == MAX)\n head = 0;\n else\n head++;\n return x;\n }",
"if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }",
"isEmpty()",
"isEmpty",
"{\n throw new Error(\"Queue Under Flow\");\n }",
"throw new Error(\"Queue Under Flow\");",
"new Error(\"Queue Under Flow\")",
"Process x = Queue[head];",
"x",
"Queue[head]",
"Queue",
"head",
"if (head + 1 == MAX)\n head = 0;\n else\n head++;",
"head + 1 == MAX",
"head + 1",
"head",
"1",
"MAX",
"head = 0",
"head",
"0",
"head++",
"head",
"return x;",
"x",
"public class Main {\n private static int head, tail;\n private final static int MAX = 100000;\n private static Process[] Queue = new Process[MAX];\n\n public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int elaps = 0;\n for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }\n\n private static void initialize() {\n head = tail = 0;\n }\n\n private static boolean isEmpty() {\n return head == tail;\n }\n\n private static boolean isFull() {\n return head == (tail + 1) % MAX;\n // if (tail == MAX) {\n // return head == 0;\n // } else\n // return tail - 1 == head;\n }\n\n private static void enqueue(Process x) {\n if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }\n Queue[tail] = x;\n if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;\n }\n\n private static Process dequeue() {\n if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }\n Process x = Queue[head];\n if (head + 1 == MAX)\n head = 0;\n else\n head++;\n return x;\n }\n\n}",
"public class Main {\n private static int head, tail;\n private final static int MAX = 100000;\n private static Process[] Queue = new Process[MAX];\n\n public static void main(final String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n int elaps = 0;\n for (int i = 1; i <= n; i++) {\n Queue[i] = new Process();\n Queue[i].name = sc.next();\n Queue[i].time = sc.nextInt();\n }\n head = 1;\n tail = n + 1;\n while (head != tail) {\n Process p = dequeue();\n int time = Math.min(p.time, q);\n p.time -= time;\n elaps += time;\n if (p.time > 0)\n enqueue(p);\n else {\n System.out.printf(\"%s %d\\n\", p.name, elaps);\n }\n }\n }\n\n private static void initialize() {\n head = tail = 0;\n }\n\n private static boolean isEmpty() {\n return head == tail;\n }\n\n private static boolean isFull() {\n return head == (tail + 1) % MAX;\n // if (tail == MAX) {\n // return head == 0;\n // } else\n // return tail - 1 == head;\n }\n\n private static void enqueue(Process x) {\n if (isFull()) {\n throw new Error(\"Queue Over Flow\");\n }\n Queue[tail] = x;\n if (tail + 1 == MAX)\n tail = 0;\n else\n tail++;\n }\n\n private static Process dequeue() {\n if (isEmpty()) {\n throw new Error(\"Queue Under Flow\");\n }\n Process x = Queue[head];\n if (head + 1 == MAX)\n head = 0;\n else\n head++;\n return x;\n }\n\n}",
"Main"
] | import java.util.Scanner;
class Process {
String name;
int time;
}
public class Main {
private static int head, tail;
private final static int MAX = 100000;
private static Process[] Queue = new Process[MAX];
public static void main(final String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
int elaps = 0;
for (int i = 1; i <= n; i++) {
Queue[i] = new Process();
Queue[i].name = sc.next();
Queue[i].time = sc.nextInt();
}
head = 1;
tail = n + 1;
while (head != tail) {
Process p = dequeue();
int time = Math.min(p.time, q);
p.time -= time;
elaps += time;
if (p.time > 0)
enqueue(p);
else {
System.out.printf("%s %d\n", p.name, elaps);
}
}
}
private static void initialize() {
head = tail = 0;
}
private static boolean isEmpty() {
return head == tail;
}
private static boolean isFull() {
return head == (tail + 1) % MAX;
// if (tail == MAX) {
// return head == 0;
// } else
// return tail - 1 == head;
}
private static void enqueue(Process x) {
if (isFull()) {
throw new Error("Queue Over Flow");
}
Queue[tail] = x;
if (tail + 1 == MAX)
tail = 0;
else
tail++;
}
private static Process dequeue() {
if (isEmpty()) {
throw new Error("Queue Under Flow");
}
Process x = Queue[head];
if (head + 1 == MAX)
head = 0;
else
head++;
return x;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
0,
13,
4,
18,
13,
0,
13,
13,
0,
13,
17,
41,
13,
20,
2,
13,
17,
41,
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,
42,
17,
30,
14,
2,
13,
13,
3,
14,
2,
13,
18,
13,
13,
30,
0,
13,
2,
18,
13,
13,
13,
0,
13,
13,
30,
0,
13,
17,
0,
13,
18,
13,
13,
0,
13,
18,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
17,
30,
40,
13,
14,
2,
13,
17,
30,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
9,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
2,
13,
17,
30,
0,
13,
17,
30,
40,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
182,
5
],
[
182,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
8,
11
],
[
11,
12
],
[
8,
13
],
[
13,
14
],
[
8,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
8,
19
],
[
19,
20
],
[
8,
21
],
[
21,
22
],
[
21,
23
],
[
8,
24
],
[
24,
25
],
[
8,
26
],
[
26,
27
],
[
26,
28
],
[
8,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
8,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
8,
39
],
[
39,
40
],
[
39,
41
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
48,
49
],
[
48,
50
],
[
8,
51
],
[
51,
52
],
[
51,
53
],
[
54,
55
],
[
54,
56
],
[
8,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
57,
62
],
[
62,
63
],
[
62,
64
],
[
57,
65
],
[
65,
66
],
[
66,
67
],
[
57,
68
],
[
69,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
70,
74
],
[
74,
75
],
[
75,
76
],
[
69,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
8,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
88,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
95,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
98,
106
],
[
106,
107
],
[
106,
108
],
[
92,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
115,
117
],
[
86,
118
],
[
118,
119
],
[
118,
120
],
[
120,
121
],
[
120,
122
],
[
86,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
128,
130
],
[
123,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
123,
135
],
[
135,
136
],
[
136,
137
],
[
86,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
143,
148
],
[
149,
149
],
[
149,
150
],
[
149,
151
],
[
149,
152
],
[
142,
153
],
[
86,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
86,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
86,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
169,
171
],
[
164,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
164,
176
],
[
176,
177
],
[
177,
178
],
[
6,
179
],
[
179,
180
],
[
0,
181
],
[
181,
182
],
[
181,
183
]
] | [
"import java.util.Scanner;\npublic class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,n,q,tail,head,hz,notime=0;\n\t\tString hzn;\n\tScanner sc = new Scanner(System.in);\n\tn=sc.nextInt();\n\tq=sc.nextInt();\n\ttail=n;\n\t//System.out.println(tail);\n\thead=0;\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }\n while(true){\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}\n \n\t}\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,n,q,tail,head,hz,notime=0;\n\t\tString hzn;\n\tScanner sc = new Scanner(System.in);\n\tn=sc.nextInt();\n\tq=sc.nextInt();\n\ttail=n;\n\t//System.out.println(tail);\n\thead=0;\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }\n while(true){\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}\n \n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,n,q,tail,head,hz,notime=0;\n\t\tString hzn;\n\tScanner sc = new Scanner(System.in);\n\tn=sc.nextInt();\n\tq=sc.nextInt();\n\ttail=n;\n\t//System.out.println(tail);\n\thead=0;\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }\n while(true){\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}\n \n\t}",
"main",
"{\n\t\t// TODO Auto-generated method stub\n\t\tint i,n,q,tail,head,hz,notime=0;\n\t\tString hzn;\n\tScanner sc = new Scanner(System.in);\n\tn=sc.nextInt();\n\tq=sc.nextInt();\n\ttail=n;\n\t//System.out.println(tail);\n\thead=0;\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }\n while(true){\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}\n \n\t}",
"int i",
"i",
"n",
"n",
"q",
"q",
"tail",
"tail",
"head",
"head",
"hz",
"hz",
"notime=0;",
"notime",
"0",
"String hzn;",
"hzn",
"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",
"tail=n",
"tail",
"n",
"head=0",
"head",
"0",
"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(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }",
"{\n \tname[i]=sc.next();\n \ttime[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 \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}",
"true",
"{\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}",
"if(tail==head)break;",
"tail==head",
"tail",
"head",
"break;",
"if(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}",
"q<=time[head]",
"q",
"time[head]",
"time",
"head",
"{\n \thz=time[head]-q;\n \tnotime+=q;\n \t}",
"hz=time[head]-q",
"hz",
"time[head]-q",
"time[head]",
"time",
"head",
"q",
"notime+=q",
"notime",
"q",
"{\n hz=0;\n notime+=time[head];\n \t}",
"hz=0",
"hz",
"0",
"notime+=time[head]",
"notime",
"time[head]",
"time",
"head",
"hzn=name[head]",
"hzn",
"name[head]",
"name",
"head",
"if(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}",
"head+1==n+1",
"head+1",
"head",
"1",
"n+1",
"n",
"1",
"{\n \t\thead=0;\n \t}",
"head=0",
"head",
"0",
"{\n \t\thead++;\n \t}",
"head++",
"head",
"if(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}",
"hz==0",
"hz",
"0",
"{\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}",
"System.out.println(hzn+\" \"+notime)",
"System.out.println",
"System.out",
"System",
"System.out",
"hzn+\" \"+notime",
"hzn+\" \"+notime",
"hzn",
"\" \"",
"notime",
"continue;",
"time[tail]=hz",
"time[tail]",
"time",
"tail",
"hz",
"name[tail]=hzn",
"name[tail]",
"name",
"tail",
"hzn",
"if(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}",
"tail+1 ==n+1",
"tail+1",
"tail",
"1",
"n+1",
"n",
"1",
"{\n \t\ttail=0;\n \t}",
"tail=0",
"tail",
"0",
"{\n \t\ttail++;\n \t}",
"tail++",
"tail",
"String[] args",
"args",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,n,q,tail,head,hz,notime=0;\n\t\tString hzn;\n\tScanner sc = new Scanner(System.in);\n\tn=sc.nextInt();\n\tq=sc.nextInt();\n\ttail=n;\n\t//System.out.println(tail);\n\thead=0;\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }\n while(true){\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}\n \n\t}\n}",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\t\tint i,n,q,tail,head,hz,notime=0;\n\t\tString hzn;\n\tScanner sc = new Scanner(System.in);\n\tn=sc.nextInt();\n\tq=sc.nextInt();\n\ttail=n;\n\t//System.out.println(tail);\n\thead=0;\n String name[]=new String[n+1];\n int time[]=new int[n+1];\n for(i=0;i<n;i++){\n \tname[i]=sc.next();\n \ttime[i]=sc.nextInt();\n }\n while(true){\n \tif(tail==head)break;\n \t\n \tif(q<=time[head]){\n \thz=time[head]-q;\n \tnotime+=q;\n \t}else{\n hz=0;\n notime+=time[head];\n \t}\n \thzn=name[head];\n \tif(head+1==n+1){\n \t\thead=0;\n \t}else{\n \t\thead++;\n \t}\n \tif(hz==0){\n \t\tSystem.out.println(hzn+\" \"+notime);\n \t\tcontinue;\n \t}\n \ttime[tail]=hz;\n \tname[tail]=hzn;\n \tif(tail+1 ==n+1){\n \t\ttail=0;\n \t}else{\n \t\ttail++;\n \t}\n \t}\n \n\t}\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,n,q,tail,head,hz,notime=0;
String hzn;
Scanner sc = new Scanner(System.in);
n=sc.nextInt();
q=sc.nextInt();
tail=n;
//System.out.println(tail);
head=0;
String name[]=new String[n+1];
int time[]=new int[n+1];
for(i=0;i<n;i++){
name[i]=sc.next();
time[i]=sc.nextInt();
}
while(true){
if(tail==head)break;
if(q<=time[head]){
hz=time[head]-q;
notime+=q;
}else{
hz=0;
notime+=time[head];
}
hzn=name[head];
if(head+1==n+1){
head=0;
}else{
head++;
}
if(hz==0){
System.out.println(hzn+" "+notime);
continue;
}
time[tail]=hz;
name[tail]=hzn;
if(tail+1 ==n+1){
tail=0;
}else{
tail++;
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
20,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
117,
5
],
[
117,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
8,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
8,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
25,
33
],
[
33,
34
],
[
34,
35
],
[
25,
36
],
[
37,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
37,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
46,
47
],
[
37,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
52,
53
],
[
53,
54
],
[
37,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
8,
59
],
[
59,
60
],
[
60,
61
],
[
8,
62
],
[
62,
63
],
[
62,
64
],
[
8,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
66,
70
],
[
65,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
71,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
89,
94
],
[
95,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
95,
100
],
[
77,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
107,
109
],
[
101,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
6,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Process {\n\t\t\tprivate String name;\n\t\t\tprivate long time;\n\t\t}\n\t\tQueue<Process> queue = new LinkedList<Process>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}\n\t\tscanner.close();\n\n\t\tlong currentTime = 0;\n\t\t\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}\n\t}\n} \n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Process {\n\t\t\tprivate String name;\n\t\t\tprivate long time;\n\t\t}\n\t\tQueue<Process> queue = new LinkedList<Process>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}\n\t\tscanner.close();\n\n\t\tlong currentTime = 0;\n\t\t\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tclass Process {\n\t\t\tprivate String name;\n\t\t\tprivate long time;\n\t\t}\n\t\tQueue<Process> queue = new LinkedList<Process>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}\n\t\tscanner.close();\n\n\t\tlong currentTime = 0;\n\t\t\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tclass Process {\n\t\t\tprivate String name;\n\t\t\tprivate long time;\n\t\t}\n\t\tQueue<Process> queue = new LinkedList<Process>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}\n\t\tscanner.close();\n\n\t\tlong currentTime = 0;\n\t\t\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}\n\t}",
"Queue<Process> queue = new LinkedList<Process>();",
"queue",
"new LinkedList<Process>()",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"long n = scanner.nextLong();",
"n",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"long q = scanner.nextLong();",
"q",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"for (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i ++",
"i ++",
"i",
"{\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}",
"{\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}",
"Process process = new Process();",
"process",
"new Process()",
"process.name = scanner.next()",
"process.name",
"process",
"process.name",
"scanner.next()",
"scanner.next",
"scanner",
"process.time = scanner.nextLong()",
"process.time",
"process",
"process.time",
"scanner.nextLong()",
"scanner.nextLong",
"scanner",
"queue.add(process)",
"queue.add",
"queue",
"process",
"scanner.close()",
"scanner.close",
"scanner",
"long currentTime = 0;",
"currentTime",
"0",
"while (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}",
"Process currentProcess = queue.remove();",
"currentProcess",
"queue.remove()",
"queue.remove",
"queue",
"if (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}",
"currentProcess.time <= q",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"q",
"{\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t}",
"currentTime += currentProcess.time",
"currentTime",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"System.out.println(currentProcess.name + \" \" + currentTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"currentProcess.name + \" \" + currentTime",
"currentProcess.name + \" \" + currentTime",
"currentProcess.name",
"currentProcess",
"currentProcess.name",
"\" \"",
"currentTime",
"{\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}",
"currentProcess.time -= q",
"currentProcess.time",
"currentProcess",
"currentProcess.time",
"q",
"currentTime += q",
"currentTime",
"q",
"queue.add(currentProcess)",
"queue.add",
"queue",
"currentProcess",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Process {\n\t\t\tprivate String name;\n\t\t\tprivate long time;\n\t\t}\n\t\tQueue<Process> queue = new LinkedList<Process>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}\n\t\tscanner.close();\n\n\t\tlong currentTime = 0;\n\t\t\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tclass Process {\n\t\t\tprivate String name;\n\t\t\tprivate long time;\n\t\t}\n\t\tQueue<Process> queue = new LinkedList<Process>();\t\t\n\t\tScanner scanner = new Scanner(System.in);\n\t\t\n\t\tlong n = scanner.nextLong();\n\t\tlong q = scanner.nextLong();\n\t\t\t\t\n\t\tfor (int i = 0; i < n; i ++) {\n\t\t\tProcess process = new Process();\n\t\t\tprocess.name = scanner.next();\n\t\t\tprocess.time = scanner.nextLong();\n\t\t\tqueue.add(process);\n\t\t}\n\t\tscanner.close();\n\n\t\tlong currentTime = 0;\n\t\t\n\t\twhile (queue.size() > 0) {\n\t\t\tProcess currentProcess = queue.remove();\n\t\t\t\n\t\t\tif (currentProcess.time <= q) {\n\t\t\t\tcurrentTime += currentProcess.time;\n\t\t\t\tSystem.out.println(currentProcess.name + \" \" + currentTime);\n\t\t\t} else {\n\t\t\t\tcurrentProcess.time -= q;\n\t\t\t\tcurrentTime += q;\n\t\t\t\tqueue.add(currentProcess);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
class Process {
private String name;
private long time;
}
Queue<Process> queue = new LinkedList<Process>();
Scanner scanner = new Scanner(System.in);
long n = scanner.nextLong();
long q = scanner.nextLong();
for (int i = 0; i < n; i ++) {
Process process = new Process();
process.name = scanner.next();
process.time = scanner.nextLong();
queue.add(process);
}
scanner.close();
long currentTime = 0;
while (queue.size() > 0) {
Process currentProcess = queue.remove();
if (currentProcess.time <= q) {
currentTime += currentProcess.time;
System.out.println(currentProcess.name + " " + currentTime);
} else {
currentProcess.time -= q;
currentTime += q;
queue.add(currentProcess);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
29,
4,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
13,
18,
13,
17,
41,
13,
4,
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,
4,
18,
13,
17,
4,
18,
13,
18,
13,
17,
4,
13,
18,
13,
17,
4,
18,
13,
18,
13,
17,
41,
13,
17,
42,
2,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
2,
4,
18,
13,
13,
13,
14,
2,
13,
17,
30,
4,
18,
13,
13,
4,
18,
13,
13,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
13,
4,
18,
13,
2,
2,
13,
17,
4,
18,
13,
13,
4,
18,
13,
13,
17,
40,
13,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
4,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
0,
19
],
[
191,
20
],
[
191,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
21,
29
],
[
29,
30
],
[
191,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
42,
43
],
[
39,
44
],
[
33,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
47,
49
],
[
49,
50
],
[
49,
51
],
[
33,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
56,
58
],
[
33,
59
],
[
59,
60
],
[
59,
61
],
[
33,
62
],
[
62,
63
],
[
62,
64
],
[
33,
65
],
[
65,
66
],
[
65,
67
],
[
33,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
68,
73
],
[
73,
74
],
[
73,
75
],
[
68,
76
],
[
76,
77
],
[
77,
78
],
[
68,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
83,
88
],
[
80,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
92,
94
],
[
89,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
97,
99
],
[
80,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
103,
104
],
[
103,
105
],
[
33,
106
],
[
106,
107
],
[
106,
108
],
[
33,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
113,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
121,
126
],
[
113,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
132,
135
],
[
131,
136
],
[
136,
137
],
[
137,
138
],
[
136,
139
],
[
136,
140
],
[
131,
141
],
[
141,
142
],
[
141,
143
],
[
127,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
144,
151
],
[
151,
152
],
[
152,
153
],
[
151,
154
],
[
155,
155
],
[
155,
156
],
[
155,
157
],
[
155,
158
],
[
158,
159
],
[
159,
160
],
[
158,
161
],
[
144,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
162,
166
],
[
144,
167
],
[
167,
168
],
[
33,
169
],
[
169,
170
],
[
169,
171
],
[
169,
172
],
[
173,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
174,
179
],
[
31,
180
],
[
180,
181
],
[
191,
182
],
[
182,
183
],
[
182,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
182,
188
],
[
188,
189
],
[
0,
190
],
[
190,
191
],
[
190,
192
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.Queue;\n\n/**\n * Created by ??\\??? on 2016/12/7.\n */\n\npublic class Main {\n static int si(String s){\n return Integer.parseInt(s);\n }\n static void run(String[] args) throws Exception{\n BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));\n String[] lines = scan.readLine().split(\" \");\n int T = si(lines[0]);\n int H = si(lines[1]);\n Map<String,Integer> m = new HashMap<>();\n Queue<String> q = new ArrayDeque<>();\n Queue<String> done = new ArrayDeque<>();\n for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }\n int time =0;\n while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }\n for(String s: done){\n System.out.println(s);\n }\n }\n public static void main(String[] args) throws Exception{\n run(args);\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.HashMap;",
"HashMap",
"java.util",
"import java.util.Map;",
"Map",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"public class Main {\n static int si(String s){\n return Integer.parseInt(s);\n }\n static void run(String[] args) throws Exception{\n BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));\n String[] lines = scan.readLine().split(\" \");\n int T = si(lines[0]);\n int H = si(lines[1]);\n Map<String,Integer> m = new HashMap<>();\n Queue<String> q = new ArrayDeque<>();\n Queue<String> done = new ArrayDeque<>();\n for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }\n int time =0;\n while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }\n for(String s: done){\n System.out.println(s);\n }\n }\n public static void main(String[] args) throws Exception{\n run(args);\n }\n}",
"Main",
"static int si(String s){\n return Integer.parseInt(s);\n }",
"si",
"{\n return Integer.parseInt(s);\n }",
"return Integer.parseInt(s);",
"Integer.parseInt(s)",
"Integer.parseInt",
"Integer",
"s",
"String s",
"s",
"static void run(String[] args) throws Exception{\n BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));\n String[] lines = scan.readLine().split(\" \");\n int T = si(lines[0]);\n int H = si(lines[1]);\n Map<String,Integer> m = new HashMap<>();\n Queue<String> q = new ArrayDeque<>();\n Queue<String> done = new ArrayDeque<>();\n for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }\n int time =0;\n while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }\n for(String s: done){\n System.out.println(s);\n }\n }",
"run",
"{\n BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));\n String[] lines = scan.readLine().split(\" \");\n int T = si(lines[0]);\n int H = si(lines[1]);\n Map<String,Integer> m = new HashMap<>();\n Queue<String> q = new ArrayDeque<>();\n Queue<String> done = new ArrayDeque<>();\n for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }\n int time =0;\n while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }\n for(String s: done){\n System.out.println(s);\n }\n }",
"BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));",
"scan",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] lines = scan.readLine().split(\" \");",
"lines",
"scan.readLine().split(\" \")",
"scan.readLine().split",
"scan.readLine()",
"scan.readLine",
"scan",
"\" \"",
"int T = si(lines[0]);",
"T",
"si(lines[0])",
"si",
"lines[0]",
"lines",
"0",
"int H = si(lines[1]);",
"H",
"si(lines[1])",
"si",
"lines[1]",
"lines",
"1",
"Map<String,Integer> m = new HashMap<>();",
"m",
"new HashMap<>()",
"Queue<String> q = new ArrayDeque<>();",
"q",
"new ArrayDeque<>()",
"Queue<String> done = new ArrayDeque<>();",
"done",
"new ArrayDeque<>()",
"for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<T",
"i",
"T",
"i++",
"i++",
"i",
"{\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }",
"{\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }",
"lines = scan.readLine().split(\" \")",
"lines",
"scan.readLine().split(\" \")",
"scan.readLine().split",
"scan.readLine()",
"scan.readLine",
"scan",
"\" \"",
"m.put(lines[0],si(lines[1]))",
"m.put",
"m",
"lines[0]",
"lines",
"0",
"si(lines[1])",
"si",
"lines[1]",
"lines",
"1",
"q.add(lines[0])",
"q.add",
"q",
"lines[0]",
"lines",
"0",
"int time =0;",
"time",
"0",
"while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }",
"T>0",
"T",
"0",
"{\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }",
"String w = q.poll();",
"w",
"q.poll()",
"q.poll",
"q",
"int ti = m.get(w)-H;",
"ti",
"m.get(w)-H",
"m.get(w)",
"m.get",
"m",
"w",
"H",
"if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }",
"ti>0",
"ti",
"0",
"{\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }",
"q.add(w)",
"q.add",
"q",
"w",
"m.replace(w,ti)",
"m.replace",
"m",
"w",
"ti",
"time+=H",
"time",
"H",
"{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }",
"time+=m.get(w)",
"time",
"m.get(w)",
"m.get",
"m",
"w",
"done.add(w+\" \"+String.valueOf(time))",
"done.add",
"done",
"w+\" \"+String.valueOf(time)",
"w+\" \"+String.valueOf(time)",
"w",
"\" \"",
"String.valueOf(time)",
"String.valueOf",
"String",
"time",
"m.replace(w,0)",
"m.replace",
"m",
"w",
"0",
"T--",
"T",
"for(String s: done){\n System.out.println(s);\n }",
"String s",
"done",
"{\n System.out.println(s);\n }",
"{\n System.out.println(s);\n }",
"System.out.println(s)",
"System.out.println",
"System.out",
"System",
"System.out",
"s",
"String[] args",
"args",
"public static void main(String[] args) throws Exception{\n run(args);\n }",
"main",
"{\n run(args);\n }",
"run(args)",
"run",
"args",
"String[] args",
"args",
"public class Main {\n static int si(String s){\n return Integer.parseInt(s);\n }\n static void run(String[] args) throws Exception{\n BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));\n String[] lines = scan.readLine().split(\" \");\n int T = si(lines[0]);\n int H = si(lines[1]);\n Map<String,Integer> m = new HashMap<>();\n Queue<String> q = new ArrayDeque<>();\n Queue<String> done = new ArrayDeque<>();\n for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }\n int time =0;\n while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }\n for(String s: done){\n System.out.println(s);\n }\n }\n public static void main(String[] args) throws Exception{\n run(args);\n }\n}",
"public class Main {\n static int si(String s){\n return Integer.parseInt(s);\n }\n static void run(String[] args) throws Exception{\n BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));\n String[] lines = scan.readLine().split(\" \");\n int T = si(lines[0]);\n int H = si(lines[1]);\n Map<String,Integer> m = new HashMap<>();\n Queue<String> q = new ArrayDeque<>();\n Queue<String> done = new ArrayDeque<>();\n for(int i = 0;i<T;i++){\n lines = scan.readLine().split(\" \");\n m.put(lines[0],si(lines[1]));\n q.add(lines[0]);\n }\n int time =0;\n while(T>0){\n String w = q.poll();\n int ti = m.get(w)-H;\n if(ti>0) {\n q.add(w);\n m.replace(w,ti);\n time+=H;\n }\n else{\n time+=m.get(w);\n done.add(w+\" \"+String.valueOf(time));\n m.replace(w,0);\n T--;\n }\n }\n for(String s: done){\n System.out.println(s);\n }\n }\n public static void main(String[] args) throws Exception{\n run(args);\n }\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
/**
* Created by ??\??? on 2016/12/7.
*/
public class Main {
static int si(String s){
return Integer.parseInt(s);
}
static void run(String[] args) throws Exception{
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
String[] lines = scan.readLine().split(" ");
int T = si(lines[0]);
int H = si(lines[1]);
Map<String,Integer> m = new HashMap<>();
Queue<String> q = new ArrayDeque<>();
Queue<String> done = new ArrayDeque<>();
for(int i = 0;i<T;i++){
lines = scan.readLine().split(" ");
m.put(lines[0],si(lines[1]));
q.add(lines[0]);
}
int time =0;
while(T>0){
String w = q.poll();
int ti = m.get(w)-H;
if(ti>0) {
q.add(w);
m.replace(w,ti);
time+=H;
}
else{
time+=m.get(w);
done.add(w+" "+String.valueOf(time));
m.replace(w,0);
T--;
}
}
for(String s: done){
System.out.println(s);
}
}
public static void main(String[] args) throws Exception{
run(args);
}
} |
[
7,
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,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
161,
11
],
[
161,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
18,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
25,
30
],
[
22,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
22,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
41,
44
],
[
44,
45
],
[
44,
46
],
[
22,
47
],
[
47,
48
],
[
47,
49
],
[
22,
50
],
[
50,
51
],
[
50,
52
],
[
22,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
53,
58
],
[
58,
59
],
[
58,
60
],
[
53,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
68,
73
],
[
65,
74
],
[
74,
75
],
[
75,
76
],
[
74,
77
],
[
22,
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
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
89,
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
],
[
89,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
113,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
12,
126
],
[
126,
127
],
[
161,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
128,
132
],
[
132,
133
],
[
128,
134
],
[
134,
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
],
[
138,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
136,
154
],
[
154,
155
],
[
136,
156
],
[
156,
157
],
[
136,
158
],
[
158,
159
],
[
0,
160
],
[
160,
161
],
[
160,
162
]
] | [
"import 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\tScanner cin = new Scanner(System.in);\n\t\twhile (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class node {\n\t\tString point;\n\t\tint value;\n\t\tint usetime;\n\t\tpublic node(String point, int value,int usetime) {\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\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\tpublic static void main(String[] args) {\n\n\t\tScanner cin = new Scanner(System.in);\n\t\twhile (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class node {\n\t\tString point;\n\t\tint value;\n\t\tint usetime;\n\t\tpublic node(String point, int value,int usetime) {\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\n\t\tScanner cin = new Scanner(System.in);\n\t\twhile (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\n\t\tScanner cin = new Scanner(System.in);\n\t\twhile (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"Scanner cin = new Scanner(System.in);",
"cin",
"new Scanner(System.in)",
"while (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"cin.hasNext()",
"cin.hasNext",
"cin",
"{\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"String[] str = cin.nextLine().split(\" \");",
"str",
"cin.nextLine().split(\" \")",
"cin.nextLine().split",
"cin.nextLine()",
"cin.nextLine",
"cin",
"\" \"",
"int rundex = Integer.parseInt(str[0]);",
"rundex",
"Integer.parseInt(str[0])",
"Integer.parseInt",
"Integer",
"str[0]",
"str",
"0",
"int step = Integer.parseInt(str[1]);",
"step",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"Queue<node> qu = new LinkedList<node>();",
"qu",
"new LinkedList<node>()",
"int time =0;",
"time",
"0",
"for (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= rundex",
"i",
"rundex",
"i++",
"i++",
"i",
"{\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}",
"{\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}",
"str = cin.nextLine().split(\" \")",
"str",
"cin.nextLine().split(\" \")",
"cin.nextLine().split",
"cin.nextLine()",
"cin.nextLine",
"cin",
"\" \"",
"qu.add(new node(str[0], Integer.parseInt(str[1]),0))",
"qu.add",
"qu",
"new node(str[0], Integer.parseInt(str[1]),0)",
"while (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}",
"!qu.isEmpty()",
"qu.isEmpty()",
"qu.isEmpty",
"qu",
"{\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}",
"node temp = qu.poll();",
"temp",
"qu.poll()",
"qu.poll",
"qu",
"if (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}",
"temp.value <= step",
"temp.value",
"temp",
"temp.value",
"step",
"{\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}",
"time+=temp.value",
"time",
"temp.value",
"temp",
"temp.value",
"System.out.println(temp.point +\" \"+time)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.point +\" \"+time",
"temp.point +\" \"+time",
"temp.point",
"temp",
"temp.point",
"\" \"",
"time",
"{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}",
"time+=step",
"time",
"step",
"temp.value-=step",
"temp.value",
"temp",
"temp.value",
"step",
"qu.add(temp)",
"qu.add",
"qu",
"temp",
"String[] args",
"args",
"static class node {\n\t\tString point;\n\t\tint value;\n\t\tint usetime;\n\t\tpublic node(String point, int value,int usetime) {\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\n\t\t}\n\t}",
"node",
"String point;",
"point",
"int value;",
"value",
"int usetime;",
"usetime",
"public node(String point, int value,int usetime) {\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\n\t\t}",
"node",
"{\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\n\t\t}",
"this.point = point",
"this.point",
"this",
"this.point",
"point",
"this.value = value",
"this.value",
"this",
"this.value",
"value",
"this.usetime=usetime",
"this.usetime",
"this",
"this.usetime",
"usetime",
"String point",
"point",
"int value",
"value",
"int usetime",
"usetime",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\tScanner cin = new Scanner(System.in);\n\t\twhile (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class node {\n\t\tString point;\n\t\tint value;\n\t\tint usetime;\n\t\tpublic node(String point, int value,int usetime) {\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\n\t\tScanner cin = new Scanner(System.in);\n\t\twhile (cin.hasNext()) {\n\t\t\tString[] str = cin.nextLine().split(\" \");\n\t\t\tint rundex = Integer.parseInt(str[0]);\n\t\t\tint step = Integer.parseInt(str[1]);\n\t\t\tQueue<node> qu = new LinkedList<node>();\n\t\t\tint time =0;\n\t\t\tfor (int i = 1; i <= rundex; i++) {\n\t\t\t\tstr = cin.nextLine().split(\" \");\n\t\t\t\tqu.add(new node(str[0], Integer.parseInt(str[1]),0));\n\t\t\t}\n\t\t\twhile (!qu.isEmpty()) {\n\t\t\t\tnode temp = qu.poll();\n\t\t\t\tif (temp.value <= step) {\n\t\t\t\t\ttime+=temp.value;\n\t\t\t\t\tSystem.out.println(temp.point +\" \"+time);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttime+=step;\n\t\t\t\t\ttemp.value-=step;\n\t\t\t\t\tqu.add(temp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic class node {\n\t\tString point;\n\t\tint value;\n\t\tint usetime;\n\t\tpublic node(String point, int value,int usetime) {\n\t\t\tthis.point = point;\n\t\t\tthis.value = value;\n\t\t\tthis.usetime=usetime;\n\t\t}\n\t}\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
while (cin.hasNext()) {
String[] str = cin.nextLine().split(" ");
int rundex = Integer.parseInt(str[0]);
int step = Integer.parseInt(str[1]);
Queue<node> qu = new LinkedList<node>();
int time =0;
for (int i = 1; i <= rundex; i++) {
str = cin.nextLine().split(" ");
qu.add(new node(str[0], Integer.parseInt(str[1]),0));
}
while (!qu.isEmpty()) {
node temp = qu.poll();
if (temp.value <= step) {
time+=temp.value;
System.out.println(temp.point +" "+time);
}
else{
time+=step;
temp.value-=step;
qu.add(temp);
}
}
}
}
static class node {
String point;
int value;
int usetime;
public node(String point, int value,int usetime) {
this.point = point;
this.value = value;
this.usetime=usetime;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
17,
13,
30,
0,
13,
18,
13,
17,
4,
18,
13,
2,
2,
18,
13,
18,
13,
17,
17,
13,
30,
0,
13,
13,
4,
18,
13,
20,
12,
13,
30,
0,
13,
20,
0,
13,
20,
4,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
20,
17,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
0,
18,
36,
13,
17,
23,
13,
12,
13,
30,
14,
2,
13,
13,
30,
0,
13,
17,
38,
5,
13,
30,
37,
20,
30,
0,
13,
4,
18,
13,
13,
14,
2,
13,
17,
29,
17,
29,
17,
12,
13,
30,
14,
4,
13,
29,
18,
13,
40,
13,
29,
40,
17,
12,
13,
30,
29,
40,
2,
2,
13,
17,
2,
13,
17,
23,
13,
12,
13,
30,
42,
2,
4,
13,
4,
13,
18,
13,
13,
40,
13,
12,
13,
30,
4,
13,
29,
4,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
20,
41,
13,
4,
13,
42,
40,
4,
13,
13,
30,
4,
18,
13,
13,
0,
13,
4,
13,
29,
4,
18,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
4,
13,
42,
4,
13,
13,
0,
13,
4,
13,
41,
13,
17,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
41,
13,
17,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
37,
20,
0,
13,
2,
2,
2,
13,
17,
13,
17,
0,
13,
4,
13,
29,
8,
13,
40,
13,
13,
12,
13,
30,
14,
40,
4,
13,
37,
20,
41,
13,
4,
13,
42,
4,
13,
13,
0,
13,
4,
13,
41,
13,
17,
14,
2,
13,
17,
30,
0,
13,
17,
0,
13,
4,
13,
41,
13,
17,
42,
40,
4,
13,
13,
30,
14,
2,
2,
13,
17,
2,
13,
17,
37,
20,
0,
13,
2,
2,
2,
13,
17,
13,
17,
0,
13,
4,
13,
29,
8,
13,
40,
13,
13,
12,
13,
30,
29,
4,
18,
13,
4,
13,
12,
13,
30,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
13,
29,
13,
23,
13,
12,
13,
30,
41,
13,
20,
13,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
0,
18,
13,
13,
4,
18,
4,
13,
29,
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
],
[
505,
26
],
[
505,
27
],
[
27,
28
],
[
505,
29
],
[
29,
30
],
[
505,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
33,
42
],
[
42,
43
],
[
42,
44
],
[
44,
45
],
[
45,
46
],
[
33,
47
],
[
47,
48
],
[
47,
49
],
[
33,
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
],
[
71,
74
],
[
33,
75
],
[
75,
76
],
[
75,
77
],
[
33,
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
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
90,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
105,
111
],
[
105,
112
],
[
89,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
505,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
124,
126
],
[
123,
127
],
[
127,
128
],
[
127,
129
],
[
123,
130
],
[
130,
131
],
[
123,
132
],
[
132,
133
],
[
133,
134
],
[
121,
135
],
[
135,
136
],
[
505,
137
],
[
137,
138
],
[
137,
139
],
[
139,
140
],
[
137,
141
],
[
141,
142
],
[
141,
143
],
[
137,
145
],
[
145,
146
],
[
137,
147
],
[
147,
148
],
[
137,
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
],
[
161,
162
],
[
162,
163
],
[
162,
164
],
[
161,
165
],
[
149,
166
],
[
166,
167
],
[
137,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
171,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
179,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
188,
189
],
[
189,
190
],
[
188,
191
],
[
175,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
192,
196
],
[
196,
197
],
[
170,
198
],
[
198,
199
],
[
137,
200
],
[
200,
201
],
[
200,
202
],
[
202,
203
],
[
203,
204
],
[
204,
205
],
[
203,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
209,
210
],
[
203,
211
],
[
211,
212
],
[
212,
213
],
[
137,
214
],
[
214,
215
],
[
214,
216
],
[
216,
217
],
[
217,
218
],
[
218,
219
],
[
219,
220
],
[
220,
221
],
[
220,
222
],
[
219,
223
],
[
223,
224
],
[
223,
225
],
[
214,
226
],
[
226,
227
],
[
137,
228
],
[
228,
229
],
[
228,
230
],
[
230,
231
],
[
231,
232
],
[
232,
233
],
[
233,
234
],
[
232,
235
],
[
235,
236
],
[
235,
237
],
[
237,
238
],
[
237,
239
],
[
231,
240
],
[
240,
241
],
[
137,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
244,
247
],
[
247,
248
],
[
248,
249
],
[
137,
250
],
[
250,
251
],
[
250,
252
],
[
252,
253
],
[
253,
254
],
[
254,
255
],
[
255,
256
],
[
253,
257
],
[
257,
258
],
[
252,
259
],
[
259,
260
],
[
259,
261
],
[
252,
262
],
[
262,
263
],
[
262,
264
],
[
264,
265
],
[
252,
266
],
[
266,
267
],
[
267,
268
],
[
268,
269
],
[
268,
270
],
[
266,
271
],
[
271,
272
],
[
272,
273
],
[
273,
274
],
[
272,
275
],
[
271,
276
],
[
276,
277
],
[
276,
278
],
[
278,
279
],
[
252,
280
],
[
280,
281
],
[
281,
282
],
[
282,
283
],
[
137,
284
],
[
284,
285
],
[
284,
286
],
[
286,
287
],
[
287,
288
],
[
288,
289
],
[
289,
290
],
[
287,
291
],
[
291,
292
],
[
286,
293
],
[
293,
294
],
[
293,
295
],
[
295,
296
],
[
286,
297
],
[
297,
298
],
[
298,
299
],
[
298,
300
],
[
297,
301
],
[
301,
302
],
[
301,
303
],
[
303,
304
],
[
286,
305
],
[
305,
306
],
[
305,
307
],
[
286,
308
],
[
308,
309
],
[
309,
310
],
[
309,
311
],
[
308,
312
],
[
312,
313
],
[
313,
314
],
[
313,
315
],
[
312,
316
],
[
316,
317
],
[
316,
318
],
[
318,
319
],
[
286,
320
],
[
320,
321
],
[
320,
322
],
[
286,
323
],
[
323,
324
],
[
324,
325
],
[
325,
326
],
[
325,
327
],
[
323,
328
],
[
328,
329
],
[
329,
330
],
[
330,
331
],
[
331,
332
],
[
331,
333
],
[
330,
334
],
[
334,
335
],
[
334,
336
],
[
329,
337
],
[
337,
338
],
[
328,
339
],
[
339,
340
],
[
339,
341
],
[
341,
342
],
[
342,
343
],
[
343,
344
],
[
343,
345
],
[
342,
346
],
[
341,
347
],
[
328,
348
],
[
348,
349
],
[
348,
350
],
[
350,
351
],
[
286,
352
],
[
352,
353
],
[
353,
354
],
[
353,
355
],
[
355,
356
],
[
353,
357
],
[
137,
358
],
[
358,
359
],
[
358,
360
],
[
360,
361
],
[
361,
362
],
[
362,
363
],
[
363,
364
],
[
361,
365
],
[
365,
366
],
[
360,
367
],
[
367,
368
],
[
367,
369
],
[
369,
370
],
[
360,
371
],
[
371,
372
],
[
372,
373
],
[
372,
374
],
[
371,
375
],
[
375,
376
],
[
375,
377
],
[
377,
378
],
[
360,
379
],
[
379,
380
],
[
379,
381
],
[
360,
382
],
[
382,
383
],
[
383,
384
],
[
383,
385
],
[
382,
386
],
[
386,
387
],
[
387,
388
],
[
387,
389
],
[
386,
390
],
[
390,
391
],
[
390,
392
],
[
392,
393
],
[
360,
394
],
[
394,
395
],
[
394,
396
],
[
360,
397
],
[
397,
398
],
[
398,
399
],
[
399,
400
],
[
399,
401
],
[
397,
402
],
[
402,
403
],
[
403,
404
],
[
404,
405
],
[
405,
406
],
[
405,
407
],
[
404,
408
],
[
408,
409
],
[
408,
410
],
[
403,
411
],
[
411,
412
],
[
402,
413
],
[
413,
414
],
[
413,
415
],
[
415,
416
],
[
416,
417
],
[
417,
418
],
[
417,
419
],
[
416,
420
],
[
415,
421
],
[
402,
422
],
[
422,
423
],
[
422,
424
],
[
424,
425
],
[
360,
426
],
[
426,
427
],
[
427,
428
],
[
427,
429
],
[
429,
430
],
[
427,
431
],
[
137,
432
],
[
432,
433
],
[
432,
434
],
[
434,
435
],
[
435,
436
],
[
436,
437
],
[
437,
438
],
[
436,
439
],
[
439,
440
],
[
137,
441
],
[
441,
442
],
[
441,
443
],
[
443,
444
],
[
444,
445
],
[
444,
446
],
[
443,
448
],
[
448,
449
],
[
449,
450
],
[
450,
451
],
[
450,
452
],
[
448,
453
],
[
453,
454
],
[
453,
455
],
[
448,
456
],
[
456,
457
],
[
457,
458
],
[
448,
459
],
[
459,
460
],
[
460,
461
],
[
461,
462
],
[
461,
463
],
[
460,
464
],
[
464,
465
],
[
443,
466
],
[
466,
467
],
[
441,
468
],
[
468,
469
],
[
137,
470
],
[
470,
471
],
[
470,
472
],
[
472,
473
],
[
473,
474
],
[
473,
475
],
[
472,
478
],
[
478,
479
],
[
479,
480
],
[
480,
481
],
[
480,
482
],
[
478,
483
],
[
483,
484
],
[
483,
485
],
[
478,
486
],
[
486,
487
],
[
487,
488
],
[
478,
489
],
[
489,
490
],
[
490,
491
],
[
491,
492
],
[
491,
493
],
[
490,
494
],
[
494,
495
],
[
495,
496
],
[
496,
497
],
[
472,
498
],
[
498,
499
],
[
470,
500
],
[
500,
501
],
[
470,
502
],
[
502,
503
],
[
0,
504
],
[
504,
505
],
[
504,
506
]
] | [
"import java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.InputMismatchException;\nimport java.util.NoSuchElementException;\nimport java.util.PriorityQueue;\n \npublic class Main{\n \n static InputReader ir;\n static PrintWriter out;\n\n static void solve(){\n Deque<int[]> que=new ArrayDeque<int[]>();\n\tint n=ir.nextInt();\n\tint q=ir.nextInt();\n\tString[] name=new String[n];\n\tfor(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}\n\tint cur=0;\n\twhile(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}\n }\n \n public static void main(String[] args) throws Exception {\n\tir = new InputReader(System.in);\n \tout = new PrintWriter(System.out);\n\tsolve();\n\tout.flush();\n }\n \n static class InputReader {\n\tprivate InputStream in;\n\tprivate byte[] buffer=new byte[1024];\n\tprivate int curbuf;\n\tprivate int lenbuf;\n\n\tpublic InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n\tpublic boolean hasNextByte() {\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}\n \n\tprivate int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n\tprivate boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n\tprivate void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n\tpublic boolean hasNext(){skip(); return hasNextByte();}\n \n\tpublic String next(){\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}\n \n\tpublic int nextInt() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic long nextLong() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic double nextDouble(){return Double.parseDouble(next());}\n \n\tpublic int[] nextIntArray(int n){\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}\n \n\tpublic char[][] nextCharMap(int n,int m){\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}\n }\n}\n",
"import java.io.InputStream;",
"InputStream",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.InputMismatchException;",
"InputMismatchException",
"java.util",
"import java.util.NoSuchElementException;",
"NoSuchElementException",
"java.util",
"import java.util.PriorityQueue;",
"PriorityQueue",
"java.util",
"public class Main{\n \n static InputReader ir;\n static PrintWriter out;\n\n static void solve(){\n Deque<int[]> que=new ArrayDeque<int[]>();\n\tint n=ir.nextInt();\n\tint q=ir.nextInt();\n\tString[] name=new String[n];\n\tfor(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}\n\tint cur=0;\n\twhile(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}\n }\n \n public static void main(String[] args) throws Exception {\n\tir = new InputReader(System.in);\n \tout = new PrintWriter(System.out);\n\tsolve();\n\tout.flush();\n }\n \n static class InputReader {\n\tprivate InputStream in;\n\tprivate byte[] buffer=new byte[1024];\n\tprivate int curbuf;\n\tprivate int lenbuf;\n\n\tpublic InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n\tpublic boolean hasNextByte() {\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}\n \n\tprivate int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n\tprivate boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n\tprivate void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n\tpublic boolean hasNext(){skip(); return hasNextByte();}\n \n\tpublic String next(){\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}\n \n\tpublic int nextInt() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic long nextLong() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic double nextDouble(){return Double.parseDouble(next());}\n \n\tpublic int[] nextIntArray(int n){\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}\n \n\tpublic char[][] nextCharMap(int n,int m){\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}\n }\n}",
"Main",
"static InputReader ir;",
"ir",
"static PrintWriter out;",
"out",
"static void solve(){\n Deque<int[]> que=new ArrayDeque<int[]>();\n\tint n=ir.nextInt();\n\tint q=ir.nextInt();\n\tString[] name=new String[n];\n\tfor(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}\n\tint cur=0;\n\twhile(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}\n }",
"solve",
"{\n Deque<int[]> que=new ArrayDeque<int[]>();\n\tint n=ir.nextInt();\n\tint q=ir.nextInt();\n\tString[] name=new String[n];\n\tfor(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}\n\tint cur=0;\n\twhile(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}\n }",
"Deque<int[]> que=new ArrayDeque<int[]>();",
"que",
"new ArrayDeque<int[]>()",
"int n=ir.nextInt();",
"n",
"ir.nextInt()",
"ir.nextInt",
"ir",
"int q=ir.nextInt();",
"q",
"ir.nextInt()",
"ir.nextInt",
"ir",
"String[] name=new String[n];",
"name",
"new String[n]",
"n",
"for(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}",
"{\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}",
"name[i]=ir.next()",
"name[i]",
"name",
"i",
"ir.next()",
"ir.next",
"ir",
"que.offerLast(new int[]{i,ir.nextInt()})",
"que.offerLast",
"que",
"new int[]{i,ir.nextInt()}",
"int cur=0;",
"cur",
"0",
"while(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}",
"int[] a=que.pollFirst();",
"a",
"que.pollFirst()",
"que.pollFirst",
"que",
"if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }",
"a[1]<=q",
"a[1]",
"a",
"1",
"q",
"{\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }",
"cur+=a[1]",
"cur",
"a[1]",
"a",
"1",
"out.println(name[a[0]]+\" \"+cur)",
"out.println",
"out",
"name[a[0]]+\" \"+cur",
"name[a[0]]+\" \"+cur",
"name[a[0]]",
"name",
"a[0]",
"a",
"0",
"\" \"",
"cur",
"{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }",
"cur+=q",
"cur",
"q",
"que.offerLast(new int[]{a[0],a[1]-q})",
"que.offerLast",
"que",
"new int[]{a[0],a[1]-q}",
"public static void main(String[] args) throws Exception {\n\tir = new InputReader(System.in);\n \tout = new PrintWriter(System.out);\n\tsolve();\n\tout.flush();\n }",
"main",
"{\n\tir = new InputReader(System.in);\n \tout = new PrintWriter(System.out);\n\tsolve();\n\tout.flush();\n }",
"ir = new InputReader(System.in)",
"ir",
"new InputReader(System.in)",
"out = new PrintWriter(System.out)",
"out",
"new PrintWriter(System.out)",
"solve()",
"solve",
"out.flush()",
"out.flush",
"out",
"String[] args",
"args",
"static class InputReader {\n\tprivate InputStream in;\n\tprivate byte[] buffer=new byte[1024];\n\tprivate int curbuf;\n\tprivate int lenbuf;\n\n\tpublic InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n\tpublic boolean hasNextByte() {\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}\n \n\tprivate int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n\tprivate boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n\tprivate void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n\tpublic boolean hasNext(){skip(); return hasNextByte();}\n \n\tpublic String next(){\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}\n \n\tpublic int nextInt() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic long nextLong() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic double nextDouble(){return Double.parseDouble(next());}\n \n\tpublic int[] nextIntArray(int n){\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}\n \n\tpublic char[][] nextCharMap(int n,int m){\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}\n }",
"InputReader",
"private InputStream in;",
"in",
"private byte[] buffer=new byte[1024];",
"buffer",
"new byte[1024]",
"1024",
"private int curbuf;",
"curbuf",
"private int lenbuf;",
"lenbuf",
"public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}",
"InputReader",
"{this.in=in; this.curbuf=this.lenbuf=0;}",
"this.in=in",
"this.in",
"this",
"this.in",
"in",
"this.curbuf=this.lenbuf=0",
"this.curbuf",
"this",
"this.curbuf",
"this.lenbuf=0",
"this.lenbuf",
"this",
"this.lenbuf",
"0",
"InputStream in",
"in",
"public boolean hasNextByte() {\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}",
"hasNextByte",
"{\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}",
"if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }",
"curbuf>=lenbuf",
"curbuf",
"lenbuf",
"{\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }",
"curbuf= 0",
"curbuf",
"0",
"try{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}",
"catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}",
"IOException e",
"{\n\t\t throw new InputMismatchException();\n\t\t}",
"throw new InputMismatchException();",
"new InputMismatchException()",
"{\n\t\t lenbuf=in.read(buffer);\n\t\t}",
"lenbuf=in.read(buffer)",
"lenbuf",
"in.read(buffer)",
"in.read",
"in",
"buffer",
"if(lenbuf<=0) return false;",
"lenbuf<=0",
"lenbuf",
"0",
"return false;",
"false",
"return true;",
"true",
"private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}",
"readByte",
"{if(hasNextByte()) return buffer[curbuf++]; else return -1;}",
"if(hasNextByte()) return buffer[curbuf++]; else return -1;",
"hasNextByte()",
"hasNextByte",
"return buffer[curbuf++];",
"buffer[curbuf++]",
"buffer",
"curbuf++",
"curbuf",
"return -1;",
"-1",
"1",
"private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}",
"isSpaceChar",
"{return !(c>=33&&c<=126);}",
"return !(c>=33&&c<=126);",
"!(c>=33&&c<=126)",
"(c>=33&&c<=126)",
"c>=33",
"c",
"33",
"c<=126",
"c",
"126",
"int c",
"c",
"private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}",
"skip",
"{while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}",
"while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;",
"hasNextByte()&&isSpaceChar(buffer[curbuf])",
"hasNextByte()",
"hasNextByte",
"isSpaceChar(buffer[curbuf])",
"isSpaceChar",
"buffer[curbuf]",
"buffer",
"curbuf",
"curbuf++",
"curbuf",
"public boolean hasNext(){skip(); return hasNextByte();}",
"hasNext",
"{skip(); return hasNextByte();}",
"skip()",
"skip",
"return hasNextByte();",
"hasNextByte()",
"hasNextByte",
"public String next(){\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}",
"next",
"{\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}",
"if(!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"StringBuilder sb=new StringBuilder();",
"sb",
"new StringBuilder()",
"int b=readByte();",
"b",
"readByte()",
"readByte",
"while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }",
"!isSpaceChar(b)",
"isSpaceChar(b)",
"isSpaceChar",
"b",
"{\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }",
"sb.appendCodePoint(b)",
"sb.appendCodePoint",
"sb",
"b",
"b=readByte()",
"b",
"readByte()",
"readByte",
"return sb.toString();",
"sb.toString()",
"sb.toString",
"sb",
"public int nextInt() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}",
"nextInt",
"{\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}",
"if(!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"int c=readByte();",
"c",
"readByte()",
"readByte",
"while (isSpaceChar(c)) c=readByte();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c=readByte()",
"c",
"readByte()",
"readByte",
"boolean minus=false;",
"minus",
"false",
"if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }",
"c=='-'",
"c",
"'-'",
"{\n\t\tminus=true;\n\t\tc=readByte();\n\t }",
"minus=true",
"minus",
"true",
"c=readByte()",
"c",
"readByte()",
"readByte",
"int res=0;",
"res",
"0",
"do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }",
"if(c<'0'||c>'9') throw new InputMismatchException();",
"c<'0'||c>'9'",
"c<'0'",
"c",
"'0'",
"c>'9'",
"c",
"'9'",
"throw new InputMismatchException();",
"new InputMismatchException()",
"res=res*10+c-'0'",
"res",
"res*10+c-'0'",
"res*10+c",
"res*10",
"res",
"10",
"c",
"'0'",
"c=readByte()",
"c",
"readByte()",
"readByte",
"return (minus)?-res:res;",
"(minus)?-res:res",
"(minus)",
"-res",
"res",
"res",
"public long nextLong() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}",
"nextLong",
"{\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}",
"if(!hasNext()) throw new NoSuchElementException();",
"!hasNext()",
"hasNext()",
"hasNext",
"throw new NoSuchElementException();",
"new NoSuchElementException()",
"int c=readByte();",
"c",
"readByte()",
"readByte",
"while (isSpaceChar(c)) c=readByte();",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"c=readByte()",
"c",
"readByte()",
"readByte",
"boolean minus=false;",
"minus",
"false",
"if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }",
"c=='-'",
"c",
"'-'",
"{\n\t\tminus=true;\n\t\tc=readByte();\n\t }",
"minus=true",
"minus",
"true",
"c=readByte()",
"c",
"readByte()",
"readByte",
"long res = 0;",
"res",
"0",
"do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));",
"!isSpaceChar(c)",
"isSpaceChar(c)",
"isSpaceChar",
"c",
"{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }",
"if(c<'0'||c>'9') throw new InputMismatchException();",
"c<'0'||c>'9'",
"c<'0'",
"c",
"'0'",
"c>'9'",
"c",
"'9'",
"throw new InputMismatchException();",
"new InputMismatchException()",
"res=res*10+c-'0'",
"res",
"res*10+c-'0'",
"res*10+c",
"res*10",
"res",
"10",
"c",
"'0'",
"c=readByte()",
"c",
"readByte()",
"readByte",
"return (minus)?-res:res;",
"(minus)?-res:res",
"(minus)",
"-res",
"res",
"res",
"public double nextDouble(){return Double.parseDouble(next());}",
"nextDouble",
"{return Double.parseDouble(next());}",
"return Double.parseDouble(next());",
"Double.parseDouble(next())",
"Double.parseDouble",
"Double",
"next()",
"next",
"public int[] nextIntArray(int n){\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}",
"nextIntArray",
"{\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}",
"int[] a=new int[n];",
"a",
"new int[n]",
"n",
"for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"a[i]=nextInt();",
"a[i]=nextInt()",
"a[i]",
"a",
"i",
"nextInt()",
"nextInt",
"return a;",
"a",
"int n",
"n",
"public char[][] nextCharMap(int n,int m){\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}",
"nextCharMap",
"{\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}",
"char[][] map=new char[n][m];",
"map",
"new char[n][m]",
"n",
"m",
"for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"map[i]=next().toCharArray();",
"map[i]=next().toCharArray()",
"map[i]",
"map",
"i",
"next().toCharArray()",
"next().toCharArray",
"next()",
"next",
"return map;",
"map",
"int n",
"n",
"int m",
"m",
"public class Main{\n \n static InputReader ir;\n static PrintWriter out;\n\n static void solve(){\n Deque<int[]> que=new ArrayDeque<int[]>();\n\tint n=ir.nextInt();\n\tint q=ir.nextInt();\n\tString[] name=new String[n];\n\tfor(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}\n\tint cur=0;\n\twhile(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}\n }\n \n public static void main(String[] args) throws Exception {\n\tir = new InputReader(System.in);\n \tout = new PrintWriter(System.out);\n\tsolve();\n\tout.flush();\n }\n \n static class InputReader {\n\tprivate InputStream in;\n\tprivate byte[] buffer=new byte[1024];\n\tprivate int curbuf;\n\tprivate int lenbuf;\n\n\tpublic InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n\tpublic boolean hasNextByte() {\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}\n \n\tprivate int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n\tprivate boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n\tprivate void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n\tpublic boolean hasNext(){skip(); return hasNextByte();}\n \n\tpublic String next(){\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}\n \n\tpublic int nextInt() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic long nextLong() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic double nextDouble(){return Double.parseDouble(next());}\n \n\tpublic int[] nextIntArray(int n){\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}\n \n\tpublic char[][] nextCharMap(int n,int m){\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}\n }\n}",
"public class Main{\n \n static InputReader ir;\n static PrintWriter out;\n\n static void solve(){\n Deque<int[]> que=new ArrayDeque<int[]>();\n\tint n=ir.nextInt();\n\tint q=ir.nextInt();\n\tString[] name=new String[n];\n\tfor(int i=0;i<n;i++){\n\t name[i]=ir.next();\n\t que.offerLast(new int[]{i,ir.nextInt()});\n\t}\n\tint cur=0;\n\twhile(!que.isEmpty()){\n\t int[] a=que.pollFirst();\n\t if(a[1]<=q){\n\t\tcur+=a[1];\n\t\tout.println(name[a[0]]+\" \"+cur);\n\t }\n\t else{\n\t\tcur+=q;\n\t\tque.offerLast(new int[]{a[0],a[1]-q});\n\t }\n\t}\n }\n \n public static void main(String[] args) throws Exception {\n\tir = new InputReader(System.in);\n \tout = new PrintWriter(System.out);\n\tsolve();\n\tout.flush();\n }\n \n static class InputReader {\n\tprivate InputStream in;\n\tprivate byte[] buffer=new byte[1024];\n\tprivate int curbuf;\n\tprivate int lenbuf;\n\n\tpublic InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n\tpublic boolean hasNextByte() {\n\t if(curbuf>=lenbuf){\n\t\tcurbuf= 0;\n\t\ttry{\n\t\t lenbuf=in.read(buffer);\n\t\t}catch(IOException e) {\n\t\t throw new InputMismatchException();\n\t\t}\n\t\tif(lenbuf<=0) return false;\n\t }\n\t return true;\n\t}\n \n\tprivate int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n\tprivate boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n\tprivate void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n\tpublic boolean hasNext(){skip(); return hasNextByte();}\n \n\tpublic String next(){\n\t if(!hasNext()) throw new NoSuchElementException();\n\t StringBuilder sb=new StringBuilder();\n\t int b=readByte();\n\t while(!isSpaceChar(b)){\n\t\tsb.appendCodePoint(b);\n\t\tb=readByte();\n\t }\n\t return sb.toString();\n\t}\n \n\tpublic int nextInt() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t int res=0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic long nextLong() {\n\t if(!hasNext()) throw new NoSuchElementException();\n\t int c=readByte();\n\t while (isSpaceChar(c)) c=readByte();\n\t boolean minus=false;\n\t if (c=='-') {\n\t\tminus=true;\n\t\tc=readByte();\n\t }\n\t long res = 0;\n\t do{\n\t\tif(c<'0'||c>'9') throw new InputMismatchException();\n\t\tres=res*10+c-'0';\n\t\tc=readByte();\n\t }while(!isSpaceChar(c));\n\t return (minus)?-res:res;\n\t}\n \n\tpublic double nextDouble(){return Double.parseDouble(next());}\n \n\tpublic int[] nextIntArray(int n){\n\t int[] a=new int[n];\n\t for(int i=0;i<n;i++)\n\t\ta[i]=nextInt();\n\t return a;\n\t}\n \n\tpublic char[][] nextCharMap(int n,int m){\n\t char[][] map=new char[n][m];\n\t for(int i=0;i<n;i++)\n\t\tmap[i]=next().toCharArray();\n\t return map;\n\t}\n }\n}",
"Main"
] | import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
public class Main{
static InputReader ir;
static PrintWriter out;
static void solve(){
Deque<int[]> que=new ArrayDeque<int[]>();
int n=ir.nextInt();
int q=ir.nextInt();
String[] name=new String[n];
for(int i=0;i<n;i++){
name[i]=ir.next();
que.offerLast(new int[]{i,ir.nextInt()});
}
int cur=0;
while(!que.isEmpty()){
int[] a=que.pollFirst();
if(a[1]<=q){
cur+=a[1];
out.println(name[a[0]]+" "+cur);
}
else{
cur+=q;
que.offerLast(new int[]{a[0],a[1]-q});
}
}
}
public static void main(String[] args) throws Exception {
ir = new InputReader(System.in);
out = new PrintWriter(System.out);
solve();
out.flush();
}
static class InputReader {
private InputStream in;
private byte[] buffer=new byte[1024];
private int curbuf;
private int lenbuf;
public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
public boolean hasNextByte() {
if(curbuf>=lenbuf){
curbuf= 0;
try{
lenbuf=in.read(buffer);
}catch(IOException e) {
throw new InputMismatchException();
}
if(lenbuf<=0) return false;
}
return true;
}
private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
public boolean hasNext(){skip(); return hasNextByte();}
public String next(){
if(!hasNext()) throw new NoSuchElementException();
StringBuilder sb=new StringBuilder();
int b=readByte();
while(!isSpaceChar(b)){
sb.appendCodePoint(b);
b=readByte();
}
return sb.toString();
}
public int nextInt() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
int res=0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public long nextLong() {
if(!hasNext()) throw new NoSuchElementException();
int c=readByte();
while (isSpaceChar(c)) c=readByte();
boolean minus=false;
if (c=='-') {
minus=true;
c=readByte();
}
long res = 0;
do{
if(c<'0'||c>'9') throw new InputMismatchException();
res=res*10+c-'0';
c=readByte();
}while(!isSpaceChar(c));
return (minus)?-res:res;
}
public double nextDouble(){return Double.parseDouble(next());}
public int[] nextIntArray(int n){
int[] a=new int[n];
for(int i=0;i<n;i++)
a[i]=nextInt();
return a;
}
public char[][] nextCharMap(int n,int m){
char[][] map=new char[n][m];
for(int i=0;i<n;i++)
map[i]=next().toCharArray();
return map;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
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,
20,
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,
4,
18,
13,
17,
18,
13,
13,
13,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
18,
13,
13,
0,
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
],
[
131,
11
],
[
131,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
14,
21
],
[
21,
22
],
[
21,
23
],
[
14,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
14,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
14,
34
],
[
34,
35
],
[
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
],
[
14,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
52,
56
],
[
51,
57
],
[
57,
58
],
[
58,
59
],
[
58,
60
],
[
60,
61
],
[
61,
62
],
[
57,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
63,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
72,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
75,
80
],
[
80,
81
],
[
81,
82
],
[
80,
83
],
[
80,
84
],
[
84,
85
],
[
84,
86
],
[
80,
87
],
[
63,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
88,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
88,
102
],
[
102,
103
],
[
102,
104
],
[
12,
105
],
[
105,
106
],
[
131,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
107,
111
],
[
111,
112
],
[
107,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
113,
126
],
[
126,
127
],
[
113,
128
],
[
128,
129
],
[
0,
130
],
[
130,
131
],
[
130,
132
]
] | [
"\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\t// write your code here\n Scanner scanner=new Scanner(System.in);\n Deque<Task> deque=new ArrayDeque<>();\n long time=0;\n int n=scanner.nextInt();\n final int limit=scanner.nextInt();\n for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }\n while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }\n }\n public static class Task{\n public String name;\n public int time;\n public Task(String name,int time){\n this.name=name;\n this.time=time;\n }\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\n public static void main(String[] args) {\n\t// write your code here\n Scanner scanner=new Scanner(System.in);\n Deque<Task> deque=new ArrayDeque<>();\n long time=0;\n int n=scanner.nextInt();\n final int limit=scanner.nextInt();\n for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }\n while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }\n }\n public static class Task{\n public String name;\n public int time;\n public Task(String name,int time){\n this.name=name;\n this.time=time;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n\t// write your code here\n Scanner scanner=new Scanner(System.in);\n Deque<Task> deque=new ArrayDeque<>();\n long time=0;\n int n=scanner.nextInt();\n final int limit=scanner.nextInt();\n for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }\n while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }\n }",
"main",
"{\n\t// write your code here\n Scanner scanner=new Scanner(System.in);\n Deque<Task> deque=new ArrayDeque<>();\n long time=0;\n int n=scanner.nextInt();\n final int limit=scanner.nextInt();\n for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }\n while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }\n }",
"Scanner scanner=new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"Deque<Task> deque=new ArrayDeque<>();",
"deque",
"new ArrayDeque<>()",
"long time=0;",
"time",
"0",
"int n=scanner.nextInt();",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"final int limit=scanner.nextInt();",
"limit",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }",
"{\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }",
"deque.addLast(new Task(scanner.next(),scanner.nextInt()))",
"deque.addLast",
"deque",
"new Task(scanner.next(),scanner.nextInt())",
"while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }",
"deque.size()>0",
"deque.size()",
"deque.size",
"deque",
"0",
"{\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }",
"Task currentTask=deque.removeFirst();",
"currentTask",
"deque.removeFirst()",
"deque.removeFirst",
"deque",
"if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }",
"currentTask.time<=limit",
"currentTask.time",
"currentTask",
"currentTask.time",
"limit",
"{\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }",
"time+=currentTask.time",
"time",
"currentTask.time",
"currentTask",
"currentTask.time",
"System.out.println(String.format(\"%s %d\",currentTask.name,time))",
"System.out.println",
"System.out",
"System",
"System.out",
"String.format(\"%s %d\",currentTask.name,time)",
"String.format",
"String",
"\"%s %d\"",
"currentTask.name",
"currentTask",
"currentTask.name",
"time",
"{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }",
"currentTask.time=currentTask.time-limit",
"currentTask.time",
"currentTask",
"currentTask.time",
"currentTask.time-limit",
"currentTask.time",
"currentTask",
"currentTask.time",
"limit",
"deque.addLast(currentTask)",
"deque.addLast",
"deque",
"currentTask",
"time+=limit",
"time",
"limit",
"String[] args",
"args",
"public static class Task{\n public String name;\n public int time;\n public Task(String name,int time){\n this.name=name;\n this.time=time;\n }\n }",
"Task",
"public String name;",
"name",
"public int time;",
"time",
"public Task(String name,int time){\n this.name=name;\n this.time=time;\n }",
"Task",
"{\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\t// write your code here\n Scanner scanner=new Scanner(System.in);\n Deque<Task> deque=new ArrayDeque<>();\n long time=0;\n int n=scanner.nextInt();\n final int limit=scanner.nextInt();\n for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }\n while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }\n }\n public static class Task{\n public String name;\n public int time;\n public Task(String name,int time){\n this.name=name;\n this.time=time;\n }\n }\n}",
"public class Main {\n\n public static void main(String[] args) {\n\t// write your code here\n Scanner scanner=new Scanner(System.in);\n Deque<Task> deque=new ArrayDeque<>();\n long time=0;\n int n=scanner.nextInt();\n final int limit=scanner.nextInt();\n for(int i=0;i<n;i++){\n deque.addLast(new Task(scanner.next(),scanner.nextInt()));\n }\n while(deque.size()>0){\n Task currentTask=deque.removeFirst();\n if(currentTask.time<=limit){\n time+=currentTask.time;\n System.out.println(String.format(\"%s %d\",currentTask.name,time));\n }else{\n currentTask.time=currentTask.time-limit;\n deque.addLast(currentTask);\n time+=limit;\n }\n }\n }\n public static class Task{\n public String name;\n public int time;\n public Task(String name,int time){\n this.name=name;\n this.time=time;\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) {
// write your code here
Scanner scanner=new Scanner(System.in);
Deque<Task> deque=new ArrayDeque<>();
long time=0;
int n=scanner.nextInt();
final int limit=scanner.nextInt();
for(int i=0;i<n;i++){
deque.addLast(new Task(scanner.next(),scanner.nextInt()));
}
while(deque.size()>0){
Task currentTask=deque.removeFirst();
if(currentTask.time<=limit){
time+=currentTask.time;
System.out.println(String.format("%s %d",currentTask.name,time));
}else{
currentTask.time=currentTask.time-limit;
deque.addLast(currentTask);
time+=limit;
}
}
}
public static class Task{
public String name;
public int time;
public Task(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,
13,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
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,
41,
13,
2,
4,
18,
13,
13,
41,
13,
4,
18,
13,
14,
2,
13,
17,
30,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
137,
11
],
[
137,
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
],
[
29,
30
],
[
14,
31
],
[
31,
32
],
[
31,
33
],
[
14,
35
],
[
35,
36
],
[
35,
37
],
[
14,
39
],
[
39,
40
],
[
39,
41
],
[
14,
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
],
[
56,
57
],
[
56,
58
],
[
55,
59
],
[
59,
60
],
[
60,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
67,
68
],
[
54,
69
],
[
69,
70
],
[
69,
71
],
[
54,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
14,
76
],
[
76,
77
],
[
76,
78
],
[
14,
79
],
[
79,
80
],
[
80,
81
],
[
81,
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
],
[
94,
95
],
[
92,
96
],
[
84,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
100,
101
],
[
84,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
106,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
106,
115
],
[
115,
116
],
[
115,
117
],
[
102,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
118,
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
]
] | [
"import java.util.AbstractMap;\nimport java.util.ArrayDeque;\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\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tString[] p = new String[n];\n\t\tint[] t = new int[n];\n//\t\tLinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();\n//\t\tLinkedHashMap[] hm = new LinkedHashMap[n];\n\t\tArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}\n\n//\t\tSystem.out.println(Arrays.toString(p));\n//\t\tSystem.out.println(Arrays.toString(t));\n//\t\tSystem.out.println(ad.poll());\n\n\t\tint time = 0;\n\t\twhile (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}",
"import java.util.AbstractMap;",
"AbstractMap",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"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\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tString[] p = new String[n];\n\t\tint[] t = new int[n];\n//\t\tLinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();\n//\t\tLinkedHashMap[] hm = new LinkedHashMap[n];\n\t\tArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}\n\n//\t\tSystem.out.println(Arrays.toString(p));\n//\t\tSystem.out.println(Arrays.toString(t));\n//\t\tSystem.out.println(ad.poll());\n\n\t\tint time = 0;\n\t\twhile (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tString[] p = new String[n];\n\t\tint[] t = new int[n];\n//\t\tLinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();\n//\t\tLinkedHashMap[] hm = new LinkedHashMap[n];\n\t\tArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}\n\n//\t\tSystem.out.println(Arrays.toString(p));\n//\t\tSystem.out.println(Arrays.toString(t));\n//\t\tSystem.out.println(ad.poll());\n\n\t\tint time = 0;\n\t\twhile (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\t// TODO ?????????????????????????????????????????????\n\t\tScanner sc = new Scanner(System.in);\n\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tString[] p = new String[n];\n\t\tint[] t = new int[n];\n//\t\tLinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();\n//\t\tLinkedHashMap[] hm = new LinkedHashMap[n];\n\t\tArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}\n\n//\t\tSystem.out.println(Arrays.toString(p));\n//\t\tSystem.out.println(Arrays.toString(t));\n//\t\tSystem.out.println(ad.poll());\n\n\t\tint time = 0;\n\t\twhile (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"sc.nextLine()",
"sc.nextLine",
"sc",
"String[] p = new String[n];",
"p",
"new String[n]",
"n",
"int[] t = new int[n];",
"t",
"new int[n]",
"n",
"ArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();",
"ad",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}",
"{\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}",
"p[i] = sc.next()",
"p[i]",
"p",
"i",
"sc.next()",
"sc.next",
"sc",
"t[i] = sc.nextInt()",
"t[i]",
"t",
"i",
"sc.nextInt()",
"sc.nextInt",
"sc",
"AbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);",
"pair",
"new AbstractMap.SimpleEntry<>(p[i], t[i])",
"ad.add(pair)",
"ad.add",
"ad",
"pair",
"int time = 0;",
"time",
"0",
"while (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}",
"!ad.isEmpty()",
"ad.isEmpty()",
"ad.isEmpty",
"ad",
"{\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}",
"AbstractMap.SimpleEntry<String, Integer> pair = ad.poll();",
"pair",
"ad.poll()",
"ad.poll",
"ad",
"int pt = pair.getValue() - q;",
"pt",
"pair.getValue() - q",
"pair.getValue()",
"pair.getValue",
"pair",
"q",
"String pn = pair.getKey();",
"pn",
"pair.getKey()",
"pair.getKey",
"pair",
"if (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}",
"pt > 0",
"pt",
"0",
"{\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t}",
"pair.setValue(pt)",
"pair.setValue",
"pair",
"pt",
"ad.add(pair)",
"ad.add",
"ad",
"pair",
"time += q",
"time",
"q",
"{\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}",
"time += pair.getValue()",
"time",
"pair.getValue()",
"pair.getValue",
"pair",
"System.out.println(pn + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"pn + \" \" + time",
"pn + \" \" + time",
"pn",
"\" \"",
"time",
"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\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tString[] p = new String[n];\n\t\tint[] t = new int[n];\n//\t\tLinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();\n//\t\tLinkedHashMap[] hm = new LinkedHashMap[n];\n\t\tArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}\n\n//\t\tSystem.out.println(Arrays.toString(p));\n//\t\tSystem.out.println(Arrays.toString(t));\n//\t\tSystem.out.println(ad.poll());\n\n\t\tint time = 0;\n\t\twhile (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\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\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tsc.nextLine();\n\n\t\tString[] p = new String[n];\n\t\tint[] t = new int[n];\n//\t\tLinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();\n//\t\tLinkedHashMap[] hm = new LinkedHashMap[n];\n\t\tArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =\n\t\t\t\tnew ArrayDeque<>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tp[i] = sc.next();\n\t\t\tt[i] = sc.nextInt();\n//\t\t\thmi.put(p[i], t[i]);\n//\t\t\t( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair =\n\t\t\t\t\tnew AbstractMap.SimpleEntry<>(p[i], t[i]);\n\t\t\tad.add(pair);\n\t\t}\n\n//\t\tSystem.out.println(Arrays.toString(p));\n//\t\tSystem.out.println(Arrays.toString(t));\n//\t\tSystem.out.println(ad.poll());\n\n\t\tint time = 0;\n\t\twhile (!ad.isEmpty()) {\n\t\t\tAbstractMap.SimpleEntry<String, Integer> pair = ad.poll();\n\t\t\t// pt: pair time\n\t\t\tint pt = pair.getValue() - q;\n\t\t\t// pp : pair name\n\t\t\tString pn = pair.getKey();\n\n\t\t\tif (pt > 0) {\n\t\t\t\tpair.setValue(pt);\n\t\t\t\tad.add(pair);\n\t\t\t\ttime += q;\n\t\t\t} else {\n\t\t\t\ttime += pair.getValue();\n\t\t\t\tSystem.out.println(pn + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.AbstractMap;
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO ?????????????????????????????????????????????
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
sc.nextLine();
String[] p = new String[n];
int[] t = new int[n];
// LinkedHashMap<String, Integer> hmi = new LinkedHashMap<>();
// LinkedHashMap[] hm = new LinkedHashMap[n];
ArrayDeque<AbstractMap.SimpleEntry<String, Integer>> ad =
new ArrayDeque<>();
for (int i = 0; i < n; i++) {
p[i] = sc.next();
t[i] = sc.nextInt();
// hmi.put(p[i], t[i]);
// ( (LinkedHashMap<String, Integer>) hm[i] ).put(p[i], t[i]);
AbstractMap.SimpleEntry<String, Integer> pair =
new AbstractMap.SimpleEntry<>(p[i], t[i]);
ad.add(pair);
}
// System.out.println(Arrays.toString(p));
// System.out.println(Arrays.toString(t));
// System.out.println(ad.poll());
int time = 0;
while (!ad.isEmpty()) {
AbstractMap.SimpleEntry<String, Integer> pair = ad.poll();
// pt: pair time
int pt = pair.getValue() - q;
// pp : pair name
String pn = pair.getKey();
if (pt > 0) {
pair.setValue(pt);
ad.add(pair);
time += q;
} else {
time += pair.getValue();
System.out.println(pn + " " + 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,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
4,
18,
4,
18,
13,
13,
4,
18,
13,
4,
18,
4,
18,
13,
13,
4,
18,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
4,
18,
4,
18,
13,
17,
17,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
4,
18,
13,
17,
17,
17,
13,
4,
18,
13,
17,
30,
0,
13,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
4,
18,
13,
2,
4,
18,
13,
17,
17,
4,
18,
13,
2,
13,
13,
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
],
[
154,
11
],
[
154,
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
],
[
45,
46
],
[
44,
47
],
[
43,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
48,
54
],
[
54,
55
],
[
55,
56
],
[
43,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
57,
63
],
[
63,
64
],
[
64,
65
],
[
14,
66
],
[
66,
67
],
[
66,
68
],
[
14,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
70,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
81,
87
],
[
75,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
96,
101
],
[
102,
102
],
[
102,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
103,
109
],
[
102,
110
],
[
102,
111
],
[
92,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
88,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
116,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
129,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
132,
136
],
[
127,
137
],
[
127,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
141,
142
],
[
141,
143
],
[
116,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
14,
148
],
[
148,
149
],
[
149,
150
],
[
12,
151
],
[
151,
152
],
[
0,
153
],
[
153,
154
],
[
153,
155
]
] | [
"\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Scanner;\n\n\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tList<List<String>> list = new ArrayList <>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}\n\t\tint sum = 0;\n\t\twhile(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\n\n}\n",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.List;",
"List",
"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 n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tList<List<String>> list = new ArrayList <>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}\n\t\tint sum = 0;\n\t\twhile(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tList<List<String>> list = new ArrayList <>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}\n\t\tint sum = 0;\n\t\twhile(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tList<List<String>> list = new ArrayList <>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}\n\t\tint sum = 0;\n\t\twhile(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"List<List<String>> list = new ArrayList <>();",
"list",
"new ArrayList <>()",
"for(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}",
"{\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}",
"list.add(new ArrayList<>())",
"list.add",
"list",
"new ArrayList<>()",
"list.get(i).add(sc.next())",
"list.get(i).add",
"list.get(i)",
"list.get",
"list",
"i",
"sc.next()",
"sc.next",
"sc",
"list.get(i).add(sc.next())",
"list.get(i).add",
"list.get(i)",
"list.get",
"list",
"i",
"sc.next()",
"sc.next",
"sc",
"int sum = 0;",
"sum",
"0",
"while(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}",
"list.size() > 0",
"list.size()",
"list.size",
"list",
"0",
"{\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}",
"int time = Integer.parseInt(list.get(0).get(1));",
"time",
"Integer.parseInt(list.get(0).get(1))",
"Integer.parseInt",
"Integer",
"list.get(0).get(1)",
"list.get(0).get",
"list.get(0)",
"list.get",
"list",
"0",
"1",
"if(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}",
"time <= q",
"time",
"q",
"{\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t}",
"sum += time",
"sum",
"time",
"System.out.println(list.get(0).get(0) + \" \" + sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"list.get(0).get(0) + \" \" + sum",
"list.get(0).get(0) + \" \" + sum",
"list.get(0).get(0)",
"list.get(0).get",
"list.get(0)",
"list.get",
"list",
"0",
"0",
"\" \"",
"sum",
"list.remove(0)",
"list.remove",
"list",
"0",
"{\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}",
"sum += q",
"sum",
"q",
"list.add(list.get(0))",
"list.add",
"list",
"list.get(0)",
"list.get",
"list",
"0",
"list.get(list.size() - 1).set(1, Integer.toString(time - q))",
"list.get(list.size() - 1).set",
"list.get(list.size() - 1)",
"list.get",
"list",
"list.size() - 1",
"list.size()",
"list.size",
"list",
"1",
"1",
"Integer.toString(time - q)",
"Integer.toString",
"Integer",
"time - q",
"time",
"q",
"list.remove(0)",
"list.remove",
"list",
"0",
"sc.close()",
"sc.close",
"sc",
"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 n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tList<List<String>> list = new ArrayList <>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}\n\t\tint sum = 0;\n\t\twhile(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}\n\t\tsc.close();\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\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tList<List<String>> list = new ArrayList <>();\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tlist.add(new ArrayList<>());\n\t\t\tlist.get(i).add(sc.next());\n\t\t\tlist.get(i).add(sc.next());\n\t\t}\n\t\tint sum = 0;\n\t\twhile(list.size() > 0) {\n\t\t\tint time = Integer.parseInt(list.get(0).get(1));\n\t\t\tif(time <= q) {\n\t\t\t\tsum += time;\n\t\t\t\tSystem.out.println(list.get(0).get(0) + \" \" + sum);\n\t\t\t\tlist.remove(0);\n\t\t\t} else {\n\t\t\t\tsum += q;\n\t\t\t\tlist.add(list.get(0));\n\t\t\t\tlist.get(list.size() - 1).set(1, Integer.toString(time - q));\n\t\t\t\tlist.remove(0);\n\t\t\t}\n\t\t}\n\t\tsc.close();\n\t}\n\n}",
"Main"
] |
import java.util.ArrayList;
import java.util.List;
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();
List<List<String>> list = new ArrayList <>();
for(int i = 0; i < n; i++) {
list.add(new ArrayList<>());
list.get(i).add(sc.next());
list.get(i).add(sc.next());
}
int sum = 0;
while(list.size() > 0) {
int time = Integer.parseInt(list.get(0).get(1));
if(time <= q) {
sum += time;
System.out.println(list.get(0).get(0) + " " + sum);
list.remove(0);
} else {
sum += q;
list.add(list.get(0));
list.get(list.size() - 1).set(1, Integer.toString(time - q));
list.remove(0);
}
}
sc.close();
}
}
|
[
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,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
13,
13,
4,
18,
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
],
[
113,
11
],
[
113,
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
],
[
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
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
89,
91
],
[
82,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
78,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
96,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
106,
106
],
[
106,
107
],
[
106,
108
],
[
106,
109
],
[
12,
110
],
[
110,
111
],
[
0,
112
],
[
112,
113
],
[
112,
114
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<String> qTask = new ArrayDeque<>();\n Queue<Integer> qTime = new ArrayDeque<>();\n \n for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }\n \n int timePoint = 0;\n while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }\n }\n }\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<String> qTask = new ArrayDeque<>();\n Queue<Integer> qTime = new ArrayDeque<>();\n \n for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }\n \n int timePoint = 0;\n while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\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 quant = sc.nextInt();\n\n Queue<String> qTask = new ArrayDeque<>();\n Queue<Integer> qTime = new ArrayDeque<>();\n \n for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }\n \n int timePoint = 0;\n while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<String> qTask = new ArrayDeque<>();\n Queue<Integer> qTime = new ArrayDeque<>();\n \n for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }\n \n int timePoint = 0;\n while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\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 quant = sc.nextInt();",
"quant",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<String> qTask = new ArrayDeque<>();",
"qTask",
"new ArrayDeque<>()",
"Queue<Integer> qTime = new ArrayDeque<>();",
"qTime",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }",
"{\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }",
"qTask.add(sc.next())",
"qTask.add",
"qTask",
"sc.next()",
"sc.next",
"sc",
"qTime.add(sc.nextInt())",
"qTime.add",
"qTime",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int timePoint = 0;",
"timePoint",
"0",
"while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }\n }",
"!qTask.isEmpty()",
"qTask.isEmpty()",
"qTask.isEmpty",
"qTask",
"{\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }\n }",
"String task = qTask.poll();",
"task",
"qTask.poll()",
"qTask.poll",
"qTask",
"int time = qTime.poll();",
"time",
"qTime.poll()",
"qTime.poll",
"qTime",
"if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }",
"time > quant",
"time",
"quant",
"{\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n }",
"timePoint += quant",
"timePoint",
"quant",
"qTime.add(time - quant)",
"qTime.add",
"qTime",
"time - quant",
"time",
"quant",
"qTask.add(task)",
"qTask.add",
"qTask",
"task",
"{\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }",
"timePoint += time",
"timePoint",
"time",
"System.out.println(task + \" \" + timePoint)",
"System.out.println",
"System.out",
"System",
"System.out",
"task + \" \" + timePoint",
"task + \" \" + timePoint",
"task",
"\" \"",
"timePoint",
"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 quant = sc.nextInt();\n\n Queue<String> qTask = new ArrayDeque<>();\n Queue<Integer> qTime = new ArrayDeque<>();\n \n for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }\n \n int timePoint = 0;\n while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }\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 quant = sc.nextInt();\n\n Queue<String> qTask = new ArrayDeque<>();\n Queue<Integer> qTime = new ArrayDeque<>();\n \n for (int i = 0; i < n; i++) {\n qTask.add(sc.next());\n qTime.add(sc.nextInt());\n }\n \n int timePoint = 0;\n while (!qTask.isEmpty()) {\n String task = qTask.poll();\n int time = qTime.poll();\n\n if (time > quant) {\n timePoint += quant;\n qTime.add(time - quant);\n qTask.add(task);\n \n } else {\n timePoint += time;\n System.out.println(task + \" \" + timePoint);\n }\n }\n }\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int quant = sc.nextInt();
Queue<String> qTask = new ArrayDeque<>();
Queue<Integer> qTime = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
qTask.add(sc.next());
qTime.add(sc.nextInt());
}
int timePoint = 0;
while (!qTask.isEmpty()) {
String task = qTask.poll();
int time = qTime.poll();
if (time > quant) {
timePoint += quant;
qTime.add(time - quant);
qTask.add(task);
} else {
timePoint += time;
System.out.println(task + " " + timePoint);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
17,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
30,
0,
13,
18,
13,
13,
0,
18,
13,
13,
2,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
173,
8
],
[
173,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
17,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
11,
42
],
[
42,
43
],
[
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
],
[
63,
65
],
[
65,
66
],
[
65,
67
],
[
54,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
70,
73
],
[
73,
74
],
[
73,
75
],
[
54,
76
],
[
76,
77
],
[
76,
78
],
[
54,
79
],
[
79,
80
],
[
80,
81
],
[
79,
82
],
[
11,
83
],
[
83,
84
],
[
83,
85
],
[
11,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
86,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
91,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
98,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
98,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
111,
113
],
[
91,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
91,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
123,
129
],
[
129,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
123,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
141,
141
],
[
141,
142
],
[
142,
143
],
[
142,
144
],
[
141,
145
],
[
141,
146
],
[
9,
147
],
[
147,
148
],
[
0,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
149,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
157,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
155,
168
],
[
168,
169
],
[
155,
170
],
[
170,
171
],
[
0,
172
],
[
172,
173
],
[
172,
174
]
] | [
"import java.util.Scanner;\nimport java.util.ArrayList;\npublic class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tArrayList<Process> processes = new ArrayList<Process>();\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}\nclass Process {\n String name;\n int time;\n Process (String name, int time) {\n\tthis.name = name;\n\tthis.time = time;\n }\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"public class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tArrayList<Process> processes = new ArrayList<Process>();\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}",
"Main",
"public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tArrayList<Process> processes = new ArrayList<Process>();\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }",
"main",
"{\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tArrayList<Process> processes = new ArrayList<Process>();\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"String[] initial = scan.nextLine().split(\" \");",
"initial",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"int n = Integer.parseInt(initial[0]);",
"n",
"Integer.parseInt(initial[0])",
"Integer.parseInt",
"Integer",
"initial[0]",
"initial",
"0",
"int q = Integer.parseInt(initial[1]);",
"q",
"Integer.parseInt(initial[1])",
"Integer.parseInt",
"Integer",
"initial[1]",
"initial",
"1",
"ArrayList<Process> processes = new ArrayList<Process>();",
"processes",
"new ArrayList<Process>()",
"for (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}",
"{\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}",
"String[] input = scan.nextLine().split(\" \");",
"input",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"String name = input[0];",
"name",
"input[0]",
"input",
"0",
"int time = Integer.parseInt(input[1]);",
"time",
"Integer.parseInt(input[1])",
"Integer.parseInt",
"Integer",
"input[1]",
"input",
"1",
"Process p = new Process(name, time);",
"p",
"new Process(name, time)",
"processes.add(p)",
"processes.add",
"processes",
"p",
"int processTime = 0;",
"processTime",
"0",
"while (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}",
"!processes.isEmpty()",
"processes.isEmpty()",
"processes.isEmpty",
"processes",
"{\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}",
"Process p = processes.remove(0);",
"p",
"processes.remove(0)",
"processes.remove",
"processes",
"0",
"if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n\t\tprocessTime += q;\n\t }",
"processTime += q",
"processTime",
"q",
"{\n\t\tprocessTime += p.time;\n\t }",
"processTime += p.time",
"processTime",
"p.time",
"p",
"p.time",
"p.time = p.time - q",
"p.time",
"p",
"p.time",
"p.time - q",
"p.time",
"p",
"p.time",
"q",
"if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }",
"p.time > 0",
"p.time",
"p",
"p.time",
"0",
"{\n\t\tprocesses.add(p);\n\t }",
"processes.add(p)",
"processes.add",
"processes",
"p",
"{\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }",
"System.out.println(p.name + \" \" + processTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + processTime",
"p.name + \" \" + processTime",
"p.name",
"p",
"p.name",
"\" \"",
"processTime",
"String[] args",
"args",
"class Process {\n String name;\n int time;\n Process (String name, int time) {\n\tthis.name = name;\n\tthis.time = time;\n }\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process (String name, int time) {\n\tthis.name = name;\n\tthis.time = time;\n }",
"Process",
"{\n\tthis.name = name;\n\tthis.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tArrayList<Process> processes = new ArrayList<Process>();\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}",
"public class Main {\n public static void main (String[] args) {\n\tScanner scan = new Scanner(System.in);\n\tString[] initial = scan.nextLine().split(\" \");\n\tint n = Integer.parseInt(initial[0]);\n\tint q = Integer.parseInt(initial[1]);\n\tArrayList<Process> processes = new ArrayList<Process>();\n\tfor (int i = 0; i < n; i++) {\n\t String[] input = scan.nextLine().split(\" \");\n\t String name = input[0];\n\t int time = Integer.parseInt(input[1]);\n\t Process p = new Process(name, time);\n\t processes.add(p);\n\t}\n\t\n\tint processTime = 0;\n\twhile (!processes.isEmpty()) {\n\t Process p = processes.remove(0);\n\t if (p.time > q) {\n\t\tprocessTime += q;\n\t } else {\n\t\tprocessTime += p.time;\n\t }\n\t p.time = p.time - q;\n\t if (p.time > 0) {\n\t\tprocesses.add(p);\n\t } else {\n\t\tSystem.out.println(p.name + \" \" + processTime);\n\t }\n\t}\n }\n \n}",
"Main"
] | import java.util.Scanner;
import java.util.ArrayList;
public class Main {
public static void main (String[] args) {
Scanner scan = new Scanner(System.in);
String[] initial = scan.nextLine().split(" ");
int n = Integer.parseInt(initial[0]);
int q = Integer.parseInt(initial[1]);
ArrayList<Process> processes = new ArrayList<Process>();
for (int i = 0; i < n; i++) {
String[] input = scan.nextLine().split(" ");
String name = input[0];
int time = Integer.parseInt(input[1]);
Process p = new Process(name, time);
processes.add(p);
}
int processTime = 0;
while (!processes.isEmpty()) {
Process p = processes.remove(0);
if (p.time > q) {
processTime += q;
} else {
processTime += p.time;
}
p.time = p.time - q;
if (p.time > 0) {
processes.add(p);
} else {
System.out.println(p.name + " " + processTime);
}
}
}
}
class Process {
String name;
int time;
Process (String name, int time) {
this.name = name;
this.time = time;
}
} |
[
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,
17,
41,
13,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
18,
13,
13,
41,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
0,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
13,
13,
0,
13,
17,
40,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
4,
18,
13,
13,
4,
18,
13,
13,
14,
2,
13,
4,
18,
13,
30,
0,
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
],
[
221,
11
],
[
221,
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,
46
],
[
46,
47
],
[
46,
48
],
[
14,
50
],
[
50,
51
],
[
50,
52
],
[
14,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
56,
58
],
[
54,
59
],
[
59,
60
],
[
59,
61
],
[
54,
62
],
[
62,
63
],
[
63,
64
],
[
54,
65
],
[
66,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
69,
74
],
[
66,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
79,
81
],
[
66,
82
],
[
82,
83
],
[
83,
84
],
[
83,
85
],
[
82,
86
],
[
86,
87
],
[
86,
88
],
[
14,
89
],
[
89,
90
],
[
89,
91
],
[
14,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
97,
98
],
[
97,
99
],
[
92,
100
],
[
100,
101
],
[
101,
102
],
[
92,
103
],
[
104,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
105,
108
],
[
108,
109
],
[
108,
110
],
[
14,
111
],
[
111,
112
],
[
111,
113
],
[
14,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
114,
119
],
[
119,
120
],
[
119,
121
],
[
114,
122
],
[
122,
123
],
[
123,
124
],
[
114,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
130,
131
],
[
130,
132
],
[
14,
133
],
[
133,
134
],
[
133,
135
],
[
14,
136
],
[
136,
137
],
[
136,
138
],
[
14,
139
],
[
139,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
139,
144
],
[
144,
145
],
[
144,
146
],
[
139,
147
],
[
147,
148
],
[
148,
149
],
[
139,
150
],
[
151,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
154,
157
],
[
157,
158
],
[
158,
159
],
[
151,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
151,
165
],
[
165,
166
],
[
165,
167
],
[
151,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
175,
177
],
[
172,
178
],
[
178,
179
],
[
178,
180
],
[
172,
181
],
[
181,
182
],
[
172,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
183,
188
],
[
189,
189
],
[
189,
190
],
[
189,
191
],
[
189,
192
],
[
168,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
197,
198
],
[
198,
199
],
[
197,
200
],
[
200,
201
],
[
201,
202
],
[
200,
203
],
[
193,
204
],
[
204,
205
],
[
205,
206
],
[
204,
207
],
[
151,
208
],
[
208,
209
],
[
209,
210
],
[
209,
211
],
[
211,
212
],
[
212,
213
],
[
208,
214
],
[
214,
215
],
[
215,
216
],
[
215,
217
],
[
12,
218
],
[
218,
219
],
[
0,
220
],
[
220,
221
],
[
220,
222
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\t//標準入力受け取り////////////////////////////////\n\t\tString[] nandqueue = scan.nextLine().split(\" \");\n\t\tint N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り\n\t\tint queue = Integer.parseInt(nandqueue[1]);\t //クオンタム受け取り\n\t\t\n\t\tString[] nameandtime = new String[2];\n\t\tString[] name = new String[N];\n\t\tString[] time = new String[N];\n\t\t\n\t\tfor(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}\n\t\t//////////////////////////////////////////////////\n\t\t\n\t\t//queue作成//////////////////////////////\n\t\t//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque1 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque2 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t/////////////////////////////////////////\n\t\t\n\t\t//System.out.println(deque); //確認用\n\t\t\n\t\t//処理///////////////////////////////////////\n\t\tint count = 0; //キューのクリアカウント\n\t\tint queuetime = 0; //queueを加算した時間\n\t\tfor(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}\n\t\t//////////////////////////////////////////////\n\t}\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\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\t//標準入力受け取り////////////////////////////////\n\t\tString[] nandqueue = scan.nextLine().split(\" \");\n\t\tint N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り\n\t\tint queue = Integer.parseInt(nandqueue[1]);\t //クオンタム受け取り\n\t\t\n\t\tString[] nameandtime = new String[2];\n\t\tString[] name = new String[N];\n\t\tString[] time = new String[N];\n\t\t\n\t\tfor(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}\n\t\t//////////////////////////////////////////////////\n\t\t\n\t\t//queue作成//////////////////////////////\n\t\t//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque1 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque2 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t/////////////////////////////////////////\n\t\t\n\t\t//System.out.println(deque); //確認用\n\t\t\n\t\t//処理///////////////////////////////////////\n\t\tint count = 0; //キューのクリアカウント\n\t\tint queuetime = 0; //queueを加算した時間\n\t\tfor(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\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\t\n\t\t//標準入力受け取り////////////////////////////////\n\t\tString[] nandqueue = scan.nextLine().split(\" \");\n\t\tint N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り\n\t\tint queue = Integer.parseInt(nandqueue[1]);\t //クオンタム受け取り\n\t\t\n\t\tString[] nameandtime = new String[2];\n\t\tString[] name = new String[N];\n\t\tString[] time = new String[N];\n\t\t\n\t\tfor(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}\n\t\t//////////////////////////////////////////////////\n\t\t\n\t\t//queue作成//////////////////////////////\n\t\t//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque1 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque2 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t/////////////////////////////////////////\n\t\t\n\t\t//System.out.println(deque); //確認用\n\t\t\n\t\t//処理///////////////////////////////////////\n\t\tint count = 0; //キューのクリアカウント\n\t\tint queuetime = 0; //queueを加算した時間\n\t\tfor(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}\n\t\t//////////////////////////////////////////////\n\t}",
"main",
"{\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\t//標準入力受け取り////////////////////////////////\n\t\tString[] nandqueue = scan.nextLine().split(\" \");\n\t\tint N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り\n\t\tint queue = Integer.parseInt(nandqueue[1]);\t //クオンタム受け取り\n\t\t\n\t\tString[] nameandtime = new String[2];\n\t\tString[] name = new String[N];\n\t\tString[] time = new String[N];\n\t\t\n\t\tfor(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}\n\t\t//////////////////////////////////////////////////\n\t\t\n\t\t//queue作成//////////////////////////////\n\t\t//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque1 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque2 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t/////////////////////////////////////////\n\t\t\n\t\t//System.out.println(deque); //確認用\n\t\t\n\t\t//処理///////////////////////////////////////\n\t\tint count = 0; //キューのクリアカウント\n\t\tint queuetime = 0; //queueを加算した時間\n\t\tfor(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}\n\t\t//////////////////////////////////////////////\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"String[] nandqueue = scan.nextLine().split(\" \");",
"nandqueue",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"int N = Integer.parseInt(nandqueue[0]);",
"N",
"Integer.parseInt(nandqueue[0])",
"Integer.parseInt",
"Integer",
"nandqueue[0]",
"nandqueue",
"0",
"int queue = Integer.parseInt(nandqueue[1]);",
"queue",
"Integer.parseInt(nandqueue[1])",
"Integer.parseInt",
"Integer",
"nandqueue[1]",
"nandqueue",
"1",
"String[] nameandtime = new String[2];",
"nameandtime",
"new String[2]",
"2",
"String[] name = new String[N];",
"name",
"new String[N]",
"N",
"String[] time = new String[N];",
"time",
"new String[N]",
"N",
"for(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}",
"{\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}",
"nameandtime = scan.nextLine().split(\" \")",
"nameandtime",
"scan.nextLine().split(\" \")",
"scan.nextLine().split",
"scan.nextLine()",
"scan.nextLine",
"scan",
"\" \"",
"name[i] = nameandtime[0]",
"name[i]",
"name",
"i",
"nameandtime[0]",
"nameandtime",
"0",
"time[i] = nameandtime[1]",
"time[i]",
"time",
"i",
"nameandtime[1]",
"nameandtime",
"1",
"Deque<String> deque1 = new ArrayDeque<>();",
"deque1",
"new ArrayDeque<>()",
"for(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tdeque1.add(time[i]);\n\t\t}",
"{\n\t\t\tdeque1.add(time[i]);\n\t\t}",
"deque1.add(time[i])",
"deque1.add",
"deque1",
"time[i]",
"time",
"i",
"Deque<String> deque2 = new ArrayDeque<>();",
"deque2",
"new ArrayDeque<>()",
"for(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tdeque2.add(name[i]);\n\t\t}",
"{\n\t\t\tdeque2.add(name[i]);\n\t\t}",
"deque2.add(name[i])",
"deque2.add",
"deque2",
"name[i]",
"name",
"i",
"int count = 0;",
"count",
"0",
"int queuetime = 0;",
"queuetime",
"0",
"for(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"count < N",
"count",
"N",
"i++",
"i++",
"i",
"{\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}",
"{\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}",
"int x =Integer.parseInt(deque1.poll());",
"x",
"Integer.parseInt(deque1.poll())",
"Integer.parseInt",
"Integer",
"deque1.poll()",
"deque1.poll",
"deque1",
"String y = deque2.poll();",
"y",
"deque2.poll()",
"deque2.poll",
"deque2",
"x -= queue",
"x",
"queue",
"if(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}",
"x <= 0",
"x",
"0",
"{\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t}",
"queuetime += (queue + x)",
"queuetime",
"(queue + x)",
"queue",
"x",
"x = 0",
"x",
"0",
"count++",
"count",
"System.out.println(y + \" \" + queuetime)",
"System.out.println",
"System.out",
"System",
"System.out",
"y + \" \" + queuetime",
"y + \" \" + queuetime",
"y",
"\" \"",
"queuetime",
"{\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}",
"queuetime += queue",
"queuetime",
"queue",
"deque1.add(String.valueOf(x))",
"deque1.add",
"deque1",
"String.valueOf(x)",
"String.valueOf",
"String",
"x",
"deque2.add(y)",
"deque2.add",
"deque2",
"y",
"if(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}",
"i < deque1.size()",
"i",
"deque1.size()",
"deque1.size",
"deque1",
"{\n\t\t\t\ti = 0;\n\t\t\t}",
"i = 0",
"i",
"0",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner scan = new Scanner(System.in);\n\t\t\n\t\t//標準入力受け取り////////////////////////////////\n\t\tString[] nandqueue = scan.nextLine().split(\" \");\n\t\tint N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り\n\t\tint queue = Integer.parseInt(nandqueue[1]);\t //クオンタム受け取り\n\t\t\n\t\tString[] nameandtime = new String[2];\n\t\tString[] name = new String[N];\n\t\tString[] time = new String[N];\n\t\t\n\t\tfor(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}\n\t\t//////////////////////////////////////////////////\n\t\t\n\t\t//queue作成//////////////////////////////\n\t\t//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque1 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque2 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t/////////////////////////////////////////\n\t\t\n\t\t//System.out.println(deque); //確認用\n\t\t\n\t\t//処理///////////////////////////////////////\n\t\tint count = 0; //キューのクリアカウント\n\t\tint queuetime = 0; //queueを加算した時間\n\t\tfor(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\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 scan = new Scanner(System.in);\n\t\t\n\t\t//標準入力受け取り////////////////////////////////\n\t\tString[] nandqueue = scan.nextLine().split(\" \");\n\t\tint N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り\n\t\tint queue = Integer.parseInt(nandqueue[1]);\t //クオンタム受け取り\n\t\t\n\t\tString[] nameandtime = new String[2];\n\t\tString[] name = new String[N];\n\t\tString[] time = new String[N];\n\t\t\n\t\tfor(int i = 0; i < N; i++) {\n\t\tnameandtime = scan.nextLine().split(\" \");\n\t\tname[i] = nameandtime[0];\n\t\ttime[i] = nameandtime[1];\n\t\t//System.out.println(time[i]); //確認用\n\t\t}\n\t\t//////////////////////////////////////////////////\n\t\t\n\t\t//queue作成//////////////////////////////\n\t\t//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque1 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque1.add(time[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\tDeque<String> deque2 = new ArrayDeque<>();\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tdeque2.add(name[i]);\n\t\t}\n\t\t//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\t\t/////////////////////////////////////////\n\t\t\n\t\t//System.out.println(deque); //確認用\n\t\t\n\t\t//処理///////////////////////////////////////\n\t\tint count = 0; //キューのクリアカウント\n\t\tint queuetime = 0; //queueを加算した時間\n\t\tfor(int i = 0; count < N; i++) {\n\t\t\tint x =Integer.parseInt(deque1.poll());\n\t\t\tString y = deque2.poll();\n\t\t\tx -= queue;\n\t\t\tif(x <= 0) {\n\t\t\t\tqueuetime += (queue + x);\n\t\t\t\tx = 0;\n\t\t\t\tcount++;\n\t\t\t\tSystem.out.println(y + \" \" + queuetime);\n\t\t\t} else {\n\t\t\t\tqueuetime += queue;\n\t\t\t\tdeque1.add(String.valueOf(x));\n\t\t\t\tdeque2.add(y);\n\t\t\t}\n\t\t\tif(i < deque1.size()) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}\n\t\t//////////////////////////////////////////////\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);
//標準入力受け取り////////////////////////////////
String[] nandqueue = scan.nextLine().split(" ");
int N = Integer.parseInt(nandqueue[0]); //プロセスの数受け取り
int queue = Integer.parseInt(nandqueue[1]); //クオンタム受け取り
String[] nameandtime = new String[2];
String[] name = new String[N];
String[] time = new String[N];
for(int i = 0; i < N; i++) {
nameandtime = scan.nextLine().split(" ");
name[i] = nameandtime[0];
time[i] = nameandtime[1];
//System.out.println(time[i]); //確認用
}
//////////////////////////////////////////////////
//queue作成//////////////////////////////
//時間のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Deque<String> deque1 = new ArrayDeque<>();
for(int i = 0; i < N; i++) {
deque1.add(time[i]);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//名前のdeque@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Deque<String> deque2 = new ArrayDeque<>();
for(int i = 0; i < N; i++) {
deque2.add(name[i]);
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
/////////////////////////////////////////
//System.out.println(deque); //確認用
//処理///////////////////////////////////////
int count = 0; //キューのクリアカウント
int queuetime = 0; //queueを加算した時間
for(int i = 0; count < N; i++) {
int x =Integer.parseInt(deque1.poll());
String y = deque2.poll();
x -= queue;
if(x <= 0) {
queuetime += (queue + x);
x = 0;
count++;
System.out.println(y + " " + queuetime);
} else {
queuetime += queue;
deque1.add(String.valueOf(x));
deque2.add(y);
}
if(i < deque1.size()) {
i = 0;
}
}
//////////////////////////////////////////////
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
41,
13,
41,
13,
20,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
13,
17,
0,
13,
2,
13,
17,
41,
13,
41,
13,
17,
42,
2,
13,
13,
30,
0,
13,
4,
13,
41,
13,
4,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
17,
18,
13,
13,
30,
4,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
4,
18,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
190,
5
],
[
190,
6
],
[
6,
7
],
[
6,
8
],
[
190,
9
],
[
9,
10
],
[
190,
11
],
[
11,
12
],
[
190,
13
],
[
13,
14
],
[
13,
15
],
[
190,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
20,
22
],
[
19,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
19,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
19,
33
],
[
33,
34
],
[
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
],
[
47,
48
],
[
47,
49
],
[
46,
50
],
[
19,
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
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
64,
70
],
[
70,
71
],
[
71,
72
],
[
63,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
74,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
19,
82
],
[
82,
83
],
[
82,
84
],
[
19,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
87,
89
],
[
19,
90
],
[
90,
91
],
[
19,
92
],
[
92,
93
],
[
92,
94
],
[
19,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
102,
103
],
[
99,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
106,
110
],
[
110,
111
],
[
110,
112
],
[
99,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
99,
118
],
[
118,
119
],
[
118,
120
],
[
99,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
124,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
121,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
138,
143
],
[
19,
144
],
[
144,
145
],
[
145,
146
],
[
17,
147
],
[
147,
148
],
[
190,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
151,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
149,
164
],
[
164,
165
],
[
190,
166
],
[
166,
167
],
[
166,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
171,
173
],
[
168,
174
],
[
174,
175
],
[
174,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
168,
181
],
[
181,
182
],
[
0,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
183,
187
],
[
187,
188
],
[
0,
189
],
[
189,
190
],
[
189,
191
]
] | [
"import java.util.Scanner;\n\n/**\n * キュー\n * @author nobu\n * @see <a href=\"http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=ja\">ALDS1_3_B</a>\n */\npublic class Main {\n\n\tprivate static final int LEN = 100005;\n\tprivate static int head, tail;\n\tprivate static P Q[] = new P[LEN];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tfor (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}\n\n\t\thead = 1;\n\t\ttail = n + 1;\n\n\t\tP u;\n\t\tint elapse = 0;\n\t\twhile (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tprivate static void enqueue(P x) {\n\t\tQ[tail] = x;\n\t\ttail = (tail + 1) % LEN;\n\t}\n\n\tprivate static P dequeue() {\n\t\tP x = Q[head];\n\t\thead = (head + 1) % LEN;\n\t\treturn x;\n\t}\n\n}\n\nclass P {\n\tString name;;\n\tint t;\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tprivate static final int LEN = 100005;\n\tprivate static int head, tail;\n\tprivate static P Q[] = new P[LEN];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tfor (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}\n\n\t\thead = 1;\n\t\ttail = n + 1;\n\n\t\tP u;\n\t\tint elapse = 0;\n\t\twhile (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tprivate static void enqueue(P x) {\n\t\tQ[tail] = x;\n\t\ttail = (tail + 1) % LEN;\n\t}\n\n\tprivate static P dequeue() {\n\t\tP x = Q[head];\n\t\thead = (head + 1) % LEN;\n\t\treturn x;\n\t}\n\n}",
"Main",
"private static final int LEN = 100005;",
"LEN",
"100005",
"private static int head",
"head",
"tail;",
"tail",
"private static P Q[] = new P[LEN];",
"Q",
"new P[LEN]",
"LEN",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tfor (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}\n\n\t\thead = 1;\n\t\ttail = n + 1;\n\n\t\tP u;\n\t\tint elapse = 0;\n\t\twhile (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tfor (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}\n\n\t\thead = 1;\n\t\ttail = n + 1;\n\n\t\tP u;\n\t\tint elapse = 0;\n\t\twhile (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < LEN",
"i",
"LEN",
"i++",
"i++",
"i",
"{\n\t\t\tQ[i] = new P();\n\t\t}",
"{\n\t\t\tQ[i] = new P();\n\t\t}",
"Q[i] = new P()",
"Q[i]",
"Q",
"i",
"new P()",
"for (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}",
"int i = 1;",
"int i = 1;",
"i",
"1",
"i <= n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}",
"{\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}",
"Q[i].name = sc.next()",
"Q[i].name",
"Q[i]",
"Q",
"i",
"Q[i].name",
"sc.next()",
"sc.next",
"sc",
"Q[i].t = sc.nextInt()",
"Q[i].t",
"Q[i]",
"Q",
"i",
"Q[i].t",
"sc.nextInt()",
"sc.nextInt",
"sc",
"head = 1",
"head",
"1",
"tail = n + 1",
"tail",
"n + 1",
"n",
"1",
"P u;",
"u",
"int elapse = 0;",
"elapse",
"0",
"while (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}",
"head != tail",
"head",
"tail",
"{\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}",
"u = dequeue()",
"u",
"dequeue()",
"dequeue",
"int c = Math.min(q, u.t);",
"c",
"Math.min(q, u.t)",
"Math.min",
"Math",
"q",
"u.t",
"u",
"u.t",
"u.t -= c",
"u.t",
"u",
"u.t",
"c",
"elapse += c",
"elapse",
"c",
"if (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}",
"0 < u.t",
"0",
"u.t",
"u",
"u.t",
"{\n\t\t\t\tenqueue(u);\n\t\t\t}",
"enqueue(u)",
"enqueue",
"u",
"{\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}",
"System.out.println(u.name + \" \" + elapse)",
"System.out.println",
"System.out",
"System",
"System.out",
"u.name + \" \" + elapse",
"u.name + \" \" + elapse",
"u.name",
"u",
"u.name",
"\" \"",
"elapse",
"sc.close()",
"sc.close",
"sc",
"String[] args",
"args",
"private static void enqueue(P x) {\n\t\tQ[tail] = x;\n\t\ttail = (tail + 1) % LEN;\n\t}",
"enqueue",
"{\n\t\tQ[tail] = x;\n\t\ttail = (tail + 1) % LEN;\n\t}",
"Q[tail] = x",
"Q[tail]",
"Q",
"tail",
"x",
"tail = (tail + 1) % LEN",
"tail",
"(tail + 1) % LEN",
"(tail + 1)",
"tail",
"1",
"LEN",
"P x",
"x",
"private static P dequeue() {\n\t\tP x = Q[head];\n\t\thead = (head + 1) % LEN;\n\t\treturn x;\n\t}",
"dequeue",
"{\n\t\tP x = Q[head];\n\t\thead = (head + 1) % LEN;\n\t\treturn x;\n\t}",
"P x = Q[head];",
"x",
"Q[head]",
"Q",
"head",
"head = (head + 1) % LEN",
"head",
"(head + 1) % LEN",
"(head + 1)",
"head",
"1",
"LEN",
"return x;",
"x",
"class P {\n\tString name;;\n\tint t;\n}",
"P",
"String name;",
"name",
"int t;",
"t",
"public class Main {\n\n\tprivate static final int LEN = 100005;\n\tprivate static int head, tail;\n\tprivate static P Q[] = new P[LEN];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tfor (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}\n\n\t\thead = 1;\n\t\ttail = n + 1;\n\n\t\tP u;\n\t\tint elapse = 0;\n\t\twhile (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tprivate static void enqueue(P x) {\n\t\tQ[tail] = x;\n\t\ttail = (tail + 1) % LEN;\n\t}\n\n\tprivate static P dequeue() {\n\t\tP x = Q[head];\n\t\thead = (head + 1) % LEN;\n\t\treturn x;\n\t}\n\n}",
"public class Main {\n\n\tprivate static final int LEN = 100005;\n\tprivate static int head, tail;\n\tprivate static P Q[] = new P[LEN];\n\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\n\t\tfor (int i = 0; i < LEN; i++) {\n\t\t\tQ[i] = new P();\n\t\t}\n\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tQ[i].name = sc.next();\n\t\t\tQ[i].t = sc.nextInt();\n\t\t}\n\n\t\thead = 1;\n\t\ttail = n + 1;\n\n\t\tP u;\n\t\tint elapse = 0;\n\t\twhile (head != tail) {\n\t\t\tu = dequeue();\n\t\t\tint c = Math.min(q, u.t);\n\t\t\tu.t -= c;\n\t\t\telapse += c;\n\t\t\tif (0 < u.t) {\n\t\t\t\tenqueue(u);\n\t\t\t} else {\n\t\t\t\tSystem.out.println(u.name + \" \" + elapse);\n\t\t\t}\n\t\t}\n\n\t\tsc.close();\n\t}\n\n\tprivate static void enqueue(P x) {\n\t\tQ[tail] = x;\n\t\ttail = (tail + 1) % LEN;\n\t}\n\n\tprivate static P dequeue() {\n\t\tP x = Q[head];\n\t\thead = (head + 1) % LEN;\n\t\treturn x;\n\t}\n\n}",
"Main"
] | import java.util.Scanner;
/**
* キュー
* @author nobu
* @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=ja">ALDS1_3_B</a>
*/
public class Main {
private static final int LEN = 100005;
private static int head, tail;
private static P Q[] = new P[LEN];
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 < LEN; i++) {
Q[i] = new P();
}
for (int i = 1; i <= n; i++) {
Q[i].name = sc.next();
Q[i].t = sc.nextInt();
}
head = 1;
tail = n + 1;
P u;
int elapse = 0;
while (head != tail) {
u = dequeue();
int c = Math.min(q, u.t);
u.t -= c;
elapse += c;
if (0 < u.t) {
enqueue(u);
} else {
System.out.println(u.name + " " + elapse);
}
}
sc.close();
}
private static void enqueue(P x) {
Q[tail] = x;
tail = (tail + 1) % LEN;
}
private static P dequeue() {
P x = Q[head];
head = (head + 1) % LEN;
return x;
}
}
class P {
String name;;
int t;
}
|
[
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,
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,
2,
18,
13,
13,
13,
17,
30,
0,
13,
18,
13,
13,
4,
18,
13,
2,
18,
13,
13,
17,
4,
18,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
4,
18,
13,
13,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
20,
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,
2,
13,
17,
0,
13,
13,
0,
13,
17,
0,
13,
17,
23,
13,
12,
13,
30,
0,
18,
13,
40,
13,
20,
14,
2,
13,
13,
0,
13,
17,
23,
13,
12,
13,
30,
41,
13,
18,
13,
40,
13,
14,
2,
13,
13,
0,
13,
17,
29,
13,
12,
13,
30,
29,
8,
2,
13,
13,
17,
17,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
219,
8
],
[
219,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
54,
55
],
[
54,
56
],
[
43,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
11,
61
],
[
61,
62
],
[
61,
63
],
[
11,
64
],
[
64,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
64,
69
],
[
69,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
69,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
76,
82
],
[
75,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
83,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
92,
96
],
[
83,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
75,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
101,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
11,
114
],
[
114,
115
],
[
115,
116
],
[
9,
117
],
[
117,
118
],
[
219,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
119,
123
],
[
123,
124
],
[
119,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
127,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
125,
138
],
[
138,
139
],
[
125,
140
],
[
140,
141
],
[
219,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
142,
146
],
[
146,
147
],
[
142,
148
],
[
148,
149
],
[
142,
150
],
[
150,
151
],
[
142,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
158,
159
],
[
158,
160
],
[
154,
161
],
[
161,
162
],
[
161,
163
],
[
154,
164
],
[
164,
165
],
[
164,
166
],
[
154,
167
],
[
167,
168
],
[
167,
169
],
[
152,
170
],
[
170,
171
],
[
142,
172
],
[
172,
173
],
[
172,
174
],
[
174,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
175,
180
],
[
174,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
185,
186
],
[
185,
187
],
[
172,
188
],
[
188,
189
],
[
142,
190
],
[
190,
191
],
[
190,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
192,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
199,
203
],
[
203,
204
],
[
203,
205
],
[
192,
206
],
[
206,
207
],
[
142,
208
],
[
208,
209
],
[
208,
210
],
[
210,
211
],
[
211,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
212,
217
],
[
0,
218
],
[
218,
219
],
[
218,
220
]
] | [
"import java.io.PrintWriter;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }\n\n int time = 0;\n while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }\n\n pw.flush();\n }\n\n static class Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = new String(name);\n this.time = time;\n }\n }\n\n static class Queue {\n Process[] Q;\n int lastIndex;\n int head;\n int tail;\n\n Queue(int n) {\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process x) {\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }\n\n Process dequeue() {\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }\n\n boolean isEmpty() {\n return head == tail ? true : false;\n }\n }\n}",
"import java.io.PrintWriter;",
"PrintWriter",
"java.io",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }\n\n int time = 0;\n while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }\n\n pw.flush();\n }\n\n static class Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = new String(name);\n this.time = time;\n }\n }\n\n static class Queue {\n Process[] Q;\n int lastIndex;\n int head;\n int tail;\n\n Queue(int n) {\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process x) {\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }\n\n Process dequeue() {\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }\n\n boolean isEmpty() {\n return head == tail ? true : false;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }\n\n int time = 0;\n while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }\n\n pw.flush();\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }\n\n int time = 0;\n while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }\n\n pw.flush();\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"PrintWriter pw = new PrintWriter(System.out);",
"pw",
"new PrintWriter(System.out)",
"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)",
"for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\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 Process x = new Process(name, time);\n queue.enqueue(x);\n }",
"{\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Process x = new Process(name, time);",
"x",
"new Process(name, time)",
"queue.enqueue(x)",
"queue.enqueue",
"queue",
"x",
"int time = 0;",
"time",
"0",
"while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }",
"Process x = queue.dequeue();",
"x",
"queue.dequeue()",
"queue.dequeue",
"queue",
"if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }",
"x.time - q <= 0",
"x.time - q",
"x.time",
"x",
"x.time",
"q",
"0",
"{\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n }",
"time += x.time",
"time",
"x.time",
"x",
"x.time",
"pw.print(x.name + \" \")",
"pw.print",
"pw",
"x.name + \" \"",
"x.name",
"x",
"x.name",
"\" \"",
"pw.println(time)",
"pw.println",
"pw",
"time",
"{\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }",
"time += q",
"time",
"q",
"x.time -= q",
"x.time",
"x",
"x.time",
"q",
"queue.enqueue(x)",
"queue.enqueue",
"queue",
"x",
"pw.flush()",
"pw.flush",
"pw",
"String[] args",
"args",
"static class Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = new String(name);\n this.time = time;\n }\n }",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time) {\n this.name = new String(name);\n this.time = time;\n }",
"Process",
"{\n this.name = new String(name);\n this.time = time;\n }",
"this.name = new String(name)",
"this.name",
"this",
"this.name",
"new String(name)",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"static class Queue {\n Process[] Q;\n int lastIndex;\n int head;\n int tail;\n\n Queue(int n) {\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process x) {\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }\n\n Process dequeue() {\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }\n\n boolean isEmpty() {\n return head == tail ? true : false;\n }\n }",
"Queue",
"Process[] Q;",
"Q",
"int lastIndex;",
"lastIndex",
"int head;",
"head",
"int tail;",
"tail",
"Queue(int n) {\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }",
"Queue",
"{\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }",
"Q = new Process[n + 1]",
"Q",
"new Process[n + 1]",
"n + 1",
"n",
"1",
"lastIndex = n",
"lastIndex",
"n",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"int n",
"n",
"void enqueue(Process x) {\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }",
"enqueue",
"{\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }",
"Q[tail++] = new Process(x.name, x.time)",
"Q[tail++]",
"Q",
"tail++",
"tail",
"new Process(x.name, x.time)",
"if (tail > lastIndex)\n tail = 0;",
"tail > lastIndex",
"tail",
"lastIndex",
"tail = 0",
"tail",
"0",
"Process x",
"x",
"Process dequeue() {\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }",
"dequeue",
"{\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }",
"Process x = Q[head++];",
"x",
"Q[head++]",
"Q",
"head++",
"head",
"if (head > lastIndex)\n head = 0;",
"head > lastIndex",
"head",
"lastIndex",
"head = 0",
"head",
"0",
"return x;",
"x",
"boolean isEmpty() {\n return head == tail ? true : false;\n }",
"isEmpty",
"{\n return head == tail ? true : false;\n }",
"return head == tail ? true : false;",
"head == tail ? true : false",
"head == tail",
"head",
"tail",
"true",
"false",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }\n\n int time = 0;\n while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }\n\n pw.flush();\n }\n\n static class Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = new String(name);\n this.time = time;\n }\n }\n\n static class Queue {\n Process[] Q;\n int lastIndex;\n int head;\n int tail;\n\n Queue(int n) {\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process x) {\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }\n\n Process dequeue() {\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }\n\n boolean isEmpty() {\n return head == tail ? true : false;\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n PrintWriter pw = new PrintWriter(System.out);\n\n int n = sc.nextInt();\n int q = sc.nextInt();\n\n Queue queue = new Queue(n);\n for (int i = 0; i < n; i++) {\n String name = sc.next();\n int time = sc.nextInt();\n Process x = new Process(name, time);\n queue.enqueue(x);\n }\n\n int time = 0;\n while (!queue.isEmpty()) {\n Process x = queue.dequeue();\n if (x.time - q <= 0) {\n time += x.time;\n pw.print(x.name + \" \");\n pw.println(time);\n } else {\n time += q;\n x.time -= q;\n queue.enqueue(x);\n }\n }\n\n pw.flush();\n }\n\n static class Process {\n String name;\n int time;\n\n Process(String name, int time) {\n this.name = new String(name);\n this.time = time;\n }\n }\n\n static class Queue {\n Process[] Q;\n int lastIndex;\n int head;\n int tail;\n\n Queue(int n) {\n Q = new Process[n + 1];\n lastIndex = n;\n head = 0;\n tail = 0;\n }\n\n void enqueue(Process x) {\n Q[tail++] = new Process(x.name, x.time);\n if (tail > lastIndex)\n tail = 0;\n }\n\n Process dequeue() {\n Process x = Q[head++];\n if (head > lastIndex)\n head = 0;\n return x;\n }\n\n boolean isEmpty() {\n return head == tail ? true : false;\n }\n }\n}",
"Main"
] | import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
int q = sc.nextInt();
Queue queue = new Queue(n);
for (int i = 0; i < n; i++) {
String name = sc.next();
int time = sc.nextInt();
Process x = new Process(name, time);
queue.enqueue(x);
}
int time = 0;
while (!queue.isEmpty()) {
Process x = queue.dequeue();
if (x.time - q <= 0) {
time += x.time;
pw.print(x.name + " ");
pw.println(time);
} else {
time += q;
x.time -= q;
queue.enqueue(x);
}
}
pw.flush();
}
static class Process {
String name;
int time;
Process(String name, int time) {
this.name = new String(name);
this.time = time;
}
}
static class Queue {
Process[] Q;
int lastIndex;
int head;
int tail;
Queue(int n) {
Q = new Process[n + 1];
lastIndex = n;
head = 0;
tail = 0;
}
void enqueue(Process x) {
Q[tail++] = new Process(x.name, x.time);
if (tail > lastIndex)
tail = 0;
}
Process dequeue() {
Process x = Q[head++];
if (head > lastIndex)
head = 0;
return x;
}
boolean isEmpty() {
return head == tail ? true : 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,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
13,
12,
13,
30,
0,
18,
36,
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,
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,
4,
18,
0,
13,
4,
18,
13,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
13,
20,
4,
18,
13,
13,
40,
13,
30,
0,
13,
13,
41,
13,
2,
4,
18,
4,
18,
13,
13,
13,
4,
18,
4,
18,
13,
13,
13,
40,
13,
30,
0,
13,
17,
14,
2,
4,
18,
13,
17,
30,
3,
28,
13,
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
],
[
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
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
35,
43
],
[
43,
44
],
[
7,
45
],
[
45,
46
],
[
45,
47
],
[
47,
48
],
[
48,
49
],
[
7,
50
],
[
50,
51
],
[
50,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
53,
57
],
[
50,
58
],
[
58,
59
],
[
0,
60
],
[
201,
61
],
[
201,
62
],
[
62,
63
],
[
62,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
64,
68
],
[
68,
69
],
[
68,
70
],
[
70,
71
],
[
71,
72
],
[
64,
73
],
[
73,
74
],
[
73,
75
],
[
75,
76
],
[
76,
77
],
[
64,
78
],
[
78,
79
],
[
78,
80
],
[
64,
81
],
[
81,
82
],
[
81,
83
],
[
64,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
84,
89
],
[
89,
90
],
[
89,
91
],
[
84,
92
],
[
92,
93
],
[
93,
94
],
[
84,
95
],
[
96,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
64,
101
],
[
101,
102
],
[
101,
103
],
[
64,
104
],
[
104,
105
],
[
104,
106
],
[
64,
107
],
[
107,
108
],
[
64,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
118,
127
],
[
117,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
128,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
128,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
128,
142
],
[
142,
143
],
[
117,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
153,
156
],
[
150,
157
],
[
144,
158
],
[
158,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
160,
163
],
[
158,
164
],
[
144,
165
],
[
165,
166
],
[
112,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
111,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
172,
176
],
[
171,
177
],
[
177,
178
],
[
64,
179
],
[
179,
180
],
[
179,
181
],
[
179,
182
],
[
183,
183
],
[
183,
184
],
[
184,
185
],
[
185,
186
],
[
186,
187
],
[
186,
188
],
[
184,
189
],
[
190,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
190,
194
],
[
190,
195
],
[
195,
196
],
[
196,
197
],
[
62,
198
],
[
198,
199
],
[
0,
200
],
[
200,
201
],
[
200,
202
]
] | [
"import java.util.ArrayList;\nimport java.util.Scanner;\n\n\nclass Process{\n\t\n\tprivate String name;\n\tprivate int time;\n\tpublic Process(String name,int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t\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\t\n\t\n}\n\npublic class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint p = sc.nextInt();\n\t\t\n\t\tArrayList<Process> ar = new ArrayList<Process>();\n\t\tArrayList<Process> result = new ArrayList<Process>();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}\n\t\t\n\t\tint totalTime=0,i=0;\n\t\tProcess process;\n\t\twhile(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}\n\t\t\n\t}\n\t\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Process{\n\t\n\tprivate String name;\n\tprivate int time;\n\tpublic Process(String name,int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t\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\t\n\t\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 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\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint p = sc.nextInt();\n\t\t\n\t\tArrayList<Process> ar = new ArrayList<Process>();\n\t\tArrayList<Process> result = new ArrayList<Process>();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}\n\t\t\n\t\tint totalTime=0,i=0;\n\t\tProcess process;\n\t\twhile(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}\n\t\t\n\t}\n\t\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint p = sc.nextInt();\n\t\t\n\t\tArrayList<Process> ar = new ArrayList<Process>();\n\t\tArrayList<Process> result = new ArrayList<Process>();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}\n\t\t\n\t\tint totalTime=0,i=0;\n\t\tProcess process;\n\t\twhile(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}\n\t\t\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint p = sc.nextInt();\n\t\t\n\t\tArrayList<Process> ar = new ArrayList<Process>();\n\t\tArrayList<Process> result = new ArrayList<Process>();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}\n\t\t\n\t\tint totalTime=0,i=0;\n\t\tProcess process;\n\t\twhile(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}\n\t\t\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int p = sc.nextInt();",
"p",
"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\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}",
"{\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}",
"ar.add(new Process(sc.next(),sc.nextInt()))",
"ar.add",
"ar",
"new Process(sc.next(),sc.nextInt())",
"int totalTime=0",
"totalTime",
"0",
"i=0;",
"i",
"0",
"Process process;",
"process",
"while(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}",
"if(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}",
"i<n",
"i",
"n",
"{\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}",
"if((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}",
"(process=ar.get(i)).getTime()<=p",
"(process=ar.get(i)).getTime()",
"(process=ar.get(i)).getTime",
"(process=ar.get(i))",
"process",
"ar.get(i)",
"ar.get",
"ar",
"i",
"p",
"{\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}",
"totalTime += process.getTime()",
"totalTime",
"process.getTime()",
"process.getTime",
"process",
"result.add(new Process(process.getName(), totalTime))",
"result.add",
"result",
"new Process(process.getName(), totalTime)",
"ar.remove(i)",
"ar.remove",
"ar",
"i",
"n--",
"n",
"{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}",
"totalTime += p",
"totalTime",
"p",
"int temp =ar.get(i).getTime()-p;",
"temp",
"ar.get(i).getTime()-p",
"ar.get(i).getTime()",
"ar.get(i).getTime",
"ar.get(i)",
"ar.get",
"ar",
"i",
"p",
"ar.get(i).setTime(temp)",
"ar.get(i).setTime",
"ar.get(i)",
"ar.get",
"ar",
"i",
"temp",
"i++",
"i",
"{\n\t\t\t\ti=0;\n\t\t\t}",
"i=0",
"i",
"0",
"if(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}",
"ar.size()==0",
"ar.size()",
"ar.size",
"ar",
"0",
"{\n\t\t\t\tbreak;\n\t\t\t}",
"break;",
"for(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}",
"Process rProcess",
"result",
"{\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}",
"{\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}",
"System.out.println(rProcess.getName()+ \" \"+rProcess.getTime())",
"System.out.println",
"System.out",
"System",
"System.out",
"rProcess.getName()+ \" \"+rProcess.getTime()",
"rProcess.getName()+ \" \"+rProcess.getTime()",
"rProcess.getName()",
"rProcess.getName",
"rProcess",
"\" \"",
"rProcess.getTime()",
"rProcess.getTime",
"rProcess",
"String[] args",
"args",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint p = sc.nextInt();\n\t\t\n\t\tArrayList<Process> ar = new ArrayList<Process>();\n\t\tArrayList<Process> result = new ArrayList<Process>();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}\n\t\t\n\t\tint totalTime=0,i=0;\n\t\tProcess process;\n\t\twhile(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}\n\t\t\n\t}\n\t\n}",
"public class Main {\n\t\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint p = sc.nextInt();\n\t\t\n\t\tArrayList<Process> ar = new ArrayList<Process>();\n\t\tArrayList<Process> result = new ArrayList<Process>();\n\t\t\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tar.add(new Process(sc.next(),sc.nextInt()));\n\t\t}\n\t\t\n\t\tint totalTime=0,i=0;\n\t\tProcess process;\n\t\twhile(true){\n\t\t\tif(i<n){\n\t\t\t\tif((process=ar.get(i)).getTime()<=p){\n\t\t\t\t\ttotalTime += process.getTime();\n\t\t\t\t\tresult.add(new Process(process.getName(), totalTime));\n\t\t\t\t\tar.remove(i);\n\t\t\t\t\tn--;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\ttotalTime += p;\n\t\t\t\t\tint temp =ar.get(i).getTime()-p;\n\t\t\t\t\tar.get(i).setTime(temp);\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\ti=0;\n\t\t\t}\n\t\t\tif(ar.size()==0){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(Process rProcess:result){\n\t\t\tSystem.out.println(rProcess.getName()+ \" \"+rProcess.getTime());\n\t\t}\n\t\t\n\t}\n\t\n}",
"Main"
] | import java.util.ArrayList;
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 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;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int p = 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(),sc.nextInt()));
}
int totalTime=0,i=0;
Process process;
while(true){
if(i<n){
if((process=ar.get(i)).getTime()<=p){
totalTime += process.getTime();
result.add(new Process(process.getName(), totalTime));
ar.remove(i);
n--;
}
else{
totalTime += p;
int temp =ar.get(i).getTime()-p;
ar.get(i).setTime(temp);
i++;
}
}
else{
i=0;
}
if(ar.size()==0){
break;
}
}
for(Process rProcess:result){
System.out.println(rProcess.getName()+ " "+rProcess.getTime());
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
17,
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,
4,
18,
13,
17,
30,
14,
2,
2,
4,
18,
13,
13,
17,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
4,
18,
18,
13,
13,
2,
2,
4,
18,
13,
17,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
11,
33
],
[
33,
34
],
[
33,
35
],
[
11,
36
],
[
36,
37
],
[
37,
38
],
[
38,
39
],
[
38,
40
],
[
36,
41
],
[
41,
42
],
[
41,
43
],
[
36,
44
],
[
44,
45
],
[
45,
46
],
[
36,
47
],
[
48,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
49,
52
],
[
52,
53
],
[
53,
54
],
[
48,
55
],
[
55,
56
],
[
56,
57
],
[
55,
58
],
[
58,
59
],
[
59,
60
],
[
11,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
62,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
70,
74
],
[
69,
75
],
[
68,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
81,
82
],
[
76,
83
],
[
83,
84
],
[
84,
85
],
[
83,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
86,
90
],
[
76,
91
],
[
91,
92
],
[
91,
93
],
[
68,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
97,
98
],
[
98,
99
],
[
94,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
106,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
106,
110
],
[
106,
111
],
[
9,
112
],
[
112,
113
]
] | [
"import java.util.*;\nimport java.io.*;\n\nclass Main{\n public static void main(String[] args) throws IOException{\n\tScanner scan = new Scanner(System.in);\n\tint n = scan.nextInt();\n\tint reg = scan.nextInt();\n\tQueue<String> method = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\tint i;\n\tint time0=0;\n\tfor(i=0 ; i<n ; i++){\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}\n\n\twhile(method.size()>0){\n\t if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }\n\t}\n }\n}\n\t\t\n\t \n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"class Main{\n public static void main(String[] args) throws IOException{\n\tScanner scan = new Scanner(System.in);\n\tint n = scan.nextInt();\n\tint reg = scan.nextInt();\n\tQueue<String> method = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\tint i;\n\tint time0=0;\n\tfor(i=0 ; i<n ; i++){\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}\n\n\twhile(method.size()>0){\n\t if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }\n\t}\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\tScanner scan = new Scanner(System.in);\n\tint n = scan.nextInt();\n\tint reg = scan.nextInt();\n\tQueue<String> method = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\tint i;\n\tint time0=0;\n\tfor(i=0 ; i<n ; i++){\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}\n\n\twhile(method.size()>0){\n\t if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }\n\t}\n }",
"main",
"{\n\tScanner scan = new Scanner(System.in);\n\tint n = scan.nextInt();\n\tint reg = scan.nextInt();\n\tQueue<String> method = new LinkedList<String>();\n\tQueue<Integer> time = new LinkedList<Integer>();\n\tint i;\n\tint time0=0;\n\tfor(i=0 ; i<n ; i++){\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}\n\n\twhile(method.size()>0){\n\t if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\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 reg = scan.nextInt();",
"reg",
"scan.nextInt()",
"scan.nextInt",
"scan",
"Queue<String> method = new LinkedList<String>();",
"method",
"new LinkedList<String>()",
"Queue<Integer> time = new LinkedList<Integer>();",
"time",
"new LinkedList<Integer>()",
"int i;",
"i",
"int time0=0;",
"time0",
"0",
"for(i=0 ; i<n ; i++){\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}",
"i=0 ;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}",
"{\n\t method.add(scan.next());\n\t time.add(scan.nextInt());\n\t}",
"method.add(scan.next())",
"method.add",
"method",
"scan.next()",
"scan.next",
"scan",
"time.add(scan.nextInt())",
"time.add",
"time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(method.size()>0){\n\t if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }\n\t}",
"method.size()>0",
"method.size()",
"method.size",
"method",
"0",
"{\n\t if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }\n\t}",
"if(time.peek() - reg>0){\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }\n\n\t \n\t else{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }",
"time.peek() - reg>0",
"time.peek() - reg",
"time.peek()",
"time.peek",
"time",
"reg",
"0",
"{\n\t\tmethod.add(method.poll());\n\t\ttime.add(time.poll() - reg);\n\t\ttime0+=reg;\n\t }",
"method.add(method.poll())",
"method.add",
"method",
"method.poll()",
"method.poll",
"method",
"time.add(time.poll() - reg)",
"time.add",
"time",
"time.poll() - reg",
"time.poll()",
"time.poll",
"time",
"reg",
"time0+=reg",
"time0",
"reg",
"{\n\t\ttime0+=time.poll();\n\t\tSystem.out.println(method.poll() + \" \" +time0);\n\t }",
"time0+=time.poll()",
"time0",
"time.poll()",
"time.poll",
"time",
"System.out.println(method.poll() + \" \" +time0)",
"System.out.println",
"System.out",
"System",
"System.out",
"method.poll() + \" \" +time0",
"method.poll() + \" \" +time0",
"method.poll()",
"method.poll",
"method",
"\" \"",
"time0",
"String[] args",
"args"
] | import java.util.*;
import java.io.*;
class Main{
public static void main(String[] args) throws IOException{
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int reg = scan.nextInt();
Queue<String> method = new LinkedList<String>();
Queue<Integer> time = new LinkedList<Integer>();
int i;
int time0=0;
for(i=0 ; i<n ; i++){
method.add(scan.next());
time.add(scan.nextInt());
}
while(method.size()>0){
if(time.peek() - reg>0){
method.add(method.poll());
time.add(time.poll() - reg);
time0+=reg;
}
else{
time0+=time.poll();
System.out.println(method.poll() + " " +time0);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
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,
4,
18,
13,
17,
4,
18,
13,
20,
4,
18,
13,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
2,
4,
18,
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,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
12,
13,
30,
29,
18,
36,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
172,
5
],
[
172,
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
],
[
8,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
28,
30
],
[
8,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
8,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
41,
43
],
[
39,
44
],
[
44,
45
],
[
44,
46
],
[
39,
47
],
[
47,
48
],
[
48,
49
],
[
39,
50
],
[
51,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
54,
59
],
[
51,
60
],
[
60,
61
],
[
61,
62
],
[
60,
63
],
[
8,
64
],
[
64,
65
],
[
65,
66
],
[
8,
67
],
[
67,
68
],
[
67,
69
],
[
8,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
71,
75
],
[
70,
76
],
[
76,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
76,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
95,
99
],
[
88,
100
],
[
100,
101
],
[
101,
102
],
[
100,
103
],
[
82,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
104,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
110,
115
],
[
116,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
116,
120
],
[
116,
121
],
[
6,
122
],
[
122,
123
],
[
0,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
124,
128
],
[
128,
129
],
[
124,
130
],
[
130,
131
],
[
130,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
132,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
138,
142
],
[
130,
143
],
[
143,
144
],
[
130,
145
],
[
145,
146
],
[
124,
147
],
[
147,
148
],
[
147,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
124,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
157,
161
],
[
154,
162
],
[
162,
163
],
[
124,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
0,
171
],
[
171,
172
],
[
171,
173
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\tQueue<Process> entries = new LinkedList<>();\n\t\tint size = Integer.parseInt(info[0]);\n\t\tint runtime = Integer.parseInt(info[1]);\n\t\tfor(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}\n\t\tsc.close();\n\t\tint totalTime = 0;\n\t\twhile(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process{\n\tString name;\n\tint time;\n\t\n\tpublic Process(String n, int t) {\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}\n\t\n\tpublic int getTime() {\n\t\treturn this.time; \n\t}\n\t\n\tpublic void setTime(int t) {\n\t\tthis.time = t;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn this.name;\n\t}\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\tQueue<Process> entries = new LinkedList<>();\n\t\tint size = Integer.parseInt(info[0]);\n\t\tint runtime = Integer.parseInt(info[1]);\n\t\tfor(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}\n\t\tsc.close();\n\t\tint totalTime = 0;\n\t\twhile(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\tQueue<Process> entries = new LinkedList<>();\n\t\tint size = Integer.parseInt(info[0]);\n\t\tint runtime = Integer.parseInt(info[1]);\n\t\tfor(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}\n\t\tsc.close();\n\t\tint totalTime = 0;\n\t\twhile(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\tQueue<Process> entries = new LinkedList<>();\n\t\tint size = Integer.parseInt(info[0]);\n\t\tint runtime = Integer.parseInt(info[1]);\n\t\tfor(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}\n\t\tsc.close();\n\t\tint totalTime = 0;\n\t\twhile(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}\n\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",
"\" \"",
"Queue<Process> entries = new LinkedList<>();",
"entries",
"new LinkedList<>()",
"int size = Integer.parseInt(info[0]);",
"size",
"Integer.parseInt(info[0])",
"Integer.parseInt",
"Integer",
"info[0]",
"info",
"0",
"int runtime = Integer.parseInt(info[1]);",
"runtime",
"Integer.parseInt(info[1])",
"Integer.parseInt",
"Integer",
"info[1]",
"info",
"1",
"for(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < size",
"i",
"size",
"i++",
"i++",
"i",
"{\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}",
"{\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}",
"info = sc.nextLine().split(\" \")",
"info",
"sc.nextLine().split(\" \")",
"sc.nextLine().split",
"sc.nextLine()",
"sc.nextLine",
"sc",
"\" \"",
"entries.add(new Process(info[0], Integer.parseInt(info[1])))",
"entries.add",
"entries",
"new Process(info[0], Integer.parseInt(info[1]))",
"sc.close()",
"sc.close",
"sc",
"int totalTime = 0;",
"totalTime",
"0",
"while(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}",
"entries.size() > 0",
"entries.size()",
"entries.size",
"entries",
"0",
"{\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}",
"Process temp = entries.remove();",
"temp",
"entries.remove()",
"entries.remove",
"entries",
"if(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}",
"temp.getTime() > runtime",
"temp.getTime()",
"temp.getTime",
"temp",
"runtime",
"{\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}",
"totalTime += runtime",
"totalTime",
"runtime",
"temp.setTime(temp.getTime() - runtime)",
"temp.setTime",
"temp",
"temp.getTime() - runtime",
"temp.getTime()",
"temp.getTime",
"temp",
"runtime",
"entries.add(temp)",
"entries.add",
"entries",
"temp",
"{\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}",
"totalTime += temp.getTime()",
"totalTime",
"temp.getTime()",
"temp.getTime",
"temp",
"System.out.println(temp.getName() + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.getName() + \" \" + totalTime",
"temp.getName() + \" \" + totalTime",
"temp.getName()",
"temp.getName",
"temp",
"\" \"",
"totalTime",
"String args[]",
"args",
"class Process{\n\tString name;\n\tint time;\n\t\n\tpublic Process(String n, int t) {\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}\n\t\n\tpublic int getTime() {\n\t\treturn this.time; \n\t}\n\t\n\tpublic void setTime(int t) {\n\t\tthis.time = t;\n\t}\n\t\n\tpublic String getName() {\n\t\treturn this.name;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String n, int t) {\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}",
"Process",
"{\n\t\tthis.name = n;\n\t\tthis.time = t;\n\t}",
"this.name = n",
"this.name",
"this",
"this.name",
"n",
"this.time = t",
"this.time",
"this",
"this.time",
"t",
"String n",
"n",
"int t",
"t",
"public int getTime() {\n\t\treturn this.time; \n\t}",
"getTime",
"{\n\t\treturn this.time; \n\t}",
"return this.time;",
"this.time",
"this",
"this.time",
"public void setTime(int t) {\n\t\tthis.time = t;\n\t}",
"setTime",
"{\n\t\tthis.time = t;\n\t}",
"this.time = t",
"this.time",
"this",
"this.time",
"t",
"int t",
"t",
"public String getName() {\n\t\treturn this.name;\n\t}",
"getName",
"{\n\t\treturn this.name;\n\t}",
"return this.name;",
"this.name",
"this",
"this.name",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\tQueue<Process> entries = new LinkedList<>();\n\t\tint size = Integer.parseInt(info[0]);\n\t\tint runtime = Integer.parseInt(info[1]);\n\t\tfor(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}\n\t\tsc.close();\n\t\tint totalTime = 0;\n\t\twhile(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tString[] info = sc.nextLine().split(\" \");\n\t\tQueue<Process> entries = new LinkedList<>();\n\t\tint size = Integer.parseInt(info[0]);\n\t\tint runtime = Integer.parseInt(info[1]);\n\t\tfor(int i = 0; i < size; i++) {\n\t\t\tinfo = sc.nextLine().split(\" \");\n\t\t\tentries.add(new Process(info[0], Integer.parseInt(info[1])));\n\t\t}\n\t\tsc.close();\n\t\tint totalTime = 0;\n\t\twhile(entries.size() > 0) {\n\t\t\tProcess temp = entries.remove();\n\t\t\tif(temp.getTime() > runtime) {\n\t\t\t\ttotalTime += runtime;\n\t\t\t\ttemp.setTime(temp.getTime() - runtime);\n\t\t\t\tentries.add(temp);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttotalTime += temp.getTime();\n\t\t\t\tSystem.out.println(temp.getName() + \" \" + totalTime);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String[] info = sc.nextLine().split(" ");
Queue<Process> entries = new LinkedList<>();
int size = Integer.parseInt(info[0]);
int runtime = Integer.parseInt(info[1]);
for(int i = 0; i < size; i++) {
info = sc.nextLine().split(" ");
entries.add(new Process(info[0], Integer.parseInt(info[1])));
}
sc.close();
int totalTime = 0;
while(entries.size() > 0) {
Process temp = entries.remove();
if(temp.getTime() > runtime) {
totalTime += runtime;
temp.setTime(temp.getTime() - runtime);
entries.add(temp);
}
else {
totalTime += temp.getTime();
System.out.println(temp.getName() + " " + totalTime);
}
}
}
}
class Process{
String name;
int time;
public Process(String n, int t) {
this.name = n;
this.time = t;
}
public int getTime() {
return this.time;
}
public void setTime(int t) {
this.time = t;
}
public String getName() {
return this.name;
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
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,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
4,
18,
13,
17,
14,
2,
13,
13,
30,
4,
18,
4,
18,
13,
17,
13,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
17,
0,
13,
13,
30,
0,
13,
4,
18,
4,
18,
13,
17,
4,
18,
13,
2,
2,
4,
18,
4,
18,
13,
17,
17,
13,
4,
18,
13,
17,
4,
18,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
41,
13,
4,
18,
13,
17,
0,
18,
36,
13,
18,
13,
17,
0,
18,
36,
13,
4,
18,
13,
18,
13,
17,
23,
13,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
29,
18,
36,
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
],
[
195,
8
],
[
195,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
11,
18
],
[
18,
19
],
[
18,
20
],
[
11,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
11,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
11,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
11,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
11,
62
],
[
62,
63
],
[
62,
64
],
[
11,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
65,
70
],
[
70,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
70,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
79,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
84,
90
],
[
83,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
83,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
83,
102
],
[
102,
103
],
[
102,
104
],
[
79,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
105,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
118,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
121,
124
],
[
118,
125
],
[
118,
126
],
[
105,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
11,
131
],
[
131,
132
],
[
132,
133
],
[
9,
134
],
[
134,
135
],
[
0,
136
],
[
136,
137
],
[
136,
138
],
[
138,
139
],
[
136,
140
],
[
140,
141
],
[
136,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
147,
150
],
[
144,
151
],
[
151,
152
],
[
152,
153
],
[
152,
154
],
[
151,
155
],
[
155,
156
],
[
155,
157
],
[
144,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
163,
164
],
[
162,
165
],
[
165,
166
],
[
165,
167
],
[
142,
168
],
[
168,
169
],
[
136,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
136,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
136,
184
],
[
184,
185
],
[
184,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
188,
190
],
[
187,
191
],
[
184,
192
],
[
192,
193
],
[
0,
194
],
[
194,
195
],
[
194,
196
]
] | [
"import java.io.*;\nimport java.util.*;\n\npublic class Main {\n\tpublic static void main(String [] args) throws NumberFormatException, IOException{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tPrintWriter pr=new PrintWriter(System.out);\n\t\tArrayList<task> ar=new ArrayList<task>();\n\t\tString[] s=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);\n\t\tfor (int i=0;i<n;i++){\n\t\t\tar.add(new task(br.readLine()));\n\t\t}\n\t\tint totaltime=0;\n\t\twhile (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}\n\t\tpr.close();\n\t}\n}\n\nclass task{\n\tprivate String name;\n\tprivate int time;\n\tpublic task(String str){\n\t\tString[] stmp=str.split(\" \");\n\t\tthis.name=stmp[0];\n\t\tthis.time=Integer.parseInt(stmp[1]);\n\t}\n\tpublic String getname(){\n\t\treturn this.name;\n\t}\n\tpublic int gettime(){\n\t\treturn this.time;\n\t}\n\tpublic void timecut(int t){\n\t\tthis.time-=t;\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String [] args) throws NumberFormatException, IOException{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tPrintWriter pr=new PrintWriter(System.out);\n\t\tArrayList<task> ar=new ArrayList<task>();\n\t\tString[] s=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);\n\t\tfor (int i=0;i<n;i++){\n\t\t\tar.add(new task(br.readLine()));\n\t\t}\n\t\tint totaltime=0;\n\t\twhile (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}\n\t\tpr.close();\n\t}\n}",
"Main",
"public static void main(String [] args) throws NumberFormatException, IOException{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tPrintWriter pr=new PrintWriter(System.out);\n\t\tArrayList<task> ar=new ArrayList<task>();\n\t\tString[] s=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);\n\t\tfor (int i=0;i<n;i++){\n\t\t\tar.add(new task(br.readLine()));\n\t\t}\n\t\tint totaltime=0;\n\t\twhile (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}\n\t\tpr.close();\n\t}",
"main",
"{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tPrintWriter pr=new PrintWriter(System.out);\n\t\tArrayList<task> ar=new ArrayList<task>();\n\t\tString[] s=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);\n\t\tfor (int i=0;i<n;i++){\n\t\t\tar.add(new task(br.readLine()));\n\t\t}\n\t\tint totaltime=0;\n\t\twhile (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}\n\t\tpr.close();\n\t}",
"BufferedReader br=new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"PrintWriter pr=new PrintWriter(System.out);",
"pr",
"new PrintWriter(System.out)",
"ArrayList<task> ar=new ArrayList<task>();",
"ar",
"new ArrayList<task>()",
"String[] s=br.readLine().split(\" \");",
"s",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n=Integer.parseInt(s[0])",
"n",
"Integer.parseInt(s[0])",
"Integer.parseInt",
"Integer",
"s[0]",
"s",
"0",
"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\tar.add(new task(br.readLine()));\n\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tar.add(new task(br.readLine()));\n\t\t}",
"{\n\t\t\tar.add(new task(br.readLine()));\n\t\t}",
"ar.add(new task(br.readLine()))",
"ar.add",
"ar",
"new task(br.readLine())",
"int totaltime=0;",
"totaltime",
"0",
"while (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}",
"!ar.isEmpty()",
"ar.isEmpty()",
"ar.isEmpty",
"ar",
"{\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}",
"int tasktime=ar.get(0).gettime();",
"tasktime",
"ar.get(0).gettime()",
"ar.get(0).gettime",
"ar.get(0)",
"ar.get",
"ar",
"0",
"if (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}",
"tasktime>q",
"tasktime",
"q",
"{\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}",
"ar.get(0).timecut(q)",
"ar.get(0).timecut",
"ar.get(0)",
"ar.get",
"ar",
"0",
"q",
"ar.add(ar.get(0))",
"ar.add",
"ar",
"ar.get(0)",
"ar.get",
"ar",
"0",
"ar.remove(0)",
"ar.remove",
"ar",
"0",
"totaltime+=q",
"totaltime",
"q",
"{\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}",
"totaltime+=ar.get(0).gettime()",
"totaltime",
"ar.get(0).gettime()",
"ar.get(0).gettime",
"ar.get(0)",
"ar.get",
"ar",
"0",
"pr.println(ar.get(0).getname()+\" \"+totaltime)",
"pr.println",
"pr",
"ar.get(0).getname()+\" \"+totaltime",
"ar.get(0).getname()+\" \"+totaltime",
"ar.get(0).getname()",
"ar.get(0).getname",
"ar.get(0)",
"ar.get",
"ar",
"0",
"\" \"",
"totaltime",
"ar.remove(0)",
"ar.remove",
"ar",
"0",
"pr.close()",
"pr.close",
"pr",
"String [] args",
"args",
"class task{\n\tprivate String name;\n\tprivate int time;\n\tpublic task(String str){\n\t\tString[] stmp=str.split(\" \");\n\t\tthis.name=stmp[0];\n\t\tthis.time=Integer.parseInt(stmp[1]);\n\t}\n\tpublic String getname(){\n\t\treturn this.name;\n\t}\n\tpublic int gettime(){\n\t\treturn this.time;\n\t}\n\tpublic void timecut(int t){\n\t\tthis.time-=t;\n\t}\n}",
"task",
"private String name;",
"name",
"private int time;",
"time",
"public task(String str){\n\t\tString[] stmp=str.split(\" \");\n\t\tthis.name=stmp[0];\n\t\tthis.time=Integer.parseInt(stmp[1]);\n\t}",
"task",
"{\n\t\tString[] stmp=str.split(\" \");\n\t\tthis.name=stmp[0];\n\t\tthis.time=Integer.parseInt(stmp[1]);\n\t}",
"String[] stmp=str.split(\" \");",
"stmp",
"str.split(\" \")",
"str.split",
"str",
"\" \"",
"this.name=stmp[0]",
"this.name",
"this",
"this.name",
"stmp[0]",
"stmp",
"0",
"this.time=Integer.parseInt(stmp[1])",
"this.time",
"this",
"this.time",
"Integer.parseInt(stmp[1])",
"Integer.parseInt",
"Integer",
"stmp[1]",
"stmp",
"1",
"String str",
"str",
"public String getname(){\n\t\treturn this.name;\n\t}",
"getname",
"{\n\t\treturn this.name;\n\t}",
"return this.name;",
"this.name",
"this",
"this.name",
"public int gettime(){\n\t\treturn this.time;\n\t}",
"gettime",
"{\n\t\treturn this.time;\n\t}",
"return this.time;",
"this.time",
"this",
"this.time",
"public void timecut(int t){\n\t\tthis.time-=t;\n\t}",
"timecut",
"{\n\t\tthis.time-=t;\n\t}",
"this.time-=t",
"this.time",
"this",
"this.time",
"t",
"int t",
"t",
"public class Main {\n\tpublic static void main(String [] args) throws NumberFormatException, IOException{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tPrintWriter pr=new PrintWriter(System.out);\n\t\tArrayList<task> ar=new ArrayList<task>();\n\t\tString[] s=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);\n\t\tfor (int i=0;i<n;i++){\n\t\t\tar.add(new task(br.readLine()));\n\t\t}\n\t\tint totaltime=0;\n\t\twhile (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}\n\t\tpr.close();\n\t}\n}",
"public class Main {\n\tpublic static void main(String [] args) throws NumberFormatException, IOException{\n\t\tBufferedReader br=new BufferedReader(new InputStreamReader(System.in));\n\t\tPrintWriter pr=new PrintWriter(System.out);\n\t\tArrayList<task> ar=new ArrayList<task>();\n\t\tString[] s=br.readLine().split(\" \");\n\t\tint n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);\n\t\tfor (int i=0;i<n;i++){\n\t\t\tar.add(new task(br.readLine()));\n\t\t}\n\t\tint totaltime=0;\n\t\twhile (!ar.isEmpty()){\n\t\t\tint tasktime=ar.get(0).gettime();\n\t\t\tif (tasktime>q){\n\t\t\t\tar.get(0).timecut(q);\n\t\t\t\tar.add(ar.get(0));\n\t\t\t\tar.remove(0);\n\t\t\t\ttotaltime+=q;\n\t\t\t}else {\n\t\t\t\ttotaltime+=ar.get(0).gettime();\n\t\t\t\tpr.println(ar.get(0).getname()+\" \"+totaltime);\n\t\t\t\tar.remove(0);\n\t\t\t}\n\t\t}\n\t\tpr.close();\n\t}\n}",
"Main"
] | import java.io.*;
import java.util.*;
public class Main {
public static void main(String [] args) throws NumberFormatException, IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pr=new PrintWriter(System.out);
ArrayList<task> ar=new ArrayList<task>();
String[] s=br.readLine().split(" ");
int n=Integer.parseInt(s[0]),q=Integer.parseInt(s[1]);
for (int i=0;i<n;i++){
ar.add(new task(br.readLine()));
}
int totaltime=0;
while (!ar.isEmpty()){
int tasktime=ar.get(0).gettime();
if (tasktime>q){
ar.get(0).timecut(q);
ar.add(ar.get(0));
ar.remove(0);
totaltime+=q;
}else {
totaltime+=ar.get(0).gettime();
pr.println(ar.get(0).getname()+" "+totaltime);
ar.remove(0);
}
}
pr.close();
}
}
class task{
private String name;
private int time;
public task(String str){
String[] stmp=str.split(" ");
this.name=stmp[0];
this.time=Integer.parseInt(stmp[1]);
}
public String getname(){
return this.name;
}
public int gettime(){
return this.time;
}
public void timecut(int t){
this.time-=t;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
17,
41,
13,
17,
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,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
2,
13,
13,
30,
0,
13,
2,
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,
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
],
[
134,
11
],
[
134,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
14,
20
],
[
20,
21
],
[
20,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
14,
26
],
[
26,
27
],
[
26,
28
],
[
14,
29
],
[
29,
30
],
[
29,
31
],
[
14,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
14,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
14,
42
],
[
42,
43
],
[
43,
44
],
[
14,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
47,
49
],
[
45,
50
],
[
50,
51
],
[
50,
52
],
[
45,
53
],
[
53,
54
],
[
54,
55
],
[
45,
56
],
[
57,
57
],
[
57,
58
],
[
58,
59
],
[
59,
60
],
[
58,
61
],
[
61,
62
],
[
62,
63
],
[
57,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
67,
68
],
[
68,
69
],
[
14,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
73,
74
],
[
70,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
75,
81
],
[
81,
82
],
[
81,
83
],
[
83,
84
],
[
84,
85
],
[
75,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
86,
90
],
[
90,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
93,
95
],
[
86,
96
],
[
96,
97
],
[
97,
98
],
[
97,
99
],
[
99,
100
],
[
99,
101
],
[
75,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
107,
110
],
[
110,
111
],
[
110,
112
],
[
106,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
102,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
118,
123
],
[
124,
124
],
[
124,
125
],
[
124,
126
],
[
124,
127
],
[
14,
128
],
[
128,
129
],
[
129,
130
],
[
12,
131
],
[
131,
132
],
[
0,
133
],
[
133,
134
],
[
133,
135
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint num, quantum = 0;\n\t\tint time = 0; // time;総時間数\n\t\tQueue<String> qName = new ArrayDeque<String>();\n\t\tQueue<Integer> qTime = new ArrayDeque<Integer>();\n\n\t\tnum = scan.nextInt(); // 入力数\n\t\tquantum = scan.nextInt(); // クオンタム(実行する処理時間)\n\t\tscan.nextLine();\n\n\t\tfor (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}\n\n\t\twhile (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}\n}\n",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint num, quantum = 0;\n\t\tint time = 0; // time;総時間数\n\t\tQueue<String> qName = new ArrayDeque<String>();\n\t\tQueue<Integer> qTime = new ArrayDeque<Integer>();\n\n\t\tnum = scan.nextInt(); // 入力数\n\t\tquantum = scan.nextInt(); // クオンタム(実行する処理時間)\n\t\tscan.nextLine();\n\n\t\tfor (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}\n\n\t\twhile (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\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 num, quantum = 0;\n\t\tint time = 0; // time;総時間数\n\t\tQueue<String> qName = new ArrayDeque<String>();\n\t\tQueue<Integer> qTime = new ArrayDeque<Integer>();\n\n\t\tnum = scan.nextInt(); // 入力数\n\t\tquantum = scan.nextInt(); // クオンタム(実行する処理時間)\n\t\tscan.nextLine();\n\n\t\tfor (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}\n\n\t\twhile (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\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 num, quantum = 0;\n\t\tint time = 0; // time;総時間数\n\t\tQueue<String> qName = new ArrayDeque<String>();\n\t\tQueue<Integer> qTime = new ArrayDeque<Integer>();\n\n\t\tnum = scan.nextInt(); // 入力数\n\t\tquantum = scan.nextInt(); // クオンタム(実行する処理時間)\n\t\tscan.nextLine();\n\n\t\tfor (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}\n\n\t\twhile (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\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 num",
"num",
"quantum = 0;",
"quantum",
"0",
"int time = 0;",
"time",
"0",
"Queue<String> qName = new ArrayDeque<String>();",
"qName",
"new ArrayDeque<String>()",
"Queue<Integer> qTime = new ArrayDeque<Integer>();",
"qTime",
"new ArrayDeque<Integer>()",
"num = scan.nextInt()",
"num",
"scan.nextInt()",
"scan.nextInt",
"scan",
"quantum = scan.nextInt()",
"quantum",
"scan.nextInt()",
"scan.nextInt",
"scan",
"scan.nextLine()",
"scan.nextLine",
"scan",
"for (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}",
"{\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}",
"qName.add(scan.next())",
"qName.add",
"qName",
"scan.next()",
"scan.next",
"scan",
"qTime.add(scan.nextInt())",
"qTime.add",
"qTime",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}\n\t\t}",
"!qName.isEmpty()",
"qName.isEmpty()",
"qName.isEmpty",
"qName",
"{\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}\n\t\t}",
"String qNamePolled = qName.poll();",
"qNamePolled",
"qName.poll()",
"qName.poll",
"qName",
"int getTime = qTime.poll();",
"getTime",
"qTime.poll()",
"qTime.poll",
"qTime",
"if (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}",
"getTime > quantum",
"getTime",
"quantum",
"{ // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t}",
"time = time + quantum",
"time",
"time + quantum",
"time",
"quantum",
"{\n\t\t\t\ttime = time + getTime;\n\t\t\t}",
"time = time + getTime",
"time",
"time + getTime",
"time",
"getTime",
"if (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}",
"getTime > quantum",
"getTime",
"quantum",
"{\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t}",
"qTime.add(getTime - quantum)",
"qTime.add",
"qTime",
"getTime - quantum",
"getTime",
"quantum",
"qName.add(qNamePolled)",
"qName.add",
"qName",
"qNamePolled",
"{ // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}",
"System.out.println(qNamePolled + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"qNamePolled + \" \" + time",
"qNamePolled + \" \" + time",
"qNamePolled",
"\" \"",
"time",
"scan.close()",
"scan.close",
"scan",
"String args[]",
"args",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint num, quantum = 0;\n\t\tint time = 0; // time;総時間数\n\t\tQueue<String> qName = new ArrayDeque<String>();\n\t\tQueue<Integer> qTime = new ArrayDeque<Integer>();\n\n\t\tnum = scan.nextInt(); // 入力数\n\t\tquantum = scan.nextInt(); // クオンタム(実行する処理時間)\n\t\tscan.nextLine();\n\n\t\tfor (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}\n\n\t\twhile (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}\n}",
"public class Main {\n\tpublic static void main(String args[]) {\n\t\tScanner scan = new Scanner(System.in);\n\t\tint num, quantum = 0;\n\t\tint time = 0; // time;総時間数\n\t\tQueue<String> qName = new ArrayDeque<String>();\n\t\tQueue<Integer> qTime = new ArrayDeque<Integer>();\n\n\t\tnum = scan.nextInt(); // 入力数\n\t\tquantum = scan.nextInt(); // クオンタム(実行する処理時間)\n\t\tscan.nextLine();\n\n\t\tfor (int i = 0; i < num; i++) {\n\t\t\tqName.add(scan.next());\n\t\t\tqTime.add(scan.nextInt());\n\t\t}\n\n\t\twhile (!qName.isEmpty()) {\n\t\t\tString qNamePolled = qName.poll();\n\t\t\tint getTime = qTime.poll();\n\n\t\t\tif (getTime > quantum) { // 総時間数をカウントしていく\n\t\t\t\ttime = time + quantum;\n\t\t\t} else {\n\t\t\t\ttime = time + getTime;\n\t\t\t}\n\n\t\t\tif (getTime > quantum) {\n\t\t\t\tqTime.add(getTime - quantum);\n\t\t\t\tqName.add(qNamePolled);\n\t\t\t} else { // 今のプロセス処理終了\n\t\t\t\tSystem.out.println(qNamePolled + \" \" + time);\n\t\t\t}\n\t\t}\n\t\tscan.close();\n\t}\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int num, quantum = 0;
int time = 0; // time;総時間数
Queue<String> qName = new ArrayDeque<String>();
Queue<Integer> qTime = new ArrayDeque<Integer>();
num = scan.nextInt(); // 入力数
quantum = scan.nextInt(); // クオンタム(実行する処理時間)
scan.nextLine();
for (int i = 0; i < num; i++) {
qName.add(scan.next());
qTime.add(scan.nextInt());
}
while (!qName.isEmpty()) {
String qNamePolled = qName.poll();
int getTime = qTime.poll();
if (getTime > quantum) { // 総時間数をカウントしていく
time = time + quantum;
} else {
time = time + getTime;
}
if (getTime > quantum) {
qTime.add(getTime - quantum);
qName.add(qNamePolled);
} else { // 今のプロセス処理終了
System.out.println(qNamePolled + " " + time);
}
}
scan.close();
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
38,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
4,
18,
13,
14,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
29,
13,
12,
13,
30,
29,
2,
18,
36,
13,
13,
23,
13,
12,
13,
30,
0,
18,
36,
13,
13,
23,
13,
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
],
[
16,
17
],
[
17,
18
],
[
17,
19
],
[
16,
20
],
[
20,
21
],
[
20,
22
],
[
16,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
29,
30
],
[
16,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
37,
38
],
[
16,
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
],
[
59,
62
],
[
62,
63
],
[
63,
64
],
[
51,
65
],
[
65,
66
],
[
66,
67
],
[
65,
68
],
[
16,
69
],
[
69,
70
],
[
69,
71
],
[
16,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
78,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
86,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
94,
96
],
[
91,
97
],
[
97,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
97,
102
],
[
103,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
103,
108
],
[
86,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
109,
113
],
[
113,
114
],
[
114,
115
],
[
113,
116
],
[
109,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
12,
121
],
[
121,
122
],
[
0,
123
],
[
123,
124
],
[
123,
125
],
[
125,
126
],
[
123,
127
],
[
127,
128
],
[
123,
129
],
[
129,
130
],
[
129,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
133,
135
],
[
132,
136
],
[
131,
137
],
[
137,
138
],
[
138,
139
],
[
138,
140
],
[
137,
141
],
[
129,
142
],
[
142,
143
],
[
129,
144
],
[
144,
145
],
[
123,
146
],
[
146,
147
],
[
146,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
152,
153
],
[
123,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
154,
163
],
[
163,
164
],
[
123,
165
],
[
165,
166
],
[
165,
167
],
[
167,
168
],
[
168,
169
],
[
169,
170
],
[
169,
171
],
[
168,
172
],
[
165,
173
],
[
173,
174
],
[
123,
175
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Deque;\nimport java.util.Scanner;\nclass Main {\n\tpublic static void main(String[] args){\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\tDeque<Process> process=new ArrayDeque<>();\n\t\t\tint n=Integer.parseInt(sc.next());\n\t\t\tint q=Integer.parseInt(sc.next());\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}\n\t\t\tint totalTime=0;\n\t\t\twhile(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process implements Cloneable{\n\tString name;\n\tint time;\n\tProcess(String name, int time){\n\t\tthis.name=name;\n\t\tthis.time=time;\n\t}\n\tpublic Process clone(){\n\t\tProcess p = new Process(this.name,this.time);\n\t\treturn p;\n\t}\n\tpublic boolean isEnds(int q){\n\t\treturn (this.time<=q);\n\t}\n\tpublic void work(int q){\n\t\tthis.time-=q;\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 Main {\n\tpublic static void main(String[] args){\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\tDeque<Process> process=new ArrayDeque<>();\n\t\t\tint n=Integer.parseInt(sc.next());\n\t\t\tint q=Integer.parseInt(sc.next());\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}\n\t\t\tint totalTime=0;\n\t\t\twhile(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\tDeque<Process> process=new ArrayDeque<>();\n\t\t\tint n=Integer.parseInt(sc.next());\n\t\t\tint q=Integer.parseInt(sc.next());\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}\n\t\t\tint totalTime=0;\n\t\t\twhile(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\ttry(Scanner sc = new Scanner(System.in)){\n\t\t\tDeque<Process> process=new ArrayDeque<>();\n\t\t\tint n=Integer.parseInt(sc.next());\n\t\t\tint q=Integer.parseInt(sc.next());\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}\n\t\t\tint totalTime=0;\n\t\t\twhile(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"try(Scanner sc = new Scanner(System.in)){\n\t\t\tDeque<Process> process=new ArrayDeque<>();\n\t\t\tint n=Integer.parseInt(sc.next());\n\t\t\tint q=Integer.parseInt(sc.next());\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}\n\t\t\tint totalTime=0;\n\t\t\twhile(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"{\n\t\t\tDeque<Process> process=new ArrayDeque<>();\n\t\t\tint n=Integer.parseInt(sc.next());\n\t\t\tint q=Integer.parseInt(sc.next());\n\t\t\tfor(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}\n\t\t\tint totalTime=0;\n\t\t\twhile(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"Scanner sc = new Scanner(System.in)",
"Scanner sc = new Scanner(System.in)",
"new Scanner(System.in)",
"Deque<Process> process=new ArrayDeque<>();",
"process",
"new ArrayDeque<>()",
"int n=Integer.parseInt(sc.next());",
"n",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"int q=Integer.parseInt(sc.next());",
"q",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"for(int i=0;i<n;i++){\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}",
"int i=0;",
"int i=0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}",
"{\n\t\t\t\tString name=sc.next();\n\t\t\t\tint time=Integer.parseInt(sc.next());\n\t\t\t\tprocess.addLast(new Process(name,time));\n\t\t\t}",
"String name=sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time=Integer.parseInt(sc.next());",
"time",
"Integer.parseInt(sc.next())",
"Integer.parseInt",
"Integer",
"sc.next()",
"sc.next",
"sc",
"process.addLast(new Process(name,time))",
"process.addLast",
"process",
"new Process(name,time)",
"int totalTime=0;",
"totalTime",
"0",
"while(process.size()!=0){\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}",
"process.size()!=0",
"process.size()",
"process.size",
"process",
"0",
"{\n\t\t\t\tProcess p = process.pollFirst().clone();\n\t\t\t\tif(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}\n\t\t\t}",
"Process p = process.pollFirst().clone();",
"p",
"process.pollFirst().clone()",
"process.pollFirst().clone",
"process.pollFirst()",
"process.pollFirst",
"process",
"if(p.isEnds(q)){\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}else{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}",
"p.isEnds(q)",
"p.isEnds",
"p",
"q",
"{\n\t\t\t\t\ttotalTime+=p.time;\n\t\t\t\t\tSystem.out.println(p.name+\" \"+totalTime);\n\t\t\t\t}",
"totalTime+=p.time",
"totalTime",
"p.time",
"p",
"p.time",
"System.out.println(p.name+\" \"+totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name+\" \"+totalTime",
"p.name+\" \"+totalTime",
"p.name",
"p",
"p.name",
"\" \"",
"totalTime",
"{\n\t\t\t\t\ttotalTime+=q;\n\t\t\t\t\tp.work(q);\n\t\t\t\t\tprocess.addLast(p);\n\t\t\t\t}",
"totalTime+=q",
"totalTime",
"q",
"p.work(q)",
"p.work",
"p",
"q",
"process.addLast(p)",
"process.addLast",
"process",
"p",
"String[] args",
"args",
"class Process implements Cloneable{\n\tString name;\n\tint time;\n\tProcess(String name, int time){\n\t\tthis.name=name;\n\t\tthis.time=time;\n\t}\n\tpublic Process clone(){\n\t\tProcess p = new Process(this.name,this.time);\n\t\treturn p;\n\t}\n\tpublic boolean isEnds(int q){\n\t\treturn (this.time<=q);\n\t}\n\tpublic void work(int q){\n\t\tthis.time-=q;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time){\n\t\tthis.name=name;\n\t\tthis.time=time;\n\t}",
"Process",
"{\n\t\tthis.name=name;\n\t\tthis.time=time;\n\t}",
"this.name=name",
"this.name",
"this",
"this.name",
"name",
"this.time=time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public Process clone(){\n\t\tProcess p = new Process(this.name,this.time);\n\t\treturn p;\n\t}",
"clone",
"{\n\t\tProcess p = new Process(this.name,this.time);\n\t\treturn p;\n\t}",
"Process p = new Process(this.name,this.time);",
"p",
"new Process(this.name,this.time)",
"return p;",
"p",
"public boolean isEnds(int q){\n\t\treturn (this.time<=q);\n\t}",
"isEnds",
"{\n\t\treturn (this.time<=q);\n\t}",
"return (this.time<=q);",
"(this.time<=q)",
"this.time",
"this",
"this.time",
"q",
"int q",
"q",
"public void work(int q){\n\t\tthis.time-=q;\n\t}",
"work",
"{\n\t\tthis.time-=q;\n\t}",
"this.time-=q",
"this.time",
"this",
"this.time",
"q",
"int q",
"q",
"Cloneable"
] | import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
class Main {
public static void main(String[] args){
try(Scanner sc = new Scanner(System.in)){
Deque<Process> process=new ArrayDeque<>();
int n=Integer.parseInt(sc.next());
int q=Integer.parseInt(sc.next());
for(int i=0;i<n;i++){
String name=sc.next();
int time=Integer.parseInt(sc.next());
process.addLast(new Process(name,time));
}
int totalTime=0;
while(process.size()!=0){
Process p = process.pollFirst().clone();
if(p.isEnds(q)){
totalTime+=p.time;
System.out.println(p.name+" "+totalTime);
}else{
totalTime+=q;
p.work(q);
process.addLast(p);
}
}
}
}
}
class Process implements Cloneable{
String name;
int time;
Process(String name, int time){
this.name=name;
this.time=time;
}
public Process clone(){
Process p = new Process(this.name,this.time);
return p;
}
public boolean isEnds(int q){
return (this.time<=q);
}
public void work(int q){
this.time-=q;
}
} |
[
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,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
4,
18,
13,
40,
13,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
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
],
[
133,
11
],
[
133,
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
],
[
45,
46
],
[
44,
47
],
[
14,
48
],
[
48,
49
],
[
48,
50
],
[
14,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
54,
55
],
[
51,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
56,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
69,
71
],
[
68,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
68,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
62,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
84,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
87,
92
],
[
93,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
93,
98
],
[
12,
99
],
[
99,
100
],
[
133,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
101,
105
],
[
105,
106
],
[
101,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
109,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
107,
120
],
[
120,
121
],
[
107,
122
],
[
122,
123
],
[
101,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
124,
130
],
[
130,
131
],
[
0,
132
],
[
132,
133
],
[
132,
134
]
] | [
"import java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<TimeTask> que = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }\n \n int timePoint = 0;\n while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }\n }\n \n static class TimeTask {\n String task;\n int time;\n TimeTask (String task, int time) {\n this.task = task;\n this.time = time;\n }\n \n void addTime(int add) {\n time += add;\n }\n }\n}",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<TimeTask> que = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }\n \n int timePoint = 0;\n while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }\n }\n \n static class TimeTask {\n String task;\n int time;\n TimeTask (String task, int time) {\n this.task = task;\n this.time = time;\n }\n \n void addTime(int add) {\n time += add;\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<TimeTask> que = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }\n \n int timePoint = 0;\n while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<TimeTask> que = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }\n \n int timePoint = 0;\n while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\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 quant = sc.nextInt();",
"quant",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Queue<TimeTask> que = new ArrayDeque<>();",
"que",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }",
"{\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }",
"que.add(new TimeTask(sc.next(), sc.nextInt()))",
"que.add",
"que",
"new TimeTask(sc.next(), sc.nextInt())",
"int timePoint = 0;",
"timePoint",
"0",
"while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }",
"TimeTask head = que.poll();",
"head",
"que.poll()",
"que.poll",
"que",
"if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }",
"head.time > quant",
"head.time",
"head",
"head.time",
"quant",
"{\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n }",
"timePoint += quant",
"timePoint",
"quant",
"head.addTime(-quant)",
"head.addTime",
"head",
"-quant",
"quant",
"que.add(head)",
"que.add",
"que",
"head",
"{\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }",
"timePoint += head.time",
"timePoint",
"head.time",
"head",
"head.time",
"System.out.println(head.task + \" \" + timePoint)",
"System.out.println",
"System.out",
"System",
"System.out",
"head.task + \" \" + timePoint",
"head.task + \" \" + timePoint",
"head.task",
"head",
"head.task",
"\" \"",
"timePoint",
"String[] args",
"args",
"static class TimeTask {\n String task;\n int time;\n TimeTask (String task, int time) {\n this.task = task;\n this.time = time;\n }\n \n void addTime(int add) {\n time += add;\n }\n }",
"TimeTask",
"String task;",
"task",
"int time;",
"time",
"TimeTask (String task, int time) {\n this.task = task;\n this.time = time;\n }",
"TimeTask",
"{\n this.task = task;\n this.time = time;\n }",
"this.task = task",
"this.task",
"this",
"this.task",
"task",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String task",
"task",
"int time",
"time",
"void addTime(int add) {\n time += add;\n }",
"addTime",
"{\n time += add;\n }",
"time += add",
"time",
"add",
"int add",
"add",
"public class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int quant = sc.nextInt();\n\n Queue<TimeTask> que = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }\n \n int timePoint = 0;\n while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }\n }\n \n static class TimeTask {\n String task;\n int time;\n TimeTask (String task, int time) {\n this.task = task;\n this.time = time;\n }\n \n void addTime(int add) {\n time += add;\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 quant = sc.nextInt();\n\n Queue<TimeTask> que = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n que.add(new TimeTask(sc.next(), sc.nextInt()));\n }\n \n int timePoint = 0;\n while (!que.isEmpty()) {\n TimeTask head = que.poll();\n\n if (head.time > quant) {\n timePoint += quant;\n head.addTime(-quant);\n que.add(head);\n \n } else {\n timePoint += head.time;\n System.out.println(head.task + \" \" + timePoint);\n }\n }\n }\n \n static class TimeTask {\n String task;\n int time;\n TimeTask (String task, int time) {\n this.task = task;\n this.time = time;\n }\n \n void addTime(int add) {\n time += add;\n }\n }\n}",
"Main"
] | import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int quant = sc.nextInt();
Queue<TimeTask> que = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
que.add(new TimeTask(sc.next(), sc.nextInt()));
}
int timePoint = 0;
while (!que.isEmpty()) {
TimeTask head = que.poll();
if (head.time > quant) {
timePoint += quant;
head.addTime(-quant);
que.add(head);
} else {
timePoint += head.time;
System.out.println(head.task + " " + timePoint);
}
}
}
static class TimeTask {
String task;
int time;
TimeTask (String task, int time) {
this.task = task;
this.time = time;
}
void addTime(int add) {
time += add;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
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,
13,
23,
13,
6,
13,
41,
13,
17,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
20,
12,
13,
30,
0,
13,
20,
12,
13,
30,
4,
18,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
40,
13,
23,
13,
23,
13,
12,
13,
30,
4,
18,
13,
18,
13,
13,
4,
18,
13,
18,
13,
13,
4,
18,
13,
18,
13,
13,
40,
13,
23,
13,
12,
13,
30,
4,
18,
13,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
4,
18,
13,
17,
40,
13,
12,
13,
30,
41,
13,
17,
4,
13,
42,
17,
30,
41,
13,
2,
18,
13,
13,
13,
14,
2,
13,
17,
30,
0,
13,
2,
13,
13,
0,
18,
13,
13,
13,
4,
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,
17,
4,
13,
3,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
0,
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
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
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
],
[
41,
47
],
[
47,
48
],
[
48,
49
],
[
11,
50
],
[
50,
51
],
[
51,
52
],
[
50,
53
],
[
9,
54
],
[
54,
55
],
[
0,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
58,
60
],
[
56,
61
],
[
61,
62
],
[
61,
63
],
[
56,
64
],
[
64,
65
],
[
64,
66
],
[
56,
67
],
[
67,
68
],
[
56,
69
],
[
69,
70
],
[
69,
71
],
[
56,
72
],
[
72,
73
],
[
72,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
56,
78
],
[
78,
79
],
[
78,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
80,
85
],
[
85,
86
],
[
86,
87
],
[
85,
88
],
[
80,
89
],
[
89,
90
],
[
90,
91
],
[
89,
92
],
[
80,
93
],
[
93,
94
],
[
78,
95
],
[
95,
96
],
[
78,
97
],
[
97,
98
],
[
56,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
102,
105
],
[
105,
106
],
[
105,
107
],
[
101,
108
],
[
108,
109
],
[
109,
110
],
[
108,
111
],
[
111,
112
],
[
111,
113
],
[
101,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
117,
118
],
[
117,
119
],
[
101,
120
],
[
120,
121
],
[
99,
122
],
[
122,
123
],
[
56,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
127,
130
],
[
130,
131
],
[
131,
132
],
[
130,
133
],
[
127,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
127,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
126,
142
],
[
142,
143
],
[
143,
144
],
[
142,
145
],
[
126,
146
],
[
146,
147
],
[
147,
148
],
[
146,
149
],
[
126,
150
],
[
150,
151
],
[
151,
152
],
[
150,
153
],
[
126,
154
],
[
154,
155
],
[
56,
156
],
[
156,
157
],
[
156,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
162,
163
],
[
158,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
169,
170
],
[
170,
171
],
[
170,
172
],
[
169,
173
],
[
166,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
174,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
181,
182
],
[
181,
183
],
[
178,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
178,
189
],
[
189,
190
],
[
189,
191
],
[
174,
192
],
[
192,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
195,
197
],
[
197,
198
],
[
197,
199
],
[
192,
200
],
[
200,
201
],
[
201,
202
],
[
202,
203
],
[
202,
204
],
[
200,
205
],
[
206,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
206,
210
],
[
206,
211
],
[
166,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
216,
217
],
[
212,
218
],
[
156,
219
],
[
219,
220
],
[
56,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
221,
225
],
[
225,
226
],
[
221,
227
],
[
227,
228
],
[
221,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
232,
233
],
[
232,
234
],
[
231,
235
],
[
235,
236
],
[
235,
237
],
[
231,
238
],
[
238,
239
],
[
238,
240
],
[
229,
241
],
[
241,
242
],
[
229,
243
],
[
243,
244
],
[
229,
245
],
[
245,
246
]
] | [
"import java.util.ArrayList;\nimport java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tOrique oq = new Orique();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}\n\t\toq.RoundRobinScheduling(q);\n\t}\n}\n\nclass Orique {\n\tprivate class kakunou {\n\t\tString kstr;\n\t\tint kint;\n\t\tint kprenum;\n\n\t\tvoid setkakunou(String s, int i, int pre) {\n\t\t\tkstr = s;\n\t\t\tkint = i;\n\t\t\tkprenum = pre;\n\t\t}\n\t}\n\n\tprivate int length = 0;\n\tArrayList<String> str = new ArrayList<String>();\n\tArrayList<Integer> in = new ArrayList<Integer>();\n\tkakunou k;\n\tprivate ArrayList<Integer> prenumber = new ArrayList<Integer>();\n\n\tOrique() {\n\t\tk = new kakunou();\n\t}\n\n\tpublic void inque(String t, int i) {\n\t\tstr.add(t);\n\t\tin.add(i);\n\t\tprenumber.add(i);\n\t\tlength++;\n\t}\n\n\tprivate void inque(kakunou k) {\n\t\tstr.add(k.kstr);\n\t\tin.add(k.kint);\n\t\tprenumber.add(k.kprenum);\n\t\tlength++;\n\t}\n\n\tprivate void deque() {\n\t\tk.setkakunou(str.get(0), in.get(0), prenumber.get(0));\n\t\tstr.remove(0);\n\t\tin.remove(0);\n\t\tprenumber.remove(0);\n\t\tlength--;\n\n\t}\n public void RoundRobinScheduling(int q) {\n\t\t\n\t\tint total=0;\n\t\tdeque();\n\t\twhile(true){\n\t\t\tint t1=k.kint-q;\n\t\t\tif(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}\n\t\t\tif(length>0)deque();\n\t\t\telse break;\n\t\t}\n\t\t}\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tOrique oq = new Orique();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}\n\t\toq.RoundRobinScheduling(q);\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tOrique oq = new Orique();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}\n\t\toq.RoundRobinScheduling(q);\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tOrique oq = new Orique();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}\n\t\toq.RoundRobinScheduling(q);\n\t}",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Orique oq = new Orique();",
"oq",
"new Orique()",
"for (int i = 0; i < n; i++) {\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}",
"{\n\t\t\toq.inque(sc.next(), sc.nextInt());\n\t\t}",
"oq.inque(sc.next(), sc.nextInt())",
"oq.inque",
"oq",
"sc.next()",
"sc.next",
"sc",
"sc.nextInt()",
"sc.nextInt",
"sc",
"oq.RoundRobinScheduling(q)",
"oq.RoundRobinScheduling",
"oq",
"q",
"String[] args",
"args",
"class Orique {\n\tprivate class kakunou {\n\t\tString kstr;\n\t\tint kint;\n\t\tint kprenum;\n\n\t\tvoid setkakunou(String s, int i, int pre) {\n\t\t\tkstr = s;\n\t\t\tkint = i;\n\t\t\tkprenum = pre;\n\t\t}\n\t}\n\n\tprivate int length = 0;\n\tArrayList<String> str = new ArrayList<String>();\n\tArrayList<Integer> in = new ArrayList<Integer>();\n\tkakunou k;\n\tprivate ArrayList<Integer> prenumber = new ArrayList<Integer>();\n\n\tOrique() {\n\t\tk = new kakunou();\n\t}\n\n\tpublic void inque(String t, int i) {\n\t\tstr.add(t);\n\t\tin.add(i);\n\t\tprenumber.add(i);\n\t\tlength++;\n\t}\n\n\tprivate void inque(kakunou k) {\n\t\tstr.add(k.kstr);\n\t\tin.add(k.kint);\n\t\tprenumber.add(k.kprenum);\n\t\tlength++;\n\t}\n\n\tprivate void deque() {\n\t\tk.setkakunou(str.get(0), in.get(0), prenumber.get(0));\n\t\tstr.remove(0);\n\t\tin.remove(0);\n\t\tprenumber.remove(0);\n\t\tlength--;\n\n\t}\n public void RoundRobinScheduling(int q) {\n\t\t\n\t\tint total=0;\n\t\tdeque();\n\t\twhile(true){\n\t\t\tint t1=k.kint-q;\n\t\t\tif(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}\n\t\t\tif(length>0)deque();\n\t\t\telse break;\n\t\t}\n\t\t}\n}",
"Orique",
"private int length = 0;",
"length",
"0",
"ArrayList<String> str = new ArrayList<String>();",
"str",
"new ArrayList<String>()",
"ArrayList<Integer> in = new ArrayList<Integer>();",
"in",
"new ArrayList<Integer>()",
"kakunou k;",
"k",
"private ArrayList<Integer> prenumber = new ArrayList<Integer>();",
"prenumber",
"new ArrayList<Integer>()",
"Orique() {\n\t\tk = new kakunou();\n\t}",
"Orique",
"{\n\t\tk = new kakunou();\n\t}",
"k = new kakunou()",
"k",
"new kakunou()",
"public void inque(String t, int i) {\n\t\tstr.add(t);\n\t\tin.add(i);\n\t\tprenumber.add(i);\n\t\tlength++;\n\t}",
"inque",
"{\n\t\tstr.add(t);\n\t\tin.add(i);\n\t\tprenumber.add(i);\n\t\tlength++;\n\t}",
"str.add(t)",
"str.add",
"str",
"t",
"in.add(i)",
"in.add",
"in",
"i",
"prenumber.add(i)",
"prenumber.add",
"prenumber",
"i",
"length++",
"length",
"String t",
"t",
"int i",
"i",
"private void inque(kakunou k) {\n\t\tstr.add(k.kstr);\n\t\tin.add(k.kint);\n\t\tprenumber.add(k.kprenum);\n\t\tlength++;\n\t}",
"inque",
"{\n\t\tstr.add(k.kstr);\n\t\tin.add(k.kint);\n\t\tprenumber.add(k.kprenum);\n\t\tlength++;\n\t}",
"str.add(k.kstr)",
"str.add",
"str",
"k.kstr",
"k",
"k.kstr",
"in.add(k.kint)",
"in.add",
"in",
"k.kint",
"k",
"k.kint",
"prenumber.add(k.kprenum)",
"prenumber.add",
"prenumber",
"k.kprenum",
"k",
"k.kprenum",
"length++",
"length",
"kakunou k",
"k",
"private void deque() {\n\t\tk.setkakunou(str.get(0), in.get(0), prenumber.get(0));\n\t\tstr.remove(0);\n\t\tin.remove(0);\n\t\tprenumber.remove(0);\n\t\tlength--;\n\n\t}",
"deque",
"{\n\t\tk.setkakunou(str.get(0), in.get(0), prenumber.get(0));\n\t\tstr.remove(0);\n\t\tin.remove(0);\n\t\tprenumber.remove(0);\n\t\tlength--;\n\n\t}",
"k.setkakunou(str.get(0), in.get(0), prenumber.get(0))",
"k.setkakunou",
"k",
"str.get(0)",
"str.get",
"str",
"0",
"in.get(0)",
"in.get",
"in",
"0",
"prenumber.get(0)",
"prenumber.get",
"prenumber",
"0",
"str.remove(0)",
"str.remove",
"str",
"0",
"in.remove(0)",
"in.remove",
"in",
"0",
"prenumber.remove(0)",
"prenumber.remove",
"prenumber",
"0",
"length--",
"length",
"public void RoundRobinScheduling(int q) {\n\t\t\n\t\tint total=0;\n\t\tdeque();\n\t\twhile(true){\n\t\t\tint t1=k.kint-q;\n\t\t\tif(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}\n\t\t\tif(length>0)deque();\n\t\t\telse break;\n\t\t}\n\t\t}",
"RoundRobinScheduling",
"{\n\t\t\n\t\tint total=0;\n\t\tdeque();\n\t\twhile(true){\n\t\t\tint t1=k.kint-q;\n\t\t\tif(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}\n\t\t\tif(length>0)deque();\n\t\t\telse break;\n\t\t}\n\t\t}",
"int total=0;",
"total",
"0",
"deque()",
"deque",
"while(true){\n\t\t\tint t1=k.kint-q;\n\t\t\tif(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}\n\t\t\tif(length>0)deque();\n\t\t\telse break;\n\t\t}",
"true",
"{\n\t\t\tint t1=k.kint-q;\n\t\t\tif(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}\n\t\t\tif(length>0)deque();\n\t\t\telse break;\n\t\t}",
"int t1=k.kint-q;",
"t1",
"k.kint-q",
"k.kint",
"k",
"k.kint",
"q",
"if(t1>0){\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}else{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}",
"t1>0",
"t1",
"0",
"{\n\t\t\t\ttotal=total+q;\n\t\t\t\tk.kint=t1;\n\t\t\t\tinque(k);\n\t\t\t\t\n\t\t\t}",
"total=total+q",
"total",
"total+q",
"total",
"q",
"k.kint=t1",
"k.kint",
"k",
"k.kint",
"t1",
"inque(k)",
"inque",
"k",
"{\n\t\t\t\ttotal=total+k.kint;\n\t\t\t\tSystem.out.println(k.kstr+\" \"+total);\n\t\t\t\t}",
"total=total+k.kint",
"total",
"total+k.kint",
"total",
"k.kint",
"k",
"k.kint",
"System.out.println(k.kstr+\" \"+total)",
"System.out.println",
"System.out",
"System",
"System.out",
"k.kstr+\" \"+total",
"k.kstr+\" \"+total",
"k.kstr",
"k",
"k.kstr",
"\" \"",
"total",
"if(length>0)deque();\n\t\t\telse break;",
"length>0",
"length",
"0",
"deque()",
"deque",
"break;",
"int q",
"q",
"private class kakunou {\n\t\tString kstr;\n\t\tint kint;\n\t\tint kprenum;\n\n\t\tvoid setkakunou(String s, int i, int pre) {\n\t\t\tkstr = s;\n\t\t\tkint = i;\n\t\t\tkprenum = pre;\n\t\t}\n\t}",
"kakunou",
"String kstr;",
"kstr",
"int kint;",
"kint",
"int kprenum;",
"kprenum",
"void setkakunou(String s, int i, int pre) {\n\t\t\tkstr = s;\n\t\t\tkint = i;\n\t\t\tkprenum = pre;\n\t\t}",
"setkakunou",
"{\n\t\t\tkstr = s;\n\t\t\tkint = i;\n\t\t\tkprenum = pre;\n\t\t}",
"kstr = s",
"kstr",
"s",
"kint = i",
"kint",
"i",
"kprenum = pre",
"kprenum",
"pre",
"String s",
"s",
"int i",
"i",
"int pre",
"pre"
] | import java.util.ArrayList;
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();
Orique oq = new Orique();
for (int i = 0; i < n; i++) {
oq.inque(sc.next(), sc.nextInt());
}
oq.RoundRobinScheduling(q);
}
}
class Orique {
private class kakunou {
String kstr;
int kint;
int kprenum;
void setkakunou(String s, int i, int pre) {
kstr = s;
kint = i;
kprenum = pre;
}
}
private int length = 0;
ArrayList<String> str = new ArrayList<String>();
ArrayList<Integer> in = new ArrayList<Integer>();
kakunou k;
private ArrayList<Integer> prenumber = new ArrayList<Integer>();
Orique() {
k = new kakunou();
}
public void inque(String t, int i) {
str.add(t);
in.add(i);
prenumber.add(i);
length++;
}
private void inque(kakunou k) {
str.add(k.kstr);
in.add(k.kint);
prenumber.add(k.kprenum);
length++;
}
private void deque() {
k.setkakunou(str.get(0), in.get(0), prenumber.get(0));
str.remove(0);
in.remove(0);
prenumber.remove(0);
length--;
}
public void RoundRobinScheduling(int q) {
int total=0;
deque();
while(true){
int t1=k.kint-q;
if(t1>0){
total=total+q;
k.kint=t1;
inque(k);
}else{
total=total+k.kint;
System.out.println(k.kstr+" "+total);
}
if(length>0)deque();
else break;
}
}
} |
[
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,
4,
18,
13,
20,
41,
13,
20,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
4,
18,
4,
18,
4,
18,
13,
18,
13,
13,
17,
13,
17,
4,
18,
18,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
132,
5
],
[
132,
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
],
[
39,
40
],
[
38,
41
],
[
8,
42
],
[
42,
43
],
[
42,
44
],
[
8,
45
],
[
45,
46
],
[
45,
47
],
[
8,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
51,
52
],
[
49,
53
],
[
48,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
57,
58
],
[
58,
59
],
[
54,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
62,
64
],
[
61,
65
],
[
60,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
66,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
66,
76
],
[
76,
77
],
[
76,
78
],
[
60,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
94,
96
],
[
89,
97
],
[
87,
98
],
[
85,
99
],
[
8,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
100,
105
],
[
6,
106
],
[
106,
107
],
[
132,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
108,
112
],
[
112,
113
],
[
108,
114
],
[
114,
115
],
[
114,
116
],
[
116,
117
],
[
117,
118
],
[
118,
119
],
[
118,
120
],
[
117,
121
],
[
116,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
114,
127
],
[
127,
128
],
[
114,
129
],
[
129,
130
],
[
0,
131
],
[
131,
132
],
[
131,
133
]
] | [
"import java.util.*;\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 ArrayDeque<Proc> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }\n StringBuilder sb = new StringBuilder();\n int current = 0;\n while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }\n System.out.print(sb);\n }\n \n static class Proc {\n String name;\n int time;\n \n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\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 n = sc.nextInt();\n int q = sc.nextInt();\n ArrayDeque<Proc> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }\n StringBuilder sb = new StringBuilder();\n int current = 0;\n while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }\n System.out.print(sb);\n }\n \n static class Proc {\n String name;\n int time;\n \n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\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 ArrayDeque<Proc> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }\n StringBuilder sb = new StringBuilder();\n int current = 0;\n while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }\n System.out.print(sb);\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n ArrayDeque<Proc> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }\n StringBuilder sb = new StringBuilder();\n int current = 0;\n while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }\n System.out.print(sb);\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",
"ArrayDeque<Proc> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }",
"{\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }",
"queue.add(new Proc(sc.next(), sc.nextInt()))",
"queue.add",
"queue",
"new Proc(sc.next(), sc.nextInt())",
"StringBuilder sb = new StringBuilder();",
"sb",
"new StringBuilder()",
"int current = 0;",
"current",
"0",
"while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }",
"Proc p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n p.time -= q;\n queue.add(p);\n current += q;\n }",
"p.time -= q",
"p.time",
"p",
"p.time",
"q",
"queue.add(p)",
"queue.add",
"queue",
"p",
"current += q",
"current",
"q",
"{\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }",
"current += p.time",
"current",
"p.time",
"p",
"p.time",
"sb.append(p.name).append(\" \").append(current).append(\"\\n\")",
"sb.append(p.name).append(\" \").append(current).append",
"sb.append(p.name).append(\" \").append(current)",
"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",
"\" \"",
"current",
"\"\\n\"",
"System.out.print(sb)",
"System.out.print",
"System.out",
"System",
"System.out",
"sb",
"String[] args",
"args",
"static class Proc {\n String name;\n int time;\n \n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }",
"Proc",
"String name;",
"name",
"int time;",
"time",
"public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Proc",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public 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 ArrayDeque<Proc> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }\n StringBuilder sb = new StringBuilder();\n int current = 0;\n while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }\n System.out.print(sb);\n }\n \n static class Proc {\n String name;\n int time;\n \n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\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 ArrayDeque<Proc> queue = new ArrayDeque<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Proc(sc.next(), sc.nextInt()));\n }\n StringBuilder sb = new StringBuilder();\n int current = 0;\n while (queue.size() > 0) {\n Proc p = queue.poll();\n if (p.time > q) {\n p.time -= q;\n queue.add(p);\n current += q;\n } else {\n current += p.time;\n sb.append(p.name).append(\" \").append(current).append(\"\\n\");\n }\n }\n System.out.print(sb);\n }\n \n static class Proc {\n String name;\n int time;\n \n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
ArrayDeque<Proc> queue = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
queue.add(new Proc(sc.next(), sc.nextInt()));
}
StringBuilder sb = new StringBuilder();
int current = 0;
while (queue.size() > 0) {
Proc p = queue.poll();
if (p.time > q) {
p.time -= q;
queue.add(p);
current += q;
} else {
current += p.time;
sb.append(p.name).append(" ").append(current).append("\n");
}
}
System.out.print(sb);
}
static class Proc {
String name;
int time;
public Proc(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,
13,
41,
13,
4,
18,
13,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
13,
4,
18,
13,
20,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
14,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
14,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
14,
28
],
[
28,
29
],
[
28,
30
],
[
14,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
31,
36
],
[
36,
37
],
[
36,
38
],
[
31,
39
],
[
39,
40
],
[
40,
41
],
[
31,
42
],
[
43,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
52,
53
],
[
43,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
14,
58
],
[
58,
59
],
[
58,
60
],
[
14,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
61,
66
],
[
66,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
66,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
72,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
83,
84
],
[
82,
85
],
[
72,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
92,
97
],
[
98,
98
],
[
98,
99
],
[
99,
100
],
[
99,
101
],
[
98,
102
],
[
98,
103
],
[
12,
104
],
[
104,
105
],
[
0,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
106,
110
],
[
110,
111
],
[
106,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
114,
118
],
[
118,
119
],
[
118,
120
],
[
112,
121
],
[
121,
122
],
[
112,
123
],
[
123,
124
]
] | [
"import java.util.Scanner;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\n\nclass Main {\n public static void main(String[] args) {\n //input\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<MyProcess> d = new ArrayDeque<MyProcess>();\n for(int i = 0; i < n; ++i) {\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }\n \n int elapsed = 0;\n while(!d.isEmpty()){\n \t MyProcess p = d.removeFirst();\n \t if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }\n }\n }\n}\n\nclass MyProcess {\n\tpublic String name;\n\tpublic int time;\n\tpublic MyProcess(String n, int t) {\n\t\tname = n;\n \t\ttime = t;\n \t}\n }",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"class Main {\n public static void main(String[] args) {\n //input\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<MyProcess> d = new ArrayDeque<MyProcess>();\n for(int i = 0; i < n; ++i) {\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }\n \n int elapsed = 0;\n while(!d.isEmpty()){\n \t MyProcess p = d.removeFirst();\n \t if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n //input\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<MyProcess> d = new ArrayDeque<MyProcess>();\n for(int i = 0; i < n; ++i) {\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }\n \n int elapsed = 0;\n while(!d.isEmpty()){\n \t MyProcess p = d.removeFirst();\n \t if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }\n }\n }",
"main",
"{\n //input\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n Deque<MyProcess> d = new ArrayDeque<MyProcess>();\n for(int i = 0; i < n; ++i) {\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }\n \n int elapsed = 0;\n while(!d.isEmpty()){\n \t MyProcess p = d.removeFirst();\n \t if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\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",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"Deque<MyProcess> d = new ArrayDeque<MyProcess>();",
"d",
"new ArrayDeque<MyProcess>()",
"for(int i = 0; i < n; ++i) {\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"++i",
"++i",
"i",
"{\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }",
"{\n \tString name = sc.next();\n \tint time = sc.nextInt();\n \td.add(new MyProcess(name, time));\n }",
"String name = sc.next();",
"name",
"sc.next()",
"sc.next",
"sc",
"int time = sc.nextInt();",
"time",
"sc.nextInt()",
"sc.nextInt",
"sc",
"d.add(new MyProcess(name, time))",
"d.add",
"d",
"new MyProcess(name, time)",
"int elapsed = 0;",
"elapsed",
"0",
"while(!d.isEmpty()){\n \t MyProcess p = d.removeFirst();\n \t if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }\n }",
"!d.isEmpty()",
"d.isEmpty()",
"d.isEmpty",
"d",
"{\n \t MyProcess p = d.removeFirst();\n \t if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }\n }",
"MyProcess p = d.removeFirst();",
"p",
"d.removeFirst()",
"d.removeFirst",
"d",
"if(p.time > q) {\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }else{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n\t \telapsed += q;\n\t \td.add(new MyProcess(p.name, p.time - q));\n \t }",
"elapsed += q",
"elapsed",
"q",
"d.add(new MyProcess(p.name, p.time - q))",
"d.add",
"d",
"new MyProcess(p.name, p.time - q)",
"{\n \t \telapsed += p.time;\n \t \tSystem.out.println(p.name + \" \" + elapsed);\n \t }",
"elapsed += p.time",
"elapsed",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + elapsed)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + elapsed",
"p.name + \" \" + elapsed",
"p.name",
"p",
"p.name",
"\" \"",
"elapsed",
"String[] args",
"args",
"class MyProcess {\n\tpublic String name;\n\tpublic int time;\n\tpublic MyProcess(String n, int t) {\n\t\tname = n;\n \t\ttime = t;\n \t}\n }",
"MyProcess",
"public String name;",
"name",
"public int time;",
"time",
"public MyProcess(String n, int t) {\n\t\tname = n;\n \t\ttime = t;\n \t}",
"MyProcess",
"{\n\t\tname = n;\n \t\ttime = t;\n \t}",
"name = n",
"name",
"n",
"time = t",
"time",
"t",
"String n",
"n",
"int t",
"t"
] | import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;
class Main {
public static void main(String[] args) {
//input
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
Deque<MyProcess> d = new ArrayDeque<MyProcess>();
for(int i = 0; i < n; ++i) {
String name = sc.next();
int time = sc.nextInt();
d.add(new MyProcess(name, time));
}
int elapsed = 0;
while(!d.isEmpty()){
MyProcess p = d.removeFirst();
if(p.time > q) {
elapsed += q;
d.add(new MyProcess(p.name, p.time - q));
}else{
elapsed += p.time;
System.out.println(p.name + " " + elapsed);
}
}
}
}
class MyProcess {
public String name;
public int time;
public MyProcess(String n, int t) {
name = n;
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,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
41,
13,
17,
42,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
13,
13,
30,
0,
13,
2,
13,
18,
13,
13,
0,
18,
13,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
40,
13,
14,
2,
13,
13,
30,
3,
30,
0,
18,
13,
13,
2,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
2,
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
] | [
[
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
],
[
23,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
23,
28
],
[
14,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
33
],
[
31,
34
],
[
34,
35
],
[
34,
36
],
[
14,
37
],
[
37,
38
],
[
37,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
42,
43
],
[
42,
44
],
[
14,
45
],
[
45,
46
],
[
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
],
[
69,
71
],
[
60,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
14,
76
],
[
76,
77
],
[
76,
78
],
[
14,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
81,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
87,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
93,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
106,
111
],
[
112,
112
],
[
112,
113
],
[
113,
114
],
[
113,
115
],
[
112,
116
],
[
112,
117
],
[
117,
118
],
[
117,
119
],
[
93,
120
],
[
120,
121
],
[
93,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
126,
127
],
[
87,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
133,
137
],
[
128,
138
],
[
138,
139
],
[
139,
140
],
[
138,
141
],
[
128,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
12,
147
],
[
147,
148
],
[
0,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
149,
153
],
[
153,
154
],
[
149,
155
],
[
155,
156
],
[
155,
157
],
[
157,
158
],
[
158,
159
],
[
159,
160
],
[
159,
161
],
[
158,
162
],
[
157,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
155,
168
],
[
168,
169
],
[
155,
170
],
[
170,
171
]
] | [
"import java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\n\nclass Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Process> queue = new ArrayDeque<Process>();\n\t\tString[] str01 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(str01[0]);\n\t\tint point = Integer.parseInt(str01[1]);\n\t\tint sumTime = 0;\n\t\t\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}\n\t\tint i = 0;\n\t\twhile (true) {\n\t\t\tProcess temp = queue.poll();\n\t\t\tif (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass Process {\n\tString name;\n\tint time;\n\n\tProcess(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"class Main {\n\n\tpublic static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Process> queue = new ArrayDeque<Process>();\n\t\tString[] str01 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(str01[0]);\n\t\tint point = Integer.parseInt(str01[1]);\n\t\tint sumTime = 0;\n\t\t\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}\n\t\tint i = 0;\n\t\twhile (true) {\n\t\t\tProcess temp = queue.poll();\n\t\t\tif (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) throws Exception {\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Process> queue = new ArrayDeque<Process>();\n\t\tString[] str01 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(str01[0]);\n\t\tint point = Integer.parseInt(str01[1]);\n\t\tint sumTime = 0;\n\t\t\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}\n\t\tint i = 0;\n\t\twhile (true) {\n\t\t\tProcess temp = queue.poll();\n\t\t\tif (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tArrayDeque<Process> queue = new ArrayDeque<Process>();\n\t\tString[] str01 = br.readLine().split(\" \");\n\t\tint n = Integer.parseInt(str01[0]);\n\t\tint point = Integer.parseInt(str01[1]);\n\t\tint sumTime = 0;\n\t\t\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}\n\t\tint i = 0;\n\t\twhile (true) {\n\t\t\tProcess temp = queue.poll();\n\t\t\tif (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"ArrayDeque<Process> queue = new ArrayDeque<Process>();",
"queue",
"new ArrayDeque<Process>()",
"String[] str01 = br.readLine().split(\" \");",
"str01",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"int n = Integer.parseInt(str01[0]);",
"n",
"Integer.parseInt(str01[0])",
"Integer.parseInt",
"Integer",
"str01[0]",
"str01",
"0",
"int point = Integer.parseInt(str01[1]);",
"point",
"Integer.parseInt(str01[1])",
"Integer.parseInt",
"Integer",
"str01[1]",
"str01",
"1",
"int sumTime = 0;",
"sumTime",
"0",
"for (int i = 0; i < n; i++) {\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}",
"{\n\t\t\tString[] str02 = br.readLine().split(\" \");\n\t\t\tProcess process = new Process(str02[0], Integer.parseInt(str02[1]));\n\t\t\tqueue.add(process);\n\t\t}",
"String[] str02 = br.readLine().split(\" \");",
"str02",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"Process process = new Process(str02[0], Integer.parseInt(str02[1]));",
"process",
"new Process(str02[0], Integer.parseInt(str02[1]))",
"queue.add(process)",
"queue.add",
"queue",
"process",
"int i = 0;",
"i",
"0",
"while (true) {\n\t\t\tProcess temp = queue.poll();\n\t\t\tif (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}\n\t\t}",
"true",
"{\n\t\t\tProcess temp = queue.poll();\n\t\t\tif (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}\n\t\t}",
"Process temp = queue.poll();",
"temp",
"queue.poll()",
"queue.poll",
"queue",
"if (temp.time <= point) {\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}",
"temp.time <= point",
"temp.time",
"temp",
"temp.time",
"point",
"{\n\t\t\t\tsumTime = sumTime + temp.time;\n\t\t\t\ttemp.time = sumTime;\n\t\t\t\tSystem.out.println(temp.name + \" \" + temp.time);\n\t\t\t\ti++;\n\t\t\t\tif(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}",
"sumTime = sumTime + temp.time",
"sumTime",
"sumTime + temp.time",
"sumTime",
"temp.time",
"temp",
"temp.time",
"temp.time = sumTime",
"temp.time",
"temp",
"temp.time",
"sumTime",
"System.out.println(temp.name + \" \" + temp.time)",
"System.out.println",
"System.out",
"System",
"System.out",
"temp.name + \" \" + temp.time",
"temp.name + \" \" + temp.time",
"temp.name",
"temp",
"temp.name",
"\" \"",
"temp.time",
"temp",
"temp.time",
"i++",
"i",
"if(i == n){\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"i == n",
"i",
"n",
"{\n\t\t\t\t\tbreak;\n\t\t\t\t}",
"break;",
"{\n\t\t\t\ttemp.time = temp.time - point;\n\t\t\t\tqueue.add(temp);\n\t\t\t\tsumTime = sumTime + point;\n\t\t\t}",
"temp.time = temp.time - point",
"temp.time",
"temp",
"temp.time",
"temp.time - point",
"temp.time",
"temp",
"temp.time",
"point",
"queue.add(temp)",
"queue.add",
"queue",
"temp",
"sumTime = sumTime + point",
"sumTime",
"sumTime + point",
"sumTime",
"point",
"String[] args",
"args",
"class Process {\n\tString name;\n\tint time;\n\n\tProcess(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time"
] | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayDeque<Process> queue = new ArrayDeque<Process>();
String[] str01 = br.readLine().split(" ");
int n = Integer.parseInt(str01[0]);
int point = Integer.parseInt(str01[1]);
int sumTime = 0;
for (int i = 0; i < n; i++) {
String[] str02 = br.readLine().split(" ");
Process process = new Process(str02[0], Integer.parseInt(str02[1]));
queue.add(process);
}
int i = 0;
while (true) {
Process temp = queue.poll();
if (temp.time <= point) {
sumTime = sumTime + temp.time;
temp.time = sumTime;
System.out.println(temp.name + " " + temp.time);
i++;
if(i == n){
break;
}
} else {
temp.time = temp.time - point;
queue.add(temp);
sumTime = sumTime + point;
}
}
}
}
class Process {
String name;
int time;
Process(String name, int time) {
this.name = name;
this.time = time;
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
13,
18,
13,
13,
0,
13,
13,
0,
18,
13,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
4,
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,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
4,
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
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
25,
29
],
[
24,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
30,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
38,
42
],
[
42,
43
],
[
42,
44
],
[
30,
45
],
[
45,
46
],
[
45,
47
],
[
30,
48
],
[
48,
49
],
[
49,
50
],
[
49,
51
],
[
48,
52
],
[
30,
53
],
[
53,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
53,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
59,
64
],
[
65,
65
],
[
65,
66
],
[
66,
67
],
[
66,
68
],
[
65,
69
],
[
65,
70
],
[
53,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
18,
75
],
[
75,
76
],
[
18,
77
],
[
77,
78
],
[
16,
79
],
[
79,
80
],
[
79,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
88,
89
],
[
81,
90
],
[
90,
91
],
[
90,
92
],
[
92,
93
],
[
93,
94
],
[
81,
95
],
[
95,
96
],
[
95,
97
],
[
81,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
103,
104
],
[
103,
105
],
[
98,
106
],
[
106,
107
],
[
107,
108
],
[
98,
109
],
[
110,
110
],
[
110,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
81,
115
],
[
115,
116
],
[
115,
117
],
[
115,
118
],
[
79,
119
],
[
119,
120
],
[
16,
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
]
] | [
"import java.util.ArrayList;\nimport java.util.List;\nimport java.util.LinkedList;\nimport java.util.Scanner;\nimport java.util.Queue;\n\nclass Main {\n\n public static class Process {\n\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 }\n\n public static void process(Queue<Process> q, int quantum) {\n\n int curr_time = 0;\n\n while (q.isEmpty() == false) {\n\n Process curr_ps = q.remove();\n\n int time_passed = Math.min(quantum, curr_ps.time);\n curr_time += time_passed;\n curr_ps.time -= time_passed;\n\n if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);\n }\n\n }\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int n = s.nextInt();\n int quantum = s.nextInt();\n Queue<Process> processes = new LinkedList<Process>();\n for (int i = 0; i < n; i++) {\n processes.add(new Process(s.next(), s.nextInt()));\n }\n process(processes, quantum);\n }\n}",
"import java.util.ArrayList;",
"ArrayList",
"java.util",
"import java.util.List;",
"List",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"class Main {\n\n public static class Process {\n\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 }\n\n public static void process(Queue<Process> q, int quantum) {\n\n int curr_time = 0;\n\n while (q.isEmpty() == false) {\n\n Process curr_ps = q.remove();\n\n int time_passed = Math.min(quantum, curr_ps.time);\n curr_time += time_passed;\n curr_ps.time -= time_passed;\n\n if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);\n }\n\n }\n\n public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int n = s.nextInt();\n int quantum = s.nextInt();\n Queue<Process> processes = new LinkedList<Process>();\n for (int i = 0; i < n; i++) {\n processes.add(new Process(s.next(), s.nextInt()));\n }\n process(processes, quantum);\n }\n}",
"Main",
"public static void process(Queue<Process> q, int quantum) {\n\n int curr_time = 0;\n\n while (q.isEmpty() == false) {\n\n Process curr_ps = q.remove();\n\n int time_passed = Math.min(quantum, curr_ps.time);\n curr_time += time_passed;\n curr_ps.time -= time_passed;\n\n if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);\n }\n\n }",
"process",
"{\n\n int curr_time = 0;\n\n while (q.isEmpty() == false) {\n\n Process curr_ps = q.remove();\n\n int time_passed = Math.min(quantum, curr_ps.time);\n curr_time += time_passed;\n curr_ps.time -= time_passed;\n\n if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);\n }\n\n }",
"int curr_time = 0;",
"curr_time",
"0",
"while (q.isEmpty() == false) {\n\n Process curr_ps = q.remove();\n\n int time_passed = Math.min(quantum, curr_ps.time);\n curr_time += time_passed;\n curr_ps.time -= time_passed;\n\n if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);\n }",
"q.isEmpty() == false",
"q.isEmpty()",
"q.isEmpty",
"q",
"false",
"{\n\n Process curr_ps = q.remove();\n\n int time_passed = Math.min(quantum, curr_ps.time);\n curr_time += time_passed;\n curr_ps.time -= time_passed;\n\n if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);\n }",
"Process curr_ps = q.remove();",
"curr_ps",
"q.remove()",
"q.remove",
"q",
"int time_passed = Math.min(quantum, curr_ps.time);",
"time_passed",
"Math.min(quantum, curr_ps.time)",
"Math.min",
"Math",
"quantum",
"curr_ps.time",
"curr_ps",
"curr_ps.time",
"curr_time += time_passed",
"curr_time",
"time_passed",
"curr_ps.time -= time_passed",
"curr_ps.time",
"curr_ps",
"curr_ps.time",
"time_passed",
"if (curr_ps.time == 0)\n System.out.println(curr_ps.name + \" \" + curr_time);\n else\n q.add(curr_ps);",
"curr_ps.time == 0",
"curr_ps.time",
"curr_ps",
"curr_ps.time",
"0",
"System.out.println(curr_ps.name + \" \" + curr_time)",
"System.out.println",
"System.out",
"System",
"System.out",
"curr_ps.name + \" \" + curr_time",
"curr_ps.name + \" \" + curr_time",
"curr_ps.name",
"curr_ps",
"curr_ps.name",
"\" \"",
"curr_time",
"q.add(curr_ps)",
"q.add",
"q",
"curr_ps",
"Queue<Process> q",
"q",
"int quantum",
"quantum",
"public static void main(String[] args) {\n Scanner s = new Scanner(System.in);\n int n = s.nextInt();\n int quantum = s.nextInt();\n Queue<Process> processes = new LinkedList<Process>();\n for (int i = 0; i < n; i++) {\n processes.add(new Process(s.next(), s.nextInt()));\n }\n process(processes, quantum);\n }",
"main",
"{\n Scanner s = new Scanner(System.in);\n int n = s.nextInt();\n int quantum = s.nextInt();\n Queue<Process> processes = new LinkedList<Process>();\n for (int i = 0; i < n; i++) {\n processes.add(new Process(s.next(), s.nextInt()));\n }\n process(processes, quantum);\n }",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int n = s.nextInt();",
"n",
"s.nextInt()",
"s.nextInt",
"s",
"int quantum = s.nextInt();",
"quantum",
"s.nextInt()",
"s.nextInt",
"s",
"Queue<Process> processes = new LinkedList<Process>();",
"processes",
"new LinkedList<Process>()",
"for (int i = 0; i < n; i++) {\n processes.add(new Process(s.next(), s.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n processes.add(new Process(s.next(), s.nextInt()));\n }",
"{\n processes.add(new Process(s.next(), s.nextInt()));\n }",
"processes.add(new Process(s.next(), s.nextInt()))",
"processes.add",
"processes",
"new Process(s.next(), s.nextInt())",
"process(processes, quantum)",
"process",
"processes",
"quantum",
"String[] args",
"args",
"public static class Process {\n\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 }",
"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"
] | import java.util.ArrayList;
import java.util.List;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Queue;
class Main {
public static class Process {
public String name;
public int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
public static void process(Queue<Process> q, int quantum) {
int curr_time = 0;
while (q.isEmpty() == false) {
Process curr_ps = q.remove();
int time_passed = Math.min(quantum, curr_ps.time);
curr_time += time_passed;
curr_ps.time -= time_passed;
if (curr_ps.time == 0)
System.out.println(curr_ps.name + " " + curr_time);
else
q.add(curr_ps);
}
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int quantum = s.nextInt();
Queue<Process> processes = new LinkedList<Process>();
for (int i = 0; i < n; i++) {
processes.add(new Process(s.next(), s.nextInt()));
}
process(processes, quantum);
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
0,
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,
41,
13,
4,
18,
13,
17,
4,
18,
13,
20,
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,
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,
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,
4,
13,
17,
17,
12,
13,
30,
29,
18,
36,
13,
12,
13,
30,
29,
18,
36,
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
],
[
189,
8
],
[
189,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
11,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
11,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
24,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
30,
33
],
[
33,
34
],
[
33,
35
],
[
11,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
38,
41
],
[
41,
42
],
[
41,
43
],
[
11,
44
],
[
44,
45
],
[
44,
46
],
[
11,
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
],
[
59,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
67,
70
],
[
59,
71
],
[
71,
72
],
[
72,
73
],
[
71,
74
],
[
11,
75
],
[
75,
76
],
[
75,
77
],
[
11,
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
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
90,
94
],
[
89,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
96,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
99,
103
],
[
95,
104
],
[
104,
105
],
[
105,
106
],
[
104,
107
],
[
95,
108
],
[
108,
109
],
[
108,
110
],
[
89,
111
],
[
111,
112
],
[
112,
113
],
[
112,
114
],
[
114,
115
],
[
115,
116
],
[
111,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
117,
122
],
[
123,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
123,
127
],
[
123,
128
],
[
11,
129
],
[
129,
130
],
[
130,
131
],
[
9,
132
],
[
132,
133
],
[
0,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
134,
138
],
[
138,
139
],
[
134,
140
],
[
140,
141
],
[
140,
142
],
[
142,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
142,
148
],
[
148,
149
],
[
149,
150
],
[
149,
151
],
[
148,
152
],
[
140,
153
],
[
153,
154
],
[
140,
155
],
[
155,
156
],
[
134,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
160,
163
],
[
134,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
167,
168
],
[
168,
169
],
[
168,
170
],
[
134,
171
],
[
171,
172
],
[
171,
173
],
[
173,
174
],
[
174,
175
],
[
175,
176
],
[
175,
177
],
[
134,
178
],
[
178,
179
],
[
178,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
178,
186
],
[
186,
187
],
[
0,
188
],
[
188,
189
],
[
188,
190
]
] | [
"import java.io.*;\nimport java.util.*;\n\n\n\npublic class Main{\n public static void main(String[] args)throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str;\n\n str = br.readLine();\n String[] strs = str.split(\"\\\\s\");\n int n = Integer.parseInt(strs[0]);\n int q = Integer.parseInt(strs[1]);\n\n Queue<Myp> d = new ArrayDeque<Myp>();\n for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }\n \n int endtime = 0;\n while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }\n\n br.close();\n }\n \n}\n\nclass Myp{\n private String name;\n private int time;\n \n Myp(String n,int t){\n this.name= n;\n this.time = t;\n }\n\n Myp(){\n this(\"\",0);\n }\n public String getname(){\n return this.name;\n }\n\n public int gettime(){\n return this.time;\n }\n\n public void settime(int t){\n this.time = t;\n }\n}",
"import java.io.*;",
"io.*",
"java",
"import java.util.*;",
"util.*",
"java",
"public class Main{\n public static void main(String[] args)throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str;\n\n str = br.readLine();\n String[] strs = str.split(\"\\\\s\");\n int n = Integer.parseInt(strs[0]);\n int q = Integer.parseInt(strs[1]);\n\n Queue<Myp> d = new ArrayDeque<Myp>();\n for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }\n \n int endtime = 0;\n while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }\n\n br.close();\n }\n \n}",
"Main",
"public static void main(String[] args)throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str;\n\n str = br.readLine();\n String[] strs = str.split(\"\\\\s\");\n int n = Integer.parseInt(strs[0]);\n int q = Integer.parseInt(strs[1]);\n\n Queue<Myp> d = new ArrayDeque<Myp>();\n for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }\n \n int endtime = 0;\n while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }\n\n br.close();\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str;\n\n str = br.readLine();\n String[] strs = str.split(\"\\\\s\");\n int n = Integer.parseInt(strs[0]);\n int q = Integer.parseInt(strs[1]);\n\n Queue<Myp> d = new ArrayDeque<Myp>();\n for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }\n \n int endtime = 0;\n while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }\n\n br.close();\n }",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String str;",
"str",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"String[] strs = str.split(\"\\\\s\");",
"strs",
"str.split(\"\\\\s\")",
"str.split",
"str",
"\"\\\\s\"",
"int n = Integer.parseInt(strs[0]);",
"n",
"Integer.parseInt(strs[0])",
"Integer.parseInt",
"Integer",
"strs[0]",
"strs",
"0",
"int q = Integer.parseInt(strs[1]);",
"q",
"Integer.parseInt(strs[1])",
"Integer.parseInt",
"Integer",
"strs[1]",
"strs",
"1",
"Queue<Myp> d = new ArrayDeque<Myp>();",
"d",
"new ArrayDeque<Myp>()",
"for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }",
"int i =0;",
"int i =0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }",
"{\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }",
"str = br.readLine()",
"str",
"br.readLine()",
"br.readLine",
"br",
"String[] temp = str.split(\"\\\\s\");",
"temp",
"str.split(\"\\\\s\")",
"str.split",
"str",
"\"\\\\s\"",
"d.offer(new Myp(temp[0],Integer.parseInt(temp[1])))",
"d.offer",
"d",
"new Myp(temp[0],Integer.parseInt(temp[1]))",
"int endtime = 0;",
"endtime",
"0",
"while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }",
"!d.isEmpty()",
"d.isEmpty()",
"d.isEmpty",
"d",
"{\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }",
"Myp p = d.poll();",
"p",
"d.poll()",
"d.poll",
"d",
"if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }",
"p.gettime() > q",
"p.gettime()",
"p.gettime",
"p",
"q",
"{\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }",
"p.settime(p.gettime() - q)",
"p.settime",
"p",
"p.gettime() - q",
"p.gettime()",
"p.gettime",
"p",
"q",
"d.offer(p)",
"d.offer",
"d",
"p",
"endtime += q",
"endtime",
"q",
"{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }",
"endtime += p.gettime()",
"endtime",
"p.gettime()",
"p.gettime",
"p",
"System.out.println(p.getname() + \" \" + endtime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.getname() + \" \" + endtime",
"p.getname() + \" \" + endtime",
"p.getname()",
"p.getname",
"p",
"\" \"",
"endtime",
"br.close()",
"br.close",
"br",
"String[] args",
"args",
"class Myp{\n private String name;\n private int time;\n \n Myp(String n,int t){\n this.name= n;\n this.time = t;\n }\n\n Myp(){\n this(\"\",0);\n }\n public String getname(){\n return this.name;\n }\n\n public int gettime(){\n return this.time;\n }\n\n public void settime(int t){\n this.time = t;\n }\n}",
"Myp",
"private String name;",
"name",
"private int time;",
"time",
"Myp(String n,int t){\n this.name= n;\n this.time = t;\n }",
"Myp",
"{\n this.name= n;\n this.time = t;\n }",
"this.name= n",
"this.name",
"this",
"this.name",
"n",
"this.time = t",
"this.time",
"this",
"this.time",
"t",
"String n",
"n",
"int t",
"t",
"Myp(){\n this(\"\",0);\n }",
"Myp",
"{\n this(\"\",0);\n }",
"this(\"\",0)",
"this",
"\"\"",
"0",
"public String getname(){\n return this.name;\n }",
"getname",
"{\n return this.name;\n }",
"return this.name;",
"this.name",
"this",
"this.name",
"public int gettime(){\n return this.time;\n }",
"gettime",
"{\n return this.time;\n }",
"return this.time;",
"this.time",
"this",
"this.time",
"public void settime(int t){\n this.time = t;\n }",
"settime",
"{\n this.time = t;\n }",
"this.time = t",
"this.time",
"this",
"this.time",
"t",
"int t",
"t",
"public class Main{\n public static void main(String[] args)throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String str;\n\n str = br.readLine();\n String[] strs = str.split(\"\\\\s\");\n int n = Integer.parseInt(strs[0]);\n int q = Integer.parseInt(strs[1]);\n\n Queue<Myp> d = new ArrayDeque<Myp>();\n for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }\n \n int endtime = 0;\n while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }\n\n br.close();\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 str;\n\n str = br.readLine();\n String[] strs = str.split(\"\\\\s\");\n int n = Integer.parseInt(strs[0]);\n int q = Integer.parseInt(strs[1]);\n\n Queue<Myp> d = new ArrayDeque<Myp>();\n for(int i =0;i<n;i++){\n str = br.readLine();\n String[] temp = str.split(\"\\\\s\");\n d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));\n }\n \n int endtime = 0;\n while(!d.isEmpty()){\n Myp p = d.poll();\n if(p.gettime() > q){\n p.settime(p.gettime() - q);\n d.offer(p);\n endtime += q;\n }else{\n endtime += p.gettime();\n System.out.println(p.getname() + \" \" + endtime);\n }\n }\n\n br.close();\n }\n \n}",
"Main"
] | import java.io.*;
import java.util.*;
public class Main{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
str = br.readLine();
String[] strs = str.split("\\s");
int n = Integer.parseInt(strs[0]);
int q = Integer.parseInt(strs[1]);
Queue<Myp> d = new ArrayDeque<Myp>();
for(int i =0;i<n;i++){
str = br.readLine();
String[] temp = str.split("\\s");
d.offer(new Myp(temp[0],Integer.parseInt(temp[1])));
}
int endtime = 0;
while(!d.isEmpty()){
Myp p = d.poll();
if(p.gettime() > q){
p.settime(p.gettime() - q);
d.offer(p);
endtime += q;
}else{
endtime += p.gettime();
System.out.println(p.getname() + " " + endtime);
}
}
br.close();
}
}
class Myp{
private String name;
private int time;
Myp(String n,int t){
this.name= n;
this.time = t;
}
Myp(){
this("",0);
}
public String getname(){
return this.name;
}
public int gettime(){
return this.time;
}
public void settime(int t){
this.time = t;
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
38,
5,
13,
30,
4,
18,
18,
13,
13,
2,
17,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
17,
41,
13,
4,
18,
13,
2,
17,
18,
13,
17,
41,
13,
4,
18,
13,
2,
17,
18,
13,
17,
41,
13,
20,
2,
13,
17,
41,
13,
20,
2,
13,
17,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
2,
13,
17,
11,
1,
0,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
17,
0,
18,
13,
13,
18,
13,
17,
0,
18,
13,
13,
4,
18,
13,
2,
17,
18,
13,
17,
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,
11,
1,
0,
13,
13,
2,
13,
2,
13,
17,
1,
40,
13,
30,
30,
0,
18,
13,
13,
18,
13,
2,
13,
17,
0,
18,
13,
13,
18,
13,
2,
13,
17,
14,
2,
13,
2,
13,
17,
0,
13,
17,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
40,
13,
14,
2,
13,
13,
0,
13,
17,
40,
13,
14,
2,
13,
13,
0,
13,
17,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
10,
11
],
[
10,
12
],
[
12,
13
],
[
13,
14
],
[
14,
15
],
[
15,
16
],
[
15,
17
],
[
13,
18
],
[
18,
19
],
[
18,
20
],
[
9,
21
],
[
21,
22
],
[
22,
23
],
[
22,
24
],
[
21,
25
],
[
25,
26
],
[
25,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
27,
32
],
[
27,
33
],
[
21,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
36,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
41,
43
],
[
21,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
49,
51
],
[
51,
52
],
[
51,
53
],
[
21,
54
],
[
54,
55
],
[
54,
56
],
[
57,
58
],
[
57,
59
],
[
21,
60
],
[
60,
61
],
[
60,
62
],
[
63,
64
],
[
63,
65
],
[
21,
66
],
[
66,
67
],
[
21,
68
],
[
68,
69
],
[
68,
70
],
[
21,
71
],
[
71,
72
],
[
71,
73
],
[
21,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
21,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
84,
85
],
[
84,
86
],
[
79,
87
],
[
87,
88
],
[
88,
89
],
[
79,
90
],
[
91,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
94,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
94,
99
],
[
94,
100
],
[
91,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
105,
107
],
[
91,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
108,
112
],
[
112,
113
],
[
113,
114
],
[
112,
115
],
[
115,
116
],
[
115,
117
],
[
117,
118
],
[
117,
119
],
[
21,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
120,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
127,
128
],
[
127,
129
],
[
126,
130
],
[
125,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
134,
136
],
[
131,
137
],
[
137,
138
],
[
138,
139
],
[
139,
140
],
[
139,
141
],
[
137,
142
],
[
143,
143
],
[
143,
144
],
[
144,
145
],
[
144,
146
],
[
143,
147
],
[
143,
148
],
[
131,
149
],
[
149,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
149,
154
],
[
154,
155
],
[
154,
156
],
[
156,
157
],
[
156,
158
],
[
149,
159
],
[
159,
160
],
[
160,
161
],
[
149,
162
],
[
163,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
164,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
170,
172
],
[
163,
173
],
[
173,
174
],
[
174,
175
],
[
174,
176
],
[
173,
177
],
[
177,
178
],
[
177,
179
],
[
179,
180
],
[
179,
181
],
[
131,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
185,
187
],
[
182,
188
],
[
188,
189
],
[
188,
190
],
[
131,
191
],
[
191,
192
],
[
192,
193
],
[
192,
194
],
[
194,
195
],
[
194,
196
],
[
191,
197
],
[
197,
198
],
[
197,
199
],
[
131,
200
],
[
200,
201
],
[
125,
202
],
[
202,
203
],
[
203,
204
],
[
203,
205
],
[
202,
206
],
[
206,
207
],
[
207,
208
],
[
207,
209
],
[
206,
210
],
[
202,
211
],
[
211,
212
],
[
202,
213
],
[
213,
214
],
[
214,
215
],
[
214,
216
],
[
213,
217
],
[
217,
218
],
[
217,
219
],
[
202,
220
],
[
220,
221
],
[
202,
222
],
[
222,
223
],
[
223,
224
],
[
223,
225
],
[
222,
226
],
[
226,
227
],
[
226,
228
],
[
6,
229
],
[
229,
230
]
] | [
"import java.io.*;\n\nclass Main{\n\tpublic static void main(String[] args){\n\t\ttry{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tString wk[] = br.readLine().split(\" \", 0);\n\t\t\tint n = Integer.parseInt(\"\"+wk[0]);\n\t\t\tint q = Integer.parseInt(\"\"+wk[1]);\n\t\t\tString name[] = new String[n+1];\n\t\t\tint time[] = new int[n+1];\n\t\t\tint i, ttime=0;\n\t\t\tint head=0, tail=n-1;\n\t\t\tfor(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}\n\t\t\twhile(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(IOException e){\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}\n\t}\n}",
"import java.io.*;",
"io.*",
"java",
"class Main{\n\tpublic static void main(String[] args){\n\t\ttry{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tString wk[] = br.readLine().split(\" \", 0);\n\t\t\tint n = Integer.parseInt(\"\"+wk[0]);\n\t\t\tint q = Integer.parseInt(\"\"+wk[1]);\n\t\t\tString name[] = new String[n+1];\n\t\t\tint time[] = new int[n+1];\n\t\t\tint i, ttime=0;\n\t\t\tint head=0, tail=n-1;\n\t\t\tfor(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}\n\t\t\twhile(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(IOException e){\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args){\n\t\ttry{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tString wk[] = br.readLine().split(\" \", 0);\n\t\t\tint n = Integer.parseInt(\"\"+wk[0]);\n\t\t\tint q = Integer.parseInt(\"\"+wk[1]);\n\t\t\tString name[] = new String[n+1];\n\t\t\tint time[] = new int[n+1];\n\t\t\tint i, ttime=0;\n\t\t\tint head=0, tail=n-1;\n\t\t\tfor(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}\n\t\t\twhile(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(IOException e){\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}\n\t}",
"main",
"{\n\t\ttry{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tString wk[] = br.readLine().split(\" \", 0);\n\t\t\tint n = Integer.parseInt(\"\"+wk[0]);\n\t\t\tint q = Integer.parseInt(\"\"+wk[1]);\n\t\t\tString name[] = new String[n+1];\n\t\t\tint time[] = new int[n+1];\n\t\t\tint i, ttime=0;\n\t\t\tint head=0, tail=n-1;\n\t\t\tfor(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}\n\t\t\twhile(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(IOException e){\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}\n\t}",
"try{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tString wk[] = br.readLine().split(\" \", 0);\n\t\t\tint n = Integer.parseInt(\"\"+wk[0]);\n\t\t\tint q = Integer.parseInt(\"\"+wk[1]);\n\t\t\tString name[] = new String[n+1];\n\t\t\tint time[] = new int[n+1];\n\t\t\tint i, ttime=0;\n\t\t\tint head=0, tail=n-1;\n\t\t\tfor(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}\n\t\t\twhile(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch(IOException e){\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}",
"catch(IOException e){\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}",
"IOException e",
"{\n\t\t\tSystem.out.println(\"Exception :\" + e);\n\t\t}",
"System.out.println(\"Exception :\" + e)",
"System.out.println",
"System.out",
"System",
"System.out",
"\"Exception :\" + e",
"\"Exception :\"",
"e",
"{\n\t\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\t\tString wk[] = br.readLine().split(\" \", 0);\n\t\t\tint n = Integer.parseInt(\"\"+wk[0]);\n\t\t\tint q = Integer.parseInt(\"\"+wk[1]);\n\t\t\tString name[] = new String[n+1];\n\t\t\tint time[] = new int[n+1];\n\t\t\tint i, ttime=0;\n\t\t\tint head=0, tail=n-1;\n\t\t\tfor(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}\n\t\t\twhile(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}\n\t\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String wk[] = br.readLine().split(\" \", 0);",
"wk",
"br.readLine().split(\" \", 0)",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"0",
"int n = Integer.parseInt(\"\"+wk[0]);",
"n",
"Integer.parseInt(\"\"+wk[0])",
"Integer.parseInt",
"Integer",
"\"\"+wk[0]",
"\"\"",
"wk[0]",
"wk",
"0",
"int q = Integer.parseInt(\"\"+wk[1]);",
"q",
"Integer.parseInt(\"\"+wk[1])",
"Integer.parseInt",
"Integer",
"\"\"+wk[1]",
"\"\"",
"wk[1]",
"wk",
"1",
"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",
"int i",
"i",
"ttime=0;",
"ttime",
"0",
"int head=0",
"head",
"0",
"tail=n-1;",
"tail",
"n-1",
"n",
"1",
"for(i=0; i<n; i++){\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}",
"{\n\t\t\t\twk = br.readLine().split(\" \", 0);\n\t\t\t\tname[i] = wk[0];\n\t\t\t\ttime[i] = Integer.parseInt(\"\"+wk[1]);\n\t\t\t}",
"wk = br.readLine().split(\" \", 0)",
"wk",
"br.readLine().split(\" \", 0)",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"0",
"name[i] = wk[0]",
"name[i]",
"name",
"i",
"wk[0]",
"wk",
"0",
"time[i] = Integer.parseInt(\"\"+wk[1])",
"time[i]",
"time",
"i",
"Integer.parseInt(\"\"+wk[1])",
"Integer.parseInt",
"Integer",
"\"\"+wk[1]",
"\"\"",
"wk[1]",
"wk",
"1",
"while(n>0){\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}",
"n>0",
"n",
"0",
"{\n\t\t\t\tif(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}\n\t\t\t}",
"if(time[head]<=q){\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t} else{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}",
"time[head]<=q",
"time[head]",
"time",
"head",
"q",
"{\n\t\t\t\t\tttime += time[head];\n\t\t\t\t\tSystem.out.println(name[head]+\" \"+ttime);\n\t\t\t\t\tfor(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}\n\t\t\t\t\tif(head==n-1) head=0;\n\t\t\t\t\tif(tail==n-1) tail=0;\n\t\t\t\t\tn--;\n\t\t\t\t}",
"ttime += time[head]",
"ttime",
"time[head]",
"time",
"head",
"System.out.println(name[head]+\" \"+ttime)",
"System.out.println",
"System.out",
"System",
"System.out",
"name[head]+\" \"+ttime",
"name[head]+\" \"+ttime",
"name[head]",
"name",
"head",
"\" \"",
"ttime",
"for(i=head; i<n-1; i++){\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}",
"i=head;",
"i=head",
"i",
"head",
"i<n-1",
"i",
"n-1",
"n",
"1",
"i++",
"i++",
"i",
"{\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}",
"{\n\t\t\t\t\t\tname[i] = name[i+1];\n\t\t\t\t\t\ttime[i] = time[i+1];\n\t\t\t\t\t}",
"name[i] = name[i+1]",
"name[i]",
"name",
"i",
"name[i+1]",
"name",
"i+1",
"i",
"1",
"time[i] = time[i+1]",
"time[i]",
"time",
"i",
"time[i+1]",
"time",
"i+1",
"i",
"1",
"if(head==n-1) head=0;",
"head==n-1",
"head",
"n-1",
"n",
"1",
"head=0",
"head",
"0",
"if(tail==n-1) tail=0;",
"tail==n-1",
"tail",
"n-1",
"n",
"1",
"tail=0",
"tail",
"0",
"n--",
"n",
"{\n\t\t\t\t\tttime += q;\n\t\t\t\t\ttime[head] -= q;\n\t\t\t\t\thead++;\n\t\t\t\t\tif(head==n) head=0;\n\t\t\t\t\ttail++;\n\t\t\t\t\tif(tail==n) tail=0;\n\t\t\t\t}",
"ttime += q",
"ttime",
"q",
"time[head] -= q",
"time[head]",
"time",
"head",
"q",
"head++",
"head",
"if(head==n) head=0;",
"head==n",
"head",
"n",
"head=0",
"head",
"0",
"tail++",
"tail",
"if(tail==n) tail=0;",
"tail==n",
"tail",
"n",
"tail=0",
"tail",
"0",
"String[] args",
"args"
] | import java.io.*;
class Main{
public static void main(String[] args){
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String wk[] = br.readLine().split(" ", 0);
int n = Integer.parseInt(""+wk[0]);
int q = Integer.parseInt(""+wk[1]);
String name[] = new String[n+1];
int time[] = new int[n+1];
int i, ttime=0;
int head=0, tail=n-1;
for(i=0; i<n; i++){
wk = br.readLine().split(" ", 0);
name[i] = wk[0];
time[i] = Integer.parseInt(""+wk[1]);
}
while(n>0){
if(time[head]<=q){
ttime += time[head];
System.out.println(name[head]+" "+ttime);
for(i=head; i<n-1; i++){
name[i] = name[i+1];
time[i] = time[i+1];
}
if(head==n-1) head=0;
if(tail==n-1) tail=0;
n--;
} else{
ttime += q;
time[head] -= q;
head++;
if(head==n) head=0;
tail++;
if(tail==n) tail=0;
}
}
} catch(IOException e){
System.out.println("Exception :" + e);
}
}
} |
[
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,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
17,
30,
14,
2,
18,
13,
13,
17,
30,
40,
13,
14,
2,
13,
13,
30,
0,
13,
17,
9,
41,
13,
2,
18,
13,
13,
13,
14,
2,
13,
17,
30,
0,
18,
13,
13,
13,
0,
13,
13,
30,
0,
18,
13,
13,
17,
0,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
2,
2,
13,
13,
13,
40,
13,
0,
13,
2,
13,
13,
14,
2,
13,
13,
30,
3,
40,
13,
14,
2,
13,
13,
30,
0,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
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
],
[
193,
5
],
[
193,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
8,
12
],
[
12,
13
],
[
12,
14
],
[
14,
15
],
[
15,
16
],
[
8,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
8,
22
],
[
22,
23
],
[
22,
24
],
[
8,
26
],
[
26,
27
],
[
26,
28
],
[
8,
30
],
[
30,
31
],
[
30,
32
],
[
8,
34
],
[
34,
35
],
[
34,
36
],
[
8,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
38,
43
],
[
43,
44
],
[
43,
45
],
[
38,
46
],
[
46,
47
],
[
47,
48
],
[
38,
49
],
[
50,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
52,
54
],
[
51,
55
],
[
55,
56
],
[
56,
57
],
[
50,
58
],
[
58,
59
],
[
59,
60
],
[
59,
61
],
[
58,
62
],
[
62,
63
],
[
63,
64
],
[
8,
65
],
[
65,
66
],
[
66,
67
],
[
8,
68
],
[
68,
69
],
[
68,
70
],
[
8,
71
],
[
71,
72
],
[
71,
73
],
[
8,
74
],
[
74,
75
],
[
74,
76
],
[
8,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
82,
83
],
[
82,
84
],
[
81,
85
],
[
80,
86
],
[
86,
87
],
[
87,
88
],
[
86,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
86,
97
],
[
79,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
100,
104
],
[
79,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
110,
114
],
[
109,
115
],
[
115,
116
],
[
115,
117
],
[
105,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
118,
124
],
[
124,
125
],
[
125,
126
],
[
125,
127
],
[
124,
128
],
[
128,
129
],
[
128,
130
],
[
118,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
136,
136
],
[
136,
137
],
[
136,
138
],
[
136,
139
],
[
118,
140
],
[
140,
141
],
[
118,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
144,
146
],
[
118,
147
],
[
147,
148
],
[
148,
149
],
[
148,
150
],
[
147,
151
],
[
151,
152
],
[
79,
153
],
[
153,
154
],
[
79,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
8,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
165,
167
],
[
163,
168
],
[
168,
169
],
[
168,
170
],
[
163,
171
],
[
171,
172
],
[
172,
173
],
[
163,
174
],
[
175,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
178,
179
],
[
178,
180
],
[
176,
181
],
[
182,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
182,
186
],
[
182,
187
],
[
187,
188
],
[
187,
189
],
[
6,
190
],
[
190,
191
],
[
0,
192
],
[
192,
193
],
[
192,
194
]
] | [
"import java.util.Scanner;\n\n\npublic class Main {\n\n\tpublic static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n String [] a = new String[n];\n int [] b = new int[n];\n String [] aa = new String[n];\n int [] bb = new int[n];\n\n for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }\n stdIn.close();\n\n \tint index =0;\n \tint basictime=0;\n int ansIndex=0;\n while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }\n for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n String [] a = new String[n];\n int [] b = new int[n];\n String [] aa = new String[n];\n int [] bb = new int[n];\n\n for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }\n stdIn.close();\n\n \tint index =0;\n \tint basictime=0;\n int ansIndex=0;\n while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }\n for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }\n }\n}",
"Main",
"public static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n String [] a = new String[n];\n int [] b = new int[n];\n String [] aa = new String[n];\n int [] bb = new int[n];\n\n for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }\n stdIn.close();\n\n \tint index =0;\n \tint basictime=0;\n int ansIndex=0;\n while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }\n for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }\n }",
"main",
"{\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n String [] a = new String[n];\n int [] b = new int[n];\n String [] aa = new String[n];\n int [] bb = new int[n];\n\n for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }\n stdIn.close();\n\n \tint index =0;\n \tint basictime=0;\n int ansIndex=0;\n while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }\n for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\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",
"String [] a = new String[n];",
"a",
"new String[n]",
"n",
"int [] b = new int[n];",
"b",
"new int[n]",
"n",
"String [] aa = new String[n];",
"aa",
"new String[n]",
"n",
"int [] bb = new int[n];",
"bb",
"new int[n]",
"n",
"for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }",
"{\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }",
"a[i] = stdIn.next()",
"a[i]",
"a",
"i",
"stdIn.next()",
"stdIn.next",
"stdIn",
"b[i] = stdIn.nextInt()",
"b[i]",
"b",
"i",
"stdIn.nextInt()",
"stdIn.nextInt",
"stdIn",
"stdIn.close()",
"stdIn.close",
"stdIn",
"int index =0;",
"index",
"0",
"int basictime=0;",
"basictime",
"0",
"int ansIndex=0;",
"ansIndex",
"0",
"while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }",
"true",
"{\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }",
"if(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}",
"b[index]==0",
"b[index]",
"b",
"index",
"0",
"{\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}",
"index++",
"index",
"if(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}",
"index==n",
"index",
"n",
"{\n \t\t//初期値へ\n \t\tindex=0;\n \t}",
"index=0",
"index",
"0",
"continue;",
"int remaining =b[index]-q;",
"remaining",
"b[index]-q",
"b[index]",
"b",
"index",
"q",
"if(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}",
"remaining >0",
"remaining",
"0",
"{\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t}",
"b[index] = remaining",
"b[index]",
"b",
"index",
"remaining",
"basictime+= q",
"basictime",
"q",
"{\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}",
"b[index] = 0",
"b[index]",
"b",
"index",
"0",
"aa[ansIndex]=a[index]",
"aa[ansIndex]",
"aa",
"ansIndex",
"a[index]",
"a",
"index",
"bb[ansIndex]=q + basictime + remaining",
"bb[ansIndex]",
"bb",
"ansIndex",
"q + basictime + remaining",
"q + basictime + remaining",
"q",
"basictime",
"remaining",
"ansIndex++",
"ansIndex",
"basictime+= q + remaining",
"basictime",
"q + remaining",
"q",
"remaining",
"if(ansIndex==n){\n \t\t\tbreak;\n \t\t}",
"ansIndex==n",
"ansIndex",
"n",
"{\n \t\t\tbreak;\n \t\t}",
"break;",
"index++",
"index",
"if(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}",
"index==n",
"index",
"n",
"{\n \t\t//初期値へ\n \t\tindex=0;\n \t}",
"index=0",
"index",
"0",
"for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < ansIndex",
"i",
"ansIndex",
"i++",
"i++",
"i",
"{\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }",
"{\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }",
"System.out.println(aa[i] + \" \" + bb[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"aa[i] + \" \" + bb[i]",
"aa[i] + \" \" + bb[i]",
"aa[i]",
"aa",
"i",
"\" \"",
"bb[i]",
"bb",
"i",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n String [] a = new String[n];\n int [] b = new int[n];\n String [] aa = new String[n];\n int [] bb = new int[n];\n\n for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }\n stdIn.close();\n\n \tint index =0;\n \tint basictime=0;\n int ansIndex=0;\n while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }\n for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }\n }\n}",
"public class Main {\n\n\tpublic static void main(String[] args){\n\t\tScanner stdIn = new Scanner(System.in);\n\n\t\tint n = stdIn.nextInt();\n\t\tint q = stdIn.nextInt();\n String [] a = new String[n];\n int [] b = new int[n];\n String [] aa = new String[n];\n int [] bb = new int[n];\n\n for(int i = 0; i < n; i++){\n \ta[i] = stdIn.next();\n \tb[i] = stdIn.nextInt();\n }\n stdIn.close();\n\n \tint index =0;\n \tint basictime=0;\n int ansIndex=0;\n while(true) {\n \tif(b[index]==0) {\n \t\tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n \t\tcontinue;\n \t}\n \tint remaining =b[index]-q;\n \tif(remaining >0){\n \t\tb[index] = remaining;\n \t\tbasictime+= q;\n \t} else {\n \t\tb[index] = 0;\n \t\taa[ansIndex]=a[index];\n \t\tbb[ansIndex]=q + basictime + remaining;\n \t\tansIndex++;\n \t\tbasictime+= q + remaining;\n \t\t//全チェックし、全てMapにあれば終了\n \t\tif(ansIndex==n){\n \t\t\tbreak;\n \t\t}\n \t}\n \tindex++;\n \tif(index==n){\n \t\t//初期値へ\n \t\tindex=0;\n \t}\n }\n for(int i = 0; i < ansIndex; i++){\n \tSystem.out.println(aa[i] + \" \" + bb[i]);\n }\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n = stdIn.nextInt();
int q = stdIn.nextInt();
String [] a = new String[n];
int [] b = new int[n];
String [] aa = new String[n];
int [] bb = new int[n];
for(int i = 0; i < n; i++){
a[i] = stdIn.next();
b[i] = stdIn.nextInt();
}
stdIn.close();
int index =0;
int basictime=0;
int ansIndex=0;
while(true) {
if(b[index]==0) {
index++;
if(index==n){
//初期値へ
index=0;
}
continue;
}
int remaining =b[index]-q;
if(remaining >0){
b[index] = remaining;
basictime+= q;
} else {
b[index] = 0;
aa[ansIndex]=a[index];
bb[ansIndex]=q + basictime + remaining;
ansIndex++;
basictime+= q + remaining;
//全チェックし、全てMapにあれば終了
if(ansIndex==n){
break;
}
}
index++;
if(index==n){
//初期値へ
index=0;
}
}
for(int i = 0; i < ansIndex; i++){
System.out.println(aa[i] + " " + bb[i]);
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
20,
13,
41,
13,
17,
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,
4,
18,
13,
4,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
41,
13,
42,
40,
4,
13,
30,
0,
13,
4,
18,
13,
0,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
13,
0,
13,
13,
4,
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,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
2,
13,
17,
13,
30,
0,
13,
17,
30,
40,
13,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
204,
5
],
[
204,
6
],
[
6,
7
],
[
6,
8
],
[
204,
9
],
[
9,
10
],
[
9,
11
],
[
204,
12
],
[
12,
13
],
[
12,
14
],
[
204,
15
],
[
15,
16
],
[
15,
17
],
[
204,
19
],
[
19,
20
],
[
19,
21
],
[
204,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
24,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
24,
33
],
[
33,
34
],
[
33,
35
],
[
35,
36
],
[
36,
37
],
[
24,
38
],
[
38,
39
],
[
38,
40
],
[
24,
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
],
[
53,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
24,
65
],
[
65,
66
],
[
65,
67
],
[
24,
68
],
[
68,
69
],
[
68,
70
],
[
24,
71
],
[
71,
72
],
[
24,
73
],
[
73,
74
],
[
24,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
83,
84
],
[
79,
85
],
[
85,
86
],
[
85,
87
],
[
87,
88
],
[
79,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
93,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
89,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
109,
110
],
[
110,
111
],
[
109,
112
],
[
105,
113
],
[
113,
114
],
[
113,
115
],
[
105,
116
],
[
116,
117
],
[
116,
118
],
[
24,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
121,
123
],
[
119,
124
],
[
124,
125
],
[
124,
126
],
[
119,
127
],
[
127,
128
],
[
128,
129
],
[
119,
130
],
[
131,
131
],
[
131,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
138,
138
],
[
138,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
138,
143
],
[
138,
144
],
[
144,
145
],
[
145,
146
],
[
144,
147
],
[
22,
148
],
[
148,
149
],
[
204,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
204,
157
],
[
157,
158
],
[
157,
159
],
[
159,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
159,
165
],
[
165,
166
],
[
166,
167
],
[
167,
168
],
[
167,
169
],
[
166,
170
],
[
165,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
165,
175
],
[
175,
176
],
[
176,
177
],
[
157,
178
],
[
178,
179
],
[
204,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
183,
185
],
[
185,
186
],
[
185,
187
],
[
182,
188
],
[
188,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
189,
193
],
[
188,
194
],
[
194,
195
],
[
195,
196
],
[
195,
197
],
[
188,
198
],
[
198,
199
],
[
199,
200
],
[
182,
201
],
[
201,
202
],
[
0,
203
],
[
203,
204
],
[
203,
205
]
] | [
"import java.util.*;\n\npublic class Main {\n static int head = 0;\n static int tail = 0;\n static final int MAX = 100000;\n static int[] Q = new int[MAX];\n static int NOW = 0;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n LinkedList<String> name = new LinkedList<>();\n for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }\n\n ArrayList<String> ansName = new ArrayList<>();\n ArrayList<Integer> ansTime = new ArrayList<>();\n String tmpName;\n int tmpTime;\n\n while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }\n\n for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }\n }\n\n static Boolean isEmpty(){\n return head == tail;\n }\n\n static void enqueue(int x){\n Q[tail] = x;\n if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }\n }\n\n static int dequeue(){\n int x = Q[head];\n if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }\n return x;\n }\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n static int head = 0;\n static int tail = 0;\n static final int MAX = 100000;\n static int[] Q = new int[MAX];\n static int NOW = 0;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n LinkedList<String> name = new LinkedList<>();\n for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }\n\n ArrayList<String> ansName = new ArrayList<>();\n ArrayList<Integer> ansTime = new ArrayList<>();\n String tmpName;\n int tmpTime;\n\n while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }\n\n for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }\n }\n\n static Boolean isEmpty(){\n return head == tail;\n }\n\n static void enqueue(int x){\n Q[tail] = x;\n if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }\n }\n\n static int dequeue(){\n int x = Q[head];\n if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }\n return x;\n }\n}",
"Main",
"static int head = 0;",
"head",
"0",
"static int tail = 0;",
"tail",
"0",
"static final int MAX = 100000;",
"MAX",
"100000",
"static int[] Q = new int[MAX];",
"Q",
"new int[MAX]",
"MAX",
"static int NOW = 0;",
"NOW",
"0",
"public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n LinkedList<String> name = new LinkedList<>();\n for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }\n\n ArrayList<String> ansName = new ArrayList<>();\n ArrayList<Integer> ansTime = new ArrayList<>();\n String tmpName;\n int tmpTime;\n\n while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }\n\n for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n LinkedList<String> name = new LinkedList<>();\n for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }\n\n ArrayList<String> ansName = new ArrayList<>();\n ArrayList<Integer> ansTime = new ArrayList<>();\n String tmpName;\n int tmpTime;\n\n while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }\n\n for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\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",
"LinkedList<String> name = new LinkedList<>();",
"name",
"new LinkedList<>()",
"for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }",
"{\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }",
"name.offer(sc.next())",
"name.offer",
"name",
"sc.next()",
"sc.next",
"sc",
"enqueue(sc.nextInt())",
"enqueue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"ArrayList<String> ansName = new ArrayList<>();",
"ansName",
"new ArrayList<>()",
"ArrayList<Integer> ansTime = new ArrayList<>();",
"ansTime",
"new ArrayList<>()",
"String tmpName;",
"tmpName",
"int tmpTime;",
"tmpTime",
"while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }",
"tmpName = name.poll()",
"tmpName",
"name.poll()",
"name.poll",
"name",
"tmpTime = dequeue()",
"tmpTime",
"dequeue()",
"dequeue",
"if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }",
"tmpTime <= q",
"tmpTime",
"q",
"{\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }",
"NOW += tmpTime",
"NOW",
"tmpTime",
"ansName.add(tmpName)",
"ansName.add",
"ansName",
"tmpName",
"ansTime.add(NOW)",
"ansTime.add",
"ansTime",
"NOW",
"{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }",
"NOW += q",
"NOW",
"q",
"name.offer(tmpName)",
"name.offer",
"name",
"tmpName",
"tmpTime -= q",
"tmpTime",
"q",
"enqueue(tmpTime)",
"enqueue",
"tmpTime",
"for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }",
"{\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }",
"System.out.println(ansName.get(i) + \" \" + ansTime.get(i))",
"System.out.println",
"System.out",
"System",
"System.out",
"ansName.get(i) + \" \" + ansTime.get(i)",
"ansName.get(i) + \" \" + ansTime.get(i)",
"ansName.get(i)",
"ansName.get",
"ansName",
"i",
"\" \"",
"ansTime.get(i)",
"ansTime.get",
"ansTime",
"i",
"String[] args",
"args",
"static Boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"static void enqueue(int x){\n Q[tail] = x;\n if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }\n }",
"enqueue",
"{\n Q[tail] = x;\n if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }\n }",
"Q[tail] = x",
"Q[tail]",
"Q",
"tail",
"x",
"if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }",
"tail + 1 == MAX",
"tail + 1",
"tail",
"1",
"MAX",
"{\n tail = 0;\n }",
"tail = 0",
"tail",
"0",
"{\n tail ++;\n }",
"tail ++",
"tail",
"int x",
"x",
"static int dequeue(){\n int x = Q[head];\n if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }\n return x;\n }",
"dequeue",
"{\n int x = Q[head];\n if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }\n return x;\n }",
"int x = Q[head];",
"x",
"Q[head]",
"Q",
"head",
"if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }",
"head + 1 == MAX",
"head + 1",
"head",
"1",
"MAX",
"{\n head = 0;\n }",
"head = 0",
"head",
"0",
"{\n head++;\n }",
"head++",
"head",
"return x;",
"x",
"public class Main {\n static int head = 0;\n static int tail = 0;\n static final int MAX = 100000;\n static int[] Q = new int[MAX];\n static int NOW = 0;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n LinkedList<String> name = new LinkedList<>();\n for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }\n\n ArrayList<String> ansName = new ArrayList<>();\n ArrayList<Integer> ansTime = new ArrayList<>();\n String tmpName;\n int tmpTime;\n\n while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }\n\n for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }\n }\n\n static Boolean isEmpty(){\n return head == tail;\n }\n\n static void enqueue(int x){\n Q[tail] = x;\n if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }\n }\n\n static int dequeue(){\n int x = Q[head];\n if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }\n return x;\n }\n}",
"public class Main {\n static int head = 0;\n static int tail = 0;\n static final int MAX = 100000;\n static int[] Q = new int[MAX];\n static int NOW = 0;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n LinkedList<String> name = new LinkedList<>();\n for (int i = 0; i < n; i++) {\n name.offer(sc.next());\n enqueue(sc.nextInt());\n }\n\n ArrayList<String> ansName = new ArrayList<>();\n ArrayList<Integer> ansTime = new ArrayList<>();\n String tmpName;\n int tmpTime;\n\n while(!isEmpty()){\n tmpName = name.poll();\n tmpTime = dequeue();\n if(tmpTime <= q){\n NOW += tmpTime;\n ansName.add(tmpName);\n ansTime.add(NOW);\n }else{\n NOW += q;\n name.offer(tmpName);\n tmpTime -= q;\n enqueue(tmpTime);\n }\n }\n\n for (int i = 0; i < n; i++) {\n System.out.println(ansName.get(i) + \" \" + ansTime.get(i));\n }\n }\n\n static Boolean isEmpty(){\n return head == tail;\n }\n\n static void enqueue(int x){\n Q[tail] = x;\n if(tail + 1 == MAX){\n tail = 0;\n }else{\n tail ++;\n }\n }\n\n static int dequeue(){\n int x = Q[head];\n if(head + 1 == MAX){\n head = 0;\n }else {\n head++;\n }\n return x;\n }\n}",
"Main"
] | import java.util.*;
public class Main {
static int head = 0;
static int tail = 0;
static final int MAX = 100000;
static int[] Q = new int[MAX];
static int NOW = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
LinkedList<String> name = new LinkedList<>();
for (int i = 0; i < n; i++) {
name.offer(sc.next());
enqueue(sc.nextInt());
}
ArrayList<String> ansName = new ArrayList<>();
ArrayList<Integer> ansTime = new ArrayList<>();
String tmpName;
int tmpTime;
while(!isEmpty()){
tmpName = name.poll();
tmpTime = dequeue();
if(tmpTime <= q){
NOW += tmpTime;
ansName.add(tmpName);
ansTime.add(NOW);
}else{
NOW += q;
name.offer(tmpName);
tmpTime -= q;
enqueue(tmpTime);
}
}
for (int i = 0; i < n; i++) {
System.out.println(ansName.get(i) + " " + ansTime.get(i));
}
}
static Boolean isEmpty(){
return head == tail;
}
static void enqueue(int x){
Q[tail] = x;
if(tail + 1 == MAX){
tail = 0;
}else{
tail ++;
}
}
static int dequeue(){
int x = Q[head];
if(head + 1 == MAX){
head = 0;
}else {
head++;
}
return x;
}
}
|
[
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 s=new Scanner(System.in);\n\tint i,n,m,gt=0;\n\n\tQueue<String>q=new LinkedList<String>();\n\tQueue<Integer>time=new LinkedList<Integer>();\n\n\tn=s.nextInt();\n\tm=s.nextInt();\n\n\tfor(i=0;i<n;i++){\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}\n\n\twhile(0<q.size()){\n\t if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\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 s=new Scanner(System.in);\n\tint i,n,m,gt=0;\n\n\tQueue<String>q=new LinkedList<String>();\n\tQueue<Integer>time=new LinkedList<Integer>();\n\n\tn=s.nextInt();\n\tm=s.nextInt();\n\n\tfor(i=0;i<n;i++){\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}\n\n\twhile(0<q.size()){\n\t if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }\n\t}\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\tScanner s=new Scanner(System.in);\n\tint i,n,m,gt=0;\n\n\tQueue<String>q=new LinkedList<String>();\n\tQueue<Integer>time=new LinkedList<Integer>();\n\n\tn=s.nextInt();\n\tm=s.nextInt();\n\n\tfor(i=0;i<n;i++){\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}\n\n\twhile(0<q.size()){\n\t if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }\n\t}\n }",
"main",
"{\n\tScanner s=new Scanner(System.in);\n\tint i,n,m,gt=0;\n\n\tQueue<String>q=new LinkedList<String>();\n\tQueue<Integer>time=new LinkedList<Integer>();\n\n\tn=s.nextInt();\n\tm=s.nextInt();\n\n\tfor(i=0;i<n;i++){\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}\n\n\twhile(0<q.size()){\n\t if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }\n\t}\n }",
"Scanner s=new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"int i",
"i",
"n",
"n",
"m",
"m",
"gt=0;",
"gt",
"0",
"Queue<String>q=new LinkedList<String>();",
"q",
"new LinkedList<String>()",
"Queue<Integer>time=new LinkedList<Integer>();",
"time",
"new LinkedList<Integer>()",
"n=s.nextInt()",
"n",
"s.nextInt()",
"s.nextInt",
"s",
"m=s.nextInt()",
"m",
"s.nextInt()",
"s.nextInt",
"s",
"for(i=0;i<n;i++){\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}",
"{\n\t q.add(s.next());\n\t time.add(s.nextInt());\n\t}",
"q.add(s.next())",
"q.add",
"q",
"s.next()",
"s.next",
"s",
"time.add(s.nextInt())",
"time.add",
"time",
"s.nextInt()",
"s.nextInt",
"s",
"while(0<q.size()){\n\t if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }\n\t}",
"0<q.size()",
"0",
"q.size()",
"q.size",
"q",
"{\n\t if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }\n\t}",
"if(0<(time.peek()-m)){\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }\n\t else{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }",
"0<(time.peek()-m)",
"0",
"(time.peek()-m)",
"time.peek()",
"time.peek",
"time",
"m",
"{\n\t\tq.add(q.poll());\n\t\ttime.add(time.poll()-m);\n\t\tgt=gt+m;\n\t }",
"q.add(q.poll())",
"q.add",
"q",
"q.poll()",
"q.poll",
"q",
"time.add(time.poll()-m)",
"time.add",
"time",
"time.poll()-m",
"time.poll()",
"time.poll",
"time",
"m",
"gt=gt+m",
"gt",
"gt+m",
"gt",
"m",
"{\n\t\tgt=gt+time.poll();\n\t\tSystem.out.println(q.poll()+\" \"+gt);\n\t }",
"gt=gt+time.poll()",
"gt",
"gt+time.poll()",
"gt",
"time.poll()",
"time.poll",
"time",
"System.out.println(q.poll()+\" \"+gt)",
"System.out.println",
"System.out",
"System",
"System.out",
"q.poll()+\" \"+gt",
"q.poll()+\" \"+gt",
"q.poll()",
"q.poll",
"q",
"\" \"",
"gt",
"String[] args",
"args"
] | import java.util.*;
import java.io.*;
class Main{
public static void main(String[] args) throws IOException{
Scanner s=new Scanner(System.in);
int i,n,m,gt=0;
Queue<String>q=new LinkedList<String>();
Queue<Integer>time=new LinkedList<Integer>();
n=s.nextInt();
m=s.nextInt();
for(i=0;i<n;i++){
q.add(s.next());
time.add(s.nextInt());
}
while(0<q.size()){
if(0<(time.peek()-m)){
q.add(q.poll());
time.add(time.poll()-m);
gt=gt+m;
}
else{
gt=gt+time.poll();
System.out.println(q.poll()+" "+gt);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
28,
13,
13,
30,
30,
4,
18,
18,
13,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
20,
41,
13,
20,
41,
13,
20,
42,
2,
4,
18,
13,
13,
30,
4,
18,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
41,
13,
17,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
14,
2,
2,
4,
18,
13,
13,
17,
30,
4,
18,
13,
2,
2,
4,
18,
13,
17,
2,
4,
18,
13,
13,
0,
13,
4,
18,
13,
30,
0,
13,
4,
18,
13,
0,
13,
13,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
13,
4,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
138,
5
],
[
138,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
9,
11
],
[
9,
12
],
[
13,
13
],
[
13,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
14,
19
],
[
6,
20
],
[
20,
21
],
[
138,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
25,
27
],
[
24,
28
],
[
28,
29
],
[
28,
30
],
[
24,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
24,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
24,
41
],
[
41,
42
],
[
41,
43
],
[
24,
44
],
[
44,
45
],
[
44,
46
],
[
24,
47
],
[
47,
48
],
[
47,
49
],
[
24,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
51,
55
],
[
50,
56
],
[
56,
57
],
[
57,
58
],
[
58,
59
],
[
57,
60
],
[
60,
61
],
[
61,
62
],
[
56,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
66,
67
],
[
67,
68
],
[
24,
69
],
[
69,
70
],
[
69,
71
],
[
24,
72
],
[
72,
73
],
[
72,
74
],
[
24,
75
],
[
75,
76
],
[
76,
77
],
[
77,
78
],
[
78,
79
],
[
76,
80
],
[
75,
81
],
[
81,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
85,
86
],
[
86,
87
],
[
84,
88
],
[
83,
89
],
[
82,
90
],
[
90,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
95,
95
],
[
95,
96
],
[
96,
97
],
[
97,
98
],
[
95,
99
],
[
95,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
100,
104
],
[
90,
105
],
[
105,
106
],
[
105,
107
],
[
107,
108
],
[
108,
109
],
[
82,
110
],
[
110,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
114,
115
],
[
110,
116
],
[
116,
117
],
[
116,
118
],
[
110,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
110,
123
],
[
123,
124
],
[
124,
125
],
[
123,
126
],
[
126,
127
],
[
127,
128
],
[
110,
129
],
[
129,
130
],
[
129,
131
],
[
24,
132
],
[
132,
133
],
[
132,
134
],
[
22,
135
],
[
135,
136
],
[
0,
137
],
[
137,
138
],
[
137,
139
]
] | [
"\nimport java.util.*;\n\n\n\n/*\n * Aizuuuuuuu\n * \n */\npublic class Main {\n\tpublic static void print(ArrayList<String> list) {\n\t\tfor (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tint globalTime = 0;\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tArrayList<String> results = new ArrayList<String>();\n\t\tLinkedList<String> ns = new LinkedList<String>();\n\t\tLinkedList<Integer> qs = new LinkedList<Integer>();\n\t\t\n\t\twhile (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}\n\t\t\n\t\tString tempS = \"\";\n\t\tint tempI = 0;\n\t\t\n\t\twhile (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}\n\t\tprint(results);\n\t\t\n\t}\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void print(ArrayList<String> list) {\n\t\tfor (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tint globalTime = 0;\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tArrayList<String> results = new ArrayList<String>();\n\t\tLinkedList<String> ns = new LinkedList<String>();\n\t\tLinkedList<Integer> qs = new LinkedList<Integer>();\n\t\t\n\t\twhile (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}\n\t\t\n\t\tString tempS = \"\";\n\t\tint tempI = 0;\n\t\t\n\t\twhile (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}\n\t\tprint(results);\n\t\t\n\t}\n}",
"Main",
"public static void print(ArrayList<String> list) {\n\t\tfor (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}",
"print",
"{\n\t\tfor (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}",
"for (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}",
"String i",
"list",
"{\n\t\t\tSystem.out.println(i);\n\t\t}",
"{\n\t\t\tSystem.out.println(i);\n\t\t}",
"System.out.println(i)",
"System.out.println",
"System.out",
"System",
"System.out",
"i",
"ArrayList<String> list",
"list",
"public static void main(String[] args) {\n\t\tint globalTime = 0;\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tArrayList<String> results = new ArrayList<String>();\n\t\tLinkedList<String> ns = new LinkedList<String>();\n\t\tLinkedList<Integer> qs = new LinkedList<Integer>();\n\t\t\n\t\twhile (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}\n\t\t\n\t\tString tempS = \"\";\n\t\tint tempI = 0;\n\t\t\n\t\twhile (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}\n\t\tprint(results);\n\t\t\n\t}",
"main",
"{\n\t\tint globalTime = 0;\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tArrayList<String> results = new ArrayList<String>();\n\t\tLinkedList<String> ns = new LinkedList<String>();\n\t\tLinkedList<Integer> qs = new LinkedList<Integer>();\n\t\t\n\t\twhile (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}\n\t\t\n\t\tString tempS = \"\";\n\t\tint tempI = 0;\n\t\t\n\t\twhile (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}\n\t\tprint(results);\n\t\t\n\t}",
"int globalTime = 0;",
"globalTime",
"0",
"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<String> results = new ArrayList<String>();",
"results",
"new ArrayList<String>()",
"LinkedList<String> ns = new LinkedList<String>();",
"ns",
"new LinkedList<String>()",
"LinkedList<Integer> qs = new LinkedList<Integer>();",
"qs",
"new LinkedList<Integer>()",
"while (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}",
"ns.size() < n",
"ns.size()",
"ns.size",
"ns",
"n",
"{\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}",
"ns.addLast(sc.next())",
"ns.addLast",
"ns",
"sc.next()",
"sc.next",
"sc",
"qs.addLast(sc.nextInt())",
"qs.addLast",
"qs",
"sc.nextInt()",
"sc.nextInt",
"sc",
"String tempS = \"\";",
"tempS",
"\"\"",
"int tempI = 0;",
"tempI",
"0",
"while (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}",
"ns.size() > 0",
"ns.size()",
"ns.size",
"ns",
"0",
"{\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}",
"if (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}",
"qs.peek() - q <= 0",
"qs.peek() - q",
"qs.peek()",
"qs.peek",
"qs",
"q",
"0",
"{\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}",
"results.add(ns.poll() + \" \" + (qs.peek()+globalTime))",
"results.add",
"results",
"ns.poll() + \" \" + (qs.peek()+globalTime)",
"ns.poll() + \" \" + (qs.peek()+globalTime)",
"ns.poll()",
"ns.poll",
"ns",
"\" \"",
"(qs.peek()+globalTime)",
"qs.peek()",
"qs.peek",
"qs",
"globalTime",
"globalTime += qs.poll()",
"globalTime",
"qs.poll()",
"qs.poll",
"qs",
"{\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}",
"tempI = qs.poll()",
"tempI",
"qs.poll()",
"qs.poll",
"qs",
"tempI -= q",
"tempI",
"q",
"qs.addLast(tempI)",
"qs.addLast",
"qs",
"tempI",
"ns.addLast(ns.poll())",
"ns.addLast",
"ns",
"ns.poll()",
"ns.poll",
"ns",
"globalTime += q",
"globalTime",
"q",
"print(results)",
"print",
"results",
"String[] args",
"args",
"public class Main {\n\tpublic static void print(ArrayList<String> list) {\n\t\tfor (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tint globalTime = 0;\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tArrayList<String> results = new ArrayList<String>();\n\t\tLinkedList<String> ns = new LinkedList<String>();\n\t\tLinkedList<Integer> qs = new LinkedList<Integer>();\n\t\t\n\t\twhile (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}\n\t\t\n\t\tString tempS = \"\";\n\t\tint tempI = 0;\n\t\t\n\t\twhile (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}\n\t\tprint(results);\n\t\t\n\t}\n}",
"public class Main {\n\tpublic static void print(ArrayList<String> list) {\n\t\tfor (String i :list) {\n\t\t\tSystem.out.println(i);\n\t\t}\n\t}\n\tpublic static void main(String[] args) {\n\t\tint globalTime = 0;\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\t\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tArrayList<String> results = new ArrayList<String>();\n\t\tLinkedList<String> ns = new LinkedList<String>();\n\t\tLinkedList<Integer> qs = new LinkedList<Integer>();\n\t\t\n\t\twhile (ns.size() < n) {\n\t\t\tns.addLast(sc.next());\n\t\t\tqs.addLast(sc.nextInt());\n\t\t}\n\t\t\n\t\tString tempS = \"\";\n\t\tint tempI = 0;\n\t\t\n\t\twhile (ns.size() > 0) {\n\t\t\tif (qs.peek() - q <= 0) {\n\t\t\t\tresults.add(ns.poll() + \" \" + (qs.peek()+globalTime));\n\t\t\t\tglobalTime += qs.poll();\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttempI = qs.poll();\n\t\t\t\ttempI -= q;\n\t\t\t\tqs.addLast(tempI);\n\t\t\t\tns.addLast(ns.poll());\n\t\t\t\tglobalTime += q;\n\t\t\t}\n\t\t}\n\t\tprint(results);\n\t\t\n\t}\n}",
"Main"
] |
import java.util.*;
/*
* Aizuuuuuuu
*
*/
public class Main {
public static void print(ArrayList<String> list) {
for (String i :list) {
System.out.println(i);
}
}
public static void main(String[] args) {
int globalTime = 0;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
ArrayList<String> results = new ArrayList<String>();
LinkedList<String> ns = new LinkedList<String>();
LinkedList<Integer> qs = new LinkedList<Integer>();
while (ns.size() < n) {
ns.addLast(sc.next());
qs.addLast(sc.nextInt());
}
String tempS = "";
int tempI = 0;
while (ns.size() > 0) {
if (qs.peek() - q <= 0) {
results.add(ns.poll() + " " + (qs.peek()+globalTime));
globalTime += qs.poll();
}
else {
tempI = qs.poll();
tempI -= q;
qs.addLast(tempI);
ns.addLast(ns.poll());
globalTime += q;
}
}
print(results);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
38,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
42,
2,
4,
18,
13,
17,
30,
41,
13,
4,
18,
13,
14,
2,
18,
13,
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,
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
],
[
117,
5
],
[
117,
6
],
[
6,
7
],
[
6,
8
],
[
8,
9
],
[
9,
10
],
[
10,
11
],
[
11,
12
],
[
11,
13
],
[
10,
14
],
[
14,
15
],
[
14,
16
],
[
10,
17
],
[
17,
18
],
[
17,
19
],
[
19,
20
],
[
20,
21
],
[
10,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
10,
27
],
[
27,
28
],
[
27,
29
],
[
10,
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
],
[
43,
46
],
[
10,
47
],
[
47,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
48,
52
],
[
47,
53
],
[
53,
54
],
[
54,
55
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
53,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
61,
63
],
[
60,
64
],
[
59,
65
],
[
65,
66
],
[
66,
67
],
[
67,
68
],
[
66,
69
],
[
65,
70
],
[
70,
71
],
[
70,
72
],
[
59,
73
],
[
73,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
76,
78
],
[
73,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
79,
84
],
[
85,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
85,
89
],
[
85,
90
],
[
6,
91
],
[
91,
92
],
[
0,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
93,
97
],
[
97,
98
],
[
93,
99
],
[
99,
100
],
[
99,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
102,
106
],
[
101,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
99,
112
],
[
112,
113
],
[
99,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
]
] | [
"\nimport java.util.*;\n\npublic class Main {\n public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }\n }\n}\n\nclass Prosess {\n String name;\n int time;\n\n Prosess(String name, int time) {\n this.name = name;\n this.time = time;\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }\n }",
"main",
"{\n try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }\n }",
"try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }",
"{\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }",
"Scanner sc = new Scanner(System.in)",
"Scanner sc = new Scanner(System.in)",
"new Scanner(System.in)",
"Queue<Prosess> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"int N = sc.nextInt();",
"N",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int time = 0;",
"time",
"0",
"for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < N",
"i",
"N",
"i++",
"i++",
"i",
"{\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }",
"{\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }",
"queue.offer(new Prosess(sc.next(), sc.nextInt()))",
"queue.offer",
"queue",
"new Prosess(sc.next(), sc.nextInt())",
"while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }",
"queue.size() != 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }",
"Prosess p = queue.poll();",
"p",
"queue.poll()",
"queue.poll",
"queue",
"if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }",
"p.time > q",
"p.time",
"p",
"p.time",
"q",
"{\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n }",
"queue.offer(new Prosess(p.name, p.time - q))",
"queue.offer",
"queue",
"new Prosess(p.name, p.time - q)",
"time += q",
"time",
"q",
"{\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }",
"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",
"String[] args",
"args",
"class Prosess {\n String name;\n int time;\n\n Prosess(String name, int time) {\n this.name = name;\n this.time = time;\n }\n}",
"Prosess",
"String name;",
"name",
"int time;",
"time",
"Prosess(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Prosess",
"{\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) {\n try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }\n }\n}",
"public class Main {\n public static void main(String[] args) {\n try (Scanner sc = new Scanner(System.in)) {\n Queue<Prosess> queue = new ArrayDeque<>();\n int N = sc.nextInt();\n int q = sc.nextInt();\n int time = 0;\n\n for (int i = 0; i < N; i++) {\n queue.offer(new Prosess(sc.next(), sc.nextInt()));\n }\n\n while (queue.size() != 0) {\n Prosess p = queue.poll();\n if (p.time > q) {\n // クオンタムだけ処理\n queue.offer(new Prosess(p.name, p.time - q));\n time += q;\n } else {\n // 処理が終わっていれば、名前とここまでかかった時間を表示して終わり\n time += p.time;\n System.out.println(p.name + \" \" + time);\n }\n\n }\n }\n }\n}",
"Main"
] |
import java.util.*;
public class Main {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
Queue<Prosess> queue = new ArrayDeque<>();
int N = sc.nextInt();
int q = sc.nextInt();
int time = 0;
for (int i = 0; i < N; i++) {
queue.offer(new Prosess(sc.next(), sc.nextInt()));
}
while (queue.size() != 0) {
Prosess p = queue.poll();
if (p.time > q) {
// クオンタムだけ処理
queue.offer(new Prosess(p.name, p.time - q));
time += q;
} else {
// 処理が終わっていれば、名前とここまでかかった時間を表示して終わり
time += p.time;
System.out.println(p.name + " " + time);
}
}
}
}
}
class Prosess {
String name;
int time;
Prosess(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,
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
],
[
113,
11
],
[
113,
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
],
[
63,
67
],
[
62,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
72,
73
],
[
73,
74
],
[
74,
75
],
[
72,
76
],
[
68,
77
],
[
77,
78
],
[
78,
79
],
[
77,
80
],
[
80,
81
],
[
81,
82
],
[
68,
83
],
[
83,
84
],
[
83,
85
],
[
68,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
87,
91
],
[
86,
92
],
[
92,
93
],
[
93,
94
],
[
93,
95
],
[
95,
96
],
[
96,
97
],
[
92,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
98,
103
],
[
104,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
104,
108
],
[
104,
109
],
[
12,
110
],
[
110,
111
],
[
0,
112
],
[
112,
113
],
[
112,
114
]
] | [
"import java.util.Deque;\nimport java.util.LinkedList;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> names = new LinkedList<>();\n\t\tint time = 0;\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\twhile (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}\n",
"import java.util.Deque;",
"Deque",
"java.util",
"import java.util.LinkedList;",
"LinkedList",
"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\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> names = new LinkedList<>();\n\t\tint time = 0;\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\twhile (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> names = new LinkedList<>();\n\t\tint time = 0;\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\twhile (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> names = new LinkedList<>();\n\t\tint time = 0;\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\twhile (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\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> names = new LinkedList<>();",
"names",
"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\tnames.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\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}",
"{\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}",
"names.add(sc.next())",
"names.add",
"names",
"sc.next()",
"sc.next",
"sc",
"queue.add(sc.nextInt())",
"queue.add",
"queue",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\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\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\n\t\t}",
"queue.addLast(queue.poll() - q)",
"queue.addLast",
"queue",
"queue.poll() - q",
"queue.poll()",
"queue.poll",
"queue",
"q",
"names.addLast(names.poll())",
"names.addLast",
"names",
"names.poll()",
"names.poll",
"names",
"time += q",
"time",
"q",
"if (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}",
"queue.peekLast() <= 0",
"queue.peekLast()",
"queue.peekLast",
"queue",
"0",
"{\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}",
"time += queue.pollLast()",
"time",
"queue.pollLast()",
"queue.pollLast",
"queue",
"System.out.println(names.pollLast() + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"names.pollLast() + \" \" + time",
"names.pollLast() + \" \" + time",
"names.pollLast()",
"names.pollLast",
"names",
"\" \"",
"time",
"String[] args",
"args",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> names = new LinkedList<>();\n\t\tint time = 0;\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\twhile (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tDeque<Integer> queue = new LinkedList<>();\n\t\tDeque<String> names = new LinkedList<>();\n\t\tint time = 0;\n\t\tint n = sc.nextInt();\n\t\tint q = sc.nextInt();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tnames.add(sc.next());\n\t\t\tqueue.add(sc.nextInt());\n\t\t}\n\t\twhile (queue.size() > 0) {\n\t\t\tqueue.addLast(queue.poll() - q);\n\t\t\tnames.addLast(names.poll());\n\t\t\ttime += q;\n\t\t\tif (queue.peekLast() <= 0) {\n\t\t\t\ttime += queue.pollLast();\n\t\t\t\tSystem.out.println(names.pollLast() + \" \" + time);\n\t\t\t}\n\t\t}\n\t}\n}",
"Main"
] | import java.util.Deque;
import java.util.LinkedList;
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> names = new LinkedList<>();
int time = 0;
int n = sc.nextInt();
int q = sc.nextInt();
for (int i = 0; i < n; i++) {
names.add(sc.next());
queue.add(sc.nextInt());
}
while (queue.size() > 0) {
queue.addLast(queue.poll() - q);
names.addLast(names.poll());
time += q;
if (queue.peekLast() <= 0) {
time += queue.pollLast();
System.out.println(names.pollLast() + " " + time);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
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,
18,
13,
17,
4,
18,
13,
18,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
14,
2,
2,
13,
13,
17,
30,
4,
18,
13,
13,
4,
18,
13,
4,
18,
13,
2,
13,
13,
0,
13,
13,
30,
0,
13,
13,
0,
18,
13,
13,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
16,
17
],
[
16,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
28,
29
],
[
29,
30
],
[
26,
31
],
[
20,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
37,
38
],
[
37,
39
],
[
20,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
42,
45
],
[
45,
46
],
[
45,
47
],
[
20,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
66,
71
],
[
63,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
63,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
81,
82
],
[
81,
83
],
[
20,
84
],
[
84,
85
],
[
84,
86
],
[
20,
88
],
[
88,
89
],
[
88,
90
],
[
20,
92
],
[
92,
93
],
[
92,
94
],
[
20,
95
],
[
95,
96
],
[
95,
97
],
[
20,
98
],
[
98,
99
],
[
99,
100
],
[
100,
101
],
[
101,
102
],
[
98,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
103,
109
],
[
109,
110
],
[
109,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
114,
115
],
[
115,
116
],
[
103,
117
],
[
117,
118
],
[
118,
119
],
[
119,
120
],
[
119,
121
],
[
118,
122
],
[
117,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
124,
127
],
[
123,
128
],
[
128,
129
],
[
129,
130
],
[
128,
131
],
[
131,
132
],
[
132,
133
],
[
131,
134
],
[
134,
135
],
[
134,
136
],
[
123,
137
],
[
137,
138
],
[
137,
139
],
[
117,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
144,
148
],
[
140,
149
],
[
149,
150
],
[
150,
151
],
[
150,
152
],
[
149,
153
],
[
140,
154
],
[
154,
155
],
[
20,
156
],
[
156,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
156,
161
],
[
161,
162
],
[
161,
163
],
[
156,
164
],
[
164,
165
],
[
165,
166
],
[
156,
167
],
[
168,
168
],
[
168,
169
],
[
169,
170
],
[
170,
171
],
[
171,
172
],
[
171,
173
],
[
169,
174
],
[
175,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
175,
180
],
[
180,
181
],
[
180,
182
],
[
18,
183
],
[
183,
184
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\nclass Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] str = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(str[0]);\n\n\t\tint q = Integer.parseInt(str[1]);\n\n\t\tDeque<String> dq = new ArrayDeque<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}\n\n\t\tint[] total_time = new int[n];\n\t\tString[] name = new String[n];\n\n\t\tint a = 0;\n\t\tint p = 0;\n\t\twhile (!(dq.isEmpty())) {\n\n\t\t\tString Now_name = dq.pollFirst();\n\n\t\t\tint now_time = Integer.parseInt(dq.pollFirst());\n\t\t\t/*\n\t\t\t * System.out.println(Now_name+\" \"+now_time);\n\t\t\t */\n\t\t\tif (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\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.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"class Main {\n\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] str = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(str[0]);\n\n\t\tint q = Integer.parseInt(str[1]);\n\n\t\tDeque<String> dq = new ArrayDeque<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}\n\n\t\tint[] total_time = new int[n];\n\t\tString[] name = new String[n];\n\n\t\tint a = 0;\n\t\tint p = 0;\n\t\twhile (!(dq.isEmpty())) {\n\n\t\t\tString Now_name = dq.pollFirst();\n\n\t\t\tint now_time = Integer.parseInt(dq.pollFirst());\n\t\t\t/*\n\t\t\t * System.out.println(Now_name+\" \"+now_time);\n\t\t\t */\n\t\t\tif (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\n\t\t}\n\t}\n}",
"Main",
"public static void main(String[] args) throws IOException {\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] str = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(str[0]);\n\n\t\tint q = Integer.parseInt(str[1]);\n\n\t\tDeque<String> dq = new ArrayDeque<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}\n\n\t\tint[] total_time = new int[n];\n\t\tString[] name = new String[n];\n\n\t\tint a = 0;\n\t\tint p = 0;\n\t\twhile (!(dq.isEmpty())) {\n\n\t\t\tString Now_name = dq.pollFirst();\n\n\t\t\tint now_time = Integer.parseInt(dq.pollFirst());\n\t\t\t/*\n\t\t\t * System.out.println(Now_name+\" \"+now_time);\n\t\t\t */\n\t\t\tif (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\n\t\t}\n\t}",
"main",
"{\n\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n\t\tString[] str = br.readLine().split(\" \");\n\n\t\tint n = Integer.parseInt(str[0]);\n\n\t\tint q = Integer.parseInt(str[1]);\n\n\t\tDeque<String> dq = new ArrayDeque<>();\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}\n\n\t\tint[] total_time = new int[n];\n\t\tString[] name = new String[n];\n\n\t\tint a = 0;\n\t\tint p = 0;\n\t\twhile (!(dq.isEmpty())) {\n\n\t\t\tString Now_name = dq.pollFirst();\n\n\t\t\tint now_time = Integer.parseInt(dq.pollFirst());\n\t\t\t/*\n\t\t\t * System.out.println(Now_name+\" \"+now_time);\n\t\t\t */\n\t\t\tif (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t}\n\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] str = br.readLine().split(\" \");",
"str",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"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",
"Deque<String> dq = new ArrayDeque<>();",
"dq",
"new ArrayDeque<>()",
"for (int i = 0; i < n; i++) {\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}",
"{\n\t\t\tString[] name_time = br.readLine().split(\" \");\n\n\t\t\tdq.offerLast(name_time[0]);\n\t\t\tdq.offerLast(name_time[1]);\n\n\t\t}",
"String[] name_time = br.readLine().split(\" \");",
"name_time",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"dq.offerLast(name_time[0])",
"dq.offerLast",
"dq",
"name_time[0]",
"name_time",
"0",
"dq.offerLast(name_time[1])",
"dq.offerLast",
"dq",
"name_time[1]",
"name_time",
"1",
"int[] total_time = new int[n];",
"total_time",
"new int[n]",
"n",
"String[] name = new String[n];",
"name",
"new String[n]",
"n",
"int a = 0;",
"a",
"0",
"int p = 0;",
"p",
"0",
"while (!(dq.isEmpty())) {\n\n\t\t\tString Now_name = dq.pollFirst();\n\n\t\t\tint now_time = Integer.parseInt(dq.pollFirst());\n\t\t\t/*\n\t\t\t * System.out.println(Now_name+\" \"+now_time);\n\t\t\t */\n\t\t\tif (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t}",
"!(dq.isEmpty())",
"(dq.isEmpty())",
"dq.isEmpty",
"dq",
"{\n\n\t\t\tString Now_name = dq.pollFirst();\n\n\t\t\tint now_time = Integer.parseInt(dq.pollFirst());\n\t\t\t/*\n\t\t\t * System.out.println(Now_name+\" \"+now_time);\n\t\t\t */\n\t\t\tif (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t}",
"String Now_name = dq.pollFirst();",
"Now_name",
"dq.pollFirst()",
"dq.pollFirst",
"dq",
"int now_time = Integer.parseInt(dq.pollFirst());",
"now_time",
"Integer.parseInt(dq.pollFirst())",
"Integer.parseInt",
"Integer",
"dq.pollFirst()",
"dq.pollFirst",
"dq",
"if (now_time - q > 0) {\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t} else {\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}",
"now_time - q > 0",
"now_time - q",
"now_time",
"q",
"0",
"{\n\t\t\t\tdq.offerLast(Now_name);\n\t\t\t\tdq.offerLast(String.valueOf(now_time - q));\n\n\t\t\t\ta += q;\n\t\t\t}",
"dq.offerLast(Now_name)",
"dq.offerLast",
"dq",
"Now_name",
"dq.offerLast(String.valueOf(now_time - q))",
"dq.offerLast",
"dq",
"String.valueOf(now_time - q)",
"String.valueOf",
"String",
"now_time - q",
"now_time",
"q",
"a += q",
"a",
"q",
"{\n\t\t\t\ta += now_time;\n\t\t\t\ttotal_time[p] = a;\n\t\t\t\tname[p] = Now_name;\n\n\t\t\t\tp++;\n\t\t\t}",
"a += now_time",
"a",
"now_time",
"total_time[p] = a",
"total_time[p]",
"total_time",
"p",
"a",
"name[p] = Now_name",
"name[p]",
"name",
"p",
"Now_name",
"p++",
"p",
"for (int i = 0; i < n; i++) {\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\n\t\t}",
"{\n\t\t\tSystem.out.println(name[i] + \" \" + total_time[i]);\n\t\t}",
"System.out.println(name[i] + \" \" + total_time[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"name[i] + \" \" + total_time[i]",
"name[i] + \" \" + total_time[i]",
"name[i]",
"name",
"i",
"\" \"",
"total_time[i]",
"total_time",
"i",
"String[] args",
"args"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] str = br.readLine().split(" ");
int n = Integer.parseInt(str[0]);
int q = Integer.parseInt(str[1]);
Deque<String> dq = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
String[] name_time = br.readLine().split(" ");
dq.offerLast(name_time[0]);
dq.offerLast(name_time[1]);
}
int[] total_time = new int[n];
String[] name = new String[n];
int a = 0;
int p = 0;
while (!(dq.isEmpty())) {
String Now_name = dq.pollFirst();
int now_time = Integer.parseInt(dq.pollFirst());
/*
* System.out.println(Now_name+" "+now_time);
*/
if (now_time - q > 0) {
dq.offerLast(Now_name);
dq.offerLast(String.valueOf(now_time - q));
a += q;
} else {
a += now_time;
total_time[p] = a;
name[p] = Now_name;
p++;
}
}
for (int i = 0; i < n; i++) {
System.out.println(name[i] + " " + total_time[i]);
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
14,
40,
4,
18,
13,
20,
30,
4,
18,
18,
13,
13,
17,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
14,
4,
18,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
14,
4,
18,
13,
30,
3,
30,
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,
14,
2,
13,
13,
30,
0,
13,
13,
29,
13,
30,
0,
13,
13,
0,
13,
17,
29,
13,
23,
13,
12,
13,
30,
29,
2,
13,
17,
6,
13,
41,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
13,
20,
13,
0,
13,
17,
0,
13,
17,
0,
13,
17,
23,
13,
12,
13,
30,
14,
4,
13,
30,
29,
17,
0,
18,
13,
40,
13,
13,
40,
13,
14,
2,
13,
18,
13,
13,
30,
0,
13,
17,
29,
17,
23,
13,
12,
13,
30,
41,
13,
17,
14,
40,
4,
13,
30,
0,
13,
18,
13,
40,
13,
40,
13,
14,
2,
13,
18,
13,
13,
30,
0,
13,
17,
29,
13,
12,
13,
30,
29,
2,
13,
17,
12,
13,
30,
29,
2,
13,
18,
13,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
290,
8
],
[
290,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
],
[
17,
22
],
[
11,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
25,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
33,
34
],
[
34,
35
],
[
33,
36
],
[
36,
37
],
[
36,
38
],
[
11,
39
],
[
39,
40
],
[
39,
41
],
[
11,
42
],
[
42,
43
],
[
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
],
[
65,
66
],
[
66,
67
],
[
65,
68
],
[
63,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
72,
74
],
[
70,
75
],
[
11,
76
],
[
76,
77
],
[
76,
78
],
[
11,
79
],
[
79,
80
],
[
80,
81
],
[
81,
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
],
[
92,
95
],
[
84,
96
],
[
96,
97
],
[
97,
98
],
[
98,
99
],
[
96,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
101,
106
],
[
107,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
107,
111
],
[
107,
112
],
[
100,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
113,
117
],
[
117,
118
],
[
96,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
9,
124
],
[
124,
125
],
[
290,
126
],
[
126,
127
],
[
126,
128
],
[
128,
129
],
[
126,
130
],
[
130,
131
],
[
126,
132
],
[
132,
133
],
[
132,
134
],
[
134,
135
],
[
135,
136
],
[
136,
137
],
[
136,
138
],
[
135,
139
],
[
134,
140
],
[
140,
141
],
[
141,
142
],
[
141,
143
],
[
140,
144
],
[
132,
145
],
[
145,
146
],
[
132,
147
],
[
147,
148
],
[
126,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
156,
157
],
[
157,
158
],
[
157,
159
],
[
156,
160
],
[
160,
161
],
[
152,
162
],
[
162,
163
],
[
163,
164
],
[
163,
165
],
[
162,
166
],
[
166,
167
],
[
166,
168
],
[
162,
169
],
[
169,
170
],
[
149,
171
],
[
171,
172
],
[
126,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
290,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
180,
184
],
[
184,
185
],
[
184,
186
],
[
180,
187
],
[
187,
188
],
[
187,
189
],
[
180,
190
],
[
190,
191
],
[
190,
192
],
[
180,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
195,
200
],
[
200,
201
],
[
200,
202
],
[
195,
203
],
[
203,
204
],
[
203,
205
],
[
195,
206
],
[
206,
207
],
[
206,
208
],
[
193,
209
],
[
209,
210
],
[
180,
211
],
[
211,
212
],
[
211,
213
],
[
213,
214
],
[
214,
215
],
[
215,
216
],
[
214,
217
],
[
217,
218
],
[
218,
219
],
[
213,
220
],
[
220,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
220,
225
],
[
213,
226
],
[
226,
227
],
[
213,
228
],
[
228,
229
],
[
229,
230
],
[
229,
231
],
[
231,
232
],
[
231,
233
],
[
228,
234
],
[
234,
235
],
[
235,
236
],
[
235,
237
],
[
213,
238
],
[
238,
239
],
[
211,
240
],
[
240,
241
],
[
180,
242
],
[
242,
243
],
[
242,
244
],
[
244,
245
],
[
245,
246
],
[
245,
247
],
[
244,
248
],
[
248,
249
],
[
249,
250
],
[
250,
251
],
[
248,
252
],
[
252,
253
],
[
253,
254
],
[
253,
255
],
[
255,
256
],
[
255,
257
],
[
257,
258
],
[
252,
259
],
[
259,
260
],
[
252,
261
],
[
261,
262
],
[
262,
263
],
[
262,
264
],
[
264,
265
],
[
264,
266
],
[
261,
267
],
[
267,
268
],
[
268,
269
],
[
268,
270
],
[
244,
271
],
[
271,
272
],
[
180,
273
],
[
273,
274
],
[
273,
275
],
[
275,
276
],
[
276,
277
],
[
277,
278
],
[
277,
279
],
[
180,
280
],
[
280,
281
],
[
280,
282
],
[
282,
283
],
[
283,
284
],
[
284,
285
],
[
284,
286
],
[
286,
287
],
[
286,
288
],
[
0,
289
],
[
289,
290
],
[
289,
291
]
] | [
"\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\n\npublic class Main {\n static class Proc {\n public String name;\n public int time;\n\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int quantum) {\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }\n\n public boolean isFinished() {\n return time == 0;\n }\n }\n\n static class Queue {\n Proc[] elements;\n int head = 0;\n int tail = 0;\n int count = 0;\n \n public Queue(int max) {\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }\n\n public boolean enqueue(Proc t) {\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }\n \n public Proc dequeue() {\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }\n\n public boolean isEmpty() {\n return count == 0;\n }\n \n public boolean isFull() {\n return count == elements.length;\n }\n }\n\n public static void main(String[] args) throws Exception {\n BufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n String[] nAndq = r.readLine().split(\" \");\n int n = Integer.parseInt(nAndq[0]);\n int q = Integer.parseInt(nAndq[1]);\n Queue queue = new Queue(n);\n \n for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }\n\n int clock = 0;\n while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }\n }\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"public class Main {\n static class Proc {\n public String name;\n public int time;\n\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int quantum) {\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }\n\n public boolean isFinished() {\n return time == 0;\n }\n }\n\n static class Queue {\n Proc[] elements;\n int head = 0;\n int tail = 0;\n int count = 0;\n \n public Queue(int max) {\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }\n\n public boolean enqueue(Proc t) {\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }\n \n public Proc dequeue() {\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }\n\n public boolean isEmpty() {\n return count == 0;\n }\n \n public boolean isFull() {\n return count == elements.length;\n }\n }\n\n public static void main(String[] args) throws Exception {\n BufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n String[] nAndq = r.readLine().split(\" \");\n int n = Integer.parseInt(nAndq[0]);\n int q = Integer.parseInt(nAndq[1]);\n Queue queue = new Queue(n);\n \n for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }\n\n int clock = 0;\n while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }\n }\n}",
"Main",
"public static void main(String[] args) throws Exception {\n BufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n String[] nAndq = r.readLine().split(\" \");\n int n = Integer.parseInt(nAndq[0]);\n int q = Integer.parseInt(nAndq[1]);\n Queue queue = new Queue(n);\n \n for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }\n\n int clock = 0;\n while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }\n }",
"main",
"{\n BufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n String[] nAndq = r.readLine().split(\" \");\n int n = Integer.parseInt(nAndq[0]);\n int q = Integer.parseInt(nAndq[1]);\n Queue queue = new Queue(n);\n \n for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }\n\n int clock = 0;\n while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }\n }",
"BufferedReader r = new BufferedReader(new InputStreamReader(System.in));",
"r",
"new BufferedReader(new InputStreamReader(System.in))",
"String[] nAndq = r.readLine().split(\" \");",
"nAndq",
"r.readLine().split(\" \")",
"r.readLine().split",
"r.readLine()",
"r.readLine",
"r",
"\" \"",
"int n = Integer.parseInt(nAndq[0]);",
"n",
"Integer.parseInt(nAndq[0])",
"Integer.parseInt",
"Integer",
"nAndq[0]",
"nAndq",
"0",
"int q = Integer.parseInt(nAndq[1]);",
"q",
"Integer.parseInt(nAndq[1])",
"Integer.parseInt",
"Integer",
"nAndq[1]",
"nAndq",
"1",
"Queue queue = new Queue(n);",
"queue",
"new Queue(n)",
"for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }",
"{\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }",
"String[] elems = r.readLine().split(\" \");",
"elems",
"r.readLine().split(\" \")",
"r.readLine().split",
"r.readLine()",
"r.readLine",
"r",
"\" \"",
"if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }",
"!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))",
"queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))",
"queue.enqueue",
"queue",
"new Proc(elems[0], Integer.parseInt(elems[1]))",
"{\n System.err.println(\"Failed enqueue.\");\n }",
"System.err.println(\"Failed enqueue.\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"Failed enqueue.\"",
"int clock = 0;",
"clock",
"0",
"while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }",
"!queue.isEmpty()",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }",
"Proc p = queue.dequeue();",
"p",
"queue.dequeue()",
"queue.dequeue",
"queue",
"clock += p.run(q)",
"clock",
"p.run(q)",
"p.run",
"p",
"q",
"if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }",
"p.isFinished()",
"p.isFinished",
"p",
"{\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n }",
"System.out.println(p.name + \" \" + clock)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + clock",
"p.name + \" \" + clock",
"p.name",
"p",
"p.name",
"\" \"",
"clock",
"if (queue.isEmpty()) {\n break;\n }",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n break;\n }",
"break;",
"{\n queue.enqueue(p);\n }",
"queue.enqueue(p)",
"queue.enqueue",
"queue",
"p",
"String[] args",
"args",
"static class Proc {\n public String name;\n public int time;\n\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int quantum) {\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }\n\n public boolean isFinished() {\n return time == 0;\n }\n }",
"Proc",
"public String name;",
"name",
"public int time;",
"time",
"public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }",
"Proc",
"{\n this.name = name;\n this.time = time;\n }",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public int run(int quantum) {\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }",
"run",
"{\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }",
"if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }",
"time > quantum",
"time",
"quantum",
"{\n time -= quantum;\n return quantum;\n }",
"time -= quantum",
"time",
"quantum",
"return quantum;",
"quantum",
"{\n quantum = time;\n time = 0;\n return quantum;\n }",
"quantum = time",
"quantum",
"time",
"time = 0",
"time",
"0",
"return quantum;",
"quantum",
"int quantum",
"quantum",
"public boolean isFinished() {\n return time == 0;\n }",
"isFinished",
"{\n return time == 0;\n }",
"return time == 0;",
"time == 0",
"time",
"0",
"static class Queue {\n Proc[] elements;\n int head = 0;\n int tail = 0;\n int count = 0;\n \n public Queue(int max) {\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }\n\n public boolean enqueue(Proc t) {\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }\n \n public Proc dequeue() {\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }\n\n public boolean isEmpty() {\n return count == 0;\n }\n \n public boolean isFull() {\n return count == elements.length;\n }\n }",
"Queue",
"Proc[] elements;",
"elements",
"int head = 0;",
"head",
"0",
"int tail = 0;",
"tail",
"0",
"int count = 0;",
"count",
"0",
"public Queue(int max) {\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }",
"Queue",
"{\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }",
"elements = new Proc[max]",
"elements",
"new Proc[max]",
"max",
"head = 0",
"head",
"0",
"tail = 0",
"tail",
"0",
"count = 0",
"count",
"0",
"int max",
"max",
"public boolean enqueue(Proc t) {\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }",
"enqueue",
"{\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }",
"if (isFull()) {\n return false;\n }",
"isFull()",
"isFull",
"{\n return false;\n }",
"return false;",
"false",
"elements[head++] = t",
"elements[head++]",
"elements",
"head++",
"head",
"t",
"count++",
"count",
"if (head >= elements.length) {\n head = 0;\n }",
"head >= elements.length",
"head",
"elements.length",
"elements",
"elements.length",
"{\n head = 0;\n }",
"head = 0",
"head",
"0",
"return true;",
"true",
"Proc t",
"t",
"public Proc dequeue() {\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }",
"dequeue",
"{\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }",
"Proc elem = null;",
"elem",
"null",
"if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }",
"!isEmpty()",
"isEmpty()",
"isEmpty",
"{\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }",
"elem = elements[tail++]",
"elem",
"elements[tail++]",
"elements",
"tail++",
"tail",
"count--",
"count",
"if (tail >= elements.length) {\n tail = 0;\n }",
"tail >= elements.length",
"tail",
"elements.length",
"elements",
"elements.length",
"{\n tail = 0;\n }",
"tail = 0",
"tail",
"0",
"return elem;",
"elem",
"public boolean isEmpty() {\n return count == 0;\n }",
"isEmpty",
"{\n return count == 0;\n }",
"return count == 0;",
"count == 0",
"count",
"0",
"public boolean isFull() {\n return count == elements.length;\n }",
"isFull",
"{\n return count == elements.length;\n }",
"return count == elements.length;",
"count == elements.length",
"count",
"elements.length",
"elements",
"elements.length",
"public class Main {\n static class Proc {\n public String name;\n public int time;\n\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int quantum) {\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }\n\n public boolean isFinished() {\n return time == 0;\n }\n }\n\n static class Queue {\n Proc[] elements;\n int head = 0;\n int tail = 0;\n int count = 0;\n \n public Queue(int max) {\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }\n\n public boolean enqueue(Proc t) {\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }\n \n public Proc dequeue() {\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }\n\n public boolean isEmpty() {\n return count == 0;\n }\n \n public boolean isFull() {\n return count == elements.length;\n }\n }\n\n public static void main(String[] args) throws Exception {\n BufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n String[] nAndq = r.readLine().split(\" \");\n int n = Integer.parseInt(nAndq[0]);\n int q = Integer.parseInt(nAndq[1]);\n Queue queue = new Queue(n);\n \n for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }\n\n int clock = 0;\n while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }\n }\n}",
"public class Main {\n static class Proc {\n public String name;\n public int time;\n\n public Proc(String name, int time) {\n this.name = name;\n this.time = time;\n }\n\n public int run(int quantum) {\n if (time > quantum) {\n time -= quantum;\n return quantum;\n } else {\n quantum = time;\n time = 0;\n return quantum;\n }\n }\n\n public boolean isFinished() {\n return time == 0;\n }\n }\n\n static class Queue {\n Proc[] elements;\n int head = 0;\n int tail = 0;\n int count = 0;\n \n public Queue(int max) {\n elements = new Proc[max];\n head = 0;\n tail = 0;\n count = 0;\n }\n\n public boolean enqueue(Proc t) {\n if (isFull()) {\n return false;\n }\n elements[head++] = t;\n count++;\n if (head >= elements.length) {\n head = 0;\n }\n return true;\n }\n \n public Proc dequeue() {\n Proc elem = null;\n if (!isEmpty()) {\n elem = elements[tail++];\n count--;\n if (tail >= elements.length) {\n tail = 0;\n }\n }\n\n return elem;\n }\n\n public boolean isEmpty() {\n return count == 0;\n }\n \n public boolean isFull() {\n return count == elements.length;\n }\n }\n\n public static void main(String[] args) throws Exception {\n BufferedReader r = new BufferedReader(new InputStreamReader(System.in));\n String[] nAndq = r.readLine().split(\" \");\n int n = Integer.parseInt(nAndq[0]);\n int q = Integer.parseInt(nAndq[1]);\n Queue queue = new Queue(n);\n \n for (int i = 0;i < n;i++) {\n String[] elems = r.readLine().split(\" \");\n if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {\n System.err.println(\"Failed enqueue.\");\n }\n }\n\n int clock = 0;\n while (!queue.isEmpty()) {\n Proc p = queue.dequeue();\n clock += p.run(q);\n if (p.isFinished()) {\n System.out.println(p.name + \" \" + clock);\n if (queue.isEmpty()) {\n break;\n }\n } else {\n queue.enqueue(p);\n }\n }\n }\n}",
"Main"
] |
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
static class Proc {
public String name;
public int time;
public Proc(String name, int time) {
this.name = name;
this.time = time;
}
public int run(int quantum) {
if (time > quantum) {
time -= quantum;
return quantum;
} else {
quantum = time;
time = 0;
return quantum;
}
}
public boolean isFinished() {
return time == 0;
}
}
static class Queue {
Proc[] elements;
int head = 0;
int tail = 0;
int count = 0;
public Queue(int max) {
elements = new Proc[max];
head = 0;
tail = 0;
count = 0;
}
public boolean enqueue(Proc t) {
if (isFull()) {
return false;
}
elements[head++] = t;
count++;
if (head >= elements.length) {
head = 0;
}
return true;
}
public Proc dequeue() {
Proc elem = null;
if (!isEmpty()) {
elem = elements[tail++];
count--;
if (tail >= elements.length) {
tail = 0;
}
}
return elem;
}
public boolean isEmpty() {
return count == 0;
}
public boolean isFull() {
return count == elements.length;
}
}
public static void main(String[] args) throws Exception {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
String[] nAndq = r.readLine().split(" ");
int n = Integer.parseInt(nAndq[0]);
int q = Integer.parseInt(nAndq[1]);
Queue queue = new Queue(n);
for (int i = 0;i < n;i++) {
String[] elems = r.readLine().split(" ");
if (!queue.enqueue(new Proc(elems[0], Integer.parseInt(elems[1])))) {
System.err.println("Failed enqueue.");
}
}
int clock = 0;
while (!queue.isEmpty()) {
Proc p = queue.dequeue();
clock += p.run(q);
if (p.isFinished()) {
System.out.println(p.name + " " + clock);
if (queue.isEmpty()) {
break;
}
} else {
queue.enqueue(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,
4,
18,
13,
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,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
4,
18,
13,
17,
4,
18,
18,
13,
13,
13,
30,
4,
18,
13,
2,
13,
13,
4,
18,
13,
4,
18,
13,
0,
13,
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
],
[
140,
11
],
[
140,
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
],
[
30,
31
],
[
31,
32
],
[
14,
33
],
[
33,
34
],
[
33,
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
],
[
59,
60
],
[
60,
61
],
[
59,
62
],
[
51,
63
],
[
63,
64
],
[
64,
65
],
[
63,
66
],
[
66,
67
],
[
66,
68
],
[
51,
69
],
[
69,
70
],
[
70,
71
],
[
69,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
75,
76
],
[
75,
77
],
[
14,
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
],
[
96,
97
],
[
96,
98
],
[
95,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
108,
112
],
[
99,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
115,
117
],
[
113,
118
],
[
95,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
120,
123
],
[
123,
124
],
[
123,
125
],
[
119,
126
],
[
126,
127
],
[
127,
128
],
[
126,
129
],
[
129,
130
],
[
130,
131
],
[
119,
132
],
[
132,
133
],
[
132,
134
],
[
89,
135
],
[
135,
136
],
[
12,
137
],
[
137,
138
],
[
0,
139
],
[
139,
140
],
[
139,
141
]
] | [
"\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\t// TODO Auto-generated method stub\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tint n=scan.nextInt();\n\t\tint tm=scan.nextInt();\n\t\tString stmp=scan.nextLine();\n\t\tQueue<Integer> q=new LinkedList<>();\n\t\tQueue<String> qstr=new LinkedList<>();\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}\n\t\tint round=0;\n\t\tint sum=0;\n\t\twhile(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\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\t// TODO Auto-generated method stub\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tint n=scan.nextInt();\n\t\tint tm=scan.nextInt();\n\t\tString stmp=scan.nextLine();\n\t\tQueue<Integer> q=new LinkedList<>();\n\t\tQueue<String> qstr=new LinkedList<>();\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}\n\t\tint round=0;\n\t\tint sum=0;\n\t\twhile(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tint n=scan.nextInt();\n\t\tint tm=scan.nextInt();\n\t\tString stmp=scan.nextLine();\n\t\tQueue<Integer> q=new LinkedList<>();\n\t\tQueue<String> qstr=new LinkedList<>();\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}\n\t\tint round=0;\n\t\tint sum=0;\n\t\twhile(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\n\t\t}\n\t}",
"main",
"{\n\t\t// TODO Auto-generated method stub\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tint n=scan.nextInt();\n\t\tint tm=scan.nextInt();\n\t\tString stmp=scan.nextLine();\n\t\tQueue<Integer> q=new LinkedList<>();\n\t\tQueue<String> qstr=new LinkedList<>();\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}\n\t\tint round=0;\n\t\tint sum=0;\n\t\twhile(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\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 tm=scan.nextInt();",
"tm",
"scan.nextInt()",
"scan.nextInt",
"scan",
"String stmp=scan.nextLine();",
"stmp",
"scan.nextLine()",
"scan.nextLine",
"scan",
"Queue<Integer> q=new LinkedList<>();",
"q",
"new LinkedList<>()",
"Queue<String> qstr=new LinkedList<>();",
"qstr",
"new LinkedList<>()",
"for(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(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\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}",
"{\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}",
"String string=scan.nextLine();",
"string",
"scan.nextLine()",
"scan.nextLine",
"scan",
"String[] str=string.split(\" \");",
"str",
"string.split(\" \")",
"string.split",
"string",
"\" \"",
"qstr.offer(str[0])",
"qstr.offer",
"qstr",
"str[0]",
"str",
"0",
"q.offer(Integer.parseInt(str[1]))",
"q.offer",
"q",
"Integer.parseInt(str[1])",
"Integer.parseInt",
"Integer",
"str[1]",
"str",
"1",
"int round=0;",
"round",
"0",
"int sum=0;",
"sum",
"0",
"while(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\n\t\t}",
"!q.isEmpty()",
"q.isEmpty()",
"q.isEmpty",
"q",
"{\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\n\t\t}",
"int tmp=q.poll();",
"tmp",
"q.poll()",
"q.poll",
"q",
"if(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}",
"tmp<=tm",
"tmp",
"tm",
"{\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}",
"sum+=tmp",
"sum",
"tmp",
"System.out.print(qstr.poll()+\" \")",
"System.out.print",
"System.out",
"System",
"System.out",
"qstr.poll()+\" \"",
"qstr.poll()",
"qstr.poll",
"qstr",
"\" \"",
"System.out.println(sum)",
"System.out.println",
"System.out",
"System",
"System.out",
"sum",
"{\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}",
"q.offer(tmp-tm)",
"q.offer",
"q",
"tmp-tm",
"tmp",
"tm",
"qstr.offer(qstr.poll())",
"qstr.offer",
"qstr",
"qstr.poll()",
"qstr.poll",
"qstr",
"sum+=tm",
"sum",
"tm",
"round++",
"round",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tint n=scan.nextInt();\n\t\tint tm=scan.nextInt();\n\t\tString stmp=scan.nextLine();\n\t\tQueue<Integer> q=new LinkedList<>();\n\t\tQueue<String> qstr=new LinkedList<>();\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}\n\t\tint round=0;\n\t\tint sum=0;\n\t\twhile(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t// TODO Auto-generated method stub\n\n\t\tScanner scan=new Scanner(System.in);\n\t\tint n=scan.nextInt();\n\t\tint tm=scan.nextInt();\n\t\tString stmp=scan.nextLine();\n\t\tQueue<Integer> q=new LinkedList<>();\n\t\tQueue<String> qstr=new LinkedList<>();\n\t\t\n\t\tfor(int i=0;i<n;i++){\n\t\t\tString string=scan.nextLine();\n\t\t\tString[] str=string.split(\" \");\n\t\t\tqstr.offer(str[0]);\n\t\t\tq.offer(Integer.parseInt(str[1]));\n\t\t}\n\t\tint round=0;\n\t\tint sum=0;\n\t\twhile(!q.isEmpty()){\n\t\t\tint tmp=q.poll();\n\t\t\tif(tmp<=tm){\n\t\t\t\tsum+=tmp;\n\t\t\t\tSystem.out.print(qstr.poll()+\" \");\n\t\t\t\t//System.out.println(round*tm+tmp%tm-com);\n\t\t\t\tSystem.out.println(sum);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tq.offer(tmp-tm);\n\t\t\t\tqstr.offer(qstr.poll());\n\t\t\t\tsum+=tm;\n\t\t\t}\n\t\t\tround++;\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) {
// TODO Auto-generated method stub
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
int tm=scan.nextInt();
String stmp=scan.nextLine();
Queue<Integer> q=new LinkedList<>();
Queue<String> qstr=new LinkedList<>();
for(int i=0;i<n;i++){
String string=scan.nextLine();
String[] str=string.split(" ");
qstr.offer(str[0]);
q.offer(Integer.parseInt(str[1]));
}
int round=0;
int sum=0;
while(!q.isEmpty()){
int tmp=q.poll();
if(tmp<=tm){
sum+=tmp;
System.out.print(qstr.poll()+" ");
//System.out.println(round*tm+tmp%tm-com);
System.out.println(sum);
}
else {
q.offer(tmp-tm);
qstr.offer(qstr.poll());
sum+=tm;
}
round++;
}
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
17,
41,
13,
17,
41,
13,
20,
38,
5,
13,
30,
30,
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,
38,
5,
13,
30,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
4,
18,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
17,
42,
2,
4,
18,
13,
17,
30,
0,
13,
2,
13,
4,
18,
13,
41,
13,
18,
4,
18,
13,
13,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
4,
18,
13,
13,
13,
17,
13,
4,
18,
13,
13,
40,
13,
30,
0,
13,
13,
0,
18,
4,
18,
13,
13,
13,
13,
40,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
164,
5
],
[
164,
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
],
[
19,
20
],
[
19,
21
],
[
18,
22
],
[
22,
23
],
[
23,
24
],
[
23,
25
],
[
25,
26
],
[
26,
27
],
[
22,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
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
],
[
54,
56
],
[
56,
57
],
[
57,
58
],
[
53,
59
],
[
59,
60
],
[
59,
61
],
[
61,
62
],
[
62,
63
],
[
53,
64
],
[
64,
65
],
[
65,
66
],
[
64,
67
],
[
8,
68
],
[
68,
69
],
[
68,
70
],
[
8,
71
],
[
71,
72
],
[
71,
73
],
[
8,
74
],
[
74,
75
],
[
74,
76
],
[
8,
77
],
[
77,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
78,
82
],
[
77,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
89,
90
],
[
83,
91
],
[
91,
92
],
[
91,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
94,
97
],
[
93,
98
],
[
83,
99
],
[
99,
100
],
[
100,
101
],
[
100,
102
],
[
99,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
113,
113
],
[
113,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
115,
118
],
[
114,
119
],
[
113,
120
],
[
113,
121
],
[
103,
122
],
[
122,
123
],
[
123,
124
],
[
122,
125
],
[
103,
126
],
[
126,
127
],
[
99,
128
],
[
128,
129
],
[
129,
130
],
[
129,
131
],
[
128,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
134,
137
],
[
133,
138
],
[
132,
139
],
[
83,
140
],
[
140,
141
],
[
6,
142
],
[
142,
143
],
[
0,
144
],
[
144,
145
],
[
144,
146
],
[
146,
147
],
[
144,
148
],
[
148,
149
],
[
144,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
153,
155
],
[
152,
156
],
[
156,
157
],
[
156,
158
],
[
150,
159
],
[
159,
160
],
[
150,
161
],
[
161,
162
],
[
0,
163
],
[
163,
164
],
[
163,
165
]
] | [
"import java.util.*;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tint n = 0, q = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\ttry {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}\n\t\tArrayList<Queue> qu = new ArrayList<Queue>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\n\t\tint i = 0, count = 0, alltime = 0;\n\t\twhile (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t}\n}\n\n\nclass Queue {\n\tString name;\n\tint time;\n\n\tpublic Queue(String n, int t) {\n\t\tname = n;\n\t\ttime = t;\n\t}\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tint n = 0, q = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\ttry {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}\n\t\tArrayList<Queue> qu = new ArrayList<Queue>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\n\t\tint i = 0, count = 0, alltime = 0;\n\t\twhile (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tint n = 0, q = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\ttry {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}\n\t\tArrayList<Queue> qu = new ArrayList<Queue>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\n\t\tint i = 0, count = 0, alltime = 0;\n\t\twhile (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t}",
"main",
"{\n\t\tint n = 0, q = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\ttry {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}\n\t\tArrayList<Queue> qu = new ArrayList<Queue>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\n\t\tint i = 0, count = 0, alltime = 0;\n\t\twhile (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t}",
"int n = 0",
"n",
"0",
"q = 0;",
"q",
"0",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"try {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}",
"catch (Exception e) {\n\t\t}",
"Exception e",
"{\n\t\t}",
"{\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t}",
"n = scanner.nextInt()",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"q = scanner.nextInt()",
"q",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"ArrayList<Queue> qu = new ArrayList<Queue>();",
"qu",
"new ArrayList<Queue>()",
"for (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}",
"{\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}",
"try {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}",
"catch (Exception e) {\n\t\t\t}",
"Exception e",
"{\n\t\t\t}",
"{\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t}",
"String name = scanner.next();",
"name",
"scanner.next()",
"scanner.next",
"scanner",
"int time = scanner.nextInt();",
"time",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"qu.add(new Queue(name, time))",
"qu.add",
"qu",
"new Queue(name, time)",
"int i = 0",
"i",
"0",
"count = 0",
"count",
"0",
"alltime = 0;",
"alltime",
"0",
"while (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}",
"qu.size() > 0",
"qu.size()",
"qu.size",
"qu",
"0",
"{\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}",
"i = i % qu.size()",
"i",
"i % qu.size()",
"i",
"qu.size()",
"qu.size",
"qu",
"int t = qu.get(i).time;",
"t",
"qu.get(i).time",
"qu.get(i)",
"qu.get",
"qu",
"i",
"qu.get(i).time",
"if (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}",
"t <= q",
"t",
"q",
"{\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t}",
"alltime += t",
"alltime",
"t",
"System.out.println(qu.get(i).name + \" \" + alltime)",
"System.out.println",
"System.out",
"System",
"System.out",
"qu.get(i).name + \" \" + alltime",
"qu.get(i).name + \" \" + alltime",
"qu.get(i).name",
"qu.get(i)",
"qu.get",
"qu",
"i",
"qu.get(i).name",
"\" \"",
"alltime",
"qu.remove(i)",
"qu.remove",
"qu",
"i",
"i--",
"i",
"{\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}",
"alltime += q",
"alltime",
"q",
"qu.get(i).time -= q",
"qu.get(i).time",
"qu.get(i)",
"qu.get",
"qu",
"i",
"qu.get(i).time",
"q",
"i++",
"i",
"String[] args",
"args",
"class Queue {\n\tString name;\n\tint time;\n\n\tpublic Queue(String n, int t) {\n\t\tname = n;\n\t\ttime = t;\n\t}\n}",
"Queue",
"String name;",
"name",
"int time;",
"time",
"public Queue(String n, int t) {\n\t\tname = n;\n\t\ttime = t;\n\t}",
"Queue",
"{\n\t\tname = n;\n\t\ttime = t;\n\t}",
"name = n",
"name",
"n",
"time = t",
"time",
"t",
"String n",
"n",
"int t",
"t",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tint n = 0, q = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\ttry {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}\n\t\tArrayList<Queue> qu = new ArrayList<Queue>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\n\t\tint i = 0, count = 0, alltime = 0;\n\t\twhile (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t}\n}",
"public class Main {\n\tpublic static void main(String[] args) {\n\t\tint n = 0, q = 0;\n\t\tScanner scanner = new Scanner(System.in);\n\t\ttry {\n\t\t\tn = scanner.nextInt();\n\t\t\tq = scanner.nextInt();\n\t\t} catch (Exception e) {\n\t\t}\n\t\tArrayList<Queue> qu = new ArrayList<Queue>();\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\ttry {\n\t\t\t\tString name = scanner.next();\n\t\t\t\tint time = scanner.nextInt();\n\t\t\t\tqu.add(new Queue(name, time));\n\t\t\t} catch (Exception e) {\n\t\t\t}\n\t\t}\n\n\t\tint i = 0, count = 0, alltime = 0;\n\t\twhile (qu.size() > 0) {\n\t\t\ti = i % qu.size();\n\t\t\tint t = qu.get(i).time;\n\t\t\tif (t <= q) {\n\t\t\t\talltime += t;\n\t\t\t\tSystem.out.println(qu.get(i).name + \" \" + alltime);\n\t\t\t\tqu.remove(i);\n\t\t\t\ti--;\n\t\t\t} else {\n\t\t\t\talltime += q;\n\t\t\t\tqu.get(i).time -= q;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t}\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
int n = 0, q = 0;
Scanner scanner = new Scanner(System.in);
try {
n = scanner.nextInt();
q = scanner.nextInt();
} catch (Exception e) {
}
ArrayList<Queue> qu = new ArrayList<Queue>();
for (int i = 0; i < n; i++) {
try {
String name = scanner.next();
int time = scanner.nextInt();
qu.add(new Queue(name, time));
} catch (Exception e) {
}
}
int i = 0, count = 0, alltime = 0;
while (qu.size() > 0) {
i = i % qu.size();
int t = qu.get(i).time;
if (t <= q) {
alltime += t;
System.out.println(qu.get(i).name + " " + alltime);
qu.remove(i);
i--;
} else {
alltime += q;
qu.get(i).time -= q;
}
i++;
}
}
}
class Queue {
String name;
int time;
public Queue(String n, int t) {
name = n;
time = t;
}
} |
[
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 S=new Scanner(System.in);\n\tint i,n,m,t=0;\n\tQueue<String>P=new LinkedList<String>();\n\tQueue<Integer>T=new LinkedList<Integer>();\n\tn=S.nextInt();\n\tm=S.nextInt();\n\tfor(i=0;i<n;i++){\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}\n\twhile(0<P.size()){\n\t if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }\n\t}\n }\n}\n\t\n\t\t\t \n",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"class Main{\n public static void main(String[] args) throws IOException{\n\tScanner S=new Scanner(System.in);\n\tint i,n,m,t=0;\n\tQueue<String>P=new LinkedList<String>();\n\tQueue<Integer>T=new LinkedList<Integer>();\n\tn=S.nextInt();\n\tm=S.nextInt();\n\tfor(i=0;i<n;i++){\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}\n\twhile(0<P.size()){\n\t if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }\n\t}\n }\n}",
"Main",
"public static void main(String[] args) throws IOException{\n\tScanner S=new Scanner(System.in);\n\tint i,n,m,t=0;\n\tQueue<String>P=new LinkedList<String>();\n\tQueue<Integer>T=new LinkedList<Integer>();\n\tn=S.nextInt();\n\tm=S.nextInt();\n\tfor(i=0;i<n;i++){\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}\n\twhile(0<P.size()){\n\t if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }\n\t}\n }",
"main",
"{\n\tScanner S=new Scanner(System.in);\n\tint i,n,m,t=0;\n\tQueue<String>P=new LinkedList<String>();\n\tQueue<Integer>T=new LinkedList<Integer>();\n\tn=S.nextInt();\n\tm=S.nextInt();\n\tfor(i=0;i<n;i++){\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}\n\twhile(0<P.size()){\n\t if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }\n\t}\n }",
"Scanner S=new Scanner(System.in);",
"S",
"new Scanner(System.in)",
"int i",
"i",
"n",
"n",
"m",
"m",
"t=0;",
"t",
"0",
"Queue<String>P=new LinkedList<String>();",
"P",
"new LinkedList<String>()",
"Queue<Integer>T=new LinkedList<Integer>();",
"T",
"new LinkedList<Integer>()",
"n=S.nextInt()",
"n",
"S.nextInt()",
"S.nextInt",
"S",
"m=S.nextInt()",
"m",
"S.nextInt()",
"S.nextInt",
"S",
"for(i=0;i<n;i++){\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}",
"i=0;",
"i=0",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}",
"{\n\t P.add(S.next());\n\t T.add(S.nextInt());\n\t}",
"P.add(S.next())",
"P.add",
"P",
"S.next()",
"S.next",
"S",
"T.add(S.nextInt())",
"T.add",
"T",
"S.nextInt()",
"S.nextInt",
"S",
"while(0<P.size()){\n\t if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }\n\t}",
"0<P.size()",
"0",
"P.size()",
"P.size",
"P",
"{\n\t if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }\n\t}",
"if(0<(T.peek()-m)){\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }\n\t else{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }",
"0<(T.peek()-m)",
"0",
"(T.peek()-m)",
"T.peek()",
"T.peek",
"T",
"m",
"{\n\t\tP.add(P.poll());\n\t\tT.add(T.poll()-m);\n\t\tt=t+m;\n\t }",
"P.add(P.poll())",
"P.add",
"P",
"P.poll()",
"P.poll",
"P",
"T.add(T.poll()-m)",
"T.add",
"T",
"T.poll()-m",
"T.poll()",
"T.poll",
"T",
"m",
"t=t+m",
"t",
"t+m",
"t",
"m",
"{\n\t\tt=t+T.poll();\n\t\tSystem.out.println(P.poll()+\" \"+t);\n\t }",
"t=t+T.poll()",
"t",
"t+T.poll()",
"t",
"T.poll()",
"T.poll",
"T",
"System.out.println(P.poll()+\" \"+t)",
"System.out.println",
"System.out",
"System",
"System.out",
"P.poll()+\" \"+t",
"P.poll()+\" \"+t",
"P.poll()",
"P.poll",
"P",
"\" \"",
"t",
"String[] args",
"args"
] | import java.util.*;
import java.io.*;
class Main{
public static void main(String[] args) throws IOException{
Scanner S=new Scanner(System.in);
int i,n,m,t=0;
Queue<String>P=new LinkedList<String>();
Queue<Integer>T=new LinkedList<Integer>();
n=S.nextInt();
m=S.nextInt();
for(i=0;i<n;i++){
P.add(S.next());
T.add(S.nextInt());
}
while(0<P.size()){
if(0<(T.peek()-m)){
P.add(P.poll());
T.add(T.poll()-m);
t=t+m;
}
else{
t=t+T.poll();
System.out.println(P.poll()+" "+t);
}
}
}
}
|
[
7,
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,
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,
4,
18,
13,
20,
42,
17,
30,
14,
4,
18,
13,
30,
3,
41,
13,
4,
18,
13,
17,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
18,
13,
17,
4,
18,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
13,
17,
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
],
[
9,
10
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
13,
15
],
[
15,
16
],
[
16,
17
],
[
16,
18
],
[
15,
19
],
[
19,
20
],
[
19,
21
],
[
13,
22
],
[
22,
23
],
[
13,
24
],
[
24,
25
],
[
0,
26
],
[
130,
27
],
[
130,
28
],
[
28,
29
],
[
28,
30
],
[
30,
31
],
[
31,
32
],
[
31,
33
],
[
30,
34
],
[
34,
35
],
[
34,
36
],
[
36,
37
],
[
37,
38
],
[
30,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
30,
44
],
[
44,
45
],
[
44,
46
],
[
30,
47
],
[
47,
48
],
[
47,
49
],
[
30,
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
],
[
30,
67
],
[
67,
68
],
[
67,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
72,
73
],
[
70,
74
],
[
74,
75
],
[
69,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
78,
81
],
[
69,
82
],
[
82,
83
],
[
83,
84
],
[
84,
85
],
[
84,
86
],
[
83,
87
],
[
82,
88
],
[
88,
89
],
[
89,
90
],
[
90,
91
],
[
90,
92
],
[
89,
93
],
[
88,
94
],
[
94,
95
],
[
94,
96
],
[
88,
97
],
[
97,
98
],
[
98,
99
],
[
97,
100
],
[
88,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
82,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
108,
110
],
[
105,
111
],
[
111,
112
],
[
112,
113
],
[
111,
114
],
[
105,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
115,
120
],
[
121,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
121,
125
],
[
121,
126
],
[
28,
127
],
[
127,
128
],
[
0,
129
],
[
129,
130
],
[
129,
131
]
] | [
"\nimport java.util.*;\nimport java.lang.*;\n\nclass Process {\n String id;\n int time;\n Process(String x, int t) {\n id = x;\n time = t;\n }\n}\n\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 qtm = sc.nextInt();\n int count = 0;\n ArrayList<Process> queue = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }\n\n while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\n }\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.lang.*;",
"lang.*",
"java",
"class Process {\n String id;\n int time;\n Process(String x, int t) {\n id = x;\n time = t;\n }\n}",
"Process",
"String id;",
"id",
"int time;",
"time",
"Process(String x, int t) {\n id = x;\n time = t;\n }",
"Process",
"{\n id = x;\n time = t;\n }",
"id = x",
"id",
"x",
"time = t",
"time",
"t",
"String x",
"x",
"int t",
"t",
"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 qtm = sc.nextInt();\n int count = 0;\n ArrayList<Process> queue = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }\n\n while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\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 qtm = sc.nextInt();\n int count = 0;\n ArrayList<Process> queue = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }\n\n while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n \n int n = sc.nextInt();\n int qtm = sc.nextInt();\n int count = 0;\n ArrayList<Process> queue = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }\n\n while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\n }\n }",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = sc.nextInt();",
"n",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int qtm = sc.nextInt();",
"qtm",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int count = 0;",
"count",
"0",
"ArrayList<Process> queue = new ArrayList<>();",
"queue",
"new ArrayList<>()",
"for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.add(new Process(sc.next(), sc.nextInt()));\n }",
"{\n queue.add(new Process(sc.next(), sc.nextInt()));\n }",
"queue.add(new Process(sc.next(), sc.nextInt()))",
"queue.add",
"queue",
"new Process(sc.next(), sc.nextInt())",
"while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\n }",
"true",
"{\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\n }",
"if (queue.isEmpty()) {\n break;\n }",
"queue.isEmpty()",
"queue.isEmpty",
"queue",
"{\n break;\n }",
"break;",
"Process element = queue.get(0);",
"element",
"queue.get(0)",
"queue.get",
"queue",
"0",
"if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }",
"element.time > qtm",
"element.time",
"element",
"element.time",
"qtm",
"{\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n }",
"element.time -= qtm",
"element.time",
"element",
"element.time",
"qtm",
"count += qtm",
"count",
"qtm",
"queue.remove(0)",
"queue.remove",
"queue",
"0",
"queue.add(element)",
"queue.add",
"queue",
"element",
"{\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }",
"count += element.time",
"count",
"element.time",
"element",
"element.time",
"queue.remove(0)",
"queue.remove",
"queue",
"0",
"System.out.println(element.id + \" \" + count)",
"System.out.println",
"System.out",
"System",
"System.out",
"element.id + \" \" + count",
"element.id + \" \" + count",
"element.id",
"element",
"element.id",
"\" \"",
"count",
"String args[]",
"args",
"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 qtm = sc.nextInt();\n int count = 0;\n ArrayList<Process> queue = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }\n\n while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\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 qtm = sc.nextInt();\n int count = 0;\n ArrayList<Process> queue = new ArrayList<>();\n for (int i = 0; i < n; i++) {\n queue.add(new Process(sc.next(), sc.nextInt()));\n }\n\n while(true) {\n if (queue.isEmpty()) {\n break;\n }\n Process element = queue.get(0);\n if (element.time > qtm) {\n element.time -= qtm;\n count += qtm;\n queue.remove(0);\n queue.add(element);\n } else {\n count += element.time;\n queue.remove(0);\n System.out.println(element.id + \" \" + count);\n }\n }\n }\n}",
"Main"
] |
import java.util.*;
import java.lang.*;
class Process {
String id;
int time;
Process(String x, int t) {
id = x;
time = t;
}
}
public class Main {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int qtm = sc.nextInt();
int count = 0;
ArrayList<Process> queue = new ArrayList<>();
for (int i = 0; i < n; i++) {
queue.add(new Process(sc.next(), sc.nextInt()));
}
while(true) {
if (queue.isEmpty()) {
break;
}
Process element = queue.get(0);
if (element.time > qtm) {
element.time -= qtm;
count += qtm;
queue.remove(0);
queue.add(element);
} else {
count += element.time;
queue.remove(0);
System.out.println(element.id + " " + count);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
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,
20,
13,
41,
13,
20,
13,
11,
1,
41,
13,
17,
40,
4,
18,
13,
30,
30,
41,
13,
4,
18,
13,
14,
2,
4,
18,
13,
13,
30,
4,
18,
13,
13,
4,
18,
13,
13,
0,
13,
13,
30,
0,
13,
4,
18,
13,
0,
18,
13,
13,
4,
18,
13,
0,
18,
13,
13,
13,
40,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
18,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
12,
13,
30,
0,
13,
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
],
[
10,
11
],
[
10,
12
],
[
0,
13
],
[
13,
14
],
[
13,
15
],
[
0,
16
],
[
212,
17
],
[
212,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
20,
24
],
[
24,
25
],
[
24,
26
],
[
20,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
31,
32
],
[
32,
33
],
[
29,
34
],
[
20,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
37,
40
],
[
40,
41
],
[
40,
42
],
[
20,
43
],
[
43,
44
],
[
43,
45
],
[
45,
46
],
[
46,
47
],
[
45,
48
],
[
48,
49
],
[
48,
50
],
[
20,
51
],
[
51,
52
],
[
52,
53
],
[
53,
54
],
[
53,
55
],
[
51,
56
],
[
56,
57
],
[
56,
58
],
[
51,
59
],
[
59,
60
],
[
60,
61
],
[
51,
62
],
[
63,
63
],
[
63,
64
],
[
64,
65
],
[
64,
66
],
[
66,
67
],
[
67,
68
],
[
68,
69
],
[
69,
70
],
[
66,
71
],
[
63,
72
],
[
72,
73
],
[
73,
74
],
[
72,
75
],
[
20,
76
],
[
76,
77
],
[
76,
78
],
[
20,
79
],
[
79,
80
],
[
79,
81
],
[
20,
83
],
[
83,
84
],
[
83,
85
],
[
20,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
87,
92
],
[
92,
93
],
[
93,
94
],
[
94,
95
],
[
87,
96
],
[
97,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
97,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
106,
107
],
[
104,
108
],
[
103,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
109,
114
],
[
114,
115
],
[
115,
116
],
[
114,
117
],
[
109,
118
],
[
118,
119
],
[
118,
120
],
[
103,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
128,
130
],
[
127,
131
],
[
131,
132
],
[
132,
133
],
[
121,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
121,
139
],
[
139,
140
],
[
20,
141
],
[
141,
142
],
[
142,
143
],
[
143,
144
],
[
143,
145
],
[
141,
146
],
[
146,
147
],
[
146,
148
],
[
141,
149
],
[
149,
150
],
[
150,
151
],
[
141,
152
],
[
153,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
154,
159
],
[
160,
160
],
[
160,
161
],
[
161,
162
],
[
161,
163
],
[
160,
164
],
[
160,
165
],
[
165,
166
],
[
165,
167
],
[
18,
168
],
[
168,
169
],
[
0,
170
],
[
170,
171
],
[
170,
172
],
[
172,
173
],
[
170,
174
],
[
174,
175
],
[
170,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
180,
181
],
[
180,
182
],
[
179,
183
],
[
178,
184
],
[
184,
185
],
[
185,
186
],
[
185,
187
],
[
184,
188
],
[
176,
189
],
[
189,
190
],
[
176,
191
],
[
191,
192
],
[
170,
193
],
[
193,
194
],
[
193,
195
],
[
195,
196
],
[
196,
197
],
[
196,
198
],
[
193,
199
],
[
199,
200
],
[
170,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
204,
205
],
[
170,
206
],
[
206,
207
],
[
206,
208
],
[
208,
209
],
[
209,
210
],
[
0,
211
],
[
211,
212
],
[
211,
213
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.ArrayDeque;\nimport java.util.Deque;\n\npublic class Main {\n\n\tpublic static void main(String[] args) throws IOException, NumberFormatException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tDeque<Pair> deq = new ArrayDeque<Pair>();\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\t\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}\n\t\t\n\t\tint timeCount = 0;\n\t\t\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\t\n\t\tfor(int i = 0; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}\n\t}\n\n}\n\nclass Pair {\n\tString name;\n\tint time;\n\t\n\tPair(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t\n\tvoid overTime(int over){\n\t\ttime -= over;\n\t}\n\tint getTime(){\n\t\treturn time;\n\t}\n\tString getName(){\n\t\treturn name;\n\t}\n}",
"import java.io.BufferedReader;",
"BufferedReader",
"java.io",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.io.InputStreamReader;",
"InputStreamReader",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Deque;",
"Deque",
"java.util",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException, NumberFormatException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tDeque<Pair> deq = new ArrayDeque<Pair>();\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\t\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}\n\t\t\n\t\tint timeCount = 0;\n\t\t\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\t\n\t\tfor(int i = 0; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws IOException, NumberFormatException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tDeque<Pair> deq = new ArrayDeque<Pair>();\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\t\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}\n\t\t\n\t\tint timeCount = 0;\n\t\t\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\t\n\t\tfor(int i = 0; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}\n\t}",
"main",
"{\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tDeque<Pair> deq = new ArrayDeque<Pair>();\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\t\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}\n\t\t\n\t\tint timeCount = 0;\n\t\t\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\t\n\t\tfor(int i = 0; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}\n\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in));",
"br",
"new BufferedReader(new InputStreamReader(System.in))",
"Deque<Pair> deq = new ArrayDeque<Pair>();",
"deq",
"new ArrayDeque<Pair>()",
"String[] str = br.readLine().split(\" \");",
"str",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"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",
"for(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], 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\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}",
"{\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}",
"str = br.readLine().split(\" \")",
"str",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"deq.addFirst(new Pair(str[0], Integer.parseInt(str[1])))",
"deq.addFirst",
"deq",
"new Pair(str[0], Integer.parseInt(str[1]))",
"int timeCount = 0;",
"timeCount",
"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; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"!deq.isEmpty()",
"deq.isEmpty()",
"deq.isEmpty",
"deq",
"{\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}",
"{\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}",
"Pair p = deq.removeLast();",
"p",
"deq.removeLast()",
"deq.removeLast",
"deq",
"if(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}",
"p.getTime() > q",
"p.getTime()",
"p.getTime",
"p",
"q",
"{\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t}",
"p.overTime(q)",
"p.overTime",
"p",
"q",
"deq.addFirst(p)",
"deq.addFirst",
"deq",
"p",
"timeCount += q",
"timeCount",
"q",
"{\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}",
"timeCount += p.getTime()",
"timeCount",
"p.getTime()",
"p.getTime",
"p",
"name[i] = p.getName()",
"name[i]",
"name",
"i",
"p.getName()",
"p.getName",
"p",
"time[i] = timeCount",
"time[i]",
"time",
"i",
"timeCount",
"i++",
"i",
"for(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}",
"{\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}",
"System.out.println(name[i] + \" \" + time[i])",
"System.out.println",
"System.out",
"System",
"System.out",
"name[i] + \" \" + time[i]",
"name[i] + \" \" + time[i]",
"name[i]",
"name",
"i",
"\" \"",
"time[i]",
"time",
"i",
"String[] args",
"args",
"class Pair {\n\tString name;\n\tint time;\n\t\n\tPair(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n\t\n\tvoid overTime(int over){\n\t\ttime -= over;\n\t}\n\tint getTime(){\n\t\treturn time;\n\t}\n\tString getName(){\n\t\treturn name;\n\t}\n}",
"Pair",
"String name;",
"name",
"int time;",
"time",
"Pair(String name, int time){\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Pair",
"{\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",
"void overTime(int over){\n\t\ttime -= over;\n\t}",
"overTime",
"{\n\t\ttime -= over;\n\t}",
"time -= over",
"time",
"over",
"int over",
"over",
"int getTime(){\n\t\treturn time;\n\t}",
"getTime",
"{\n\t\treturn time;\n\t}",
"return time;",
"time",
"String getName(){\n\t\treturn name;\n\t}",
"getName",
"{\n\t\treturn name;\n\t}",
"return name;",
"name",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException, NumberFormatException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tDeque<Pair> deq = new ArrayDeque<Pair>();\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\t\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}\n\t\t\n\t\tint timeCount = 0;\n\t\t\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\t\n\t\tfor(int i = 0; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) throws IOException, NumberFormatException {\n\t\t// TODO ?????????????????????????????????????????????\n\t\tBufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\t\tDeque<Pair> deq = new ArrayDeque<Pair>();\n\t\t\n\t\tString[] str = br.readLine().split(\" \");\n\t\t\n\t\tint n = Integer.parseInt(str[0]);\n\t\tint q = Integer.parseInt(str[1]);\n\t\t\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tstr = br.readLine().split(\" \");\n\t\t\tdeq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));\n\t\t}\n\t\t\n\t\tint timeCount = 0;\n\t\t\n\t\tString[] name = new String[n];\n\t\tint[] time = new int[n];\n\t\t\n\t\tfor(int i = 0; !deq.isEmpty();){\n\t\t\t\n\t\t\tPair p = deq.removeLast();\n\t\t\t\n\t\t\tif(p.getTime() > q){\n\t\t\t\tp.overTime(q);\n\t\t\t\tdeq.addFirst(p);\n\t\t\t\ttimeCount += q;\n\t\t\t} else {\n\t\t\t\ttimeCount += p.getTime();\n\t\t\t\t\n\t\t\t\tname[i] = p.getName();\n\t\t\t\ttime[i] = timeCount;\n\t\t\t\ti++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < n; i++){\n\t\t\tSystem.out.println(name[i] + \" \" + time[i]);\n\t\t}\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
public static void main(String[] args) throws IOException, NumberFormatException {
// TODO ?????????????????????????????????????????????
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Deque<Pair> deq = new ArrayDeque<Pair>();
String[] str = br.readLine().split(" ");
int n = Integer.parseInt(str[0]);
int q = Integer.parseInt(str[1]);
for(int i = 0; i < n; i++){
str = br.readLine().split(" ");
deq.addFirst(new Pair(str[0], Integer.parseInt(str[1])));
}
int timeCount = 0;
String[] name = new String[n];
int[] time = new int[n];
for(int i = 0; !deq.isEmpty();){
Pair p = deq.removeLast();
if(p.getTime() > q){
p.overTime(q);
deq.addFirst(p);
timeCount += q;
} else {
timeCount += p.getTime();
name[i] = p.getName();
time[i] = timeCount;
i++;
}
}
for(int i = 0; i < n; i++){
System.out.println(name[i] + " " + time[i]);
}
}
}
class Pair {
String name;
int time;
Pair(String name, int time){
this.name = name;
this.time = time;
}
void overTime(int over){
time -= over;
}
int getTime(){
return time;
}
String getName(){
return name;
}
} |
[
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,
41,
13,
20,
41,
13,
20,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
13,
30,
0,
13,
13,
4,
18,
13,
4,
18,
13,
4,
18,
13,
2,
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,
17,
4,
18,
13,
4,
18,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
140,
5
],
[
140,
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
],
[
56,
58
],
[
8,
59
],
[
59,
60
],
[
59,
61
],
[
8,
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
],
[
74,
75
],
[
74,
76
],
[
73,
77
],
[
77,
78
],
[
78,
79
],
[
78,
80
],
[
77,
81
],
[
81,
82
],
[
82,
83
],
[
81,
84
],
[
84,
85
],
[
85,
86
],
[
77,
87
],
[
87,
88
],
[
88,
89
],
[
87,
90
],
[
73,
91
],
[
91,
92
],
[
92,
93
],
[
92,
94
],
[
91,
95
],
[
95,
96
],
[
96,
97
],
[
95,
98
],
[
98,
99
],
[
99,
100
],
[
91,
101
],
[
101,
102
],
[
102,
103
],
[
101,
104
],
[
104,
105
],
[
104,
106
],
[
8,
107
],
[
107,
108
],
[
108,
109
],
[
109,
110
],
[
109,
111
],
[
107,
112
],
[
112,
113
],
[
112,
114
],
[
107,
115
],
[
115,
116
],
[
116,
117
],
[
107,
118
],
[
119,
119
],
[
119,
120
],
[
120,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
120,
125
],
[
126,
126
],
[
126,
127
],
[
127,
128
],
[
128,
129
],
[
126,
130
],
[
126,
131
],
[
131,
132
],
[
132,
133
],
[
8,
134
],
[
134,
135
],
[
135,
136
],
[
6,
137
],
[
137,
138
],
[
0,
139
],
[
139,
140
],
[
139,
141
]
] | [
"import java.util.*;\n\npublic class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint num = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\tint totTime = 0;\n\t\tQueue<String> resultNames = new LinkedList<String>();\n\t\tQueue<Integer> resultTimes = new LinkedList<Integer>();\n\t\t\n\t\twhile(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}\n\t\t\n\t\tin.close();\n\t\t\n\t}\n\n}\n",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint num = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\tint totTime = 0;\n\t\tQueue<String> resultNames = new LinkedList<String>();\n\t\tQueue<Integer> resultTimes = new LinkedList<Integer>();\n\t\t\n\t\twhile(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}\n\t\t\n\t\tin.close();\n\t\t\n\t}\n\n}",
"Main",
"public static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint num = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\tint totTime = 0;\n\t\tQueue<String> resultNames = new LinkedList<String>();\n\t\tQueue<Integer> resultTimes = new LinkedList<Integer>();\n\t\t\n\t\twhile(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}\n\t\t\n\t\tin.close();\n\t\t\n\t}",
"main",
"{\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint num = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\tint totTime = 0;\n\t\tQueue<String> resultNames = new LinkedList<String>();\n\t\tQueue<Integer> resultTimes = new LinkedList<Integer>();\n\t\t\n\t\twhile(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}\n\t\t\n\t\tin.close();\n\t\t\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int num = in.nextInt();",
"num",
"in.nextInt()",
"in.nextInt",
"in",
"int quantum = in.nextInt();",
"quantum",
"in.nextInt()",
"in.nextInt",
"in",
"Queue<String> names = new LinkedList<String>();",
"names",
"new LinkedList<String>()",
"Queue<Integer> times = new LinkedList<Integer>();",
"times",
"new LinkedList<Integer>()",
"for(int i = 0; i < num; 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 < num",
"i",
"num",
"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",
"int totTime = 0;",
"totTime",
"0",
"Queue<String> resultNames = new LinkedList<String>();",
"resultNames",
"new LinkedList<String>()",
"Queue<Integer> resultTimes = new LinkedList<Integer>();",
"resultTimes",
"new LinkedList<Integer>()",
"while(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}",
"!names.isEmpty()",
"names.isEmpty()",
"names.isEmpty",
"names",
"{\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}",
"int tempTime = times.remove();",
"tempTime",
"times.remove()",
"times.remove",
"times",
"if(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}",
"tempTime <= quantum",
"tempTime",
"quantum",
"{\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t}",
"totTime += tempTime",
"totTime",
"tempTime",
"resultNames.add(names.remove())",
"resultNames.add",
"resultNames",
"names.remove()",
"names.remove",
"names",
"resultTimes.add(totTime)",
"resultTimes.add",
"resultTimes",
"totTime",
"{\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}",
"totTime += quantum",
"totTime",
"quantum",
"names.add(names.remove())",
"names.add",
"names",
"names.remove()",
"names.remove",
"names",
"times.add(tempTime - quantum)",
"times.add",
"times",
"tempTime - quantum",
"tempTime",
"quantum",
"for(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < num",
"i",
"num",
"i++",
"i++",
"i",
"{\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}",
"{\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}",
"System.out.println(resultNames.remove() + \" \" + resultTimes.remove())",
"System.out.println",
"System.out",
"System",
"System.out",
"resultNames.remove() + \" \" + resultTimes.remove()",
"resultNames.remove() + \" \" + resultTimes.remove()",
"resultNames.remove()",
"resultNames.remove",
"resultNames",
"\" \"",
"resultTimes.remove()",
"resultTimes.remove",
"resultTimes",
"in.close()",
"in.close",
"in",
"String[] args",
"args",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint num = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\tint totTime = 0;\n\t\tQueue<String> resultNames = new LinkedList<String>();\n\t\tQueue<Integer> resultTimes = new LinkedList<Integer>();\n\t\t\n\t\twhile(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}\n\t\t\n\t\tin.close();\n\t\t\n\t}\n\n}",
"public class Main {\n\n\tpublic static void main(String[] args) {\n\t\t\n\t\tScanner in = new Scanner(System.in);\n\t\tint num = in.nextInt();\n\t\tint quantum = in.nextInt();\n\t\t\n\t\tQueue<String> names = new LinkedList<String>();\n\t\tQueue<Integer> times = new LinkedList<Integer>();\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\tnames.add(in.next());\n\t\t\ttimes.add(in.nextInt());\n\t\t}\n\t\t\n\t\tint totTime = 0;\n\t\tQueue<String> resultNames = new LinkedList<String>();\n\t\tQueue<Integer> resultTimes = new LinkedList<Integer>();\n\t\t\n\t\twhile(!names.isEmpty()) {\n\t\t\t\n\t\t\tint tempTime = times.remove();\n\t\t\t\n\t\t\tif(tempTime <= quantum) {\n\t\t\t\t\n\t\t\t\ttotTime += tempTime;\n\t\t\t\tresultNames.add(names.remove());\n\t\t\t\tresultTimes.add(totTime);\n\t\t\t\t\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\ttotTime += quantum;\n\t\t\t\tnames.add(names.remove());\n\t\t\t\ttimes.add(tempTime - quantum);\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor(int i = 0; i < num; i++) {\n\t\t\t\n\t\t\tSystem.out.println(resultNames.remove() + \" \" + resultTimes.remove());\n\t\t\t\n\t\t}\n\t\t\n\t\tin.close();\n\t\t\n\t}\n\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int quantum = in.nextInt();
Queue<String> names = new LinkedList<String>();
Queue<Integer> times = new LinkedList<Integer>();
for(int i = 0; i < num; i++) {
names.add(in.next());
times.add(in.nextInt());
}
int totTime = 0;
Queue<String> resultNames = new LinkedList<String>();
Queue<Integer> resultTimes = new LinkedList<Integer>();
while(!names.isEmpty()) {
int tempTime = times.remove();
if(tempTime <= quantum) {
totTime += tempTime;
resultNames.add(names.remove());
resultTimes.add(totTime);
} else {
totTime += quantum;
names.add(names.remove());
times.add(tempTime - quantum);
}
}
for(int i = 0; i < num; i++) {
System.out.println(resultNames.remove() + " " + resultTimes.remove());
}
in.close();
}
}
|
[
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,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
18,
13,
20,
4,
18,
4,
18,
13,
2,
4,
18,
13,
17,
4,
18,
13,
4,
18,
13,
42,
2,
4,
18,
13,
17,
30,
41,
13,
17,
28,
13,
4,
18,
4,
18,
13,
17,
30,
30,
0,
13,
13,
41,
13,
4,
18,
4,
18,
13,
17,
13,
4,
18,
13,
17,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
13,
4,
18,
13,
20,
4,
18,
4,
18,
13,
2,
4,
18,
13,
17,
13,
2,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
140,
5
],
[
140,
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
],
[
40,
45
],
[
45,
46
],
[
46,
47
],
[
47,
48
],
[
48,
49
],
[
47,
50
],
[
50,
51
],
[
51,
52
],
[
52,
53
],
[
50,
54
],
[
45,
55
],
[
55,
56
],
[
56,
57
],
[
45,
58
],
[
58,
59
],
[
59,
60
],
[
8,
61
],
[
61,
62
],
[
62,
63
],
[
63,
64
],
[
64,
65
],
[
62,
66
],
[
61,
67
],
[
67,
68
],
[
68,
69
],
[
68,
70
],
[
67,
71
],
[
71,
72
],
[
71,
73
],
[
73,
74
],
[
74,
75
],
[
75,
76
],
[
76,
77
],
[
75,
78
],
[
71,
79
],
[
80,
80
],
[
80,
81
],
[
81,
82
],
[
81,
83
],
[
67,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
88,
89
],
[
89,
90
],
[
88,
91
],
[
86,
92
],
[
67,
93
],
[
93,
94
],
[
94,
95
],
[
93,
96
],
[
67,
97
],
[
97,
98
],
[
98,
99
],
[
98,
100
],
[
97,
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
],
[
97,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
120,
121
],
[
119,
122
],
[
115,
123
],
[
123,
124
],
[
124,
125
],
[
125,
126
],
[
126,
127
],
[
125,
128
],
[
128,
129
],
[
129,
130
],
[
130,
131
],
[
128,
132
],
[
123,
133
],
[
123,
134
],
[
134,
135
],
[
134,
136
],
[
6,
137
],
[
137,
138
],
[
0,
139
],
[
139,
140
],
[
139,
141
]
] | [
"import java.util.*;\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 List<Map<String, Integer>> queue = new ArrayList<>();\n int second = 0;\n for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }\n while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }\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 n = sc.nextInt();\n int q = sc.nextInt();\n List<Map<String, Integer>> queue = new ArrayList<>();\n int second = 0;\n for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }\n while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\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 List<Map<String, Integer>> queue = new ArrayList<>();\n int second = 0;\n for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }\n while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }\n }\n }",
"main",
"{\n Scanner sc = new Scanner(System.in);\n int n = sc.nextInt();\n int q = sc.nextInt();\n List<Map<String, Integer>> queue = new ArrayList<>();\n int second = 0;\n for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }\n while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - 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",
"List<Map<String, Integer>> queue = new ArrayList<>();",
"queue",
"new ArrayList<>()",
"int second = 0;",
"second",
"0",
"for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }",
"{\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }",
"queue.add(new HashMap<>())",
"queue.add",
"queue",
"new HashMap<>()",
"queue.get(queue.size() - 1).put(sc.next(), sc.nextInt())",
"queue.get(queue.size() - 1).put",
"queue.get(queue.size() - 1)",
"queue.get",
"queue",
"queue.size() - 1",
"queue.size()",
"queue.size",
"queue",
"1",
"sc.next()",
"sc.next",
"sc",
"sc.nextInt()",
"sc.nextInt",
"sc",
"while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }\n }",
"queue.size() > 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }\n }",
"String s = \"\";",
"s",
"\"\"",
"for(String e : queue.get(0).keySet()) {\n s = e;\n }",
"String e",
"queue.get(0).keySet()",
"queue.get(0).keySet",
"queue.get(0)",
"queue.get",
"queue",
"0",
"{\n s = e;\n }",
"{\n s = e;\n }",
"s = e",
"s",
"e",
"int a = queue.get(0).get(s);",
"a",
"queue.get(0).get(s)",
"queue.get(0).get",
"queue.get(0)",
"queue.get",
"queue",
"0",
"s",
"queue.remove(0)",
"queue.remove",
"queue",
"0",
"if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }",
"a <= q",
"a",
"q",
"{\n second += a;\n System.out.println(s + \" \" + second);\n }",
"second += a",
"second",
"a",
"System.out.println(s + \" \" + second)",
"System.out.println",
"System.out",
"System",
"System.out",
"s + \" \" + second",
"s + \" \" + second",
"s",
"\" \"",
"second",
"{\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }",
"second += q",
"second",
"q",
"queue.add(new HashMap<>())",
"queue.add",
"queue",
"new HashMap<>()",
"queue.get(queue.size() - 1).put(s, a - q)",
"queue.get(queue.size() - 1).put",
"queue.get(queue.size() - 1)",
"queue.get",
"queue",
"queue.size() - 1",
"queue.size()",
"queue.size",
"queue",
"1",
"s",
"a - q",
"a",
"q",
"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 List<Map<String, Integer>> queue = new ArrayList<>();\n int second = 0;\n for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }\n while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }\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 List<Map<String, Integer>> queue = new ArrayList<>();\n int second = 0;\n for(int i = 0; i < n; i++) {\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());\n }\n while(queue.size() > 0) {\n String s = \"\";\n for(String e : queue.get(0).keySet()) {\n s = e;\n }\n int a = queue.get(0).get(s);\n queue.remove(0);\n if(a <= q) {\n second += a;\n System.out.println(s + \" \" + second);\n } else {\n second += q;\n queue.add(new HashMap<>());\n queue.get(queue.size() - 1).put(s, a - q);\n }\n }\n }\n}",
"Main"
] | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int q = sc.nextInt();
List<Map<String, Integer>> queue = new ArrayList<>();
int second = 0;
for(int i = 0; i < n; i++) {
queue.add(new HashMap<>());
queue.get(queue.size() - 1).put(sc.next(), sc.nextInt());
}
while(queue.size() > 0) {
String s = "";
for(String e : queue.get(0).keySet()) {
s = e;
}
int a = queue.get(0).get(s);
queue.remove(0);
if(a <= q) {
second += a;
System.out.println(s + " " + second);
} else {
second += q;
queue.add(new HashMap<>());
queue.get(queue.size() - 1).put(s, a - q);
}
}
}
}
|
[
7,
15,
13,
17,
6,
13,
41,
13,
20,
41,
13,
17,
41,
13,
17,
41,
13,
20,
13,
41,
13,
20,
13,
41,
13,
17,
41,
13,
17,
41,
13,
17,
41,
13,
17,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
0,
18,
13,
13,
13,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
29,
13,
12,
13,
30,
41,
13,
18,
13,
13,
14,
2,
13,
2,
13,
17,
0,
13,
17,
40,
13,
29,
13,
12,
13,
30,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
4,
13,
4,
18,
13,
4,
13,
4,
18,
13,
41,
13,
41,
13,
42,
2,
13,
13,
30,
0,
13,
4,
13,
0,
13,
4,
13,
14,
2,
13,
13,
30,
0,
13,
13,
4,
18,
18,
13,
13,
17,
13,
13,
9,
0,
13,
13,
4,
13,
13,
4,
13,
13,
0,
13,
13,
12,
13,
30,
4,
18,
20,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
210,
5
],
[
210,
6
],
[
6,
7
],
[
6,
8
],
[
210,
9
],
[
9,
10
],
[
9,
11
],
[
210,
12
],
[
12,
13
],
[
12,
14
],
[
210,
15
],
[
15,
16
],
[
15,
17
],
[
210,
19
],
[
19,
20
],
[
19,
21
],
[
210,
23
],
[
23,
24
],
[
23,
25
],
[
210,
26
],
[
26,
27
],
[
26,
28
],
[
210,
29
],
[
29,
30
],
[
29,
31
],
[
210,
32
],
[
32,
33
],
[
32,
34
],
[
210,
35
],
[
35,
36
],
[
35,
37
],
[
37,
38
],
[
38,
39
],
[
39,
40
],
[
39,
41
],
[
38,
42
],
[
37,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
46,
48
],
[
43,
49
],
[
49,
50
],
[
49,
51
],
[
43,
52
],
[
52,
53
],
[
35,
54
],
[
54,
55
],
[
210,
56
],
[
56,
57
],
[
56,
58
],
[
58,
59
],
[
59,
60
],
[
60,
61
],
[
60,
62
],
[
59,
63
],
[
58,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
64,
73
],
[
73,
74
],
[
56,
75
],
[
75,
76
],
[
210,
77
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
86,
88
],
[
88,
89
],
[
88,
90
],
[
85,
91
],
[
91,
92
],
[
91,
93
],
[
85,
94
],
[
94,
95
],
[
79,
96
],
[
96,
97
],
[
210,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
100,
106
],
[
106,
107
],
[
107,
108
],
[
107,
109
],
[
109,
110
],
[
109,
111
],
[
106,
112
],
[
112,
113
],
[
112,
114
],
[
106,
115
],
[
115,
116
],
[
100,
117
],
[
117,
118
],
[
210,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
125,
126
],
[
121,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
121,
132
],
[
132,
133
],
[
133,
134
],
[
134,
135
],
[
134,
136
],
[
132,
137
],
[
137,
138
],
[
137,
139
],
[
132,
140
],
[
140,
141
],
[
141,
142
],
[
132,
143
],
[
144,
144
],
[
144,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
144,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
121,
155
],
[
155,
156
],
[
121,
157
],
[
157,
158
],
[
121,
159
],
[
159,
160
],
[
160,
161
],
[
160,
162
],
[
159,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
166,
167
],
[
163,
168
],
[
168,
169
],
[
168,
170
],
[
170,
171
],
[
163,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
176,
177
],
[
177,
178
],
[
177,
179
],
[
176,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
180,
185
],
[
180,
186
],
[
180,
187
],
[
176,
188
],
[
163,
189
],
[
189,
190
],
[
189,
191
],
[
163,
192
],
[
192,
193
],
[
192,
194
],
[
163,
195
],
[
195,
196
],
[
195,
197
],
[
163,
198
],
[
198,
199
],
[
198,
200
],
[
210,
201
],
[
201,
202
],
[
201,
203
],
[
203,
204
],
[
204,
205
],
[
205,
206
],
[
201,
207
],
[
207,
208
],
[
0,
209
],
[
209,
210
],
[
209,
211
]
] | [
"import java.util.*;\n\npublic class Main {\n Scanner sc = new Scanner(System.in);\n \n\tint n = 100001 ; int total = 0 ;\n\tint[] time = new int[n];\n\tString[] name = new String[n];\n\tint topInt = 0 ,topString=0; //キューの先頭\n\tint bottomInt = 0 ,bottomString=0;//キューの末尾 +1\n\t\n\tvoid enQueueInt(int m){\n\t\ttime[bottomInt] = m ;\n\t\tif(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;\n\t}\n\tvoid enQueueString(String m){\n\t\tname[bottomString] = m ;\n\t\tif(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;\n\t}\n\t\n\t\n\tint deQueueInt(){\n\t\tint x = time[topInt];\n\t\tif(topInt == n-1) topInt = 0;\n\t\telse topInt++;\n\t\treturn x ;\n\t}\n\tString deQueueString(){\n\t\tString x = name[topString];\n\t\tif(topString == n-1) topString = 0;\n\t\telse topString++;\n\t\treturn x ;\n\t}\n\t\n\tvoid run(){\n\t int m = sc.nextInt();\n\t int q = sc.nextInt();\n\t \n\t for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }\n\n\t int x ; String y ;\n\t while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }\n\t}\n\t\n public static void main(String[] args) throws Exception {\n new Main().run();\n }\n}",
"import java.util.*;",
"util.*",
"java",
"public class Main {\n Scanner sc = new Scanner(System.in);\n \n\tint n = 100001 ; int total = 0 ;\n\tint[] time = new int[n];\n\tString[] name = new String[n];\n\tint topInt = 0 ,topString=0; //キューの先頭\n\tint bottomInt = 0 ,bottomString=0;//キューの末尾 +1\n\t\n\tvoid enQueueInt(int m){\n\t\ttime[bottomInt] = m ;\n\t\tif(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;\n\t}\n\tvoid enQueueString(String m){\n\t\tname[bottomString] = m ;\n\t\tif(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;\n\t}\n\t\n\t\n\tint deQueueInt(){\n\t\tint x = time[topInt];\n\t\tif(topInt == n-1) topInt = 0;\n\t\telse topInt++;\n\t\treturn x ;\n\t}\n\tString deQueueString(){\n\t\tString x = name[topString];\n\t\tif(topString == n-1) topString = 0;\n\t\telse topString++;\n\t\treturn x ;\n\t}\n\t\n\tvoid run(){\n\t int m = sc.nextInt();\n\t int q = sc.nextInt();\n\t \n\t for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }\n\n\t int x ; String y ;\n\t while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }\n\t}\n\t\n public static void main(String[] args) throws Exception {\n new Main().run();\n }\n}",
"Main",
"Scanner sc = new Scanner(System.in);",
"sc",
"new Scanner(System.in)",
"int n = 100001 ;",
"n",
"100001",
"int total = 0 ;",
"total",
"0",
"int[] time = new int[n];",
"time",
"new int[n]",
"n",
"String[] name = new String[n];",
"name",
"new String[n]",
"n",
"int topInt = 0",
"topInt",
"0",
"topString=0; //キューの先頭",
"topString",
"0",
"int bottomInt = 0",
"bottomInt",
"0",
"bottomString=0;//キューの末尾 +1",
"bottomString",
"0",
"void enQueueInt(int m){\n\t\ttime[bottomInt] = m ;\n\t\tif(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;\n\t}",
"enQueueInt",
"{\n\t\ttime[bottomInt] = m ;\n\t\tif(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;\n\t}",
"time[bottomInt] = m",
"time[bottomInt]",
"time",
"bottomInt",
"m",
"if(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;",
"bottomInt == n-1",
"bottomInt",
"n-1",
"n",
"1",
"bottomInt = 0",
"bottomInt",
"0",
"bottomInt++",
"bottomInt",
"int m",
"m",
"void enQueueString(String m){\n\t\tname[bottomString] = m ;\n\t\tif(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;\n\t}",
"enQueueString",
"{\n\t\tname[bottomString] = m ;\n\t\tif(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;\n\t}",
"name[bottomString] = m",
"name[bottomString]",
"name",
"bottomString",
"m",
"if(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;",
"bottomString == n-1",
"bottomString",
"n-1",
"n",
"1",
"bottomString = 0",
"bottomString",
"0",
"bottomString++",
"bottomString",
"String m",
"m",
"int deQueueInt(){\n\t\tint x = time[topInt];\n\t\tif(topInt == n-1) topInt = 0;\n\t\telse topInt++;\n\t\treturn x ;\n\t}",
"deQueueInt",
"{\n\t\tint x = time[topInt];\n\t\tif(topInt == n-1) topInt = 0;\n\t\telse topInt++;\n\t\treturn x ;\n\t}",
"int x = time[topInt];",
"x",
"time[topInt]",
"time",
"topInt",
"if(topInt == n-1) topInt = 0;\n\t\telse topInt++;",
"topInt == n-1",
"topInt",
"n-1",
"n",
"1",
"topInt = 0",
"topInt",
"0",
"topInt++",
"topInt",
"return x ;",
"x",
"String deQueueString(){\n\t\tString x = name[topString];\n\t\tif(topString == n-1) topString = 0;\n\t\telse topString++;\n\t\treturn x ;\n\t}",
"deQueueString",
"{\n\t\tString x = name[topString];\n\t\tif(topString == n-1) topString = 0;\n\t\telse topString++;\n\t\treturn x ;\n\t}",
"String x = name[topString];",
"x",
"name[topString]",
"name",
"topString",
"if(topString == n-1) topString = 0;\n\t\telse topString++;",
"topString == n-1",
"topString",
"n-1",
"n",
"1",
"topString = 0",
"topString",
"0",
"topString++",
"topString",
"return x ;",
"x",
"void run(){\n\t int m = sc.nextInt();\n\t int q = sc.nextInt();\n\t \n\t for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }\n\n\t int x ; String y ;\n\t while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }\n\t}",
"run",
"{\n\t int m = sc.nextInt();\n\t int q = sc.nextInt();\n\t \n\t for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }\n\n\t int x ; String y ;\n\t while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }\n\t}",
"int m = sc.nextInt();",
"m",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int q = sc.nextInt();",
"q",
"sc.nextInt()",
"sc.nextInt",
"sc",
"for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<m",
"i",
"m",
"i++",
"i++",
"i",
"{\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }",
"{\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }",
"enQueueString(sc.next())",
"enQueueString",
"sc.next()",
"sc.next",
"sc",
"enQueueInt(sc.nextInt())",
"enQueueInt",
"sc.nextInt()",
"sc.nextInt",
"sc",
"int x ;",
"x",
"String y ;",
"y",
"while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }",
"topInt != bottomInt",
"topInt",
"bottomInt",
"{\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }",
"x = deQueueInt()",
"x",
"deQueueInt()",
"deQueueInt",
"y = deQueueString()",
"y",
"deQueueString()",
"deQueueString",
"if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }",
"x <= q",
"x",
"q",
"{\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }",
"total += x",
"total",
"x",
"System.out.printf(\"%s %d\\n\",y,total)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"y",
"total",
"continue;",
"x -= q",
"x",
"q",
"enQueueInt(x)",
"enQueueInt",
"x",
"enQueueString(y)",
"enQueueString",
"y",
"total+=q",
"total",
"q",
"public static void main(String[] args) throws Exception {\n new Main().run();\n }",
"main",
"{\n new Main().run();\n }",
"new Main().run()",
"new Main().run",
"new Main()",
"String[] args",
"args",
"public class Main {\n Scanner sc = new Scanner(System.in);\n \n\tint n = 100001 ; int total = 0 ;\n\tint[] time = new int[n];\n\tString[] name = new String[n];\n\tint topInt = 0 ,topString=0; //キューの先頭\n\tint bottomInt = 0 ,bottomString=0;//キューの末尾 +1\n\t\n\tvoid enQueueInt(int m){\n\t\ttime[bottomInt] = m ;\n\t\tif(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;\n\t}\n\tvoid enQueueString(String m){\n\t\tname[bottomString] = m ;\n\t\tif(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;\n\t}\n\t\n\t\n\tint deQueueInt(){\n\t\tint x = time[topInt];\n\t\tif(topInt == n-1) topInt = 0;\n\t\telse topInt++;\n\t\treturn x ;\n\t}\n\tString deQueueString(){\n\t\tString x = name[topString];\n\t\tif(topString == n-1) topString = 0;\n\t\telse topString++;\n\t\treturn x ;\n\t}\n\t\n\tvoid run(){\n\t int m = sc.nextInt();\n\t int q = sc.nextInt();\n\t \n\t for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }\n\n\t int x ; String y ;\n\t while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }\n\t}\n\t\n public static void main(String[] args) throws Exception {\n new Main().run();\n }\n}",
"public class Main {\n Scanner sc = new Scanner(System.in);\n \n\tint n = 100001 ; int total = 0 ;\n\tint[] time = new int[n];\n\tString[] name = new String[n];\n\tint topInt = 0 ,topString=0; //キューの先頭\n\tint bottomInt = 0 ,bottomString=0;//キューの末尾 +1\n\t\n\tvoid enQueueInt(int m){\n\t\ttime[bottomInt] = m ;\n\t\tif(bottomInt == n-1) bottomInt = 0;\n\t\telse bottomInt++ ;\n\t}\n\tvoid enQueueString(String m){\n\t\tname[bottomString] = m ;\n\t\tif(bottomString == n-1) bottomString = 0;\n\t\telse bottomString++ ;\n\t}\n\t\n\t\n\tint deQueueInt(){\n\t\tint x = time[topInt];\n\t\tif(topInt == n-1) topInt = 0;\n\t\telse topInt++;\n\t\treturn x ;\n\t}\n\tString deQueueString(){\n\t\tString x = name[topString];\n\t\tif(topString == n-1) topString = 0;\n\t\telse topString++;\n\t\treturn x ;\n\t}\n\t\n\tvoid run(){\n\t int m = sc.nextInt();\n\t int q = sc.nextInt();\n\t \n\t for(int i=0;i<m;i++){\n\t enQueueString(sc.next());\n\t enQueueInt(sc.nextInt());\n\t }\n\n\t int x ; String y ;\n\t while(topInt != bottomInt){\n\t x = deQueueInt();\n\t y = deQueueString();\n\t \n\t if(x <= q){\n\t total += x;\n\t System.out.printf(\"%s %d\\n\",y,total);\n\t continue;\n\t }\n\t \n\t x -= q; enQueueInt(x); enQueueString(y); total+=q;\n\t }\n\t}\n\t\n public static void main(String[] args) throws Exception {\n new Main().run();\n }\n}",
"Main"
] | import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
int n = 100001 ; int total = 0 ;
int[] time = new int[n];
String[] name = new String[n];
int topInt = 0 ,topString=0; //キューの先頭
int bottomInt = 0 ,bottomString=0;//キューの末尾 +1
void enQueueInt(int m){
time[bottomInt] = m ;
if(bottomInt == n-1) bottomInt = 0;
else bottomInt++ ;
}
void enQueueString(String m){
name[bottomString] = m ;
if(bottomString == n-1) bottomString = 0;
else bottomString++ ;
}
int deQueueInt(){
int x = time[topInt];
if(topInt == n-1) topInt = 0;
else topInt++;
return x ;
}
String deQueueString(){
String x = name[topString];
if(topString == n-1) topString = 0;
else topString++;
return x ;
}
void run(){
int m = sc.nextInt();
int q = sc.nextInt();
for(int i=0;i<m;i++){
enQueueString(sc.next());
enQueueInt(sc.nextInt());
}
int x ; String y ;
while(topInt != bottomInt){
x = deQueueInt();
y = deQueueString();
if(x <= q){
total += x;
System.out.printf("%s %d\n",y,total);
continue;
}
x -= q; enQueueInt(x); enQueueString(y); total+=q;
}
}
public static void main(String[] args) throws Exception {
new Main().run();
}
}
|
[
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,
41,
13,
41,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
13,
0,
13,
20,
13,
0,
13,
17,
0,
13,
40,
17,
0,
13,
17,
23,
13,
12,
13,
30,
14,
2,
13,
2,
13,
17,
0,
13,
40,
17,
0,
18,
13,
40,
13,
13,
40,
13,
23,
13,
12,
13,
30,
41,
13,
18,
13,
40,
13,
14,
2,
13,
13,
0,
13,
17,
40,
13,
29,
13,
12,
13,
30,
29,
2,
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,
17,
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,
41,
13,
4,
18,
13,
13,
18,
13,
13,
0,
18,
13,
13,
13,
0,
13,
13,
14,
2,
18,
13,
13,
17,
30,
4,
18,
13,
13,
30,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
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
],
[
27,
31
],
[
31,
32
],
[
27,
33
],
[
33,
34
],
[
27,
35
],
[
35,
36
],
[
27,
37
],
[
37,
38
],
[
27,
39
],
[
39,
40
],
[
39,
41
],
[
41,
42
],
[
42,
43
],
[
42,
44
],
[
41,
45
],
[
45,
46
],
[
45,
47
],
[
41,
49
],
[
49,
50
],
[
49,
51
],
[
41,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
41,
56
],
[
56,
57
],
[
56,
58
],
[
39,
59
],
[
59,
60
],
[
27,
61
],
[
61,
62
],
[
61,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
67,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
63,
74
],
[
74,
75
],
[
75,
76
],
[
75,
77
],
[
77,
78
],
[
74,
79
],
[
63,
80
],
[
80,
81
],
[
61,
82
],
[
82,
83
],
[
27,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
86,
93
],
[
93,
94
],
[
94,
95
],
[
94,
96
],
[
93,
97
],
[
97,
98
],
[
97,
99
],
[
86,
100
],
[
100,
101
],
[
86,
102
],
[
102,
103
],
[
27,
104
],
[
104,
105
],
[
104,
106
],
[
106,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
0,
111
],
[
111,
112
],
[
111,
113
],
[
113,
114
],
[
113,
115
],
[
115,
116
],
[
116,
117
],
[
116,
118
],
[
115,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
122,
123
],
[
115,
124
],
[
124,
125
],
[
124,
126
],
[
126,
127
],
[
127,
128
],
[
115,
129
],
[
129,
130
],
[
129,
131
],
[
115,
132
],
[
132,
133
],
[
132,
134
],
[
115,
135
],
[
135,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
135,
140
],
[
140,
141
],
[
140,
142
],
[
135,
143
],
[
143,
144
],
[
144,
145
],
[
135,
146
],
[
147,
147
],
[
147,
148
],
[
148,
149
],
[
149,
150
],
[
148,
151
],
[
115,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
152,
157
],
[
157,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
161,
162
],
[
157,
163
],
[
163,
164
],
[
163,
165
],
[
165,
166
],
[
166,
167
],
[
165,
168
],
[
165,
169
],
[
169,
170
],
[
169,
171
],
[
157,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
172,
176
],
[
157,
177
],
[
177,
178
],
[
177,
179
],
[
157,
180
],
[
180,
181
],
[
181,
182
],
[
182,
183
],
[
182,
184
],
[
181,
185
],
[
180,
186
],
[
186,
187
],
[
187,
188
],
[
188,
189
],
[
187,
190
],
[
180,
191
],
[
191,
192
],
[
192,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
192,
197
],
[
198,
198
],
[
198,
199
],
[
199,
200
],
[
199,
201
],
[
198,
202
],
[
198,
203
],
[
113,
204
],
[
204,
205
]
] | [
"import java.util.Scanner;\n\nclass Process{\n\tint time;\n\tString name;\n\tpublic Process(String name,int time){\n\t\tthis.time = time;\n\t\tthis.name = name;\n\t}\n}\n\nclass Queue{\n\tprivate Process[] queArray;\n\tprivate int front;\n\tprivate int rear;\n\tprivate int maxSize;\n\tprivate int nItems;\n\t\n\tpublic Queue(int size){\n\t\tmaxSize = size;\n\t\tqueArray = new Process[maxSize];\n\t\tfront = 0;\n\t\trear = -1;\n\t\tnItems = 0;\n\t}\n\tpublic void insert(Process p){\n\t\tif(rear == maxSize -1) rear = -1;\n\t\tqueArray[++rear] = p;\n\t\tnItems++;\n\t}\n\tpublic Process remove(){\n\t\tProcess temp = queArray[front++];\n\t\tif(front == maxSize) front = 0;\n\t\tnItems--;\n\t\t\treturn temp;\n\t}\n\tpublic boolean isEmpty(){\n\t\t//return (rear+1==front || (front+maxSize-1==rear));\n\t\treturn (nItems == 0);\n\t}\n}\n\n class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue que = new Queue(n);\n\t\tint finTime = 0;\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}\n\t\t\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess remove = que.remove();\n\t\t\tint c = Math.min(q, remove.time);\n\t\t\tremove.time -= c;\n\t\t\tfinTime += c;\n\t\t\tif(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}\n\t}\n\n\t}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"class Process{\n\tint time;\n\tString name;\n\tpublic Process(String name,int time){\n\t\tthis.time = time;\n\t\tthis.name = name;\n\t}\n}",
"Process",
"int time;",
"time",
"String name;",
"name",
"public Process(String name,int time){\n\t\tthis.time = time;\n\t\tthis.name = name;\n\t}",
"Process",
"{\n\t\tthis.time = time;\n\t\tthis.name = name;\n\t}",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"String name",
"name",
"int time",
"time",
"class Queue{\n\tprivate Process[] queArray;\n\tprivate int front;\n\tprivate int rear;\n\tprivate int maxSize;\n\tprivate int nItems;\n\t\n\tpublic Queue(int size){\n\t\tmaxSize = size;\n\t\tqueArray = new Process[maxSize];\n\t\tfront = 0;\n\t\trear = -1;\n\t\tnItems = 0;\n\t}\n\tpublic void insert(Process p){\n\t\tif(rear == maxSize -1) rear = -1;\n\t\tqueArray[++rear] = p;\n\t\tnItems++;\n\t}\n\tpublic Process remove(){\n\t\tProcess temp = queArray[front++];\n\t\tif(front == maxSize) front = 0;\n\t\tnItems--;\n\t\t\treturn temp;\n\t}\n\tpublic boolean isEmpty(){\n\t\t//return (rear+1==front || (front+maxSize-1==rear));\n\t\treturn (nItems == 0);\n\t}\n}",
"Queue",
"private Process[] queArray;",
"queArray",
"private int front;",
"front",
"private int rear;",
"rear",
"private int maxSize;",
"maxSize",
"private int nItems;",
"nItems",
"public Queue(int size){\n\t\tmaxSize = size;\n\t\tqueArray = new Process[maxSize];\n\t\tfront = 0;\n\t\trear = -1;\n\t\tnItems = 0;\n\t}",
"Queue",
"{\n\t\tmaxSize = size;\n\t\tqueArray = new Process[maxSize];\n\t\tfront = 0;\n\t\trear = -1;\n\t\tnItems = 0;\n\t}",
"maxSize = size",
"maxSize",
"size",
"queArray = new Process[maxSize]",
"queArray",
"new Process[maxSize]",
"maxSize",
"front = 0",
"front",
"0",
"rear = -1",
"rear",
"-1",
"1",
"nItems = 0",
"nItems",
"0",
"int size",
"size",
"public void insert(Process p){\n\t\tif(rear == maxSize -1) rear = -1;\n\t\tqueArray[++rear] = p;\n\t\tnItems++;\n\t}",
"insert",
"{\n\t\tif(rear == maxSize -1) rear = -1;\n\t\tqueArray[++rear] = p;\n\t\tnItems++;\n\t}",
"if(rear == maxSize -1) rear = -1;",
"rear == maxSize -1",
"rear",
"maxSize -1",
"maxSize",
"1",
"rear = -1",
"rear",
"-1",
"1",
"queArray[++rear] = p",
"queArray[++rear]",
"queArray",
"++rear",
"rear",
"p",
"nItems++",
"nItems",
"Process p",
"p",
"public Process remove(){\n\t\tProcess temp = queArray[front++];\n\t\tif(front == maxSize) front = 0;\n\t\tnItems--;\n\t\t\treturn temp;\n\t}",
"remove",
"{\n\t\tProcess temp = queArray[front++];\n\t\tif(front == maxSize) front = 0;\n\t\tnItems--;\n\t\t\treturn temp;\n\t}",
"Process temp = queArray[front++];",
"temp",
"queArray[front++]",
"queArray",
"front++",
"front",
"if(front == maxSize) front = 0;",
"front == maxSize",
"front",
"maxSize",
"front = 0",
"front",
"0",
"nItems--",
"nItems",
"return temp;",
"temp",
"public boolean isEmpty(){\n\t\t//return (rear+1==front || (front+maxSize-1==rear));\n\t\treturn (nItems == 0);\n\t}",
"isEmpty",
"{\n\t\t//return (rear+1==front || (front+maxSize-1==rear));\n\t\treturn (nItems == 0);\n\t}",
"return (nItems == 0);",
"(nItems == 0)",
"nItems",
"0",
"class Main{\n\tpublic static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue que = new Queue(n);\n\t\tint finTime = 0;\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}\n\t\t\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess remove = que.remove();\n\t\t\tint c = Math.min(q, remove.time);\n\t\t\tremove.time -= c;\n\t\t\tfinTime += c;\n\t\t\tif(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}\n\t}\n\n\t}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue que = new Queue(n);\n\t\tint finTime = 0;\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}\n\t\t\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess remove = que.remove();\n\t\t\tint c = Math.min(q, remove.time);\n\t\t\tremove.time -= c;\n\t\t\tfinTime += c;\n\t\t\tif(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}\n\t}\n\n\t}",
"main",
"{\n\t\tScanner in = new Scanner(System.in);\n\t\tint n = in.nextInt();\n\t\tint q = in.nextInt();\n\t\tQueue que = new Queue(n);\n\t\tint finTime = 0;\n\t\tfor(int i = 0;i<n;i++){\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}\n\t\t\n\t\twhile(!que.isEmpty()){\n\t\t\tProcess remove = que.remove();\n\t\t\tint c = Math.min(q, remove.time);\n\t\t\tremove.time -= c;\n\t\t\tfinTime += c;\n\t\t\tif(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}\n\t}\n\n\t}",
"Scanner in = new Scanner(System.in);",
"in",
"new Scanner(System.in)",
"int n = in.nextInt();",
"n",
"in.nextInt()",
"in.nextInt",
"in",
"int q = in.nextInt();",
"q",
"in.nextInt()",
"in.nextInt",
"in",
"Queue que = new Queue(n);",
"que",
"new Queue(n)",
"int finTime = 0;",
"finTime",
"0",
"for(int i = 0;i<n;i++){\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i<n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}",
"{\n\t\t\tque.insert(new Process(in.next(),in.nextInt()) );\n\t\t}",
"que.insert(new Process(in.next(),in.nextInt()) )",
"que.insert",
"que",
"new Process(in.next(),in.nextInt())",
"while(!que.isEmpty()){\n\t\t\tProcess remove = que.remove();\n\t\t\tint c = Math.min(q, remove.time);\n\t\t\tremove.time -= c;\n\t\t\tfinTime += c;\n\t\t\tif(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}\n\t}",
"!que.isEmpty()",
"que.isEmpty()",
"que.isEmpty",
"que",
"{\n\t\t\tProcess remove = que.remove();\n\t\t\tint c = Math.min(q, remove.time);\n\t\t\tremove.time -= c;\n\t\t\tfinTime += c;\n\t\t\tif(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}\n\t}",
"Process remove = que.remove();",
"remove",
"que.remove()",
"que.remove",
"que",
"int c = Math.min(q, remove.time);",
"c",
"Math.min(q, remove.time)",
"Math.min",
"Math",
"q",
"remove.time",
"remove",
"remove.time",
"remove.time -= c",
"remove.time",
"remove",
"remove.time",
"c",
"finTime += c",
"finTime",
"c",
"if(remove.time>0){\n\t\t\t\tque.insert(remove);\n\t\t\t}else{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}",
"remove.time>0",
"remove.time",
"remove",
"remove.time",
"0",
"{\n\t\t\t\tque.insert(remove);\n\t\t\t}",
"que.insert(remove)",
"que.insert",
"que",
"remove",
"{\n\t\t\t\tSystem.out.println(remove.name+ \" \" +finTime);\n\t\t\t}",
"System.out.println(remove.name+ \" \" +finTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"remove.name+ \" \" +finTime",
"remove.name+ \" \" +finTime",
"remove.name",
"remove",
"remove.name",
"\" \"",
"finTime",
"String[] args",
"args"
] | import java.util.Scanner;
class Process{
int time;
String name;
public Process(String name,int time){
this.time = time;
this.name = name;
}
}
class Queue{
private Process[] queArray;
private int front;
private int rear;
private int maxSize;
private int nItems;
public Queue(int size){
maxSize = size;
queArray = new Process[maxSize];
front = 0;
rear = -1;
nItems = 0;
}
public void insert(Process p){
if(rear == maxSize -1) rear = -1;
queArray[++rear] = p;
nItems++;
}
public Process remove(){
Process temp = queArray[front++];
if(front == maxSize) front = 0;
nItems--;
return temp;
}
public boolean isEmpty(){
//return (rear+1==front || (front+maxSize-1==rear));
return (nItems == 0);
}
}
class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int q = in.nextInt();
Queue que = new Queue(n);
int finTime = 0;
for(int i = 0;i<n;i++){
que.insert(new Process(in.next(),in.nextInt()) );
}
while(!que.isEmpty()){
Process remove = que.remove();
int c = Math.min(q, remove.time);
remove.time -= c;
finTime += c;
if(remove.time>0){
que.insert(remove);
}else{
System.out.println(remove.name+ " " +finTime);
}
}
}
} |
[
7,
15,
13,
17,
6,
13,
41,
13,
17,
12,
13,
30,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
41,
13,
18,
13,
13,
14,
40,
2,
2,
13,
13,
17,
30,
4,
18,
13,
13,
0,
18,
13,
13,
2,
13,
13,
0,
13,
13,
9,
30,
4,
18,
18,
13,
13,
17,
18,
13,
13,
2,
13,
13,
0,
13,
13,
23,
13,
23,
13,
23,
13,
12,
13,
30,
41,
13,
20,
41,
13,
41,
13,
41,
13,
20,
0,
13,
4,
18,
13,
41,
13,
20,
13,
0,
13,
4,
18,
13,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
18,
13,
13,
20,
0,
18,
18,
13,
13,
13,
4,
18,
13,
0,
18,
18,
13,
13,
13,
4,
18,
13,
4,
18,
13,
18,
13,
13,
4,
13,
13,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
6,
13,
41,
13,
41,
13,
17,
41,
13,
20,
13,
12,
13,
30,
29,
2,
13,
2,
2,
13,
17,
13,
12,
13,
30,
29,
2,
13,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
0,
18,
13,
13,
13,
14,
2,
40,
13,
13,
0,
13,
17,
29,
17,
23,
13,
12,
13,
30,
14,
4,
13,
30,
37,
20,
41,
13,
18,
13,
13,
14,
2,
40,
13,
13,
0,
13,
17,
29,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
238,
5
],
[
238,
6
],
[
6,
7
],
[
6,
8
],
[
238,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
16,
17
],
[
17,
18
],
[
18,
19
],
[
15,
20
],
[
20,
21
],
[
21,
22
],
[
21,
23
],
[
23,
24
],
[
24,
25
],
[
20,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
28,
30
],
[
20,
31
],
[
31,
32
],
[
32,
33
],
[
33,
34
],
[
34,
35
],
[
34,
36
],
[
33,
37
],
[
31,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
39,
42
],
[
38,
43
],
[
43,
44
],
[
44,
45
],
[
44,
46
],
[
43,
47
],
[
47,
48
],
[
47,
49
],
[
38,
50
],
[
50,
51
],
[
50,
52
],
[
38,
53
],
[
31,
54
],
[
54,
55
],
[
55,
56
],
[
56,
57
],
[
57,
58
],
[
57,
59
],
[
55,
60
],
[
55,
61
],
[
61,
62
],
[
61,
63
],
[
55,
64
],
[
64,
65
],
[
64,
66
],
[
54,
67
],
[
67,
68
],
[
67,
69
],
[
9,
70
],
[
70,
71
],
[
9,
72
],
[
72,
73
],
[
9,
74
],
[
74,
75
],
[
238,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
79,
81
],
[
78,
82
],
[
82,
83
],
[
78,
84
],
[
84,
85
],
[
78,
86
],
[
86,
87
],
[
86,
88
],
[
78,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
78,
94
],
[
94,
95
],
[
94,
96
],
[
78,
98
],
[
98,
99
],
[
98,
100
],
[
100,
101
],
[
101,
102
],
[
78,
103
],
[
103,
104
],
[
104,
105
],
[
105,
106
],
[
105,
107
],
[
103,
108
],
[
108,
109
],
[
108,
110
],
[
103,
111
],
[
111,
112
],
[
112,
113
],
[
103,
114
],
[
115,
115
],
[
115,
116
],
[
116,
117
],
[
117,
118
],
[
117,
119
],
[
116,
120
],
[
115,
121
],
[
121,
122
],
[
122,
123
],
[
123,
124
],
[
123,
125
],
[
122,
126
],
[
121,
127
],
[
127,
128
],
[
128,
129
],
[
115,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
115,
139
],
[
139,
140
],
[
140,
141
],
[
139,
142
],
[
142,
143
],
[
142,
144
],
[
78,
145
],
[
145,
146
],
[
145,
147
],
[
145,
148
],
[
145,
149
],
[
76,
150
],
[
150,
151
],
[
238,
152
],
[
152,
153
],
[
152,
154
],
[
154,
155
],
[
152,
156
],
[
156,
157
],
[
238,
158
],
[
158,
159
],
[
158,
160
],
[
160,
161
],
[
158,
162
],
[
162,
163
],
[
162,
164
],
[
158,
165
],
[
165,
166
],
[
165,
167
],
[
158,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
172,
173
],
[
173,
174
],
[
173,
175
],
[
175,
176
],
[
176,
177
],
[
176,
178
],
[
175,
179
],
[
158,
180
],
[
180,
181
],
[
180,
182
],
[
182,
183
],
[
183,
184
],
[
184,
185
],
[
184,
186
],
[
158,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
190,
193
],
[
193,
194
],
[
194,
195
],
[
189,
196
],
[
196,
197
],
[
197,
198
],
[
197,
199
],
[
196,
200
],
[
189,
201
],
[
201,
202
],
[
202,
203
],
[
203,
204
],
[
202,
205
],
[
201,
206
],
[
206,
207
],
[
206,
208
],
[
189,
209
],
[
209,
210
],
[
187,
211
],
[
211,
212
],
[
158,
213
],
[
213,
214
],
[
213,
215
],
[
215,
216
],
[
216,
217
],
[
217,
218
],
[
216,
219
],
[
219,
220
],
[
220,
221
],
[
215,
222
],
[
222,
223
],
[
222,
224
],
[
224,
225
],
[
224,
226
],
[
215,
227
],
[
227,
228
],
[
228,
229
],
[
229,
230
],
[
228,
231
],
[
227,
232
],
[
232,
233
],
[
232,
234
],
[
215,
235
],
[
235,
236
],
[
0,
237
],
[
237,
238
],
[
237,
239
]
] | [
"import java.util.Scanner;\n\npublic class Main {\n public static int MAX = 100001;\n public static class Task{\n String name;\n int t;\n }\n public static class MyQueue {\n int head, tail = 0;\n Task[] a = new Task[MAX];\n public boolean isFull(){\n return head == (tail + 1) % MAX;\n }\n public boolean isEmpty(){\n return head == tail;\n }\n public boolean enqueue(Task s){\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }\n public Task dequeue(){\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }\n }\n public static void startSchedule(MyQueue myQueue, int q, Task[] tasks){\n int countTime = 0;\n while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }\n }\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int n,q;\n MyQueue myQueue = new MyQueue();\n n = scanner.nextInt();\n Task[] tasks = new Task[n];\n q = scanner.nextInt();\n for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }\n startSchedule(myQueue, q, tasks);\n }\n}\n",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n public static int MAX = 100001;\n public static class Task{\n String name;\n int t;\n }\n public static class MyQueue {\n int head, tail = 0;\n Task[] a = new Task[MAX];\n public boolean isFull(){\n return head == (tail + 1) % MAX;\n }\n public boolean isEmpty(){\n return head == tail;\n }\n public boolean enqueue(Task s){\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }\n public Task dequeue(){\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }\n }\n public static void startSchedule(MyQueue myQueue, int q, Task[] tasks){\n int countTime = 0;\n while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }\n }\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int n,q;\n MyQueue myQueue = new MyQueue();\n n = scanner.nextInt();\n Task[] tasks = new Task[n];\n q = scanner.nextInt();\n for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }\n startSchedule(myQueue, q, tasks);\n }\n}",
"Main",
"public static int MAX = 100001;",
"MAX",
"100001",
"public static void startSchedule(MyQueue myQueue, int q, Task[] tasks){\n int countTime = 0;\n while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }\n }",
"startSchedule",
"{\n int countTime = 0;\n while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }\n }",
"int countTime = 0;",
"countTime",
"0",
"while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }",
"!myQueue.isEmpty()",
"myQueue.isEmpty()",
"myQueue.isEmpty",
"myQueue",
"{\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }",
"Task task = myQueue.dequeue();",
"task",
"myQueue.dequeue()",
"myQueue.dequeue",
"myQueue",
"int value = task.t;",
"value",
"task.t",
"task",
"task.t",
"if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }",
"!(value - q <= 0)",
"(value - q <= 0)",
"value - q",
"value",
"q",
"0",
"{\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }",
"myQueue.enqueue(task)",
"myQueue.enqueue",
"myQueue",
"task",
"task.t = value - q",
"task.t",
"task",
"task.t",
"value - q",
"value",
"q",
"countTime += q",
"countTime",
"q",
"continue;",
"{\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }",
"System.out.printf(\"%s %d\\n\",task.name, countTime + value)",
"System.out.printf",
"System.out",
"System",
"System.out",
"\"%s %d\\n\"",
"task.name",
"task",
"task.name",
"countTime + value",
"countTime",
"value",
"countTime += value",
"countTime",
"value",
"MyQueue myQueue",
"myQueue",
"int q",
"q",
"Task[] tasks",
"tasks",
"public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int n,q;\n MyQueue myQueue = new MyQueue();\n n = scanner.nextInt();\n Task[] tasks = new Task[n];\n q = scanner.nextInt();\n for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }\n startSchedule(myQueue, q, tasks);\n }",
"main",
"{\n Scanner scanner = new Scanner(System.in);\n int n,q;\n MyQueue myQueue = new MyQueue();\n n = scanner.nextInt();\n Task[] tasks = new Task[n];\n q = scanner.nextInt();\n for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }\n startSchedule(myQueue, q, tasks);\n }",
"Scanner scanner = new Scanner(System.in);",
"scanner",
"new Scanner(System.in)",
"int n",
"n",
"q;",
"q",
"MyQueue myQueue = new MyQueue();",
"myQueue",
"new MyQueue()",
"n = scanner.nextInt()",
"n",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"Task[] tasks = new Task[n];",
"tasks",
"new Task[n]",
"n",
"q = scanner.nextInt()",
"q",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }",
"{\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }",
"tasks[i] = new Task()",
"tasks[i]",
"tasks",
"i",
"new Task()",
"tasks[i].name = scanner.next()",
"tasks[i].name",
"tasks[i]",
"tasks",
"i",
"tasks[i].name",
"scanner.next()",
"scanner.next",
"scanner",
"tasks[i].t = scanner.nextInt()",
"tasks[i].t",
"tasks[i]",
"tasks",
"i",
"tasks[i].t",
"scanner.nextInt()",
"scanner.nextInt",
"scanner",
"myQueue.enqueue(tasks[i])",
"myQueue.enqueue",
"myQueue",
"tasks[i]",
"tasks",
"i",
"startSchedule(myQueue, q, tasks)",
"startSchedule",
"myQueue",
"q",
"tasks",
"String[] args",
"args",
"public static class Task{\n String name;\n int t;\n }",
"Task",
"String name;",
"name",
"int t;",
"t",
"public static class MyQueue {\n int head, tail = 0;\n Task[] a = new Task[MAX];\n public boolean isFull(){\n return head == (tail + 1) % MAX;\n }\n public boolean isEmpty(){\n return head == tail;\n }\n public boolean enqueue(Task s){\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }\n public Task dequeue(){\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }\n }",
"MyQueue",
"int head",
"head",
"tail = 0;",
"tail",
"0",
"Task[] a = new Task[MAX];",
"a",
"new Task[MAX]",
"MAX",
"public boolean isFull(){\n return head == (tail + 1) % MAX;\n }",
"isFull",
"{\n return head == (tail + 1) % MAX;\n }",
"return head == (tail + 1) % MAX;",
"head == (tail + 1) % MAX",
"head",
"(tail + 1) % MAX",
"(tail + 1)",
"tail",
"1",
"MAX",
"public boolean isEmpty(){\n return head == tail;\n }",
"isEmpty",
"{\n return head == tail;\n }",
"return head == tail;",
"head == tail",
"head",
"tail",
"public boolean enqueue(Task s){\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }",
"enqueue",
"{\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }",
"if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }",
"isFull()",
"isFull",
"{\n throw new NullPointerException(\"queue is full\");\n }",
"throw new NullPointerException(\"queue is full\");",
"new NullPointerException(\"queue is full\")",
"a[tail] = s",
"a[tail]",
"a",
"tail",
"s",
"if (++tail == MAX) tail = 0;",
"++tail == MAX",
"++tail",
"tail",
"MAX",
"tail = 0",
"tail",
"0",
"return true;",
"true",
"Task s",
"s",
"public Task dequeue(){\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }",
"dequeue",
"{\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }",
"if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }",
"isEmpty()",
"isEmpty",
"{\n throw new NullPointerException(\"queue is empty\");\n }",
"throw new NullPointerException(\"queue is empty\");",
"new NullPointerException(\"queue is empty\")",
"Task s = a[head];",
"s",
"a[head]",
"a",
"head",
"if (++head == MAX) head = 0;",
"++head == MAX",
"++head",
"head",
"MAX",
"head = 0",
"head",
"0",
"return s;",
"s",
"public class Main {\n public static int MAX = 100001;\n public static class Task{\n String name;\n int t;\n }\n public static class MyQueue {\n int head, tail = 0;\n Task[] a = new Task[MAX];\n public boolean isFull(){\n return head == (tail + 1) % MAX;\n }\n public boolean isEmpty(){\n return head == tail;\n }\n public boolean enqueue(Task s){\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }\n public Task dequeue(){\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }\n }\n public static void startSchedule(MyQueue myQueue, int q, Task[] tasks){\n int countTime = 0;\n while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }\n }\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int n,q;\n MyQueue myQueue = new MyQueue();\n n = scanner.nextInt();\n Task[] tasks = new Task[n];\n q = scanner.nextInt();\n for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }\n startSchedule(myQueue, q, tasks);\n }\n}",
"public class Main {\n public static int MAX = 100001;\n public static class Task{\n String name;\n int t;\n }\n public static class MyQueue {\n int head, tail = 0;\n Task[] a = new Task[MAX];\n public boolean isFull(){\n return head == (tail + 1) % MAX;\n }\n public boolean isEmpty(){\n return head == tail;\n }\n public boolean enqueue(Task s){\n if (isFull()) {\n throw new NullPointerException(\"queue is full\");\n }\n a[tail] = s;\n if (++tail == MAX) tail = 0;\n return true;\n }\n public Task dequeue(){\n if (isEmpty()){\n throw new NullPointerException(\"queue is empty\");\n }\n Task s = a[head];\n if (++head == MAX) head = 0;\n return s;\n }\n }\n public static void startSchedule(MyQueue myQueue, int q, Task[] tasks){\n int countTime = 0;\n while (!myQueue.isEmpty()) {\n Task task = myQueue.dequeue();\n int value = task.t;\n if (!(value - q <= 0)){\n myQueue.enqueue(task);\n task.t = value - q;\n countTime += q;\n continue;\n }\n else {\n System.out.printf(\"%s %d\\n\",task.name, countTime + value);\n countTime += value;\n }\n\n }\n }\n public static void main(String[] args){\n Scanner scanner = new Scanner(System.in);\n int n,q;\n MyQueue myQueue = new MyQueue();\n n = scanner.nextInt();\n Task[] tasks = new Task[n];\n q = scanner.nextInt();\n for (int i = 0; i < n; i++){\n tasks[i] = new Task();\n tasks[i].name = scanner.next();\n tasks[i].t = scanner.nextInt();\n myQueue.enqueue(tasks[i]);\n }\n startSchedule(myQueue, q, tasks);\n }\n}",
"Main"
] | import java.util.Scanner;
public class Main {
public static int MAX = 100001;
public static class Task{
String name;
int t;
}
public static class MyQueue {
int head, tail = 0;
Task[] a = new Task[MAX];
public boolean isFull(){
return head == (tail + 1) % MAX;
}
public boolean isEmpty(){
return head == tail;
}
public boolean enqueue(Task s){
if (isFull()) {
throw new NullPointerException("queue is full");
}
a[tail] = s;
if (++tail == MAX) tail = 0;
return true;
}
public Task dequeue(){
if (isEmpty()){
throw new NullPointerException("queue is empty");
}
Task s = a[head];
if (++head == MAX) head = 0;
return s;
}
}
public static void startSchedule(MyQueue myQueue, int q, Task[] tasks){
int countTime = 0;
while (!myQueue.isEmpty()) {
Task task = myQueue.dequeue();
int value = task.t;
if (!(value - q <= 0)){
myQueue.enqueue(task);
task.t = value - q;
countTime += q;
continue;
}
else {
System.out.printf("%s %d\n",task.name, countTime + value);
countTime += value;
}
}
}
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int n,q;
MyQueue myQueue = new MyQueue();
n = scanner.nextInt();
Task[] tasks = new Task[n];
q = scanner.nextInt();
for (int i = 0; i < n; i++){
tasks[i] = new Task();
tasks[i].name = scanner.next();
tasks[i].t = scanner.nextInt();
myQueue.enqueue(tasks[i]);
}
startSchedule(myQueue, q, tasks);
}
}
|
[
7,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
19,
18,
20,
11,
1,
41,
13,
17,
2,
13,
4,
18,
20,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
19,
18,
20,
4,
18,
13,
13,
41,
13,
4,
18,
20,
41,
13,
17,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
14,
2,
13,
18,
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,
2,
18,
13,
13,
13,
4,
18,
13,
13,
0,
13,
13,
23,
13,
6,
13,
41,
13,
41,
13,
41,
13,
12,
13,
30,
0,
13,
20,
17,
0,
13,
40,
17,
0,
13,
40,
17,
12,
13,
30,
14,
2,
13,
17,
0,
13,
40,
17,
40,
13,
0,
18,
13,
13,
13,
23,
13,
12,
13,
30,
14,
2,
13,
17,
0,
13,
40,
17,
40,
13,
41,
13,
18,
13,
13,
0,
18,
13,
13,
17,
29,
13,
12,
13,
30,
29,
2,
18,
36,
13,
18,
36,
13,
6,
13,
41,
13,
41,
13,
12,
13,
30,
0,
18,
36,
13,
13,
0,
18,
36,
13,
13,
23,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
222,
5
],
[
222,
6
],
[
6,
7
],
[
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
],
[
8,
25
],
[
25,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
25,
30
],
[
30,
31
],
[
30,
32
],
[
32,
33
],
[
33,
34
],
[
25,
35
],
[
35,
36
],
[
36,
37
],
[
25,
38
],
[
39,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
42,
43
],
[
43,
44
],
[
44,
45
],
[
45,
46
],
[
42,
47
],
[
39,
48
],
[
48,
49
],
[
48,
50
],
[
50,
51
],
[
51,
52
],
[
39,
53
],
[
53,
54
],
[
54,
55
],
[
53,
56
],
[
8,
57
],
[
57,
58
],
[
57,
59
],
[
59,
60
],
[
60,
61
],
[
8,
62
],
[
62,
63
],
[
62,
64
],
[
8,
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
],
[
77,
78
],
[
77,
79
],
[
79,
80
],
[
79,
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
],
[
76,
100
],
[
100,
101
],
[
101,
102
],
[
102,
103
],
[
102,
104
],
[
101,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
105,
109
],
[
100,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
100,
114
],
[
114,
115
],
[
114,
116
],
[
6,
117
],
[
117,
118
],
[
222,
119
],
[
119,
120
],
[
119,
121
],
[
121,
122
],
[
119,
123
],
[
123,
124
],
[
119,
125
],
[
125,
126
],
[
119,
127
],
[
127,
128
],
[
127,
129
],
[
129,
130
],
[
130,
131
],
[
130,
132
],
[
129,
134
],
[
134,
135
],
[
134,
136
],
[
136,
137
],
[
129,
138
],
[
138,
139
],
[
138,
140
],
[
140,
141
],
[
119,
142
],
[
142,
143
],
[
142,
144
],
[
144,
145
],
[
145,
146
],
[
146,
147
],
[
146,
148
],
[
145,
149
],
[
149,
150
],
[
149,
151
],
[
151,
152
],
[
144,
153
],
[
153,
154
],
[
144,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
142,
160
],
[
160,
161
],
[
119,
162
],
[
162,
163
],
[
162,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
165,
169
],
[
169,
170
],
[
169,
171
],
[
171,
172
],
[
164,
173
],
[
173,
174
],
[
164,
175
],
[
175,
176
],
[
175,
177
],
[
177,
178
],
[
177,
179
],
[
164,
180
],
[
180,
181
],
[
181,
182
],
[
181,
183
],
[
180,
184
],
[
164,
185
],
[
185,
186
],
[
119,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
191,
192
],
[
192,
193
],
[
192,
194
],
[
191,
195
],
[
195,
196
],
[
195,
197
],
[
222,
198
],
[
198,
199
],
[
198,
200
],
[
200,
201
],
[
198,
202
],
[
202,
203
],
[
198,
204
],
[
204,
205
],
[
204,
206
],
[
206,
207
],
[
207,
208
],
[
208,
209
],
[
208,
210
],
[
207,
211
],
[
206,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
204,
217
],
[
217,
218
],
[
204,
219
],
[
219,
220
],
[
0,
221
],
[
221,
222
],
[
221,
223
]
] | [
"import java.util.Scanner;\n\n\npublic class Main{\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString[] one = s.nextLine().split(\" \");\n\t\tQueueImpl qqq = new Main().new QueueImpl();\n\t\tfor(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}\n\n\t\tint quon = new Integer(one[1]).intValue();\n\t\tint totalTime = 0;\n\t\twhile(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic class QueueImpl {\n\t\tProcess[] array;\n\t\tint head;\n\t\tint tail;\n\t\tpublic QueueImpl() {\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}\n\n\t\tpublic void enqueue(Process obj) {\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}\n\n\t\tpublic boolean isEmpty(){\n\t\t\treturn this.head == this.tail;\n\t\t}\n\t}\n\n\tpublic class Process {\n\t\tString name;\n\t\tint time;\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}\n}",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString[] one = s.nextLine().split(\" \");\n\t\tQueueImpl qqq = new Main().new QueueImpl();\n\t\tfor(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}\n\n\t\tint quon = new Integer(one[1]).intValue();\n\t\tint totalTime = 0;\n\t\twhile(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic class QueueImpl {\n\t\tProcess[] array;\n\t\tint head;\n\t\tint tail;\n\t\tpublic QueueImpl() {\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}\n\n\t\tpublic void enqueue(Process obj) {\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}\n\n\t\tpublic boolean isEmpty(){\n\t\t\treturn this.head == this.tail;\n\t\t}\n\t}\n\n\tpublic class Process {\n\t\tString name;\n\t\tint time;\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}\n}",
"Main",
"public static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString[] one = s.nextLine().split(\" \");\n\t\tQueueImpl qqq = new Main().new QueueImpl();\n\t\tfor(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}\n\n\t\tint quon = new Integer(one[1]).intValue();\n\t\tint totalTime = 0;\n\t\twhile(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}\n\t}",
"main",
"{\n\t\tScanner s = new Scanner(System.in);\n\t\tString[] one = s.nextLine().split(\" \");\n\t\tQueueImpl qqq = new Main().new QueueImpl();\n\t\tfor(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}\n\n\t\tint quon = new Integer(one[1]).intValue();\n\t\tint totalTime = 0;\n\t\twhile(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}\n\t}",
"Scanner s = new Scanner(System.in);",
"s",
"new Scanner(System.in)",
"String[] one = s.nextLine().split(\" \");",
"one",
"s.nextLine().split(\" \")",
"s.nextLine().split",
"s.nextLine()",
"s.nextLine",
"s",
"\" \"",
"QueueImpl qqq = new Main().new QueueImpl();",
"qqq",
"new Main().new QueueImpl()",
"new Main()",
"new Main()",
"for(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}",
"int i=0 ;",
"int i=0 ;",
"i",
"0",
"i<new Integer(one[0]).intValue()",
"i",
"new Integer(one[0]).intValue()",
"new Integer(one[0]).intValue",
"new Integer(one[0])",
"i++",
"i++",
"i",
"{\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}",
"{\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}",
"String[] two = s.nextLine().split(\" \");",
"two",
"s.nextLine().split(\" \")",
"s.nextLine().split",
"s.nextLine()",
"s.nextLine",
"s",
"\" \"",
"Process p = new Main().new Process(two[0], new Integer(two[1]).intValue());",
"p",
"new Main().new Process(two[0], new Integer(two[1]).intValue())",
"new Main()",
"new Main()",
"qqq.enqueue(p)",
"qqq.enqueue",
"qqq",
"p",
"int quon = new Integer(one[1]).intValue();",
"quon",
"new Integer(one[1]).intValue()",
"new Integer(one[1]).intValue",
"new Integer(one[1])",
"int totalTime = 0;",
"totalTime",
"0",
"while(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}",
"! qqq.isEmpty()",
"qqq.isEmpty()",
"qqq.isEmpty",
"qqq",
"{\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}",
"Process p = qqq.dequeue();",
"p",
"qqq.dequeue()",
"qqq.dequeue",
"qqq",
"if(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}",
"quon >= p.time",
"quon",
"p.time",
"p",
"p.time",
"{\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}",
"totalTime += p.time",
"totalTime",
"p.time",
"p",
"p.time",
"System.out.println(p.name + \" \" + totalTime)",
"System.out.println",
"System.out",
"System",
"System.out",
"p.name + \" \" + totalTime",
"p.name + \" \" + totalTime",
"p.name",
"p",
"p.name",
"\" \"",
"totalTime",
"{\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}",
"p.time = p.time - quon",
"p.time",
"p",
"p.time",
"p.time - quon",
"p.time",
"p",
"p.time",
"quon",
"qqq.enqueue(p)",
"qqq.enqueue",
"qqq",
"p",
"totalTime += quon",
"totalTime",
"quon",
"String[] args",
"args",
"public class QueueImpl {\n\t\tProcess[] array;\n\t\tint head;\n\t\tint tail;\n\t\tpublic QueueImpl() {\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}\n\n\t\tpublic void enqueue(Process obj) {\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}\n\n\t\tpublic boolean isEmpty(){\n\t\t\treturn this.head == this.tail;\n\t\t}\n\t}",
"QueueImpl",
"Process[] array;",
"array",
"int head;",
"head",
"int tail;",
"tail",
"public QueueImpl() {\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}",
"QueueImpl",
"{\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}",
"array = new Process[100000]",
"array",
"new Process[100000]",
"100000",
"head = -1",
"head",
"-1",
"1",
"tail = -1",
"tail",
"-1",
"1",
"public void enqueue(Process obj) {\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}",
"enqueue",
"{\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}",
"if(tail == 99999)\n\t\t\t\ttail = -1;",
"tail == 99999",
"tail",
"99999",
"tail = -1",
"tail",
"-1",
"1",
"tail++",
"tail",
"array[tail] = obj",
"array[tail]",
"array",
"tail",
"obj",
"Process obj",
"obj",
"public Process dequeue() {\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}",
"dequeue",
"{\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}",
"if(head == 99999)\n\t\t\t\thead = -1;",
"head == 99999",
"head",
"99999",
"head = -1",
"head",
"-1",
"1",
"head++",
"head",
"Process tmp = array[head];",
"tmp",
"array[head]",
"array",
"head",
"array[head] = null",
"array[head]",
"array",
"head",
"null",
"return tmp;",
"tmp",
"public boolean isEmpty(){\n\t\t\treturn this.head == this.tail;\n\t\t}",
"isEmpty",
"{\n\t\t\treturn this.head == this.tail;\n\t\t}",
"return this.head == this.tail;",
"this.head == this.tail",
"this.head",
"this",
"this.head",
"this.tail",
"this",
"this.tail",
"public class Process {\n\t\tString name;\n\t\tint time;\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}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"Process",
"{\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString[] one = s.nextLine().split(\" \");\n\t\tQueueImpl qqq = new Main().new QueueImpl();\n\t\tfor(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}\n\n\t\tint quon = new Integer(one[1]).intValue();\n\t\tint totalTime = 0;\n\t\twhile(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic class QueueImpl {\n\t\tProcess[] array;\n\t\tint head;\n\t\tint tail;\n\t\tpublic QueueImpl() {\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}\n\n\t\tpublic void enqueue(Process obj) {\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}\n\n\t\tpublic boolean isEmpty(){\n\t\t\treturn this.head == this.tail;\n\t\t}\n\t}\n\n\tpublic class Process {\n\t\tString name;\n\t\tint time;\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}\n}",
"public class Main{\n\n\tpublic static void main(String[] args) {\n\t\tScanner s = new Scanner(System.in);\n\t\tString[] one = s.nextLine().split(\" \");\n\t\tQueueImpl qqq = new Main().new QueueImpl();\n\t\tfor(int i=0 ; i<new Integer(one[0]).intValue() ; i++){\n\t\t\tString[] two = s.nextLine().split(\" \");\n\t\t\tProcess p = new Main().new Process(two[0], new Integer(two[1]).intValue());\n\t\t\tqqq.enqueue(p);\n\t\t}\n\n\t\tint quon = new Integer(one[1]).intValue();\n\t\tint totalTime = 0;\n\t\twhile(! qqq.isEmpty()) {\n\t\t\tProcess p = qqq.dequeue();\n\t\t\tif(quon >= p.time) {\n\t\t\t\ttotalTime += p.time;\n\t\t\t\tSystem.out.println(p.name + \" \" + totalTime);\n\t\t\t}else {\n\t\t\t\tp.time = p.time - quon;\n\t\t\t\tqqq.enqueue(p);\n\t\t\t\ttotalTime += quon;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic class QueueImpl {\n\t\tProcess[] array;\n\t\tint head;\n\t\tint tail;\n\t\tpublic QueueImpl() {\n\t\t\tarray = new Process[100000];\n\t\t\thead = -1;\n\t\t\ttail = -1;\n\t\t}\n\n\t\tpublic void enqueue(Process obj) {\n\t\t\tif(tail == 99999)\n\t\t\t\ttail = -1;\n\t\t\ttail++;\n\t\t\tarray[tail] = obj;\n\t\t}\n\n\t\tpublic Process dequeue() {\n\t\t\tif(head == 99999)\n\t\t\t\thead = -1;\n\t\t\thead++;\n\t\t\tProcess tmp = array[head];\n\t\t\tarray[head] = null;\n\t\t\treturn tmp;\n\t\t}\n\n\t\tpublic boolean isEmpty(){\n\t\t\treturn this.head == this.tail;\n\t\t}\n\t}\n\n\tpublic class Process {\n\t\tString name;\n\t\tint time;\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}\n}",
"Main"
] | import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String[] one = s.nextLine().split(" ");
QueueImpl qqq = new Main().new QueueImpl();
for(int i=0 ; i<new Integer(one[0]).intValue() ; i++){
String[] two = s.nextLine().split(" ");
Process p = new Main().new Process(two[0], new Integer(two[1]).intValue());
qqq.enqueue(p);
}
int quon = new Integer(one[1]).intValue();
int totalTime = 0;
while(! qqq.isEmpty()) {
Process p = qqq.dequeue();
if(quon >= p.time) {
totalTime += p.time;
System.out.println(p.name + " " + totalTime);
}else {
p.time = p.time - quon;
qqq.enqueue(p);
totalTime += quon;
}
}
}
public class QueueImpl {
Process[] array;
int head;
int tail;
public QueueImpl() {
array = new Process[100000];
head = -1;
tail = -1;
}
public void enqueue(Process obj) {
if(tail == 99999)
tail = -1;
tail++;
array[tail] = obj;
}
public Process dequeue() {
if(head == 99999)
head = -1;
head++;
Process tmp = array[head];
array[head] = null;
return tmp;
}
public boolean isEmpty(){
return this.head == this.tail;
}
}
public class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
} |
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
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,
4,
18,
13,
41,
13,
4,
18,
13,
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,
13,
2,
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,
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,
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
],
[
166,
14
],
[
166,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
18,
20
],
[
17,
21
],
[
21,
22
],
[
21,
23
],
[
17,
24
],
[
24,
25
],
[
24,
26
],
[
26,
27
],
[
27,
28
],
[
17,
29
],
[
29,
30
],
[
29,
31
],
[
31,
32
],
[
32,
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
],
[
57,
59
],
[
46,
60
],
[
60,
61
],
[
61,
62
],
[
60,
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
],
[
73,
84
],
[
84,
85
],
[
85,
86
],
[
85,
87
],
[
84,
88
],
[
88,
89
],
[
89,
90
],
[
89,
91
],
[
88,
92
],
[
92,
93
],
[
93,
94
],
[
92,
95
],
[
95,
96
],
[
95,
97
],
[
88,
98
],
[
98,
99
],
[
99,
100
],
[
98,
101
],
[
84,
102
],
[
102,
103
],
[
103,
104
],
[
103,
105
],
[
105,
106
],
[
106,
107
],
[
102,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
110,
112
],
[
108,
113
],
[
114,
114
],
[
114,
115
],
[
115,
116
],
[
116,
117
],
[
114,
118
],
[
114,
119
],
[
15,
120
],
[
120,
121
],
[
166,
122
],
[
122,
123
],
[
122,
124
],
[
124,
125
],
[
122,
126
],
[
126,
127
],
[
122,
128
],
[
128,
129
],
[
128,
130
],
[
130,
131
],
[
131,
132
],
[
132,
133
],
[
132,
134
],
[
131,
135
],
[
130,
136
],
[
136,
137
],
[
137,
138
],
[
137,
139
],
[
136,
140
],
[
128,
141
],
[
141,
142
],
[
128,
143
],
[
143,
144
],
[
122,
145
],
[
145,
146
],
[
145,
147
],
[
147,
148
],
[
148,
149
],
[
122,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
154,
156
],
[
153,
157
],
[
150,
158
],
[
158,
159
],
[
122,
160
],
[
160,
161
],
[
160,
162
],
[
162,
163
],
[
163,
164
],
[
0,
165
],
[
165,
166
],
[
165,
167
]
] | [
"import java.io.IOException;\nimport java.util.ArrayDeque;\nimport java.util.Queue;\nimport java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tQueue<DataS> queue = new ArrayDeque<>();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class DataS{\n\t\tprivate String name;\n\t\tprivate int time;\n\t\tpublic DataS(String name , int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn time;\n\t\t}\n\t}\n\n}\n",
"import java.io.IOException;",
"IOException",
"java.io",
"import java.util.ArrayDeque;",
"ArrayDeque",
"java.util",
"import java.util.Queue;",
"Queue",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tQueue<DataS> queue = new ArrayDeque<>();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class DataS{\n\t\tprivate String name;\n\t\tprivate int time;\n\t\tpublic DataS(String name , int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"Main",
"public static void main(String[] args) throws IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tQueue<DataS> queue = new ArrayDeque<>();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}\n\n\t}",
"main",
"{\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tQueue<DataS> queue = new ArrayDeque<>();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}\n\n\t}",
"Scanner scan = new Scanner(System.in);",
"scan",
"new Scanner(System.in)",
"Queue<DataS> queue = new ArrayDeque<>();",
"queue",
"new ArrayDeque<>()",
"int n = scan.nextInt();",
"n",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int q = scan.nextInt();",
"q",
"scan.nextInt()",
"scan.nextInt",
"scan",
"for (int i = 0; i < n ; i++) {\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}",
"{\n\t\t\tString name = scan.next();\n\t\t\tint time = scan.nextInt();\n\t\t\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}",
"String name = scan.next();",
"name",
"scan.next()",
"scan.next",
"scan",
"int time = scan.nextInt();",
"time",
"scan.nextInt()",
"scan.nextInt",
"scan",
"DataS dataS = new DataS( name, time );",
"dataS",
"new DataS( name, time )",
"queue.add(dataS)",
"queue.add",
"queue",
"dataS",
"int time = 0;",
"time",
"0",
"while(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}",
"queue.size() != 0",
"queue.size()",
"queue.size",
"queue",
"0",
"{\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}",
"DataS dataS = queue.poll();",
"dataS",
"queue.poll()",
"queue.poll",
"queue",
"int dataTime = dataS.getTime();",
"dataTime",
"dataS.getTime()",
"dataS.getTime",
"dataS",
"if(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}",
"dataTime > q",
"dataTime",
"q",
"{\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}",
"time += q",
"time",
"q",
"dataS.setTime(dataTime - q)",
"dataS.setTime",
"dataS",
"dataTime - q",
"dataTime",
"q",
"queue.add(dataS)",
"queue.add",
"queue",
"dataS",
"{\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}",
"time += dataS.getTime()",
"time",
"dataS.getTime()",
"dataS.getTime",
"dataS",
"System.out.println(dataS.getName() + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"dataS.getName() + \" \" + time",
"dataS.getName() + \" \" + time",
"dataS.getName()",
"dataS.getName",
"dataS",
"\" \"",
"time",
"String[] args",
"args",
"static class DataS{\n\t\tprivate String name;\n\t\tprivate int time;\n\t\tpublic DataS(String name , int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn time;\n\t\t}\n\t}",
"DataS",
"private String name;",
"name",
"private int time;",
"time",
"public DataS(String name , int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}",
"DataS",
"{\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 String getName() {\n\t\t\treturn name;\n\t\t}",
"getName",
"{\n\t\t\treturn name;\n\t\t}",
"return name;",
"name",
"public void setTime(int 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 int getTime() {\n\t\t\treturn time;\n\t\t}",
"getTime",
"{\n\t\t\treturn time;\n\t\t}",
"return time;",
"time",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tQueue<DataS> queue = new ArrayDeque<>();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class DataS{\n\t\tprivate String name;\n\t\tprivate int time;\n\t\tpublic DataS(String name , int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"public class Main {\n\tpublic static void main(String[] args) throws IOException {\n\n\t\tScanner scan = new Scanner(System.in);\n\n\t\tQueue<DataS> queue = new ArrayDeque<>();\n\t\tint n = scan.nextInt();\n\t\tint q = scan.nextInt();\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\tDataS dataS = new DataS( name, time );\n\t\t\tqueue.add(dataS);\n\t\t}\n\n\t\tint time = 0;\n\t\twhile(queue.size() != 0) {\n\t\t\tDataS dataS = queue.poll();\n\t\t\tint dataTime = dataS.getTime();\n\t\t\tif(dataTime > q) {\n\t\t\t\ttime += q;\n\t\t\t\tdataS.setTime(dataTime - q);\n\t\t\t\tqueue.add(dataS);\n\t\t\t}else {\n\t\t\t\ttime += dataS.getTime();\n\t\t\t\tSystem.out.println(dataS.getName() + \" \" + time);\n\t\t\t}\n\t\t}\n\n\t}\n\n\tstatic class DataS{\n\t\tprivate String name;\n\t\tprivate int time;\n\t\tpublic DataS(String name , int time) {\n\t\t\tthis.name = name;\n\t\t\tthis.time = time;\n\t\t}\n\t\tpublic String getName() {\n\t\t\treturn name;\n\t\t}\n\n\t\tpublic void setTime(int time) {\n\t\t\tthis.time = time;\n\t\t}\n\n\t\tpublic int getTime() {\n\t\t\treturn time;\n\t\t}\n\t}\n\n}",
"Main"
] | import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
Queue<DataS> queue = new ArrayDeque<>();
int n = scan.nextInt();
int q = scan.nextInt();
for (int i = 0; i < n ; i++) {
String name = scan.next();
int time = scan.nextInt();
DataS dataS = new DataS( name, time );
queue.add(dataS);
}
int time = 0;
while(queue.size() != 0) {
DataS dataS = queue.poll();
int dataTime = dataS.getTime();
if(dataTime > q) {
time += q;
dataS.setTime(dataTime - q);
queue.add(dataS);
}else {
time += dataS.getTime();
System.out.println(dataS.getName() + " " + time);
}
}
}
static class DataS{
private String name;
private int time;
public DataS(String name , int time) {
this.name = name;
this.time = time;
}
public String getName() {
return name;
}
public void setTime(int time) {
this.time = time;
}
public int getTime() {
return time;
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
41,
13,
41,
13,
41,
13,
17,
12,
13,
30,
42,
40,
4,
18,
13,
30,
41,
13,
4,
18,
13,
0,
13,
4,
18,
13,
13,
14,
2,
18,
13,
13,
17,
4,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
4,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
4,
18,
13,
18,
13,
17,
0,
13,
20,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
0,
13,
4,
18,
4,
18,
13,
17,
41,
13,
20,
4,
18,
13,
13,
4,
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,
41,
13,
8,
2,
18,
36,
13,
13,
13,
18,
36,
13,
0,
18,
36,
13,
13,
29,
13,
23,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
9,
10
],
[
7,
11
],
[
11,
12
],
[
7,
13
],
[
13,
14
],
[
7,
15
],
[
15,
16
],
[
15,
17
],
[
7,
18
],
[
18,
19
],
[
18,
20
],
[
20,
21
],
[
21,
22
],
[
22,
23
],
[
23,
24
],
[
24,
25
],
[
21,
26
],
[
26,
27
],
[
27,
28
],
[
27,
29
],
[
29,
30
],
[
30,
31
],
[
26,
32
],
[
32,
33
],
[
32,
34
],
[
34,
35
],
[
35,
36
],
[
34,
37
],
[
26,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
40,
42
],
[
39,
43
],
[
38,
44
],
[
44,
45
],
[
45,
46
],
[
44,
47
],
[
38,
48
],
[
48,
49
],
[
49,
50
],
[
50,
51
],
[
50,
52
],
[
48,
53
],
[
54,
54
],
[
54,
55
],
[
55,
56
],
[
55,
57
],
[
54,
58
],
[
54,
59
],
[
7,
60
],
[
60,
61
],
[
60,
62
],
[
62,
63
],
[
63,
64
],
[
63,
65
],
[
62,
66
],
[
66,
67
],
[
66,
68
],
[
68,
69
],
[
69,
70
],
[
70,
71
],
[
71,
72
],
[
68,
73
],
[
62,
74
],
[
74,
75
],
[
74,
76
],
[
76,
77
],
[
77,
78
],
[
76,
79
],
[
79,
80
],
[
79,
81
],
[
62,
82
],
[
82,
83
],
[
82,
84
],
[
84,
85
],
[
85,
86
],
[
84,
87
],
[
87,
88
],
[
87,
89
],
[
62,
90
],
[
90,
91
],
[
90,
92
],
[
62,
93
],
[
93,
94
],
[
94,
95
],
[
95,
96
],
[
95,
97
],
[
93,
98
],
[
98,
99
],
[
98,
100
],
[
93,
101
],
[
101,
102
],
[
102,
103
],
[
93,
104
],
[
105,
105
],
[
105,
106
],
[
106,
107
],
[
106,
108
],
[
108,
109
],
[
109,
110
],
[
110,
111
],
[
111,
112
],
[
108,
113
],
[
105,
114
],
[
114,
115
],
[
114,
116
],
[
105,
117
],
[
117,
118
],
[
118,
119
],
[
117,
120
],
[
62,
121
],
[
121,
122
],
[
60,
123
],
[
123,
124
],
[
7,
125
],
[
125,
126
],
[
125,
127
],
[
127,
128
],
[
125,
129
],
[
129,
130
],
[
125,
131
],
[
131,
132
],
[
131,
133
],
[
133,
134
],
[
134,
135
],
[
135,
136
],
[
135,
137
],
[
134,
138
],
[
133,
139
],
[
139,
140
],
[
140,
141
],
[
140,
142
],
[
139,
143
],
[
131,
144
],
[
144,
145
],
[
131,
146
],
[
146,
147
],
[
125,
148
],
[
148,
149
],
[
148,
150
],
[
150,
151
],
[
151,
152
],
[
151,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
155,
157
],
[
154,
158
],
[
153,
159
],
[
153,
160
],
[
160,
161
],
[
160,
162
],
[
150,
163
],
[
163,
164
],
[
164,
165
],
[
164,
166
],
[
163,
167
],
[
150,
168
],
[
168,
169
],
[
148,
170
],
[
170,
171
]
] | [
"import java.util.*;\nimport java.io.*;\n\nclass Main{\n static ArrayDeque<Elem> dq;\n static int size;\n static int max;\n static int time = 0;\n\n static class Elem{\n String s;\n Integer i;\n public Elem(String s, Integer i){\n this.s = s;\n this.i = i;\n }\n public int minus(int i){\n int j = this.i>=i ? i : this.i;\n this.i -= j;\n return j;\n }\n }\n static void runqueue(){\n while(!dq.isEmpty()){\n Elem e = dq.pollFirst();\n time += e.minus(max);\n\n if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);\n }\n }\n\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 size = Integer.parseInt(line[0]);\n max = Integer.parseInt(line[1]);\n\n dq = new ArrayDeque<>();\n for(int i=0; i<size; i++){\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }\n runqueue();\n }\n}",
"import java.util.*;",
"util.*",
"java",
"import java.io.*;",
"io.*",
"java",
"class Main{\n static ArrayDeque<Elem> dq;\n static int size;\n static int max;\n static int time = 0;\n\n static class Elem{\n String s;\n Integer i;\n public Elem(String s, Integer i){\n this.s = s;\n this.i = i;\n }\n public int minus(int i){\n int j = this.i>=i ? i : this.i;\n this.i -= j;\n return j;\n }\n }\n static void runqueue(){\n while(!dq.isEmpty()){\n Elem e = dq.pollFirst();\n time += e.minus(max);\n\n if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);\n }\n }\n\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 size = Integer.parseInt(line[0]);\n max = Integer.parseInt(line[1]);\n\n dq = new ArrayDeque<>();\n for(int i=0; i<size; i++){\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }\n runqueue();\n }\n}",
"Main",
"static ArrayDeque<Elem> dq;",
"dq",
"static int size;",
"size",
"static int max;",
"max",
"static int time = 0;",
"time",
"0",
"static void runqueue(){\n while(!dq.isEmpty()){\n Elem e = dq.pollFirst();\n time += e.minus(max);\n\n if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);\n }\n }",
"runqueue",
"{\n while(!dq.isEmpty()){\n Elem e = dq.pollFirst();\n time += e.minus(max);\n\n if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);\n }\n }",
"while(!dq.isEmpty()){\n Elem e = dq.pollFirst();\n time += e.minus(max);\n\n if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);\n }",
"!dq.isEmpty()",
"dq.isEmpty()",
"dq.isEmpty",
"dq",
"{\n Elem e = dq.pollFirst();\n time += e.minus(max);\n\n if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);\n }",
"Elem e = dq.pollFirst();",
"e",
"dq.pollFirst()",
"dq.pollFirst",
"dq",
"time += e.minus(max)",
"time",
"e.minus(max)",
"e.minus",
"e",
"max",
"if(e.i>0)\n dq.offerLast(e);\n else\n System.out.println(e.s + \" \" + time);",
"e.i>0",
"e.i",
"e",
"e.i",
"0",
"dq.offerLast(e)",
"dq.offerLast",
"dq",
"e",
"System.out.println(e.s + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"e.s + \" \" + time",
"e.s + \" \" + time",
"e.s",
"e",
"e.s",
"\" \"",
"time",
"public static void main(String[] args) throws IOException{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n size = Integer.parseInt(line[0]);\n max = Integer.parseInt(line[1]);\n\n dq = new ArrayDeque<>();\n for(int i=0; i<size; i++){\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }\n runqueue();\n }",
"main",
"{\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n String[] line = br.readLine().split(\" \");\n size = Integer.parseInt(line[0]);\n max = Integer.parseInt(line[1]);\n\n dq = new ArrayDeque<>();\n for(int i=0; i<size; i++){\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }\n runqueue();\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",
"\" \"",
"size = Integer.parseInt(line[0])",
"size",
"Integer.parseInt(line[0])",
"Integer.parseInt",
"Integer",
"line[0]",
"line",
"0",
"max = Integer.parseInt(line[1])",
"max",
"Integer.parseInt(line[1])",
"Integer.parseInt",
"Integer",
"line[1]",
"line",
"1",
"dq = new ArrayDeque<>()",
"dq",
"new ArrayDeque<>()",
"for(int i=0; i<size; i++){\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }",
"int i=0;",
"int i=0;",
"i",
"0",
"i<size",
"i",
"size",
"i++",
"i++",
"i",
"{\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }",
"{\n line = br.readLine().split(\" \");\n Elem e = new Elem(line[0], Integer.parseInt(line[1]));\n dq.offerLast(e);\n }",
"line = br.readLine().split(\" \")",
"line",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"Elem e = new Elem(line[0], Integer.parseInt(line[1]));",
"e",
"new Elem(line[0], Integer.parseInt(line[1]))",
"dq.offerLast(e)",
"dq.offerLast",
"dq",
"e",
"runqueue()",
"runqueue",
"String[] args",
"args",
"static class Elem{\n String s;\n Integer i;\n public Elem(String s, Integer i){\n this.s = s;\n this.i = i;\n }\n public int minus(int i){\n int j = this.i>=i ? i : this.i;\n this.i -= j;\n return j;\n }\n }",
"Elem",
"String s;",
"s",
"Integer i;",
"i",
"public Elem(String s, Integer i){\n this.s = s;\n this.i = i;\n }",
"Elem",
"{\n this.s = s;\n this.i = i;\n }",
"this.s = s",
"this.s",
"this",
"this.s",
"s",
"this.i = i",
"this.i",
"this",
"this.i",
"i",
"String s",
"s",
"Integer i",
"i",
"public int minus(int i){\n int j = this.i>=i ? i : this.i;\n this.i -= j;\n return j;\n }",
"minus",
"{\n int j = this.i>=i ? i : this.i;\n this.i -= j;\n return j;\n }",
"int j = this.i>=i ? i : this.i;",
"j",
"this.i>=i ? i : this.i",
"this.i>=i",
"this.i",
"this",
"this.i",
"i",
"i",
"this.i",
"this",
"this.i",
"this.i -= j",
"this.i",
"this",
"this.i",
"j",
"return j;",
"j",
"int i",
"i"
] | import java.util.*;
import java.io.*;
class Main{
static ArrayDeque<Elem> dq;
static int size;
static int max;
static int time = 0;
static class Elem{
String s;
Integer i;
public Elem(String s, Integer i){
this.s = s;
this.i = i;
}
public int minus(int i){
int j = this.i>=i ? i : this.i;
this.i -= j;
return j;
}
}
static void runqueue(){
while(!dq.isEmpty()){
Elem e = dq.pollFirst();
time += e.minus(max);
if(e.i>0)
dq.offerLast(e);
else
System.out.println(e.s + " " + time);
}
}
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] line = br.readLine().split(" ");
size = Integer.parseInt(line[0]);
max = Integer.parseInt(line[1]);
dq = new ArrayDeque<>();
for(int i=0; i<size; i++){
line = br.readLine().split(" ");
Elem e = new Elem(line[0], Integer.parseInt(line[1]));
dq.offerLast(e);
}
runqueue();
}
} |
[
7,
15,
13,
17,
15,
13,
17,
6,
13,
12,
13,
30,
41,
13,
20,
41,
13,
4,
18,
13,
41,
13,
4,
18,
13,
41,
13,
17,
41,
13,
20,
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,
0,
13,
2,
13,
13,
4,
18,
18,
13,
13,
2,
2,
13,
17,
13,
30,
0,
13,
2,
13,
13,
0,
13,
2,
13,
13,
4,
18,
13,
13,
4,
18,
13,
13,
23,
13,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
117,
8
],
[
117,
9
],
[
9,
10
],
[
9,
11
],
[
11,
12
],
[
12,
13
],
[
12,
14
],
[
11,
15
],
[
15,
16
],
[
15,
17
],
[
17,
18
],
[
18,
19
],
[
11,
20
],
[
20,
21
],
[
20,
22
],
[
22,
23
],
[
23,
24
],
[
11,
25
],
[
25,
26
],
[
25,
27
],
[
11,
28
],
[
28,
29
],
[
28,
30
],
[
11,
31
],
[
31,
32
],
[
31,
33
],
[
11,
34
],
[
34,
35
],
[
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
],
[
11,
59
],
[
59,
60
],
[
60,
61
],
[
61,
62
],
[
62,
63
],
[
59,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
67,
68
],
[
68,
69
],
[
64,
70
],
[
70,
71
],
[
70,
72
],
[
72,
73
],
[
73,
74
],
[
64,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
75,
79
],
[
79,
80
],
[
80,
81
],
[
80,
82
],
[
82,
83
],
[
82,
84
],
[
79,
85
],
[
85,
86
],
[
86,
87
],
[
87,
88
],
[
87,
89
],
[
85,
90
],
[
91,
91
],
[
91,
92
],
[
91,
93
],
[
91,
94
],
[
75,
95
],
[
95,
96
],
[
96,
97
],
[
96,
98
],
[
98,
99
],
[
98,
100
],
[
95,
101
],
[
101,
102
],
[
101,
103
],
[
103,
104
],
[
103,
105
],
[
95,
106
],
[
106,
107
],
[
107,
108
],
[
106,
109
],
[
95,
110
],
[
110,
111
],
[
111,
112
],
[
110,
113
],
[
9,
114
],
[
114,
115
],
[
0,
116
],
[
116,
117
],
[
116,
118
]
] | [
"import java.util.LinkedList;\nimport java.util.Scanner;\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 clock = scan.nextInt();\n int time = 0;\n LinkedList<String> names = new LinkedList<>();\n LinkedList<Integer> amounts = new LinkedList<>();\n for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }\n while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\n }\n\n }\n}",
"import java.util.LinkedList;",
"LinkedList",
"java.util",
"import java.util.Scanner;",
"Scanner",
"java.util",
"public class Main{\n public static void main(String[] args) {\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int clock = scan.nextInt();\n int time = 0;\n LinkedList<String> names = new LinkedList<>();\n LinkedList<Integer> amounts = new LinkedList<>();\n for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }\n while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\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 clock = scan.nextInt();\n int time = 0;\n LinkedList<String> names = new LinkedList<>();\n LinkedList<Integer> amounts = new LinkedList<>();\n for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }\n while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\n }\n\n }",
"main",
"{\n Scanner scan = new Scanner(System.in);\n int n = scan.nextInt();\n int clock = scan.nextInt();\n int time = 0;\n LinkedList<String> names = new LinkedList<>();\n LinkedList<Integer> amounts = new LinkedList<>();\n for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }\n while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\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 clock = scan.nextInt();",
"clock",
"scan.nextInt()",
"scan.nextInt",
"scan",
"int time = 0;",
"time",
"0",
"LinkedList<String> names = new LinkedList<>();",
"names",
"new LinkedList<>()",
"LinkedList<Integer> amounts = new LinkedList<>();",
"amounts",
"new LinkedList<>()",
"for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }",
"int x =0;",
"int x =0;",
"x",
"0",
"x < n",
"x",
"n",
"x++",
"x++",
"x",
"{\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }",
"{\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }",
"names.add(scan.next())",
"names.add",
"names",
"scan.next()",
"scan.next",
"scan",
"amounts.add(scan.nextInt())",
"amounts.add",
"amounts",
"scan.nextInt()",
"scan.nextInt",
"scan",
"while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\n }",
"!amounts.isEmpty()",
"amounts.isEmpty()",
"amounts.isEmpty",
"amounts",
"{\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\n }",
"String name = names.removeFirst();",
"name",
"names.removeFirst()",
"names.removeFirst",
"names",
"int amount = amounts.removeFirst();",
"amount",
"amounts.removeFirst()",
"amounts.removeFirst",
"amounts",
"if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }",
"amount <= clock",
"amount",
"clock",
"{\n time = time + amount;\n System.out.println(name + \" \" + time);\n }",
"time = time + amount",
"time",
"time + amount",
"time",
"amount",
"System.out.println(name + \" \" + time)",
"System.out.println",
"System.out",
"System",
"System.out",
"name + \" \" + time",
"name + \" \" + time",
"name",
"\" \"",
"time",
"{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }",
"time = time + clock",
"time",
"time + clock",
"time",
"clock",
"amount = amount - clock",
"amount",
"amount - clock",
"amount",
"clock",
"names.add(name)",
"names.add",
"names",
"name",
"amounts.add(amount)",
"amounts.add",
"amounts",
"amount",
"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 clock = scan.nextInt();\n int time = 0;\n LinkedList<String> names = new LinkedList<>();\n LinkedList<Integer> amounts = new LinkedList<>();\n for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }\n while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\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 clock = scan.nextInt();\n int time = 0;\n LinkedList<String> names = new LinkedList<>();\n LinkedList<Integer> amounts = new LinkedList<>();\n for(int x =0; x < n; x++){\n names.add(scan.next());\n amounts.add(scan.nextInt());\n }\n while(!amounts.isEmpty()){\n String name = names.removeFirst();\n int amount = amounts.removeFirst();\n if(amount <= clock){\n time = time + amount;\n System.out.println(name + \" \" + time);\n }\n else{\n time = time + clock;\n amount = amount - clock;\n names.add(name);\n amounts.add(amount);\n }\n\n }\n\n }\n}",
"Main"
] | import java.util.LinkedList;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int clock = scan.nextInt();
int time = 0;
LinkedList<String> names = new LinkedList<>();
LinkedList<Integer> amounts = new LinkedList<>();
for(int x =0; x < n; x++){
names.add(scan.next());
amounts.add(scan.nextInt());
}
while(!amounts.isEmpty()){
String name = names.removeFirst();
int amount = amounts.removeFirst();
if(amount <= clock){
time = time + amount;
System.out.println(name + " " + time);
}
else{
time = time + clock;
amount = amount - clock;
names.add(name);
amounts.add(amount);
}
}
}
}
|
[
7,
15,
13,
17,
15,
13,
17,
15,
13,
17,
6,
13,
41,
13,
17,
41,
13,
17,
41,
13,
20,
17,
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,
17,
11,
1,
41,
13,
17,
2,
13,
13,
1,
40,
13,
30,
30,
41,
13,
4,
18,
4,
18,
13,
17,
41,
13,
18,
13,
17,
41,
13,
4,
18,
13,
18,
13,
17,
41,
13,
20,
4,
13,
13,
42,
2,
13,
13,
30,
41,
13,
4,
13,
14,
2,
18,
13,
13,
13,
30,
0,
18,
13,
13,
13,
0,
13,
13,
4,
13,
13,
30,
0,
13,
18,
13,
13,
4,
18,
18,
13,
13,
2,
2,
18,
13,
13,
17,
13,
23,
13,
12,
13,
30,
14,
2,
2,
2,
13,
17,
18,
13,
13,
13,
30,
4,
18,
18,
13,
13,
17,
29,
0,
18,
13,
13,
13,
0,
13,
2,
2,
13,
17,
18,
13,
13,
23,
13,
12,
13,
30,
41,
13,
17,
14,
2,
13,
13,
30,
4,
18,
18,
13,
13,
17,
30,
0,
13,
18,
13,
13,
0,
13,
2,
2,
13,
17,
18,
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,
10,
6,
13
] | [
[
0,
1
],
[
1,
2
],
[
1,
3
],
[
0,
4
],
[
4,
5
],
[
4,
6
],
[
0,
7
],
[
7,
8
],
[
7,
9
],
[
0,
10
],
[
245,
11
],
[
245,
12
],
[
12,
13
],
[
12,
14
],
[
245,
15
],
[
15,
16
],
[
15,
17
],
[
245,
18
],
[
18,
19
],
[
18,
20
],
[
245,
22
],
[
22,
23
],
[
22,
24
],
[
24,
25
],
[
25,
26
],
[
26,
27
],
[
26,
28
],
[
28,
29
],
[
29,
30
],
[
30,
31
],
[
25,
32
],
[
32,
33
],
[
33,
34
],
[
33,
35
],
[
32,
36
],
[
36,
37
],
[
36,
38
],
[
38,
39
],
[
39,
40
],
[
40,
41
],
[
41,
42
],
[
38,
43
],
[
32,
44
],
[
44,
45
],
[
44,
46
],
[
46,
47
],
[
47,
48
],
[
46,
49
],
[
49,
50
],
[
49,
51
],
[
32,
52
],
[
52,
53
],
[
52,
54
],
[
54,
55
],
[
55,
56
],
[
54,
57
],
[
57,
58
],
[
57,
59
],
[
32,
60
],
[
60,
61
],
[
60,
62
],
[
32,
63
],
[
63,
64
],
[
64,
65
],
[
65,
66
],
[
65,
67
],
[
63,
68
],
[
68,
69
],
[
68,
70
],
[
63,
71
],
[
71,
72
],
[
72,
73
],
[
63,
74
],
[
75,
75
],
[
75,
76
],
[
76,
77
],
[
76,
78
],
[
78,
79
],
[
79,
80
],
[
80,
81
],
[
81,
82
],
[
78,
83
],
[
75,
84
],
[
84,
85
],
[
84,
86
],
[
86,
87
],
[
86,
88
],
[
75,
89
],
[
89,
90
],
[
89,
91
],
[
91,
92
],
[
92,
93
],
[
91,
94
],
[
94,
95
],
[
94,
96
],
[
75,
97
],
[
97,
98
],
[
97,
99
],
[
75,
100
],
[
100,
101
],
[
100,
102
],
[
32,
103
],
[
103,
104
],
[
104,
105
],
[
104,
106
],
[
103,
107
],
[
107,
108
],
[
108,
109
],
[
108,
110
],
[
110,
111
],
[
107,
112
],
[
112,
113
],
[
113,
114
],
[
114,
115
],
[
114,
116
],
[
113,
117
],
[
112,
118
],
[
118,
119
],
[
119,
120
],
[
120,
121
],
[
120,
122
],
[
119,
123
],
[
118,
124
],
[
124,
125
],
[
124,
126
],
[
118,
127
],
[
127,
128
],
[
127,
129
],
[
112,
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
],
[
22,
148
],
[
148,
149
],
[
245,
150
],
[
150,
151
],
[
150,
152
],
[
152,
153
],
[
153,
154
],
[
154,
155
],
[
155,
156
],
[
156,
157
],
[
156,
158
],
[
155,
159
],
[
159,
160
],
[
159,
161
],
[
154,
162
],
[
153,
163
],
[
163,
164
],
[
164,
165
],
[
165,
166
],
[
166,
167
],
[
166,
168
],
[
164,
169
],
[
163,
170
],
[
152,
171
],
[
171,
172
],
[
172,
173
],
[
172,
174
],
[
171,
175
],
[
152,
176
],
[
176,
177
],
[
176,
178
],
[
178,
179
],
[
179,
180
],
[
179,
181
],
[
178,
182
],
[
182,
183
],
[
182,
184
],
[
150,
185
],
[
185,
186
],
[
245,
187
],
[
187,
188
],
[
187,
189
],
[
189,
190
],
[
190,
191
],
[
190,
192
],
[
189,
193
],
[
193,
194
],
[
194,
195
],
[
194,
196
],
[
193,
197
],
[
197,
198
],
[
198,
199
],
[
199,
200
],
[
200,
201
],
[
200,
202
],
[
198,
203
],
[
193,
204
],
[
204,
205
],
[
205,
206
],
[
205,
207
],
[
207,
208
],
[
207,
209
],
[
204,
210
],
[
210,
211
],
[
210,
212
],
[
212,
213
],
[
213,
214
],
[
213,
215
],
[
212,
216
],
[
216,
217
],
[
216,
218
],
[
189,
219
],
[
219,
220
],
[
0,
221
],
[
221,
222
],
[
221,
223
],
[
223,
224
],
[
221,
225
],
[
225,
226
],
[
221,
227
],
[
227,
228
],
[
227,
229
],
[
229,
230
],
[
230,
231
],
[
231,
232
],
[
231,
233
],
[
230,
234
],
[
229,
235
],
[
235,
236
],
[
236,
237
],
[
236,
238
],
[
235,
239
],
[
227,
240
],
[
240,
241
],
[
227,
242
],
[
242,
243
],
[
0,
244
],
[
244,
245
],
[
244,
246
]
] | [
"import java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class Main {\n\tstatic int head = 0;\n\tstatic int tail = 0;\n\tstatic Process[] queue = new Process[100005];\n\n\tpublic static void main(String[] args) {\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n\tstatic void enqueue(Process p) {\n\t\tif ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}\n\t\tqueue[tail] = p;\n\t\ttail = (tail + 1) % queue.length;\n\t}\n\n\tstatic Process dequeue() {\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n}\n\nclass Process {\n\tString name;\n\tint time;\n\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"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\tstatic int head = 0;\n\tstatic int tail = 0;\n\tstatic Process[] queue = new Process[100005];\n\n\tpublic static void main(String[] args) {\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n\tstatic void enqueue(Process p) {\n\t\tif ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}\n\t\tqueue[tail] = p;\n\t\ttail = (tail + 1) % queue.length;\n\t}\n\n\tstatic Process dequeue() {\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n}",
"Main",
"static int head = 0;",
"head",
"0",
"static int tail = 0;",
"tail",
"0",
"static Process[] queue = new Process[100005];",
"queue",
"new Process[100005]",
"100005",
"public static void main(String[] args) {\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}",
"main",
"{\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}",
"try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\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 nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"BufferedReader br = new BufferedReader(new InputStreamReader(System.in))",
"new BufferedReader(new InputStreamReader(System.in))",
"String nq[] = br.readLine().split(\" \");",
"nq",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"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",
"int total = 0;",
"total",
"0",
"for (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}",
"int i = 0;",
"int i = 0;",
"i",
"0",
"i < n",
"i",
"n",
"i++",
"i++",
"i",
"{\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}",
"{\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}",
"String[] tmp = br.readLine().split(\" \");",
"tmp",
"br.readLine().split(\" \")",
"br.readLine().split",
"br.readLine()",
"br.readLine",
"br",
"\" \"",
"String name = tmp[0];",
"name",
"tmp[0]",
"tmp",
"0",
"int time = Integer.parseInt(tmp[1]);",
"time",
"Integer.parseInt(tmp[1])",
"Integer.parseInt",
"Integer",
"tmp[1]",
"tmp",
"1",
"Process p = new Process(name, time);",
"p",
"new Process(name, time)",
"enqueue(p)",
"enqueue",
"p",
"while (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}",
"head != tail",
"head",
"tail",
"{\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}",
"Process cur = dequeue();",
"cur",
"dequeue()",
"dequeue",
"if (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}",
"cur.time > q",
"cur.time",
"cur",
"cur.time",
"q",
"{\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t}",
"cur.time -= q",
"cur.time",
"cur",
"cur.time",
"q",
"total += q",
"total",
"q",
"enqueue(cur)",
"enqueue",
"cur",
"{\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}",
"total += cur.time",
"total",
"cur.time",
"cur",
"cur.time",
"System.out.println(cur.name + \" \" + total)",
"System.out.println",
"System.out",
"System",
"System.out",
"cur.name + \" \" + total",
"cur.name + \" \" + total",
"cur.name",
"cur",
"cur.name",
"\" \"",
"total",
"String[] args",
"args",
"static void enqueue(Process p) {\n\t\tif ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}\n\t\tqueue[tail] = p;\n\t\ttail = (tail + 1) % queue.length;\n\t}",
"enqueue",
"{\n\t\tif ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}\n\t\tqueue[tail] = p;\n\t\ttail = (tail + 1) % queue.length;\n\t}",
"if ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}",
"(tail + 1) % queue.length == head",
"(tail + 1) % queue.length",
"(tail + 1)",
"tail",
"1",
"queue.length",
"queue",
"queue.length",
"head",
"{\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}",
"System.err.println(\"キューが満タンです\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"キューが満タンです\"",
"return;",
"queue[tail] = p",
"queue[tail]",
"queue",
"tail",
"p",
"tail = (tail + 1) % queue.length",
"tail",
"(tail + 1) % queue.length",
"(tail + 1)",
"tail",
"1",
"queue.length",
"queue",
"queue.length",
"Process p",
"p",
"static Process dequeue() {\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}\n\n\t\treturn ret;\n\t}",
"dequeue",
"{\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}\n\n\t\treturn ret;\n\t}",
"Process ret = null;",
"ret",
"null",
"if (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}",
"head == tail",
"head",
"tail",
"{\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t}",
"System.err.println(\"キューが空です\")",
"System.err.println",
"System.err",
"System",
"System.err",
"\"キューが空です\"",
"{\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}",
"ret = queue[head]",
"ret",
"queue[head]",
"queue",
"head",
"head = (head + 1) % queue.length",
"head",
"(head + 1) % queue.length",
"(head + 1)",
"head",
"1",
"queue.length",
"queue",
"queue.length",
"return ret;",
"ret",
"class Process {\n\tString name;\n\tint time;\n\n\tpublic Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}\n}",
"Process",
"String name;",
"name",
"int time;",
"time",
"public Process(String name, int time) {\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"Process",
"{\n\t\tthis.name = name;\n\t\tthis.time = time;\n\t}",
"this.name = name",
"this.name",
"this",
"this.name",
"name",
"this.time = time",
"this.time",
"this",
"this.time",
"time",
"String name",
"name",
"int time",
"time",
"public class Main {\n\tstatic int head = 0;\n\tstatic int tail = 0;\n\tstatic Process[] queue = new Process[100005];\n\n\tpublic static void main(String[] args) {\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n\tstatic void enqueue(Process p) {\n\t\tif ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}\n\t\tqueue[tail] = p;\n\t\ttail = (tail + 1) % queue.length;\n\t}\n\n\tstatic Process dequeue() {\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n}",
"public class Main {\n\tstatic int head = 0;\n\tstatic int tail = 0;\n\tstatic Process[] queue = new Process[100005];\n\n\tpublic static void main(String[] args) {\n\t\ttry (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {\n\t\t\tString nq[] = br.readLine().split(\" \");\n\t\t\tint n = Integer.parseInt(nq[0]);\n\t\t\tint q = Integer.parseInt(nq[1]);\n\t\t\tint total = 0;\n\t\t\tfor (int i = 0; i < n; i++) {\n\t\t\t\tString[] tmp = br.readLine().split(\" \");\n\t\t\t\tString name = tmp[0];\n\t\t\t\tint time = Integer.parseInt(tmp[1]);\n\t\t\t\tProcess p = new Process(name, time);\n\t\t\t\tenqueue(p);\n\t\t\t}\n\t\t\twhile (head != tail) {\n\t\t\t\tProcess cur = dequeue();\n\t\t\t\tif (cur.time > q) {\n\t\t\t\t\tcur.time -= q;\n\t\t\t\t\ttotal += q;\n\t\t\t\t\tenqueue(cur);\n\t\t\t\t} else {\n\t\t\t\t\ttotal += cur.time;\n\t\t\t\t\tSystem.out.println(cur.name + \" \" + total);\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} catch (IOException e) {\n\t\t\te.printStackTrace();\n\t\t}\n\n\t}\n\n\tstatic void enqueue(Process p) {\n\t\tif ((tail + 1) % queue.length == head) {\n\t\t\tSystem.err.println(\"キューが満タンです\");\n\t\t\treturn;\n\t\t}\n\t\tqueue[tail] = p;\n\t\ttail = (tail + 1) % queue.length;\n\t}\n\n\tstatic Process dequeue() {\n\t\tProcess ret = null;\n\t\tif (head == tail) {\n\t\t\tSystem.err.println(\"キューが空です\");\n\t\t} else {\n\t\t\tret = queue[head];\n\t\t\thead = (head + 1) % queue.length;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n}",
"Main"
] | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static int head = 0;
static int tail = 0;
static Process[] queue = new Process[100005];
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String nq[] = br.readLine().split(" ");
int n = Integer.parseInt(nq[0]);
int q = Integer.parseInt(nq[1]);
int total = 0;
for (int i = 0; i < n; i++) {
String[] tmp = br.readLine().split(" ");
String name = tmp[0];
int time = Integer.parseInt(tmp[1]);
Process p = new Process(name, time);
enqueue(p);
}
while (head != tail) {
Process cur = dequeue();
if (cur.time > q) {
cur.time -= q;
total += q;
enqueue(cur);
} else {
total += cur.time;
System.out.println(cur.name + " " + total);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
static void enqueue(Process p) {
if ((tail + 1) % queue.length == head) {
System.err.println("キューが満タンです");
return;
}
queue[tail] = p;
tail = (tail + 1) % queue.length;
}
static Process dequeue() {
Process ret = null;
if (head == tail) {
System.err.println("キューが空です");
} else {
ret = queue[head];
head = (head + 1) % queue.length;
}
return ret;
}
}
class Process {
String name;
int time;
public Process(String name, int time) {
this.name = name;
this.time = time;
}
}
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.