CodeForces-721B-Passwords
链接:
https://vjudge.net/problem/CodeForces-721B
题意:
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing their lengths, and he will enter passwords of same length in arbitrary order. Just when Vanya will have entered the correct password, he is immediately authorized on the site. Vanya will not enter any password twice.
Entering any passwords takes one second for Vanya. But if Vanya will enter wrong password k times, then he is able to make the next try only 5 seconds after that. Vanya makes each try immediately, that is, at each moment when Vanya is able to enter password, he is doing that.
Determine how many seconds will Vanya need to enter Codehorses in the best case for him (if he spends minimum possible number of second) and in the worst case (if he spends maximum possible amount of seconds).
思路:
算一下长度小的字符串要花的时间和长度相等要花的时间即可.
代码:
#include <bits/stdc++.h>
using namespace std;
string s[110];
bool cmp(string a, string b)
{
return a.length() < b.length();
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
string ss;
cin >> n >> k;
for (int i = 1;i <= n;i++)
cin >> s[i];
cin >> ss;
sort(s+1, s+1+n, cmp);
int small = 0, same = 0;
for (int i = 1;i <= n;i++)
{
if (s[i].length() > ss.length())
break;
if (s[i].length() < ss.length())
small++;
if (s[i].length() == ss.length())
same++;
}
int mmin = small+1+(small/k)*5;
int mmax = small+same+((small+same-1)/k)*5;
cout << mmin << ' ' << mmax << endl;
return 0;
}
CodeForces-721B-Passwords的更多相关文章
- CodeForces 721B Passwords (水题)
题意:给定 n 个密码,你要按长度不递减的顺序进行尝试,问你最多和最少试多少次可能找出密码,每尝试 k 次错误的,就要等5秒. 析:我们只要把长度全都统计下来,然后从1开始去找目标长度,最少的就是正好 ...
- codeforces 721B B. Passwords(贪心)
题目链接: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 【37.21%】【codeforces 721B】Passwords
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 721B
B. Passwords time limit per test:2 seconds memory limit per test:256 megabytes input:standard input ...
- CodeForces 721B Journey (DP)
题意:给定一个有向图,你从1出发到n,走尽可能多的点,并且使总权值不大于t. 析:在比赛时,竟然看成有向图了,就想了好久,感觉dp,但是不会啊...如果是有向图就好做多了,枚举边,然后打印就好,dp[ ...
- Codeforces Round #374 (Div. 2) B. Passwords 贪心
B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter ...
- Codeforces Round #374 (Div. 2) B. Passwords —— 基础题
题目链接:http://codeforces.com/contest/721/problem/B B. Passwords time limit per test 2 seconds memory l ...
- Codeforces Round #603 (Div. 2) D. Secret Passwords 并查集
D. Secret Passwords One unknown hacker wants to get the admin's password of AtForces testing system, ...
- Codeforces Round #603 (Div. 2) D. Secret Passwords(并查集)
链接: https://codeforces.com/contest/1263/problem/D 题意: One unknown hacker wants to get the admin's pa ...
- Codeforces Round 371 Div2 B.Passwords
原题: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
随机推荐
- Java学习之==>数组【array】
一.定义数组 /** * 一维数组定义 * * 为数组插入元素 */ public void case1() { // 声明 int[] arr1; // 声明+初始化 int[] arr2 = ne ...
- SAS数据挖掘实战篇【六】
SAS数据挖掘实战篇[六] 6.3 决策树 决策树主要用来描述将数据划分为不同组的规则.第一条规则首先将整个数据集划分为不同大小的 子集,然后将另外的规则应用在子数据集中,数据集不同相应的规则也不同 ...
- 修改主机名、hosts解析记录
.hostname和hosts的区别 /etc/hostname中存放的是主机名 /etc/hosts存放的是域名与ip的对应关系 .修改主机名 需要下面两个步骤的结合才可以 2.1.修改网络主机名 ...
- app测试自动化之打开简书的登录界面,等待五秒后关闭
from appium import webdriverfrom time import *desired_caps={ -----desired_caps为自定义变量名 'platformName' ...
- python学习之面向对象(三)
6.8 类的结构细化 6.8.1 类的私有成员 类中的私有成员包括:私有类的属性,私有对象属性,私有类方法 私有静态属性 类的内部可以访问,类的外部不可以访问,派生类中不可以访问 class A: _ ...
- CentOS 7 Tomcat 启动后 外部无法访问的问题
1.启动tomcat 2. 验证tomcat 是否启动成功 ps -ef|grep tomcat 这样是启动成功了的 3 检查防火墙是否启动 firewall-cmd --state 防火墙 已 ...
- 微信小程序开发(一)----- 基础知识
1.什么是微信小程序 概念:小程序是一种不需要下载安装即可使用的应用,它实现了应用“触手可及”的梦想,用户扫一扫或者搜一下即可打开应用,体现了“用完即走”的理念,用户不需要关心是否安装太多应用的问题, ...
- Atomic实现原子性源码分析:CAS(比较并交换)、Unsafe类
1.CAS: 比较并交换(Compare And Swap),是Unsafe类中的一条CPU系统原语,原语的执行必须是连续的,在执行过程中不允许被中断,即CAS是一条CPU的原子指令,不会造成数据不一 ...
- day16 常用模块 sys os json pickle
知识点 os:和操作系统相关sys:和解释器相关 json:和操作JSON(一种数据交换格式)相关pickle:序列化 hashlib:加密算法Collections:集合类型 ...
- phpstudy配置多站点
1.打开vhosts.conf文件 目录 Apache/conf/vhosts.conf #开启apache的vhost模块 (此模块默认是关闭的,去掉前面的#号) LoadModule vh ...