Codeforces 1166A - Silent Classroom
题目链接:http://codeforces.com/problemset/problem/1166/A



思路:统计所有首字母出现的次数,由贪心可知对半分最少。
AC代码:
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int vis[];
int n;
string a;
int main()
{
cin >> n;
for(int i = ;i < n;i++)
{
cin >> a;
vis[a[] - 'a']++;
}
int ans = ;
for(int i = ;i < ;i++)
{
int l = vis[i] / ,r = vis[i] - l;
ans += l*(l - )/ + r * (r - )/;
}
cout << ans;
return ;
}
Codeforces 1166A - Silent Classroom的更多相关文章
- Codeforces Round #561 (Div. 2) A. Silent Classroom(贪心)
		A. Silent Classroom time limit per test1 second memory limit per test256 megabytes inputstandard inp ... 
- Codeforces Round #561 (Div. 2) A. Silent Classroom
		链接:https://codeforces.com/contest/1166/problem/A 题意: There are nn students in the first grade of Nlo ... 
- codeforces 876 C. Classroom Watch
		http://codeforces.com/contest/876/problem/C C. Classroom Watch time limit per test 1 second memory l ... 
- CF1166A Silent Classroom 题解
		Content 现在有 \(n\) 名学生,我们需要将这些学生分到两个班上.对于两名在同一班级的学生,如果他们的名字首字母相同,他们就会聊天. 现在给定这些学生的名字,问最少有多少对学生会在一起聊天. ... 
- Codeforces Round #441 (Div. 2)【A、B、C、D】
		Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ... 
- Codeforces C. Classroom Watch
		C. Classroom Watch time limit per test 1 second memory limit per test 512 megabytes input standard i ... 
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)  C. Classroom Watch
		http://codeforces.com/contest/876/problem/C 题意: 现在有一个数n,它是由一个数x加上x每一位的数字得到的,现在给出n,要求找出符合条件的每一个x. 思路: ... 
- Codeforces 876C Classroom Watch:枚举
		题目链接:http://codeforces.com/contest/876/problem/C 题意: 定义函数:f(x) = x + 十进制下x各位上的数字之和 给你f(x)的值(f(x) < ... 
- codeforces Round #441 C  Classroom Watch【枚举/注意起点】
		C. time limit per test 1 second memory limit per test 512 megabytes input standard input output stan ... 
随机推荐
- Linux特殊权限设置以及使用
			Linux文件权限特殊权限(s-s-t) 什么是suid权限 SUID是可执行文件的特殊文件权限,使其他用户能够以文件所有者的有效权限运行文件. 代替执行权限的正常x代替用户的s(指示SUID )特权 ... 
- SQL中忘记用户登陆密码该如何修改
			1.每个数据库登陆之前都必须先启动它本身的数据服务,SQL数据库也不例外,首先我们要做的是先打开我们的SQL数据服务! 2.随后在我们的开始菜单中找到我们的SQL启动图标,打开即可 3.弹出登录窗体( ... 
- spring AOP (使用AspectJ的注解方式 的aop实现) (6)
			目录 一.在 Spring 中启用 AspectJ 注解支持 二.AspectJ 支持 5 种类型的通知注解: 2.1.使用之前的 计算器接口和实现类 ArithmeticCalculator.jav ... 
- html  视频播放器
			html 视频播放器 <html> <script> /** *视频播放 *参数说明 u - 媒体URL w - 媒体宽度width h - 媒体高度height */ // ... 
- SpringBoot项目框架下ThreadPoolExecutor线程池+Queue缓冲队列实现高并发中进行下单业务
			主要是自己在项目中(中小型项目) 有支付下单业务(只是办理VIP,没有涉及到商品库存),目前用户量还没有上来,目前没有出现问题,但是想到如果用户量变大,下单并发量变大,可能会出现一系列的问题,趁着空闲 ... 
- 7. Python运算符之逻辑、成员、身份运算符及优先级
			运算符 逻辑表达式 描述 and x and y 布尔"与" - 如果 x 为 False,x and y 返回 False,否则它返回 y 的计算值. or x or y 布尔& ... 
- 4.2.1 Vector bit-select and part-select addressing
			Frm:IEEE Std 1364™-2001, IEEE Standard Verilog® Hardware Description Language Bit-selects extract a ... 
- 注册页面-使用form模块搭建
			基于Django的form模块,快速的搭建注册页面,每个限制条件,都放在form模块里面,不单独对每一项编写标签,使用模版的 for 循环来渲染. 首先设置form模块 在blogs模块下创建一个bl ... 
- 如果手工启动chromedriver
			使用selenium模拟登陆网站时,有些网站会识别chrome driver里的json信息,从而判断是不是爬虫程序,做到反爬效果.(比如知乎) 下面说明下怎么手动启动chromedriver 1). ... 
- 【POJ】1679 The Unique MST
			题目链接:http://poj.org/problem?id=1679 题意:给你一组数据,让你判断是否是唯一的最小生成树. 题解:这里用的是kuangbin大佬的次小生成树的模板.直接判断一下次小生 ... 
