-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChocolatesCost.java
More file actions
41 lines (34 loc) · 830 Bytes
/
Copy pathChocolatesCost.java
File metadata and controls
41 lines (34 loc) · 830 Bytes
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
package jpmorgan;
import java.util.*;
import java.util.Map.Entry;;
public class ChocolatesCost {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int mney=sc.nextInt();
String c=sc.next();
char []d = {5,4,4,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
MaxChoco(a,mney,c,d);
}
public static int MaxChoco(int a,int mney,String c,char[] d) {
Map<Character,Integer>cost=new HashMap<>();
for(int i=0;i<26;i++) {
cost.put((char)('a'+ i), d[i]);
int m=0;
int t=0,s=0;
HashS
for(int free:new HashSet<>(Arrays.asList(c.toCharArray())))){
}
// l = 0
for(int n=0;n<c.length();n++) {
if(c.charAt(n)!=0)
t+=cost.get(c.charAt(n));
while(t>mney) {
//t -= cost.get(l)
//l++
}
m--;
}
}
}
}