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 bytes | Nr. Clusters |
359 | 1 |
7164 | 2 |
561 | 1 |
3120 | 1 |
4029 | 1 |
2741 | 1 |
5619 | 2 |
7737 | 2 |
Total number of
clusters |
11 |
There are 11 clusters and each of the cluster is 4K. Thus,
totally 44KB.
Для отправки решений необходимо выполнить вход.
|