B - Final Problem

探讨在技能等级从1到10的团队参与的比赛中,如何通过添加一道题目,确保每支队伍至少能解决一个问题,同时求解新增题目可能的最大难度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

You have a problem set of ten problems. Each team in the contest has a skill level from 1 to 10 and each of the ten problems has a difficulty level from 1 to 10. A team can only solve problems that have a difficulty level less than or equal to their skill level.

You want to add one more problem with difficulty from 1 to 10 such that each team solves at least one problem. What is the maximum difficulty that this problem can have?

Input
The first line of input contains n (1 ≤ n ≤ 32), the number of teams participating in the contest.

The second line of input contains n integers si (1 ≤ si ≤ 10), the skill level of the teams.

The third line of input contains 10 integers di (1 ≤ di ≤ 10), the difficulty level of the problems in the problem set so far.

Output
Output on a single line the maximum possible difficulty level for the new problem from 1 to 10 such that each team solves at least one problem.

Example
Input
4
3 7 5 5
4 6 5 7 4 4 9 10 7 9
Output
3

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int  maxn = 2e5 + 5;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int minn = inf;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d",&a[i]);
        minn = min (minn, a[i]);
    }
    int minn1 = inf;
    int tmp;
    for(int i = 1; i <= 10; i++)
    {
        scanf("%d",&tmp);
        minn1 = min (minn1 , tmp);
    }
    if(minn < minn1)
    {
        printf("%d\n",minn);
    }
    else
    {
        printf("%d\n", 10);

    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值