HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Arithmetic > problem:


50392 - How much space

Guest
• Review clarifications (2)

Section problems

• 50661 - nth Power of a Digit
• 50249 - Ladders
• 50641 - Strong Prime Power
• 50640 - Cubes
• 50412 - K numbers
• 50310 - Kinetic Energy
• 50316 - Population Bar Chart
• 50314 - Falling Distance
• 50392 - How much space
• 50330 - Find the average of n numbers
• 50297 - Divisible By Five
• 50394 - Water Bills
• 50363 - Class GPA Average
• 50398 - Sum of kth Anti-diagonal
• 50651 - Largest power of two
• 50388 - Number of Armstrong Num...
• 50359 - Mode of a Series

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