forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCYN.java
More file actions
76 lines (64 loc) · 1.73 KB
/
CYN.java
File metadata and controls
76 lines (64 loc) · 1.73 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
75
76
package BiShi;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Scanner;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Author MaoTian
* @Classname CYN
* @Description TODO
* @Date 下午4:29 2019/9/6
* @Version 1.0
* @Created by mao<[email protected]>
*/
interface Test1{
public void test1();
}
interface Test2 extends Test1{
}
public class CYN {
public static int getDays(int[] nums,int k){
int count=0;
int i=0;
for(;i<nums.length;i++){
count+=nums[i];
if(count>=k){
break;
}
}
if(count>=k){
return i;
}else {
return -1;
}
}
public static void main(String[] args) throws FileNotFoundException {
ThreadPoolExecutor s;
Executors.newFixedThreadPool(9);
Executors.newCachedThreadPool();
Executors.newSingleThreadExecutor();
// Scanner sc=new Scanner(System.in);
Scanner sc=new Scanner(new File("/home/mao/workspace/java/src/BiShi/test"));
while (sc.hasNext()){
int n=sc.nextInt();
int k=sc.nextInt();
ArrayList<Integer> tmp=new ArrayList<>();
for (int i = 0; i <n ; i++) {
int v=sc.nextInt();
while (v>8){
tmp.add(8);
v=v-8;
}
tmp.add(v);
}
int[] nums=new int[tmp.size()];
for (int i = 0; i <tmp.size() ; i++) {
nums[i]=tmp.get(i);
}
System.out.println(getDays(nums,k));
}
}
}