Codeforces712 B. Passwords (贪心水题)
来源:互联网 发布:mac安装python2.7 编辑:程序博客网 时间:2024/06/18 09:31
题目连接:http://codeforces.com/contest/721/problem/B
题目大意:输入n串密码,按长度非递减输入(不是按给出的顺序输入),第n+1行密码是真密码,没输入k次密码后要等5s后才能再次输入,求最短时间与最长时间。
解题思路:直接贪心模拟。
/* ***********************************************┆ ┏┓ ┏┓ ┆┆┏┛┻━━━┛┻┓ ┆┆┃ ┃ ┆┆┃ ━ ┃ ┆┆┃ ┳┛ ┗┳ ┃ ┆┆┃ ┃ ┆┆┃ ┻ ┃ ┆┆┗━┓ 马 ┏━┛ ┆┆ ┃ 勒 ┃ ┆ ┆ ┃ 戈 ┗━━━┓ ┆┆ ┃ 壁 ┣┓┆┆ ┃ 的草泥马 ┏┛┆┆ ┗┓┓┏━┳┓┏┛ ┆┆ ┃┫┫ ┃┫┫ ┆┆ ┗┻┛ ┗┻┛ ┆************************************************ */#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <stack>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <bitset>using namespace std;#define rep(i,a,b) for (int i=(a),_ed=(b);i<=_ed;i++)#define per(i,a,b) for (int i=(b),_ed=(a);i>=_ed;i--)#define pb push_back#define mp make_pairconst int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define LL long long#define ULL unsigned long long#define MS0(X) memset((X), 0, sizeof((X)))#define SelfType intSelfType Gcd(SelfType p,SelfType q){return q==0?p:Gcd(q,p%q);}SelfType Pow(SelfType p,SelfType q){SelfType ans=1;while(q){if(q&1)ans=ans*p;p=p*p;q>>=1;}return ans;}#define Sd(X) int (X); scanf("%d", &X)#define Sdd(X, Y) int X, Y; scanf("%d%d", &X, &Y)#define Sddd(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())#define all(a) a.begin(), a.end()#define mem(x,v) memset(x,v,sizeof(x))typedef pair<int, int> pii;typedef pair<long long, long long> pll;typedef vector<int> vi;typedef vector<long long> vll;inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,rx=getchar();return ra*fh;}//#pragma comment(linker, "/STACK:102400000,102400000")int main(){//freopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);int n,k;n = read(), k = read();string ans;string s[105];for(int i=1;i<=n;i++) cin>>s[i]; cin>>ans; int cnt1 = 0,cnt2 = 0;for(int i=1;i<=n;i++) { if(s[i].size()<ans.size())cnt1++; else if(s[i].size()==ans.size())cnt2++; } int res1 = cnt1 / k; int mi = cnt1+1+res1*5; int res2 = (cnt1+cnt2-1) / k; int mx = cnt1+cnt2+res2*5; cout<<mi<<" "<<mx<<endl;return 0;}
0 0
- Codeforces712 B. Passwords (贪心水题)
- CodeForces 721B. Passwords(水题,贪心)
- B. Passwords
- Codeforces Round #374 (Div. 2) B. Passwords 贪心
- codeforces712
- Codeforces712 D. Maxim and Array (贪心)
- CodeForces 721B Passwords
- Codeforces #374(Div.2)B. Passwords【模拟】
- zoj 2514 Generate Passwords(水!)
- 【37.21%】【codeforces 721B】Passwords
- Passwords Codeforces Round#374-B
- codeforces 721B B. Passwords -- by lethalboyd
- Passwords
- 二分贪心 B题
- B. Lorry (贪心)
- Codeforces Round #374 (Div. 2) B. Passwords —— 基础题
- Codeforces712 C. Journey (DP / 记忆化搜索)
- ZOJ 2514 Generate Passwords 水
- Java学习总结第十二天Java类与对象
- Codeforces721 A. One-dimensional Japanese Crossword (水题)
- STM32 GPIO设置
- STM32F407 VS STM32F103 主要功能及资源对比
- spring MVC3.x和JDK 8不兼容问题
- Codeforces712 B. Passwords (贪心水题)
- java内部类的分类和创建
- redhat tftp server配置
- POJ 2481 Cows (树状数组)
- 更新Xcode后遇到的坑
- Servlet开发(一) 转载
- 登陆案例
- hibernate3.3.2学习笔记---One2One关联单向
- 用户登录及用户注销