codeforces 192a
link: http://codeforces.com/contest/330/problem/A
brute force.
/*
ID: zypz4571
LANG: C++
TASK: 191a.cpp
*/ #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <set>
#include <queue>
#include <list>
#include <map>
#define INF 0x3f3f3f3f
#define mid int m=(l+r)/2
using namespace std;
int a[];
int main ( int argc, char *argv[] )
{
#ifndef ONLINE_JUDGE
freopen("191a.in", "r", stdin);
#endif
int n, n1=, cnt=, Max=; scanf("%d", &n);
for (int i=; i<n; ++i){
scanf("%d",a+i); if(a[i]) n1++;
}
if (n1 == n) Max = n1-;
else
{
Max = n1;
for (int i=; i<n; ++i) {
for (int j=; j<n; ++j) {
cnt = n1;
for (int k=i; k<=j; ++k) {
if (!a[k]) cnt++; else cnt--;
}
if (cnt > Max) Max = cnt;
}
}
}
printf("%d\n", Max); return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */
It is so easy. However, I got a WA at first. sad......
codeforces 192a的更多相关文章
- codeforces 192A Funky Numbers
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- 学习KMP算法的一点小心得
KMP算法应用于 在一篇有n个字母的文档中 查找某个想要查找的长度为m的单词:暴力枚举:从文档的前m个字母和单词对比,然后是第2到m+1个,然后是第3到m+2个:这样算法复杂度最坏就达到了O(m*n) ...
- 关于java.lang.reflect.InvocationTargetException
今天遇到java.lang.reflect.InvocationTargetException错误,卡了好一会儿,报错代码 try { Class<?> c= Class.forName( ...
- JSP初识
JSP最终会变成一个完整的servlet在web应用中运行.它与其他的servlet非常相似,只不过这个servlet类会由容器编写. 1.JSP的生命周期 如果一个web应用包含JSP,部署这个应用 ...
- DB2事务日志已满的解决方法
DB2命令终端输入: db2 update db cfg for <dbname> using LOGPRIMARY 50 db2 update db cfg for <dbname ...
- Spring依赖关系
在Spring中,各个模块的依赖关系通过简单的IoC配置文件进行描述,使这些外部化的信息集中并且明了,我们在使用其他组件服务时,只需要去配置文件中了解和配置这些依赖关系即可,也就是说这里关心的是接口, ...
- JS随鼠标坐标移动,显示浮动层内容
在表单等项目中往往会遇到类似于“备注”.“说明”等100个字内的内容需要显示. 这些内容如果全部呈现开,会影响布局和美观,确又没有必要设计一个层或是一个页面. 那么,我们可以把这些内容放到浮动层中,鼠 ...
- CSS 的class属性居然可以并(有点像并,有点像与)操作
<a href="javascript:;" class="btn btn-default doc-event-1">创建div容器</a&g ...
- ios 检测应用程序升级问题
app 上其实已经有自动检测我们版本的功能. 其实我也觉得对于一个程序员来说检测功能让,系统来维护更合适和合理.开发者只要告诉苹果即可. 然而今天老大非要实现自己版本更新的问题,因此也查找了相关的资 ...
- php的数组与数据结构
一.数组的分类与定义 分类: 1.索引数组 $array = array(1,2,3,4,5); 2.关联数组 $array=array(1=>"aa","bb ...
- UIViewController添加子控制器(addChildViewController)
// // TaskHallViewController.m // yybjproject // // Created by bingjun on 15/10/27. // Copyright ...