链接:

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. Eclipse_Package Presentation

    Package Presentation ->Flat ->Hierarchical更常用

  2. harbor报错解决

    1. [root@host-10-1-1-71 harbor]# docker login 10.1.1.71:5000Username (admin): Password: Error respon ...

  3. 关于使用unittest单元测试框架的一些问题集

    1.使用unittest.TestSuites生成的测试套件,使用HtmlTestRunner运行时报Type Error. 1)是由于使用unittest.TestSuites生成的测试套件里的Te ...

  4. vue项目与node项目分离

    为了前后端分离,我们在前端和api层中间,架构了一层node层,用来做服务端渲染,来加快用户的首屏可用和对搜索引擎的友好.项目一开始放置在同一个git仓库里面,分别放在client目录和server目 ...

  5. noi.ac-CSP模拟Day5T2 灯

    算是一道思维题吧,没有什么算法在里面. 之前想的是,能走的话就尽量走远,走过去开灯然后再回去关灯,然后再走,每一段路要走3次. 然而,“能走的话就尽量走远”只是yy的一个贪心,没有任何依据.假设在中间 ...

  6. 【VS开发】【图像处理】V4L2 pixel format

    目录(?)[-] v4l2_pix_format定义 2 具体Pixel Format定义 1. v4l2_pix_format定义 [cpp] view plain copy /* *  V I D ...

  7. mv 命令 移动或重命名文件

    mv 命令 移动或重命名文件 [root@localhost soft]# .txt [root@localhost soft]# [root@localhost soft]# ls .txt [ro ...

  8. 从零开始学习GDI+ (二) 基本概念与基本操作

    从零开始学习GDI+ (一)我的第一个GDI+程序 上文给新手学习GDI+讲述了vs环境等的准备工作,并且可以直接用GDI+绘图了.本文开始,讲述的可能偏理论,建议学习的过程中大胆尝试,多使用API. ...

  9. HDU 1171 Big Event in HDU (动态规划、01背包)

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  10. axios中设置Content-Type不生效的问题

    Api:axios(config): config中无data字段时,headers里的Content-Type无效果,这应该出于优化的层面,此时的Content-Length=0,无需向服务端提供C ...