PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000225. Đặt bẫy bắt nhiều ếch nhất (We Were Both Children)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đặt bẫy bắt nhiều ếch nhất (We Were Both Children)
We Were Both Children
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are frogs starting at coordinate ; frog repeatedly jumps forward by . You may place one trap at an integer coordinate . A frog is caught iff . Find the maximum number caught. Equal jump lengths still correspond to different frogs.
Input
First line contains ; second line contains .
Output
Print the maximum number of frogs.
Subtasks
-
Subtask 1 (20 points): .
-
Subtask 2 (30 points): .
-
Subtask 3 (50 points): .
Examples
Example 1
Input
5
1 2 3 4 5
Output
3
Explanation
Placing the trap at coordinate 4 catches the frogs of jump lengths 1,2 and 4, for a total of three.
Example 2
Input
3
2 2 2
Output
3
Explanation
A trap at coordinate 2 catches all three frogs.
Example 3
Input
1
10
Output
0
Explanation
The frog lands only at 10,20,..., but the sole allowed trap location is coordinate 1.