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的更多相关文章

  1. codeforces 192A Funky Numbers

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. PhpStorm注册码 key license

    User name: EMBRACE License key: ===== LICENSE BEGIN =====43136-1204201000002UsvSON704l"dILe1PVx ...

  2. H5 技术

    1,HTML5预加载标签 <!-- 页面,可以使用绝对或者相对路径 --> <link rel="prefetch" href="page2.html& ...

  3. android 原生dialog对话框

    http://www.cnblogs.com/xiaoluo501395377/p/3419398.html

  4. iOS知名第三方框架和流行APP们所用的第三方框架小结

    网易新闻AppleReachabilityASIHTTPRequestEGOTableViewPullRefreshGTMNSString+HTMLMGTemplateEngineMPOAuthReg ...

  5. SharePoint开发 - 自定义导航菜单(三)附其他代码

    博客地址 http://blog.csdn.net/foxdave 接上篇点击打开链接 LeftNavGroupTemplate.cs internal class LeftNavGroupTempl ...

  6. linux安装时出现your cpu does not support long mode的解决方法

    如果你确定你的电脑支持64bit且是64bit的宿主系统,则需要修改BIOS中的Inter Virtualization Technology为enabled.

  7. 如何为Eclipse设置代理

    看图,不解释:

  8. hdu 2096

    PS:做不出前面几道题...很不爽..扒拉了几下找了简单题来做.... #include "stdio.h" int cal(int a); int main(){ int a,b ...

  9. 让一个小Div(子)在大Div(父)中垂直水平都居中

    方法1: .parent {          width:800px;          height:500px;          border:2px solid #000;          ...

  10. php大力力 [017节]来来来,庆祝一下🎁大力力第一个数据库录入程序完成!

    庆祝一下