Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C
A:链接:http://codeforces.com/contest/831/problem/A
解题思路:
从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes;
实现代码:
#include<bits/stdc++.h>
using namespace std; int main()
{
int m,i,ans=,a[];
cin>>m;
for(i=;i<m;i++){
cin>>a[i];
}
for(i=;i<m-;i++){
if(a[i]<a[i+])
ans++;
else
break;
}
//cout<<i<<endl;
for(;i<m-;i++){
if(a[i]==a[i+])
ans++;
else
break;
}
//cout<<i<<endl;
for(;i<m-;i++){
if(a[i]>a[i+])
ans++;
else
break;
}
//cout<<ans<<endl;
if(ans==m)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}
B:链接:http://codeforces.com/contest/831/problem/B
解题思路:
就是求第三个字符串中的字符在第一的序列的位置,输出第二个字符串当前位置的字符
实现代码:
#include<bits/stdc++.h>
using namespace std; int main()
{
string s1,s2,s3;
char c;
int i,j;
cin>>s1; cin>>s2; cin>>s3;
int len = s3.size();
for(i=;i<len;i++){
if(s3[i]>='A'&&s3[i]<='Z'){
c = tolower(s3[i]);
for(j=;j<s1.size();j++){
if((char)c==s1[j]){
cout<<(char)(s2[j]-);
break;}
}
}
else if(s3[i]>='a'&&s3[i]<='z'){
for(j=;j<s1.size();j++)
if(s3[i]==s1[j])
cout<<s2[j];
}
else
cout<<s3[i];
}
cout<<endl;
return ;
}
C:链接:http://codeforces.com/contest/831/problem/C
解题思路:
a[]表示评委给的分,b[]表示某个状态的分数
先前缀和处理一下a[i],由于初始分数可能由最小的b[]加上某一个a[i]表示,所以先设存在一个初值=b[1]-a[i],依次判断,如果这个初值能满足加上任意评委给的分,都能得到某状态的分数:x+a[i]=b[j] 可转化为: a[i] = b[j] - x;能满足的初值,存进集合里,最后输出数量即可
#include<bits/stdc++.h>
using namespace std;
set<int>st;
int main()
{
int m,n,a[],b[],i,j,temp,flag;
cin>>m>>n;
memset(a,,sizeof(a));
for(i=;i<=m;i++){
cin>>a[i];
a[i] += a[i-];
}
sort(a+,a+m+);
for(i=;i<=n;i++)
cin>>b[i];
sort(b+,b++n);
for(i=;i<=m;i++){
flag = ;int x = b[] - a[i];
for(j=;j <= n;j++){
temp = b[j] - x;
int ans = lower_bound(a+i,a++m,temp) - a;
if(ans>m||a[ans]!=temp){
flag = ;
break;
}
}
if(flag)
st.insert(a[i]);
}
cout<<(int)st.size()<<endl;
return ;
}
Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)A,B,C的更多相关文章
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per te ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem F (Codeforces 831F) - 数论 - 暴力
题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem D (Codeforces 831D) - 贪心 - 二分答案 - 动态规划
There are n people and k keys on a straight line. Every person wants to get to the office which is l ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem E (Codeforces 831E) - 线段树 - 树状数组
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this int ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem A - B
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is cons ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) A 水 B stl C stl D 暴力 E 树状数组
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - D
题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终 ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - C
题目链接:http://codeforces.com/contest/831/problem/C 题意:给定k个评委,n个中间结果. 假设参赛者初始分数为x,按顺序累加这k个评委的给分后得到k个结果, ...
随机推荐
- 13-(基础入门篇)系统教程演示(GPRS模块)
https://www.cnblogs.com/yangfengwu/p/9966702.html 前几节作为基础教程和系统教程的开端,有了前面的基础才更好的学习基础教程和系统教程. https:// ...
- 解决 在Android开发上使用KSOAP2上传大图片到服务器经常报错的问题
原文首发我的主力博客 http://anforen.com/wp/2017/04/android_ksoap2_unexpected_type_position_end_document_null_j ...
- item 8: 比起0和NULL更偏爱nullptr
本文翻译自modern effective C++,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 先让我们看一些概念:字面上的0是一个int,不是一个指针.如果C+ ...
- Qt Creator 中,如何更改h,cpp,ui的文件并不让ui失效
这个星期在使用qt,碰到一个很蛋疼的问题:创建对话框的时候,不小心输错了名字.而且是在很迟才发现的.这个时候对话框都已经布局差不多了,为了改名字,碰到更蛋疼的问题,改了名字后就无法使用转到槽的功能了. ...
- 2018年高教社杯全国大学生数学建模竞赛B题解题思路
题目 先贴下B题的题目吧 问题B 智能RGV的动态调度策略 图1是一个智能加工系统的示意图,由8台计算机数控机床(Computer Number Controller,CNC).1辆轨道式自动引 ...
- C语言----数据类型(基础篇一)
C语言的入门程序模板 #include <stdio.h> /*使用或者包含系统里面的程序*/ main() /*程序入口点*/ { /*起点*/ +; /*叫计算机执行的指令*/ } / ...
- Spring Cloud :断路器集群监控(Turbine)
一. 简介 上一篇文章我们已经实现了对单个服务实例的监控,当然在实际应用中,单个实例的监控数据没有多大的价值,我们更需要的是一个集群系统的监控信息,这时我们就需要引入Turbine.Turb ...
- Codeforces Round #503 (by SIS, Div. 2)-C. Elections
枚举每个获胜的可能的票数+按照花费排序 #include<iostream> #include<stdio.h> #include<string.h> #inclu ...
- uml 图学习记录
UML类图与类的关系详解 2011-04-21 来源:网络 在画类图的时候,理清类和类之间的关系是重点.类的关系有泛化(Generalization).实现(Realization).依赖(D ...
- (第十二周)final预发布视频
项目名:食物链教学工具 组名:奋斗吧兄弟 组长:黄兴 组员:李俞寰.杜桥.栾骄阳.王东涵 Final阶段视频发布 平台:优酷 链接:http://v.youku.com/v_show/id_XMTg0 ...