Codeforces Round #532(Div. 2) A.Roman and Browser
链接:https://codeforces.com/contest/1100/problem/A
题意:
给定n,k。
给定一串由正负1组成的数。
任选b,c = b + i*k(i为任意整数)。将c所有c位置的数删除,求-1和1个数差值绝对值的最大值。
思路:
暴力遍历
代码:
#include <bits/stdc++.h>
using namespace std;
int a[110]; int main()
{
int n,k;
scanf("%d%d",&n,&k);
int sum_e = 0,sum_s = 0;
for (int i = 1;i<=n;i++)
{
scanf("%d",&a[i]);
if (a[i] == 1)
sum_e++;
else
sum_s++;
}
int Max = 0;
for (int i = 1;i<=k;i++)
{
int sub_e = 0,sub_s = 0;
for (int j = i;j <= n;j += k)
{
if (a[j] == 1)
sub_e++;
else
sub_s++;
}
Max = max(Max,abs((sum_e-sub_e)-(sum_s-sub_s)));
}
printf("%d\n",Max); return 0;
}
Codeforces Round #532(Div. 2) A.Roman and Browser的更多相关文章
- Codeforces Round #532 (Div. 2)
Codeforces Round #532 (Div. 2) A - Roman and Browser #include<bits/stdc++.h> #include<iostr ...
- Codeforces Round #532 (Div. 2) 题解
Codeforces Round #532 (Div. 2) 题目总链接:https://codeforces.com/contest/1100 A. Roman and Browser 题意: 给出 ...
- Codeforces Round #532 (Div. 2) Solution
A. Roman and Browser 签到. #include <bits/stdc++.h> using namespace std; ]; int get(int b) { ]; ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers(如压力dp)
Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standard i ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers 状压dp+数位dp
题目链接: http://codeforces.com/problemset/problem/401/D D. Roman and Numbers time limit per test4 secon ...
- Codeforces Round #235 (Div. 2) D. Roman and Numbers (数位dp、状态压缩)
D. Roman and Numbers time limit per test 4 seconds memory limit per test 512 megabytes input standar ...
- Codeforces Round #532 (Div. 2) F 线性基(新坑) + 贪心 + 离线处理
https://codeforces.com/contest/1100/problem/F 题意 一个有n个数组c[],q次询问,每次询问一个区间的子集最大异或和 题解 单问区间子集最大异或和,线性基 ...
- Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...
- Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目
D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
随机推荐
- Linux 驱动面试题总结【转】
本文转载自:http://zkread.com/article/872291.html 1. Linux设备中字符设备与块设备有什么主要的区别?请分别列举一些实际的设备说出它们是属于哪一类设备. 字符 ...
- hihocoder #1062 : 最近公共祖先·一(小数据量 map+set模拟+标记检查 *【模板】思路 )
#1062 : 最近公共祖先·一 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho最近发现了一个神奇的网站!虽然还不够像58同城那样神奇,但这个网站仍然让小Ho乐在 ...
- RobotFramework教程使用笔记——RobotFramework的安装配置
(一) Python的安装和pip配置 首先,从Python的官方网站 www.python.org http://www.python.org/ftp/python 然后,运行下载的MSI安装包, ...
- Python GIL、线程锁、信号量及事件
GIL是什么? GIL并不是Python的特性,它是在实现Python解析器(CPython)时所引入的一个概念.就好比C++是一套语言(语法)标准,但是可以用不同的编译器来编译成可执行代码.有名的编 ...
- hdu 1391 Number Steps(规律)
题意:找规律 思路:找规律 #include<iostream> #include<stdio.h> using namespace std; int main(){ int ...
- Linux档案属性
输入命令:ls -al 档案类型权限: 第一個字元代表这个档案是『目录.档案或链接档等等』: 当为[ d ]则是目录: 当为[ - ]则是目录: 若是[ l ]则表示为链接档(link file): ...
- redis-cluster的实例动态调整内存
当redis.conf中的最大内存配置为10G的时候,恰好程序已经写满了,但是物理主机是有内存的, 此时可以通过config set xxxx xxxx 来设置实例的内存大小,而不需要重启实例. 获取 ...
- Swift Optional Chaining
Optional Chaining介绍 关于「optional chaining」,<The Swift Programming Language>是这么描述的: Optional cha ...
- python虚拟环境管理包virtualenvwrapper
1.打开cmd 2.安装virtualenvwrapper pip install virtualenvwrapper-win 3.配置虚拟环境的位置 新建系统变量默认在c盘 4.新建虚拟环境 mkv ...
- hdu 3932 Groundhog Build Home —— 模拟退火
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3932 找一个位置使距离最远的点的距离最小: 上模拟退火: 每次向距离最远的点移动,注意判断一下距离最远的点 ...