这次的前三题挺简单的,可是我做的不快也不对。

A. Bank Robbery
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.

Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line, where the i-th safe from the left is called safe i. There are n banknotes left in all the safes in total. The i-th banknote is in safe xi. Oleg is now at safe a. There are two security guards, one of which guards the safe b such that b < a, i.e. the first guard is to the left of Oleg. The other guard guards the safe c so that c > a, i.e. he is to the right of Oleg.

The two guards are very lazy, so they do not move. In every second, Oleg can either take all the banknotes from the current safe or move to any of the neighboring safes. However, he cannot visit any safe that is guarded by security guards at any time, becaues he might be charged for stealing. Determine the maximum amount of banknotes Oleg can gather.

Input

The first line of input contains three space-separated integers, ab and c (1 ≤ b < a < c ≤ 109), denoting the positions of Oleg, the first security guard and the second security guard, respectively.

The next line of input contains a single integer n (1 ≤ n ≤ 105), denoting the number of banknotes.

The next line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109), denoting that the i-th banknote is located in the xi-th safe. Note that xi are not guaranteed to be distinct.

Output

Output a single integer: the maximum number of banknotes Oleg can take.

Examples
input
5 3 7
8
4 7 5 5 3 6 2 8
output
4
input
6 5 7
5
1 5 7 92 3
output
0
Note

In the first example Oleg can take the banknotes in positions 4, 5, 6 (note that there are 2 banknotes at position 5). Oleg can't take the banknotes in safes 7 and 8 because he can't run into the second security guard. Similarly, Oleg cannot take the banknotes at positions 3and 2 because he can't run into the first security guard. Thus, he can take a maximum of 4 banknotes.

For the second sample, Oleg can't take any banknotes without bumping into any of the security guards.

A题就是给n个数判定有几个数在b和c之间,早都打出来了,不敢交。交完AC但是感觉没有关输入输出流会被FST就又再交了一次,谁知道扣了我那么多分,罪过啊。2333,又去试了下,确实没卡,忧伤。

#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int a,b,c;
cin>>a>>b>>c;
int n;
cin>>n;
int num=;
int p;
for(int i=;i<n;i++){
cin>>p;
if(p>b&&p<c)
num++;}
printf("%d\n",num); return ;
}
B. Cutting Carrot
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Igor the analyst has adopted n little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into n pieces of equal area.

Formally, the carrot can be viewed as an isosceles triangle with base length equal to 1 and height equal to h. Igor wants to make n - 1cuts parallel to the base to cut the carrot into n pieces. He wants to make sure that all n pieces have the same area. Can you help Igor determine where to cut the carrot so that each piece have equal area?

Illustration to the first example.

Input

The first and only line of input contains two space-separated integers, n and h (2 ≤ n ≤ 1000, 1 ≤ h ≤ 105).

Output

The output should contain n - 1 real numbers x1, x2, ..., xn - 1. The number xi denotes that the i-th cut must be made xi units away from the apex of the carrot. In addition, 0 < x1 < x2 < ... < xn - 1 < h must hold.

Your output will be considered correct if absolute or relative error of every number in your output doesn't exceed 10 - 6.

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if .

Examples
input
3 2
output
1.154700538379 1.632993161855
input
2 100000
output
70710.678118654752
B题很简单啊,我推对了,可是程序写错了,毕竟我手算不出来这些数啊,尴尬,推了好几遍,但是这个是真的简单啊。还以为会真的卡精度,也没有,自己想太多。
拿n-1条平行于底边的线,使每个封闭图形面积相等
#include <bits/stdc++.h>
using namespace std;
int main()
{ios::sync_with_stdio(false);
cin.tie();
int n,m;
cin>>n>>m;
double c=n*1.0;
for(int i=;i<n;i++){
printf("%.12f\n",sqrt(double(i)/c)*m);
} return ;
}
C. Naming Company
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.

To settle this problem, they've decided to play a game. The company name will consist of n letters. Oleg and Igor each have a set of nletters (which might contain multiple copies of the same letter, the sets can be different). Initially, the company name is denoted by nquestion marks. Oleg and Igor takes turns to play the game, Oleg moves first. In each turn, a player can choose one of the letters c in his set and replace any of the question marks with c. Then, a copy of the letter c is removed from his set. The game ends when all the question marks has been replaced by some letter.

