链接:

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 树形结构 根据指定节点 获取其所有叶子节点

    背景说明 需求:MySQL树形结构, 根据指定的节点,获取其下属的所有叶子节点. 叶子节点:如果一个节点下不再有子节点,则为叶子节点. 问题分析 1.可以使用类似Java这种面向对象的语言,对节点集合 ...

  2. ubuntu中将本地文件上传到服务器

    (1)在本地的终端下,而不是在服务器上.在本地的终端上才能将本地的文件拷入服务器. (2) scp -r localfile.txt username@192.168.0.1:/home/userna ...

  3. 实现 laravel 的artisan

    laravel 的 artisan 命令行太好用了,换个框架没有这个功能,于是自己学习实现一些,直接上代码 新建目录 -artisan --bin --src 进入artisan composer i ...

  4. USACO刷题索引

    序 在距离CSP2019还有41天的国庆备战中,考了一场画风非常奇特的六校联赛,然后被教练建议刷一下这个巩固代码实现能力,然后就来了||ヽ(* ̄▽ ̄*)ノミ|Ю. 这个网站还是挺好玩儿的吧,刚开始各种 ...

  5. form 源码刨析

    def clean_name(self) value = self.cleaned_data.get('name') if "金-瓶-梅" not in value: raise ...

  6. String StringBuffer StringBuilder区别与联系

    java.lang.String.java.lang.StringBuffer.java.lang.StringBuilder都是字符串类型,是Java中用于处理字符串常用的三个类.它们主要有以下区别 ...

  7. spring boot-5.配置文件注入

    配置文件注入这一部分内容主要有以下几点内容: 1.全局配置文件值注入 2.自定义配置文件值注入 3.自定义的Spring 配置文件生效 (1)首先介绍全局配置文件的值注入,全局配置文件值注入有两种方式 ...

  8. 手撕ES6--Promise

    手撕ES6--Promise:https://www.jianshu.com/p/0925eae38d2c 手写一个Promise,附源码分析:https://blog.csdn.net/weixin ...

  9. url简单加密

    使用urlencode和urldecode可以对传输的字符串进行简单的加密,也可用于将汉字转换为16进制数字进行传输,每个16进制数前面都带一个% urlencode : 将中文转换为16进制数 ur ...

  10. Codeforces 1220B. Multiplication Table

    传送门 冷静分析容易发现,我们只要能确定一个数的值,所有值也就可以确定了 确定一个数的值很容易,$a_ia_j=M_{i,j},a_ia_k=M_{i,k},a_ja_k=M_{j,k}$ 然后就可以 ...