Codeforces Round #343 (Div. 2)【A,B水题】
A. Far Relative’s Birthday Cake
题意:
求在同一行、同一列的巧克力对数。
分析:
水题~样例搞明白再下笔!
代码:
#include<iostream>
using namespace std;
const int maxn = 105;
char a[maxn][maxn];
int main (void)
{
int N;cin>>N;
int cnt = 0, res = 0;
for(int i = 0; i < N; i++){
cnt = 0;
for(int j = 0; j < N; j++){
cin>>a[i][j];
if(a[i][j]=='C') cnt++;
}
res += cnt * (cnt - 1)/2;
}
for(int j = 0; j < N; j++){
cnt = 0;
for(int i = 0; i <N; i++){
if(a[i][j]=='C')
cnt++;
}
res += cnt * (cnt - 1)/2;
}
cout<<res<<endl;
return 0;
}
B. Far Relative’s Problem
题意:
给定男生女生的空余时间,求出满足在该天空余的男生数与女生数相等且人数最多的一天。
分析:
白痴的WA了一次。。。直接暴力
代码:
#include<iostream>
#include<cmath>
using namespace std;
const int maxn = 5005, maxm = 400;
int cnt[maxm], flag[maxm];
int main (void)
{
int N;cin>>N;
char a;
int b ,c, l = 400, r = 0;
for(int i = 0; i < N; i++){
cin>>a>>b>>c;
for(int j = b; j <= c; j++){
cnt[j]++;
if(a=='M') flag[j]++;
else flag[j]--;
}
}
int res = 0;
for(int i = 1; i <= 366; i++){
if(flag[i]!=0) cnt[i] -= abs(flag[i] - 0);
if(res<cnt[i]) res = cnt[i];
}
cout<<res<<endl;
}
Codeforces Round #343 (Div. 2)【A,B水题】的更多相关文章
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...
- Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告
对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
- Codeforces Round #340 (Div. 2) D. Polyline 水题
D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...
- Codeforces Round #338 (Div. 2) A. Bulbs 水题
A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...
- Codeforces Round #282 (Div. 1) A. Treasure 水题
A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
随机推荐
- Android开发学习——简单类图
1.类A继承于类B (B 是父类,A是 子类) 2.小汽车.自行车 实现车的接口 3.A中有B这个成员变量,单向关联 4.聚合,整体与部分的关系.has-a B中的构造函数(或set方法)需要 ...
- A8通用权限框架
- Java8-Lomda表达式
Lomda表达式 /** * All rights Reserved, Designed By www.bingo.com * @Title TestLamda.java * @author yang ...
- 聊聊mq的使用场景
mq的作用 通过异步方式对系统解耦 增加系统的并发处理能力 通过异步方式对系统解耦 以用户注册为例,一般情况下: 分下一下,上面过程存在的一些问题: 注册过程会调用4个服务(注册服务.邮件服务.短信服 ...
- android ListView 分析(一)
需要了解的内容 1. listview中的getItemAtPosition与Adapter的getItem的position的区别 listView中的getItemAtPosit ...
- 短视频SDK用于旅游行业
超级简单易用的短视频SDK来自RDSDK.COM.锐动天地为开发者提供短视频编辑.视频直播.特效.录屏.编解码.视频转换,等多种解决方案,涵盖PC.iOS.Android多平台.以市场为导向,不断打磨 ...
- 鸢尾花数据集-iris.data
iris.data 5.1,3.5,1.4,0.2,Iris-setosa 4.9,3.0,1.4,0.2,Iris-setosa 4.7,3.2,1.3,0.2,Iris-setosa 4.6,3. ...
- v使用索引的注意事项及常见场景、案例
索引的原理与作用,各种书籍和网络上的介绍可以说是铺天盖地,基本上主流数据库系统的也都是一致的.选择索引字段的原则,比如外键字段.数据类型较小的字段.经常用于查询或排序的字段.表关联的字段等等,在此不做 ...
- 初学者SQL shell(psql)无法登陆问题
因为项目第一次接触postgresql,有个问题搞死我了,如果初学,估计大家也会遇见这样的问题,希望可以节约时间. 用户postgres的口令不显示啊!服!
- Google浏览器开发者工具:CSSViewer(一个Css查看器)
CSSViewer的简介 CSSViewer是一款可以帮助用户快速查看当前的网页元素的CSS属性的谷歌浏览器插件,在Chrome中安装了CSSViewer插件以后,用户就可以在设计网页的时候,快速地模 ...