Bank Robbery 1
InterviewTime limit1sMemory limit256 MB
Given banks at positions X_i with open times T_i and rewards C_i, find the maximum total reward Siwoo can collect on one rightward path.
- Level
Easy3 of 10
- Topics
- Hash map, Implementation
- Solved
- No attempts yet
Problem
Siwoo, a professional bank robber, wants to rob banks. There are banks along the straight path he runs on. The -th bank is at a distinct coordinate on the line, and its door is open only when the time is exactly . Robbing this bank yields won.
Siwoo starts at any integer coordinate on the line and moves. While he moves, the coordinate must increase. He cannot stop. Time starts at 0, and each time the coordinate increases by 1, the time increases by 1. When Siwoo reaches a bank whose door is open, he must rob it. He is so skilled that robbing a bank takes no time at all. Find the maximum amount of money Siwoo can get when he starts from a suitable position.
Input
The first line contains ().
From the second line on, the next lines each contain the integers , in increasing order of . Here .
All are distinct.
Output
Print the maximum amount of money Siwoo can get.