Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round)

A.
A. Contest for Robots
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Polycarp is preparing the first programming contest for robots. There are n problems in it, and a lot of robots are going to participate in it. Each robot solving the problem i gets pi points, and the score of each robot in the competition is calculated as the sum of pi over all problems i solved by it. For each problem, pi is an integer not less than 1.

Two corporations specializing in problem-solving robot manufacturing, “Robo-Coder Inc.” and “BionicSolver Industries”, are going to register two robots (one for each corporation) for participation as well. Polycarp knows the advantages and flaws of robots produced by these companies, so, for each problem, he knows precisely whether each robot will solve it during the competition. Knowing this, he can try predicting the results — or manipulating them.

For some reason (which absolutely cannot involve bribing), Polycarp wants the “Robo-Coder Inc.” robot to outperform the “BionicSolver Industries” robot in the competition. Polycarp wants to set the values of pi in such a way that the “Robo-Coder Inc.” robot gets strictly more points than the “BionicSolver Industries” robot. However, if the values of pi will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of pi over all problems. Can you help Polycarp to determine the minimum possible upper bound on the number of points given for solving the problems?

Input
The first line contains one integer n (1≤n≤100) — the number of problems.

The second line contains n integers r1, r2, …, rn (0≤ri≤1). ri=1 means that the “Robo-Coder Inc.” robot will solve the i-th problem, ri=0 means that it won’t solve the i-th problem.

The third line contains n integers b1, b2, …, bn (0≤bi≤1). bi=1 means that the “BionicSolver Industries” robot will solve the i-th problem, bi=0 means that it won’t solve the i-th problem.

Output
If “Robo-Coder Inc.” robot cannot outperform the “BionicSolver Industries” robot by any means, print one integer −1.

Otherwise, print the minimum possible value of maxi=1npi, if all values of pi are set in such a way that the “Robo-Coder Inc.” robot gets strictly more points than the “BionicSolver Industries” robot.

Examples
inputCopy
5
1 1 1 0 0
0 1 1 1 1
outputCopy
3
inputCopy
3
0 0 0
0 0 0
outputCopy
-1
inputCopy
4
1 1 1 1
1 1 1 1
outputCopy
-1
inputCopy
9
1 0 0 0 0 0 0 0 1
0 1 1 0 1 1 1 1 0
outputCopy
4
Note
In the first example, one of the valid score assignments is p=[3,1,3,1,1]. Then the “Robo-Coder” gets 7 points, the “BionicSolver” — 6 points.

In the second example, both robots get 0 points, and the score distribution does not matter.

In the third example, both robots solve all problems, so their points are equal.

题意:有两个机器人 分别回答n个题目 给出他们的正确情况 1 代表正确 0 代表错误 每道题目有对应的分数 在不改变正确情况下给出修改题目的分数使得第一个机器人的分数比第二个人更高 为了不太离谱 要求修改题目的分数尽量小

思路:首先很容易知道如果一道题两个都对的话是对答案没有影响的 不必理会 统计两者相异的情况 让第二个机器人对的分数都为1 然后从第一个机器人对的地方补回即可

#include <bits/stdc++.h>

using namespace std;

#define LL long long

const int mod = 1e9 + 7,N = 105;

int a[N],b[N];

int main()
{
    int n;

    cin >> n;

    for(int i = 0; i < n; i ++)
        cin >> a[i];

    for(int i = 0; i < n; i ++)
        cin >> b[i];

    bool flag = 1;

    for(int i = 0; i < n; i ++)
    {
        if(a[i] != b[i])
        {
            flag = 0;
            break;
        }
    }

    if(flag)
    {
        cout << "-1" << '\n';
        return 0;
    }

    int sum = 0;
    int res = 0;

    for(int i = 0;i < n;i ++)
    {
         if(a[i]!=0  && b[i] == 0)
            sum ++;

         if(a[i] ==0 && b[i] != 0)
            res += b[i];
    }

    if(sum == 0)
    {
        printf("-1\n");
        return 0;
    }

    int ans = 0;

    if(sum > res)
    {
        ans = 1;
    }
    else if(sum <= res)
    {
         ans = res/sum + 1;
    }

    cout << ans << '\n';

    return 0;
}

