A1288 | [COCI-2013_2014-contest1]#3 ORGANIZATOR
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Unexpected problems with law enforcement have convinced Mirko to take up a less lucrative but less morally ambiguous career: he has become the chief organizer of a team computer science contest.
There are N CS clubs that wish to participate in the contest. The presidents of the clubs are quite stubborn and will participate in the contest only if the contest team size makes it possible for all club members to participate.
The contest consists of two rounds: qualifications and finals. All teams that are competing must have an equal number of members and all members of one team must belong to the same club. Any number of teams from each club can participate in the qualification round, and the best team from each club earns a spot in the finals.
Mirko is aware that, with a new and unproven contest, he needs publicity. For that reason, he wants to set the team size such that the number of individual participants in the finals is as large as possible.
Remember, each club that participates has a right to one team in the finals. Furthermore, at least two clubs must participate in the contest, otherwise the contest would be too boring to attract sponsors.
Determine the maximum possible number of participants in the finals so that Mirko can double check his team size choice.
There are N CS clubs that wish to participate in the contest. The presidents of the clubs are quite stubborn and will participate in the contest only if the contest team size makes it possible for all club members to participate.
The contest consists of two rounds: qualifications and finals. All teams that are competing must have an equal number of members and all members of one team must belong to the same club. Any number of teams from each club can participate in the qualification round, and the best team from each club earns a spot in the finals.
Mirko is aware that, with a new and unproven contest, he needs publicity. For that reason, he wants to set the team size such that the number of individual participants in the finals is as large as possible.
Remember, each club that participates has a right to one team in the finals. Furthermore, at least two clubs must participate in the contest, otherwise the contest would be too boring to attract sponsors.
Determine the maximum possible number of participants in the finals so that Mirko can double check his team size choice.
输入格式
The first line of input contains the positive integer N (2 ≤ N ≤ 200 000), the number of clubs.
The second line of input contains N space-separated integers from the interval [1, 2 000 000], the number of members of each club.
The second line of input contains N space-separated integers from the interval [1, 2 000 000], the number of members of each club.
输出格式
The first and only line of output must contain the maximum possible number of finalists.
输入输出样例
输入 #1
3 1 2 4
输出 #1
4
输入 #2
2 1 5
输出 #2
2
输入 #3
5 4 6 3 8 9
输出 #3
9
In test data worth at least 30% of total points, N will be less than 1000.
Clarification of the first example: Mirko decides on 2 members per team, so clubs 2 and 3
participate.
Clarification of the first example: Mirko decides on 2 members per team, so clubs 2 and 3
participate.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted