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个结果, ...
随机推荐
- 《MySQL必知必会》[06] 触发器
1.触发器 MySQL中的触发器概念,和Java中的事件监听器有点相似.当你想要某条语句在某个事件发生时自动执行,就要用到触发器了. 触发器能响应如下三类语句: DELETE INSERT UPDAT ...
- 通过重建清理SVN服务器无用目录,不丢失其他目录修改记录
1.主要时有时间希望调整一些文件的目录结构,或者移除一个大量占用空间的文件节省服务器磁盘,但是又不希望调整后,对应的修改记录丢失.这时可以通过服务器目录重建实现. 2.重建后只是被排除掉的目录的修改记 ...
- Java使用数字证书加密通信(加解密/加签验签)
本文中使用的Base64Utils.java可参考:http://www.cnblogs.com/shindo/p/6346618.html 证书制作方法可参考:http://www.cnblogs. ...
- Luogu3825 NOI2017 游戏 2-SAT
传送门 第一眼看上去似乎是一个3-SAT问题 然而\(d \leq 8\)给我们的信息就是:暴力枚举 枚举\(x\)型地图变成\(a\)型地图还是\(b\)型地图(实际上不要枚举\(c\),因为\(a ...
- Luogu4609 FJOI2016 建筑师 第一类斯特林数
题目传送门 题意:给出$N$个高度从$1$到$N$的建筑,问有多少种从左往右摆放这些建筑的方法,使得从左往右看能看到$A$个建筑,从右往左看能看到$B$个建筑.$N \leq 5 \times 10^ ...
- UOJ67 新年的毒瘤 tarjan
题目传送门 题意:给出一个$N$个点.$M$条边的无向图,找出其中的点,满足去掉该点与和它相连的边之后,这个图会变成一棵树.$N , M \leq 10^5$ 说是毒瘤,真的不毒瘤 思考一下,我们需要 ...
- (转) Ubuntu 更改文件夹及子文件夹权限
Linux系统下如何修改文档及文件夹(含子文件夹)权限,我们来看一下. 一 介绍: 可以使用命令chmod来为文件或目录赋予权限.Linux/Unix 的档案存取权限分为三级 : 档案拥有者.群组.其 ...
- CSS 边框(border)实例
CSS 边框(border)实例:元素的边框 (border) 是围绕元素内容和内边距的一条或多条线. CSS border 属性允许你规定元素边框的样式.宽度和颜色. CSS 边框属性属性 描述bo ...
- DNS之BIND使用小结(Forward转发)
之前详细介绍了DNS及其在linux下的部署过程,今天再说下DNS的BIND高级特性-forwarder转发功能.比如下面一个案例:1)已经在测试环境下部署了两台内网DNS环境,DNS的zone域名为 ...
- 20135323符运锦----第七周:Linux内核如何装载和启动一个可执行程序
可执行程序的装载 一.预处理.编译.链接和目标文件的格式 1.可执行程序是怎么得来的 ①编译器预处理 gcc -E -o XX.cpp XX.c (-m32)// 注:把include的文件包含进来, ...