-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
74 lines (51 loc) · 1.59 KB
/
Test.java
File metadata and controls
74 lines (51 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package recruit.byte01;
import java.util.Arrays;
import java.util.Scanner;
/**
* 测试nextInt和nextLine->再分割 的性能问题
*
* @author wshten
* @date 2018/8/23 0023
*/
public class Test {
private static Scanner in;
public static void main(String[] args) {
in = new Scanner(System.in);
// long time1 = readline();
long time2 = readints();
in.close();
// System.out.println(time1);
System.out.println(time2);
// int 621 599
// line
/* test case:
100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
*/
}
private static long readints() {
int n = in.nextInt();
long start = System.currentTimeMillis();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = in.nextInt();
}
long end = System.currentTimeMillis();
System.out.println(Arrays.toString(arr));
return end - start;
}
private static long readline() {
int n = in.nextInt();
long start = System.currentTimeMillis();
in.nextLine();
int[] arr = new int[n];
String nums = in.nextLine();
String[] numList = nums.split(" ");
long end = System.currentTimeMillis();
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(numList[i]);
}
System.out.println(Arrays.toString(arr));
return end - start;
}
}