For example, suppose Oleg has the set of letters {i, o, i} and Igor has the set of letters {i, m, o}. One possible game is as follows :

Initially, the company name is ???.

Oleg replaces the second question mark with 'i'. The company name becomes ?i?. The set of letters Oleg have now is {i, o}.

Igor replaces the third question mark with 'o'. The company name becomes ?io. The set of letters Igor have now is {i, m}.

Finally, Oleg replaces the first question mark with 'o'. The company name becomes oio. The set of letters Oleg have now is {i}.

In the end, the company name is oio.

Oleg wants the company name to be as lexicographically small as possible while Igor wants the company name to be as lexicographically large as possible. What will be the company name if Oleg and Igor always play optimally?

A string s = s1s2...sm is called lexicographically smaller than a string t = t1t2...tm (where s ≠ t) if si < ti where i is the smallest index such that si ≠ ti. (so sj = tj for all j < i)

Input

The first line of input contains a string s of length n (1 ≤ n ≤ 3·105). All characters of the string are lowercase English letters. This string denotes the set of letters Oleg has initially.

The second line of input contains a string t of length n. All characters of the string are lowercase English letters. This string denotes the set of letters Igor has initially.

Output

The output should contain a string of n lowercase English letters, denoting the company name if Oleg and Igor plays optimally.

Examples
input
tinkoff
zscoder
output
fzfsirk
input
xxxxxx
xxxxxx
output
xxxxxx
input
ioi
imo
output
ioi
Note

One way to play optimally in the first sample is as follows :

  • Initially, the company name is ???????.
  • Oleg replaces the first question mark with 'f'. The company name becomes f??????.
  • Igor replaces the second question mark with 'z'. The company name becomes fz?????.
  • Oleg replaces the third question mark with 'f'. The company name becomes fzf????.
  • Igor replaces the fourth question mark with 's'. The company name becomes fzfs???.
  • Oleg replaces the fifth question mark with 'i'. The company name becomes fzfsi??.
  • Igor replaces the sixth question mark with 'r'. The company name becomes fzfsir?.
  • Oleg replaces the seventh question mark with 'k'. The company name becomes fzfsirk.

For the second sample, no matter how they play, the company name will always be xxxxxx.

这个题我要不是wa4,要不就wa6,要不就wa5.总之各种wa,事后群里人说才知道自己的贪心不对,两个人都是要选择,放字符到前面还是后面的。还以为sort也会超时,用了优先队列,好像无关紧要,不过熟悉了一把pq

#include <bits/stdc++.h>
using namespace std;
char s[],s1[],s2[];
struct cmp {
char c;
friend bool operator < (cmp x,cmp y) {
return x.c > y.c;
}
};
struct cmp1 {
char c;
friend bool operator < (cmp1 x,cmp1 y) {
return x.c<y.c;
}
};
int main() {
gets(s);
int n=;
priority_queue<cmp>qu;
for(int i=; s[i]; i++) {
n++;
cmp a;
a.c=s[i];
qu.push(a);
}
priority_queue<cmp1>qu1;
gets(s);
for(int i=; s[i]; i++) {
cmp1 a;
a.c=s[i];
qu1.push(a);
}
int f1=,f2=;
for(int i=; i<n; i++) {
if(i%){
s2[f1++]=qu1.top().c;
qu1.pop();
}
else{
s1[f2++]=qu.top().c;
qu.pop();
}
}
int l1 = ;
int r1 = f2-;
int l2 = ;
int r2 = f1-;
int l = ;
int r = n - ;
for (int i = , first = ; i < n; ++i, first = - first) {
if (first) {
if (s1[l1] < s2[l2]) {
s[l] = s1[l1];
++l1;
++l;
} else {
s[r] = s1[r1];
--r1;
--r;
}
} else {
if (s2[l2] > s1[l1]) {
s[l] = s2[l2];
++l2;
++l;
} else {
s[r] = s2[r2];
--r2;
--r;
}
}
}
s[n]=;
printf("%s",s); return ;
}

Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 继续跪一把的更多相关文章

  1. Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2)

    A: 思路:就是找b,c之前有多个s[i] 代码: #include<stdio.h>#define ll long longusing namespace std;ll a,b,c;in ...

  2. Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 【ABC】

    老年人题解,语言python3 A - Bank Robbery 题意:给你ABC,以及n个数,问你在(B,C)之间的数有多少个. 题解:对于每个数判断一下就好了嘛 x,y,z = map(int,i ...

  3. 【构造】Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) D. Labelling Cities

    考试的时候想的是,将所有的完全子图缩起来,然后如果剩下的是一条链,依次对其进行标号即可. 看了官方题解,发现完全子图这个条件太强了,缩点的条件仅仅需要保证原本两个点的“邻接表”相同即可.(注意这里的“ ...

  4. 【贪心】【multiset】Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) C. Naming Company

    考虑两个人,先把各自的集合排个序,丢掉一半,因为比较劣的那一半一定用不到. 然后贪心地放,只有两种决策,要么把一个最优的放在开头,要么把一个最劣的放在结尾. 如果我的最优的比对方所有的都劣(或等于), ...

  5. Tinkoff Challenge - Final Round (ABC)

    A题:从两个保安中间那钞票 #include <bits/stdc++.h> using namespace std; int main() { int a,b,c; scanf(&quo ...

  6. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)

    A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...

  7. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心

    A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  8. Codeforces 1023 A.Single Wildcard Pattern Matching-匹配字符 (Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Fi)

    Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A. Single Wildcard Patter ...

  9. CF Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)

    1. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) B. Batch Sort    暴力枚举,水 1.题意:n*m的数组, ...

