链接:

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的更多相关文章

  1. CodeForces 721B Passwords (水题)

    题意:给定 n 个密码,你要按长度不递减的顺序进行尝试,问你最多和最少试多少次可能找出密码,每尝试 k 次错误的,就要等5秒. 析:我们只要把长度全都统计下来,然后从1开始去找目标长度,最少的就是正好 ...

  2. codeforces 721B B. Passwords(贪心)

    题目链接: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. 【37.21%】【codeforces 721B】Passwords

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. CodeForces 721B

    B. Passwords time limit per test:2 seconds memory limit per test:256 megabytes input:standard input ...

  5. CodeForces 721B Journey (DP)

    题意:给定一个有向图,你从1出发到n,走尽可能多的点,并且使总权值不大于t. 析:在比赛时,竟然看成有向图了,就想了好久,感觉dp,但是不会啊...如果是有向图就好做多了,枚举边,然后打印就好,dp[ ...

  6. Codeforces Round #374 (Div. 2) B. Passwords 贪心

    B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter ...

  7. Codeforces Round #374 (Div. 2) B. Passwords —— 基础题

    题目链接:http://codeforces.com/contest/721/problem/B B. Passwords time limit per test 2 seconds memory l ...

  8. 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, ...

  9. 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 ...

  10. Codeforces Round 371 Div2 B.Passwords

    原题: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

随机推荐

  1. 安装MySQL Enterprise Monitor

    MySQL Enterprise Monitor是专门为MySQL数据库而设计的一款企业级监控,能非常好地与MySQL各方面特性相结合,包括:MySQL的关键性能指标.主机.磁 盘.备份.新特性相关以 ...

  2. CSS 设计指南(第3版) 初读笔记

    第1章 HTML标记与文档结构 关于<title>标签:搜索引擎会给<title>标签中的文字内容赋予很高的权重.而且这些文字也会作为网页标题出现在搜索结果列表中. 无论你想了 ...

  3. cocos2dx[3.2](4) 入口类AppDelegate

    这是游戏程序的入口,主要用于游戏程序的逻辑初始化,并创建运行程序的入口界面(即第一个游戏界面场景). 里面有三个方法: // applicationDidFinishLaunching(); //逻辑 ...

  4. 配置java开发环境,存在多个版本JDK时,怎样让所需版本生效

    我本地有个1.7.0的java版本,后来我新装了一个13的版本,但是命令行查java版本的时候,生效的还是1.7.0的版本,经过资料查询以及自身亲测,现将过程记录如下: 1.电脑右键选择--属性--高 ...

  5. 【miscellaneous】星光级超低照度摄像机技术分析

    低照度摄像机采用了超灵敏度图像传感器和独有的电子倍增和噪点控制技术能够极大地提高摄像机的灵敏度,并且具备24小时全彩色实时效果,绝无普通低照度摄像机出现的拖尾现象,以满足对夜间高品质监控的需求.    ...

  6. webpack的介绍

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA5EAAAGpCAIAAACbBiUBAAAgAElEQVR4Aey9CVwb553/L04JcSPuw5

  7. Kettle的Kitchen和Span

    Kitchen——工作(job)执行器 (命令行方式) -rep  : Repository name   任务包所在存储名    -user  : Repository username   执行人 ...

  8. oracle sid_name service_name

    在工作中也遇到了这种情况,使用oracle这么长时间一直使用的都是SID的概念.也是给自己扩充了一下知识,所以后面在配置oracle数据库连接的时候需要确认拿到的是service还是sid再进行相应的 ...

  9. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  10. ubuntu下python3虚拟环境的配置

    安装相关包 sudo pip3 install virtualenv # 虚拟环境包 sudo pip3 install virtualenvwrapper # 虚拟环境管理包 创建虚拟环境目录 su ...