Codeforces Round #424 Div. 1】的更多相关文章

http://codeforces.com/contest/831 A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Array of integers is unimodal, if: it is strictly increasing in the beginning; after that…
A:链接:http://codeforces.com/contest/831/problem/A 解题思路: 从前往后分别统计递增,相等,递减序列的长度,如果最后长度和原序列长度相等那么就输出yes: 实现代码: #include<bits/stdc++.h> using namespace std; int main() { ,a[]; cin>>m; ;i<m;i++){ cin>>a[i]; } ;i<m-;i++){ ]) ans++; else b…
题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum_{i = 1}^{n} a_{i} \leqslant K$的最大正整数$d$. 整理一下可以得到条件是$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil \leqslant K + \sum_{i = 1}^{n} a_{i}$…
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebo…
Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 000, inclusive. It is possible that some cards have the same integers on them. Vasily decided to sort the cards. To do this,…
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added…
Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of thi…
[Link]:http://codeforces.com/contest/831/problem/A [Description] 让你判断一个数列是不是这样一个数列: 一开始是严格上升 然后开始全都是一个数字 然后又开始严格下降 [Solution] 枚举中间全部相同的是哪个数字; 假设是i..j这一段 则看看1..i是不是严格上升,以及j+1..n是不是严格下降; 如果所有的这样的i..j都不满足则无解; 找到一组则有解; [NumberOf WA] 0 [Reviw] 找到最特殊的地方: 抓…
[Link]:http://codeforces.com/contest/831/problem/B [Description] 两个键盘的字母的位置不一样; 数字键的位置一样; 告诉你第一个键盘按某个键,在第二个键盘上对应哪个键(大写.小写字母) 然后给你一段由第一个键盘输入的文本,问如果用第二个键盘输入,会输出什么. [Solution] 用map一一对应就好; [NumberOf WA] 0 [Reviw] 这种对应关系的题,map无敌; [Code] #include <bits/std…
[Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对这个人评分; 依照时间顺序依次给出这k个人的评分(可能为负数,负数的时候,表示分数会降低,而如果为正,则分数增加); 然后有一个人记得这k次评分中的n次评分过后这个人的评分; (即知道其中k个评委评完分之后,那个人的k个即时分数) (这k个分数各不相同); 问你x有多少种不同可能; [Solutio…
题目链接:http://codeforces.com/contest/831/problem/D 题意:在一个一维坐标里,有n个人,k把钥匙(钥匙出现的位置不会重复并且对应位置只有一把钥匙),和一个终点p.问你每个人都拿到一把钥匙并且回到终点的情况下,n个人之中所花时间最长的那个人时间最少是多少?(一秒只能走一个单位的距离) 思路:考虑二分x,x为每个人能走的步数.对于两个人a,b和两把钥匙c,d 那么当p[a]<p[b]并且p[c]<p[d]时, a拿c钥匙,b拿d钥匙是最优的,因为对于p[…
题目链接:http://codeforces.com/contest/831/problem/C 题意:给定k个评委,n个中间结果. 假设参赛者初始分数为x,按顺序累加这k个评委的给分后得到k个结果,在这个过程中,某人只记得其中n次结果(n次结果不一样按照时间顺序来排列),问你参赛者的初始合法分数有多少种. 思路:维护一个评委给分的前缀和,然后枚举每一种可能的初始分数,然后判断当前枚举的这个分数经过k次累加分数后得到的k个结果有n个结果等于给定的中间结果即可. #define _CRT_SECU…
题目链接:http://codeforces.com/contest/831/problem/B 题意:给第2个26个字母并不重复的字符串(2个字符串对于一个映射),第1个字符串为key集合,第2个字符串为对应的value集合. 然后给了一个字符串(包括小写字母和数字),按照映射规则输出结果(数字不变,字母则对照给定2个字符串的映射规则,大写字母先转换成对应小写字母然后映射完之后在转换成对应的大写字母) 思路:按照题目意思模拟即可. #define _CRT_SECURE_NO_DEPRECAT…
题目链接:http://codeforces.com/contest/831/problem/A 题意:给定一个序列,问你这个序列是否是单峰的. 定义单峰的序列为: (序列值的变化趋势)开始是递增的,然后是平缓的,最后是递减的. 对于开始(递增)和结尾(递减)的那部分可以不出现 思路:按照题目判即可. import java.io.*; import java.util.*; public class Main { public static final int MAXN=100+24; pub…
[Link]:http://codeforces.com/contest/831/problem/D [Description] 有n个人,它们都要去一个终点,终点位于p; 但是,在去终点之前,他们都要先拿到一把钥匙; 钥匙散落在k个位置(k>=n) 然后告诉你n个人的起始位置; 然后每个人,每秒钟移动一个单位长度; 问你最少需要多长时间,可以使得,每个人都拿到钥匙,且都走到终点; [Solution] 把初始位置a数组和钥匙位置b数组,都分别升序排; 假设有一个长度为n的窗口; 用这个窗口,一…
当时晚上打CF时候比较晚,加上是集训期间的室友都没有晚上刷题的习惯,感觉这场CF很不在状态.A题写复杂WA了一发后去厕所洗了个脸冷静了下,换个简单写法,可是用cin加了ios::sync_with_stdio(false)还是WA了,真无语.B题读半天题,读懂后轻松A了,看了下比赛时间就快结束了,把C题读了一遍后,感觉能做,最后还是选择了睡觉23333.................. A题大意:平平平 增平减 ,缺任一都可,判断是否为这样的数列 #include<stdio.h> #inc…
A 题意:给你人的坐标,钥匙的坐标,办公室的坐标.要求所有人能够拿到钥匙并且走到办公室的最短时间.一个位置只能有一个人,一个位置只有一把钥匙,人和钥匙可以在同一个位置. 思路:DP+贪心,dp[i]表示i这把钥匙被使用时人走的距离 代码: #include<stdio.h>#include<algorithm>#include<string.h>#define Inf 1e19;#define ll long longusing namespace std;int n,…
A:二分答案,从左往右考虑每个人,选尽量靠左的钥匙即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define int long long #define N 2010 #de…
E. Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 10…
D. Office Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as wel…
A. Unimodal Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is…
Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 100 0…
Office Keys time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well.…
Splay要支持找最左侧的最小值所在的位置.类似线段树一样处理一下,如果左子树最小值等于全局最小值,就查左子树:否则如果当前节点等于全局最小值,就查当前节点:否则查右子树. 为了统计答案,当然还得维护子树大小的函数. 找到位置以后,直接将左右子树交换即可.不需要打标记. 删除节点时,直接将其前驱(是指序列下标的前驱,就是将待删除节点Splay到根后,左子树的最右节点)Splay到根,将其后继(类似)Splay到根的儿子. 然后将后继的左儿子删除即可. 别忘了及时Maintain(); 这份代码的…
选择的钥匙一定是连续的,人和钥匙一定从左到右连续对应. 就枚举钥匙区间即可. #include<cstdio> #include<algorithm> using namespace std; int Abs(int x){ return x<0 ? (-x) : x; } int n,K,p,a[1010],ans=2147483647,b[2010]; int main(){ scanf("%d%d%d",&n,&K,&p);…
#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ]; ]; ][]; //dp[i][j] 前i个人从前j个药匙中到达终点的最小时间 int main() { int n,k,p; while(~scanf("%d%d%d",&n,&k,&p)) { memset…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…