随机推荐

  1. 关于nodejs模块安装后找不到包解决办法

    主要原因是类似bower.gulp这些包后,没有添加到环境变量,但是有洁癖的我也不希望添加太多的软链接,所以在用phpstorm开始时有需要的情况下 定义临时的环境变量 http://stackove ...

  2. phpmyadmin解决“高级功能尚未完全设置,部分功能未激活”

    首先在点击主页中的导入, 在“从计算机中上传:”选择/usr/share/doc/phpmyadmin/examples的“create_tables.sql.gz”文件 点击执行 但是我的电脑上还是 ...

  3. JS添加事件和解绑事件:addEventListener()与removeEventListener()

    作用: addEventListener()与removeEventListener()用于处理指定和删除事件处理程序操作. 它们都接受3个参数:事件名.事件处理的函数和布尔值. 布尔值参数是true ...

  4. 在每天黄金时刻将数据库中数据获取包装成Excel表

    过程: 1.由Timer对象实现安排指定的任务在指定的时间进行重复的固定的延迟操作 a.设定时间间隔24小时:PERIOD_DAY = 24 * 60 * 60 * 100; b.指定每天执行操作的时 ...

  5. 保存 http request 的数据到数据库表

    开发需求:把 http request 对象的数据保存到数据库中 第一步:编写 RequestInfoService 类,保存方法名是 saveRequestInfo // 保存request信息 p ...

  6. 面向阿里云专家的 Azure 云服务介绍

    本文是面向阿里云专家的 Azure 云服务介绍,参考本文可以帮助大家“按图索骥”在 Azure 的平台上找到能满足自己需求的服务. 在公有云计算蓬勃发展的同时,中国也出现了越来越多的本土公有云平台.针 ...

  7. K-means、KNN学习笔记

    1.K-means:聚类算法,无监督 输入:k, data[n]; (1) 选择k个初始中心点,例如c[0]=data[0],…c[k-1]=data[k-1]; (2) 对于data[0]….dat ...

  8. 洛谷 2299 Mzc和体委的争夺战

    题目背景 mzc与djn第四弹. 题目描述 mzc家很有钱(开玩笑),他家有n个男家丁(做过前三弹的都知道).但如此之多的男家丁吸引来了我们的体委(矮胖小伙),他要来与mzc争夺男家丁. mzc很生气 ...

  9. js 下载文件/导出

    const url = '/sasd/fsd/xxxx/exportMailData2Excel'this.downloadFile(url, 'blob', this.isSearch) // 调用 ...

  10. CPP-基础:关于多态

        类的多态特性是支持面向对象的语言最主要的特性,有过非面向对象语言开发经历的人,通常对这一章节的内容会觉得不习惯,因为很多人错误的认为,支持类的封装的语言就是支持面向对象的,其实不然,Visua ...