CF Edu Round 169

A

有 n( 2 ≤ n ≤ 40 2≤n≤40 2n40) 个点,再插入一个点,要求所有点到该点的距离比到其他点都要小,求有没有这样的点。

Solution
显然,只有 n=2 的时候才有这样的点。

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

const int maxn = 100;
int a[maxn];

void solve()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(n>2)
    {
        cout<<"NO"<<endl;
        return ;
    }
    else
    {
        int dis=abs(a[2]-a[1]);
        if(dis>1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        return ;
    }
}

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T; cin>>T;
    while(T--) solve();
    return 0;
}
B

先求出交集,再判断一下左右边界是否被包围即可。

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

void solve()
{
    int l1,l2,r1,r2;
    cin>>l1>>r1>>l2>>r2;
    if(min(r1,r2)<max(l1,l2))
    {
        cout<<1<<endl;
        return ;
    }
    else
    {
        int ans=min(r1,r2)-max(l1,l2);
        ans+=(l1!=l2);
        ans+=(r1!=r2);
        cout<<ans<<endl;
        return ;
    }
}

int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T; cin>>T;
    while(T--) solve();
    return 0;
}
C

简单贪心,两人每次都会选序列中最大的数,先排序,然后依次选,选完后用 k 来缩小差距,扫一遍 Bob 选的数让其加到与当前回合 Alice 选的数一样大即可,直到把 k 用完或扫完序列为止。

#include<bits/stdc++.h>
#define endl '\n'
#define int long long

using namespace std;

const int maxn = 2e5+3;
int a[maxn];

bool cmp(int &x,int &b)
{
    return x>b;
}

void solve()
{
    int n,k; cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+1+n,cmp);
    int sum1=0,sum2=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2) sum1+=a[i];
        else sum2+=a[i];
    }
    int kk=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==0)
        {
            kk+=a[i-1]-a[i];
        }
    }
    int ans=sum1-sum2;
    if(ans>=min(k,kk)) cout<<ans-min(k,kk)<<endl;
    else cout<<0<<endl;
    return ; 
}

signed main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T; cin>>T;
    while(T--) solve();
    return 0;
}
### 关于Codeforces Round 927的比赛详情 对于特定编号为927的Codeforces比赛的信息,在当前提供的参考资料中并未直接提及该轮次的具体情况。然而,通常情况下,每一轮Codeforces竞赛都会包含一系列算法挑战题,面向不同级别的参赛者提供多样化的难度级别。 为了获取关于Codeforces Round 927更精确的数据,包括题目列表以及官方解题思路,建议访问Codeforces官方网站并查找对应的比赛页面。一般而言,这类比赛会记录详细的赛况,包括但不限于: - **比赛时间**:具体日期和持续时间段。 - **参与人数**:注册选手数量统计。 - **题目概览**:涉及的问题种类及其大致描述。 - **排名情况**:最终得分排行榜前几名的情况。 - **赛后讨论区**:社区成员分享见解和个人解决方案的地方。 如果希望获得针对此轮赛事更为具体的分析或某道题目的解答方法,则可能需要参考其他第三方博客文章或是论坛帖子,这些资源往往由经验丰富的程序员撰写,能够提供深入的技术解析和支持[^1]。 ```python # 示例代码用于展示如何通过API请求获取CF比赛信息(假设存在这样的功能) import requests def get_cf_round_info(round_id): url = f"https://codeforces.com/api/contest.standings?contestId={round_id}" response = requests.get(url) data = response.json() if 'result' in data and 'problems' in data['result']: problems = data['result']['problems'] for problem in problems: print(f"Problem Name: {problem['name']}, Index: {problem['index']}") get_cf_round_info(927) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值