System Call
Time limit1sMemory limit512 MB
Choose one buffer size K for all files to minimize sum over files of ceil(F_i/K) times (T+K).
- Level
Hard8 of 10
- Topics
- Math, Number theory, Brute force, Implementation
- Solved
- No attempts yet
Problem
Operating systems in the Unix family provide a system call named read() for reading files. When passed a buffer of bytes, read() loads file contents into that buffer, and one call takes time, where is the fixed per-call overhead. The running time depends only on the buffer size, never on how many bytes are actually read. For example, with a 10-byte buffer, reading 3 bytes and reading 7 bytes both take time.
Reading a single file of bytes therefore needs calls. The total time to read all of files with sizes bytes is
Mingyu decided to use one fixed buffer size for every file, where is a positive integer. Find the buffer size that minimizes the total reading time.
Input
The first line contains the number of files . The second line contains positive integers , the file sizes in bytes. The third line contains the fixed per-call time , a nonnegative integer.
Output
Print the shortest achievable total reading time and the buffer size attaining it, separated by a space. If several buffer sizes achieve the shortest time, print the smallest such .
Hint
Linux is a representative Unix-family operating system. macOS also belongs to the Unix family, along with FreeBSD, NetBSD, Solaris, and others.