HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN111 Homeworks 2013-2015 > problem:


50392 - How much space

CEN111 Homeworks 2013-2015

Start: Jan.10.2015 at 10:00:00 AM
Finish: Jan.10.2015 at 03:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (2)

Contest problems

• 50389 - Reverse an Array
• 50392 - How much space
• 50378 - Sum of the given digits
• 13-Fall2-10. 50379 - a^b modulus k
• 13-Fall2-20. 50399 - Mobile Base Sta...
• 13-Fall2-40. 50401 - Sum of Odd N...
• 13-Fall2-50. 50400 - nth Row rth El...
• 14-Fall1-10. 50532 - Close City
• 14-Fall1-30. 50500 - Find Student
• 14-Fall1-40. 50511 - Class Average

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