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个结果, ...
随机推荐
- java 之UDP编程
大白话:每一台电脑都有自己的ip地址,向指定的ip地址发数据,数据就发送到了指定的电脑.UDP通信只是一种通信方式而已,其特点就不多说.有了ip地址数据就能发送到指定的电脑了,但是呢!我把数据发送到电 ...
- 『转』MySQL存储过程语法例子
原文地址:http://blog.chinaunix.net/uid-540802-id-138873.html ------------------------- 自动生成随机数据存储过程 ---- ...
- sql新语句
SQL语句查找重复数据的写法: select partner_id,* from sale_origin where partner_id in (select partner_id from ...
- jquery ajax超时设置(转载)
var ajaxTimeoutTest = $.ajax({ url:'', //请求的URL timeout : 1000, //超时时间设置,单位毫秒 type : 'get', //请求方式,g ...
- 如何在Virtual box 下安装Mac os
这几天,突然奇想,想要试一试Mac os ,毕竟是贵族系统,装完之后,确实感觉字体很不错. 其他更优秀的功能还没发现,不过,还是希望在这里做一个记录. 以下附录我参照的网址:https://blog ...
- flask-sqlalchemy组件
一.简介 flask本身没有内置orm框架,需要依赖第三方模块,这里介绍flask-sqlalchemy,而flask-sqlalchemy是一个flask的扩展,本质上是对sqlalchemy的进一 ...
- npm install报错 npm ERR! enoent ENOENT: no such file or directory
在npm之后出现如下错误: $ npm install npm WARN checkPermissions Missing write access to /Users/lucas/code/js/v ...
- 11.10 (下午)开课二个月零六天(ajax验证用户名,ajax调数据库)
用ajax验证用户名是否可用 testuid.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&quo ...
- Http指南(1)
网关:是一种特殊的服务器,作为其他服务器的中间实体使用; Agent代理:所有发布web请求的应用程序都是HTTP Agent代理.Web浏览器其实就是一种代理; HTTP报文是在HTTP应用程序之间 ...
- RabbitMQ在特来电的深度应用
特来电是一个互联网公司,而且是技术领先的互联网公司.互联网公司的标配是什么?答案就是缓存+MQ.没错,您没看错,就是MQ--消息队列,我们今天要讨论的RabbitMQ就是消息队列中功能非常强大的一种. ...