-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC208D.java
More file actions
60 lines (49 loc) · 1.4 KB
/
Copy pathC208D.java
File metadata and controls
60 lines (49 loc) · 1.4 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
import java.io.*;
/**
* */
public class C208D {
/**
* @param args
*/
public static void main(String[] args){
try {
BufferedReader reader =new BufferedReader(new InputStreamReader(System.in)); // STDIN
Integer nPoints=Integer.valueOf(reader.readLine().trim());
String[] szPoints=reader.readLine().trim().split(" ",nPoints);
long[] rPoints=new long[nPoints];
for(int i=0;i!=nPoints;i++){
rPoints[i]=Long.valueOf(szPoints[i].trim());
}
String[] szPrizes=reader.readLine().trim().split(" ",5);
long[] rPrizes=new long[5];
long[] rCounts=new long[5];
for(int i=0;i!=5;i++){
rCounts[i]=0;
rPrizes[i]=Long.valueOf(szPrizes[i].trim());
}
//
Long sum=0L;
for(int i=0;i!=rPoints.length;i++){
sum+=rPoints[i];
while(sum.compareTo((long)rPrizes[0])>=0){
int j=4;
while(j>=0){
if(sum.compareTo((long)rPrizes[j])>=0){
long c=(long) Math.floor((double) sum/rPrizes[j]);
rCounts[j]+=c;
sum-=(rPrizes[j]*c);
}
j--;
}
}
}
String szResult="";
for(int i=0;i!=5;i++)
szResult+=rCounts[i]+" ";
System.out.println(szResult);
System.out.println(sum);
}catch(Exception e){
e.printStackTrace(System.err);
}
}
}