注意sum = 0时 也是怎样改都不行的 特判 不然会RE

B. Journey Planning
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Tanya wants to go on a journey across the cities of Berland. There are n cities situated along the main railroad line of Berland, and these cities are numbered from 1 to n.

Tanya plans her journey as follows. First of all, she will choose some city c1 to start her journey. She will visit it, and after that go to some other city c2>c1, then to some other city c3>c2, and so on, until she chooses to end her journey in some city ck>ck−1. So, the sequence of visited cities [c1,c2,…,ck] should be strictly increasing.

There are some additional constraints on the sequence of cities Tanya visits. Each city i has a beauty value bi associated with it. If there is only one city in Tanya’s journey, these beauty values imply no additional constraints. But if there are multiple cities in the sequence, then for any pair of adjacent cities ci and ci+1, the condition ci+1−ci=bci+1−bci must hold.

For example, if n=8 and b=[3,4,4,6,6,7,8,9], there are several three possible ways to plan a journey:

c=[1,2,4];
c=[3,5,6,8];
c=[7] (a journey consisting of one city is also valid).
There are some additional ways to plan a journey that are not listed above.

Tanya wants her journey to be as beautiful as possible. The beauty value of the whole journey is the sum of beauty values over all visited cities. Can you help her to choose the optimal plan, that is, to maximize the beauty value of the journey?

Input
The first line contains one integer n (1≤n≤2⋅105) — the number of cities in Berland.

The second line contains n integers b1, b2, …, bn (1≤bi≤4⋅105), where bi is the beauty value of the i-th city.

Output
Print one integer — the maximum beauty of a journey Tanya can choose.

Examples
inputCopy
6
10 7 1 9 10 15
outputCopy
26
inputCopy
1
400000
outputCopy
400000
inputCopy
7
8 9 26 11 12 29 14
outputCopy
55
Note
The optimal journey plan in the first example is c=[2,4,5].

The optimal journey plan in the second example is c=[1].

The optimal journey plan in the third example is c=[3,6].

题意:给出n个点 带有魅力值 要求选出一些点 满足 ci+1−ci=bci+1−bci 并且 ci 是递增的 使得魅力值最大 求出这个魅力值

思路:c(i+1) - c(i) = b(ci + 1) - b(ci) 移项一下 发现就是当前位置 和 魅力值之间的差值 排个序 然后后分类计算权值即可

#include <bits/stdc++.h>

using namespace std;

#define LL long long

const int mod = 1e9 + 7,N = 2e5+5;

struct node
{
    LL x,y;
    LL id;
} a[N];

    int n;
bool cmp(node a,node b)
{
    if(a.y != b.y)
        return a.y > b.y;
    return a.id < b.id;
}

void print()
{
    for(int i = 1;i <= n;i ++)
        printf("x%lld  id%lld  cha %lld\n",a[i].x,a[i].id,a[i].y);

}

int main()
{
    cin >> n;

    LL maxx = -1;

    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i].x;
        a[i].id = i;
        a[i].y = a[i].x - a[i].id;
        maxx = max(maxx,a[i].x);
    }

    sort(a + 1,a + 1 + n,cmp);


   // print();

    LL sum = a[1].x;
    LL y = a[1].y;
    LL res = maxx;

    for(int i = 2; i <= n; i ++)
    {
        if(a[i].y != y)
        {
            res = max(res,sum);///只写这个会WA 有可能存在只有一类的情况
            sum = a[i].x;
            y = a[i].y;
        }
        else
        {
            sum += a[i].x;
            res = max(res,sum);///注意这个判断大小的位置 
        }
    }

    cout << res << '\n';

    return 0;
}
/*
5
1 2 3 4 5
*/

