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:Review(Oracle-HTML-CSS)
20170708_review: 1.oracle: 对表的操作: 使用命令行建立一张表:create table 表名 (列名 列名的类型 primarty key, ....); alter ta ...
- nova计算服务
1. nova介绍 Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源.OpenStack 作为 IaaS 的云操作系统,虚拟机生命周期管理也就是通过 Nova 来实现的. ...
- MyBatis框架原理2:SqlSession运行过程
获取SqlSession对象 SqlSession session = sqlSessionFactory.openSession(); 首先通过SqlSessionFactory的openSessi ...
- 使用 Unity* 进行并行处理的一种方法
本文展示如何使用 Unity* 对游戏进行并行处理,以及如何使用游戏引擎执行与游戏相关的物理.在这个领域内,现实感是成功的一个重要标志.为了模拟真实世界,许多动作需要同时发生,这需要并行处理.创建两个 ...
- 奥比中光Astra Pro在ROS系统中的使用
奥比中光Astra Pro在ROS系统中的使用 上一次介绍了Astra Pro在ubuntu中的使用,由于Astra Pro使用uvc传输彩色图像,所以当用rqt_image_view窗口 时,看不到 ...
- 面试题 | 数据库笔试题集合·之·SQL语句(2)
第2章 SQL 语句 2.1 选择2.1.1 DELETE FROM S WHERE 年龄>60 语句的功能是( A ) A.从 S 表中彻底删除年龄大于 60 岁的记录B.S 表中年龄大于 6 ...
- JDBC的一些简单通用代码
JDBC的一些简单通用代码 功能包括 连接数据库 查询操作 执行sql语句 jdbc相关类的加载 关闭连接 获取数据库格式的当前时间 代码 package dao; import java.sql.C ...
- 三校联训 小澳的葫芦(calabash) 题解
题面:小澳的葫芦[ 题目描述]小澳最喜欢的歌曲就是<葫芦娃>.一日表演唱歌,他尽了洪荒之力,唱响心中圣歌.随之,小澳进入了葫芦世界.葫芦世界有 n 个葫芦,标号为 1~ n. n 个葫芦由 ...
- springboot2.0和Druid整合配置数据源
1. idea使用spring 初始化工具初始化springboot项目(要选中web) 下一步,下一步 2. 在pom.xml中,引入Druid连接池依赖: <dependency> & ...
- HTTPS为什么是安全的?
学习自https://www.cnblogs.com/zhangsanfeng/p/9125732.html,感谢博主 超文本传输协议HTTP被用于在web浏览器和网站服务器之间传递信息,但以明文方式 ...