HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


135. 50392 - How much space

Guest
• Review clarifications (2)

Volume problems

• 095. 50651 - Largest power of two
• 110. 50288 - Even numbers in even...
• 115. 50425 - Calculating Weekly Pay
• 118. 50514 - Bookkeeping
• 120. 50426 - Calculating Sales
• 125. 50484 - Number Of Letters
• 130. 50440 - Call Center
• 132. 50504 - School contest
• 135. 50392 - How much space
• 136. 50443 - Dajte Express
• 140. 50655 - Divisibility by 9
• 145. 50656 - Divisibility by 11
• 147. 50553 - Divisible by m
• 148. 50596 - Your Ride Is Here (US...
• 148. 50596 - Your Ride Is Here (US...
• 150. 50763 - Valid Password
• 151. 50560 - Max Distance

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ibrahim Mesecan.

How much space do they occupy?

For faster access, operating systems (OS) divide the HDD into clusters of the size 512Bytes up to 64KB. Thus, OS can search files faster. But larger cluster size is more space wasted, thus, usually 4096Bytes (4KB) space is used.

If a file is smaller than the cluster size, the rest of the cluster is left empty, and the next file starts from the next cluster. For example, if the file's 10000Bytes and cluster size is 4096, then it will fit into 3 clusters (12 KiloBytes). And, the next file starts from the 4th cluster.

Question:
Write a program that is going to read several file information. Then, it's going to calculate the total size (in KB) occupied on HDD.
Note:

  • 1KB=1024Bytes.
  • You can use ceil function to calculate the number of clusters needed for the active file.

Input specification
You will be first given 2 integer numbers (n and clusterSize in KB) where 0 ≤ n ≤ 10000 and 1 ≤ clusterSize ≤ 64. Then the following n lines will give n file sizes (in Bytes) where each of the file size is between 0 and 1010.

Output specification
Show the total space occupied by all files.
(The_number_of_cluster x Cluster_size)

Sample Input I
8 4
359
7164
561
3120
4029
2741
5619
7737
Sample Input II
10 1
9235
5119
5034
8056
736
2367
2880
6192
1552
3891
Sample Output I
44
Sample Output II
48

Explanation for Sample Input I:

 Number of bytesNr. Clusters
3591
71642
5611
31201
40291
27411
56192
77372
 Total number of clusters  11

There are 11 clusters and each of the cluster is 4K. Thus, totally 44KB.

Для отправки решений необходимо выполнить вход.

www.contester.ru