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 ...
随机推荐
- bzoj1098题解
[题意分析] 给你一张无向图,求其补图的联通块数及各个联通块大小. [解题思路] 暴搜! 然而n2会T怎么办? 仔细观察发现m远小于n2,也就是说这是一张极其稠密的补图. 这时就要用到黑科技了:flo ...
- 51nod-1204 并查集
你的朋友写下一串包含1和0的串让你猜,你可以从中选择一个连续的子串(例如其中的第3到第5个数字)问他,该子串中包含了奇数个还是偶数个1,他会回答你的问题,然后你可以继续提问......你怀疑朋友的答案 ...
- Openstack组件部署 — Nova_Install and configure a compute node
目录 目录 前文列表 Prerequisites 先决条件 Install and configure a compute node Install the packages Edit the etc ...
- csdn左侧个人栏目美化,css英文颜色大全,跑马灯效果,点击转到qq联系,点击转到发送邮件。
跑马灯效果: <a href="http://mmmmmm.me" target="_blank"><marquee><font ...
- 剑指offer第二版面试题4:替换空格(JAVA版)
题目:请实现一个函数,把字符串中的每个空格替换成“%20”.例如输入“We are happy”,则输出”We%20are%20happy”. 原因:在网络编程中,如果URL参数中含有特殊字符,如:空 ...
- redis 配置文件aof配置
redis 配置文件aof配置: bind 127.0.0.1 port 6379 daemonize yes dbfilename dump.rdb dir /new_renpeng/redis/ ...
- Java对图片压缩
背景:图片上传服务器时候的大小限制取消之后,上传图片太大导致前台显示加载缓慢 需求:服务器对接收到的图片进行压缩 方法:1.上传后的文件保存在临时文件夹“/usr/upload/tmp” 2.压 ...
- 矢量切片应用中geoserver与geowebcache分布式部署方案
在进行GIS项目开发中,常使用Geoserver作为开源的地图服务器,Geoserver是一个JavaEE项目,常通过Tomcat进行部署.而GeoWebCache是一个采用Java实现用于缓存WMS ...
- linux常用命令 满足99%的开发需要
1.# 表示权限用户(如:root),$ 表示普通用户开机提示:Login:输入用户名password:输入口令 用户是系统注册用户成功登陆后,可以进入相应的用户环境.退出当前shell,输入:exi ...
- 结对编程-Core 第12组 [pb15061359+pb15061351]
一.项目要求 1.输入题目数量,生成操作数为3~5个的四则运算题目 2.输入上限值控制生成的操作数的最大值以及结果的最大值 3.输入支持的操作符类型:加.减.乘.除.乘方.括号 4.输入支持的操作数类 ...