C. Remove Adjacent
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given a string s consisting of lowercase Latin letters. Let the length of s be |s|. You may perform several operations on this string.

In one operation, you can choose some index i and remove the i-th character of s (si) if at least one of its adjacent characters is the previous letter in the Latin alphabet for si. For example, the previous letter for b is a, the previous letter for s is r, the letter a has no previous letters. Note that after each removal the length of the string decreases by one. So, the index i should satisfy the condition 1≤i≤|s| during each operation.

For the character si adjacent characters are si−1 and si+1. The first and the last characters of s both have only one adjacent character (unless |s|=1).

Consider the following example. Let s= bacabcab.

During the first move, you can remove the first character s1= b because s2= a. Then the string becomes s= acabcab.
During the second move, you can remove the fifth character s5= c because s4= b. Then the string becomes s= acabab.
During the third move, you can remove the sixth character s6=‘b’ because s5= a. Then the string becomes s= acaba.
During the fourth move, the only character you can remove is s4= b, because s3= a (or s5= a). The string becomes s= acaa and you cannot do anything with it.
Your task is to find the maximum possible number of characters you can remove if you choose the sequence of operations optimally.

Input
The first line of the input contains one integer |s| (1≤|s|≤100) — the length of s.

The second line of the input contains one string s consisting of |s| lowercase Latin letters.

Output
Print one integer — the maximum possible number of characters you can remove if you choose the sequence of moves optimally.

Examples
inputCopy
8
bacabcab
outputCopy
4
inputCopy
4
bcda
outputCopy
3
inputCopy
6
abbbbb
outputCopy
5
Note
The first example is described in the problem statement. Note that the sequence of moves provided in the statement is not the only, but it can be shown that the maximum possible answer to this test is 4.

In the second example, you can remove all but one character of s. The only possible answer follows.

During the first move, remove the third character s3= d, s becomes bca.
During the second move, remove the second character s2= c, s becomes ba.
And during the third move, remove the first character s1= b, s becomes a.

题意:长度为n的字符串 如果其中一个字符相邻的存在比它小1的字符 那么这个字符就可以被删除 问被删除的最大次数
思路:考虑贪心 一定要从大的字符开始操作 然后就是模拟了

#include <bits/stdc++.h>

using namespace std;

#define LL long long

const int mod = 1e9 + 7,N = 2e5+5;

int vis[155];

int main()
{
    string s;

    int n;

    cin >> n;

    cin >> s;

    for(int i = 0; i < s.size(); i ++)
        vis[s[i]] ++ ;

    char ch ;

    int res = 0;

    for(ch = 'z' ; ch >= 'a' ; ch --)
    {
        if(!vis[ch])
            continue;


        for(int i = 0; i < n; i ++)
        {
            if(s[i] == ch)
            {
                if((i + 1 < n && ch - 1 == s[i + 1]) || (i - 1 >= 0 && ch - 1 == s[i - 1]))
                {
                    s.erase(s.begin() + i);
                    res ++ ;
                    i -- ;
                }
            }
        }

        for(int i = n - 1; i >= 0; i --)
        {
            if(s[i] == ch)
            {
                if((i + 1 < n && ch - 1 == s[i + 1]) || (i - 1 >= 0 && s[i - 1] == ch - 1))
                {
                    s.erase(s.begin() + i);
                    res ++ ;
                    i ++ ;
                }
            }
        }
    }

    cout << res << '\n';

    return 0;
}
/*
5
1 2 3 4 5
*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的转变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 经导师精心指导并认可、获 98 分的毕业设计项目!【项目资源】:微信小程序。【项目说明】:聚焦计算机相关专业毕设及实战操练,可作课程设计与期末大作业,含全部源码,能直用于毕设,经严格调试,运行有保障!【项目服务】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值