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 ...
随机推荐
- 【Flutter学习】基本组件之图标组件Icon
一,概述 图标组件(Icon)为展示图标的组件,该组件不可交互,要实现可交互的图标,可以考虑使用IconButton组件. 图标组件相关的几个组件: IconButton:可交互的Icon: Icon ...
- error C2872: “ACCESS_MASK”: 不明确的符号
原因:opencv3.0或者3.1的using namespace cv和windows.h中ACCESS_MASK定义冲突. 解决方案:注释掉所有的using namespace cv,然后在需要的 ...
- web跨域问题解决方案
在前端开发及调试过程中总能遇到浏览器报如下错误: Response to preflight request doesn't pass access control check: No 'Access ...
- 框架-.NET:Spring.Net
ylbtech-框架-Spring.Net:Spring.Net Spring.NET为建立企业级应用提供了一套轻量级的解决方案.通过Spring.NET,我们可以用统一且透明的方式来配置应用程序.S ...
- CSS:CSS Float(浮动)
ylbtech-CSS:CSS Float(浮动) 1.返回顶部 1. CSS Float(浮动) 什么是 CSS Float(浮动)? CSS 的 Float(浮动),会使元素向左或向右移动,其周围 ...
- 【HTML】框架集(Framesets)
1.Frameset的使用 所谓框架便是网页画面分成几个框窗,同时取得多个 URL.只 要 <FRAMESET> <FRAME> 即可,而所有框架标记 要放在一个总起的 htm ...
- jsp+servlet中文乱码问题
jsp+servlet中文乱码问题 servlet想要获得前台传来的值 String strName=new String(request.getParameter("name") ...
- 从pcap文件中分析出数据包
import dpkt import struct import sys,os f=file(sys.argv[1],"rb") pcap=dpkt.pcap.Reader(f) ...
- react-loadable路由懒加载
load.js import Loadable from 'react-loadable'; import './styles/load.styl' // 按需加载组件 export default ...
- java中trim()方法是用来干什么的?
trim()的作用是去掉字符串两端的多余的空格,注意,是两端的空格,且无论两端的空格有多少个都会去掉,当然 中间的那些空格不会被去掉,如: String s = " a s f g ...