AmazonOA #141
Amazon Execute Processes (a.k.a. AWS Processor)
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
Tasks run in their original order. Tasks with the same original duration belong to the same group; each time a task runs, the current duration of every other not-yet-run task in its group becomes half of that task's current duration, rounded up. Tasks whose original durations differ but later become equal cannot be grouped.
Input
The first line contains n, and the second line contains n initial durations. The import catalog lists n≤100000, and this site extends it to 1≤n≤200000 with durations in 1..10^9.
Output
Output a single integer answer.
Example 1
Input:
6
5 5 3 6 5 3
Output:
21
Example 2
Input:
3
1 1 1
Output:
3
Example 3
Input:
3
4 2 4
Output:
8
Example notes
Example 1: the actual times are 5, 3, 3, 6, 2, 2, for a total of 21. Example 2: 1 halved and rounded up is still 1, for a total of 3. Example 3: the three tasks take 4, 2, 2, for a total of 8; the initial 2 is not grouped with the 4 that was later reduced to 2.
Editorial
Loading solution…