贪心 Codeforces Round #191 (Div. 2) A. Flipping Game
/*
贪心:暴力贪心水水
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std; const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
int a[MAXN]; int main(void) //Codeforces Round #191 (Div. 2) A. Flipping Game
{
int n; scanf ("%d", &n);
int sum = ;
for (int i=; i<=n; ++i) scanf ("%d", &a[i]), sum += a[i]; int ans = ;
for (int i=; i<=n; ++i)
{
for (int j=; j<=n-i+; ++j)
{
int pre = ; int now = ;
for (int k=j; k<=j+i-; ++k)
{
pre += a[k]; now += - a[k];
}
ans = max (ans, sum - pre + now);
}
} printf ("%d\n", ans); return ;
}
贪心 Codeforces Round #191 (Div. 2) A. Flipping Game的更多相关文章
- Codeforces Round #191 (Div. 2)---A. Flipping Game
Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces水题100道 第二十题 Codeforces Round #191 (Div. 2) A. Flipping Game (brute force)
题目链接:http://www.codeforces.com/problemset/problem/327/A题意:你现在有n张牌,这些派一面是0,另一面是1.编号从1到n,你需要翻转[i,j]区间的 ...
- Codeforces Round #191 (Div. 2) A. Flipping Game(简单)
A. Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #191 (Div. 2) A. Flipping Game【*枚举/DP/每次操作可将区间[i,j](1=<i<=j<=n)内牌的状态翻转(即0变1,1变0),求一次翻转操作后,1的个数尽量多】
A. Flipping Game time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...
- 贪心 Codeforces Round #301 (Div. 2) B. School Marks
题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...
- 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...
- 贪心 Codeforces Round #304 (Div. 2) B. Soldier and Badges
题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdi ...
- 贪心 Codeforces Round #303 (Div. 2) B. Equidistant String
题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #includ ...
随机推荐
- view属性大全
- JavaScript判断页面是否已经加载完毕
做页面时经常会遇到当前页面加载完成后,执行某些初始化工作.这时候就要知道如何判断页面(包括IFRAME)已经加载完成,代码如下: < script language = "javasc ...
- HDU 1754_I Hate It
[题意]给定区间求最大值 [分析]线段树单点更新 [代码] #include<cstdio> #include<iostream> using namespace std; c ...
- Critical Links-UVa796(无向图求桥)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- POJ2632 Crashing Robots 解题报告
Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...
- 2019.4.1今日一练String类中的方法
package com.pjc.objects; replaceAll()方法的理解引出正则表达式import java.util.regex.Patte ...
- Redis的集群方案之Sentinel(哨兵模式)(待实践)
哨兵模式是主从切换的一种方案,但是可以借助此方案实现集群,达到高可用. 先收集教程,待实践. 参考: https://redis.io/topics/sentinel(官方文档) http://ife ...
- 关于 TCP 并发连接的几个思考题与试验
http://blog.csdn.net/solstice/article/details/6579232
- Java循环中删除一个列表元素
本文主要想讲述一下我对之前看到一篇文章的说法.假设跟你的想法有出入,欢迎留言.一起讨论. #3. 在循环中删除一个列表元素 考虑以下的代码.迭代过程中删除元素: ArrayList<String ...
- 异 形 卵 709 南阳oj
http://acm.nyist.net/JudgeOnline/problem.php? pid=709 异 形 卵 时间限制:1000 ms | 内存限制:65535 KB 难度: 描写叙述 ...