eolymp
bolt
Try our new interface for solving problems
Problems

Miners

Miners

Statement for this problem is only available as a file.
Time limit 0.8 seconds
Memory limit 256 MiB
Input example #1
5
5 1 0 0 0
100 1 1 2 4
1 6
1 1
2 2
2 -1
Output example #1
32