题目链接 K-Periodic Array

简单题,直接模拟即可。

 #include <bits/stdc++.h>

 using namespace std;

 #define REP(i,n)                for(int i(0); i <  (n); ++i)
#define rep(i,a,b) for(int i(a); i <= (b); ++i)
const int N = + ; int a[N];
int n, k;
int ans;
int b[N], c[N];
int x; int main(){ scanf("%d%d", &n, &k);
rep(i, , n) scanf("%d", a + i);
rep(i, , n){
x = i % k;
if (a[i] == ) b[x]++; else c[x]++;
} REP(i, k) ans += min(b[i], c[i]);
printf("%d\n", ans);
return ; }

Codeforces 371A K-Periodic Array(模拟)的更多相关文章

  1. Codeforces Round #504 D. Array Restoration

    Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...

  2. CodeForces.158A Next Round (水模拟)

    CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...

  3. Codeforces 442C Artem and Array(stack+贪婪)

    题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...

  4. FB面经Prepare: Merge K sorted Array

    Merge K sorted Array 跟Merge K sorted lists不同在于,从PQ里poll出来以后不知道下一个需要被加入PQ的是哪一个 所以需要写一个wrapper class p ...

  5. Codeforces 980 并查集/模拟贪心最小字典序 找规律/数去除完全平方因子 逆思维倍增预处理祖先标记点

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...

  6. Codeforces 439C Devu and Partitioning of the Array(模拟)

    题目链接:Codeforces 439C Devu and Partitioning of the Array 题目大意:给出n个数,要分成k份,每份有若干个数,可是仅仅须要关注该份的和为奇数还是偶数 ...

  7. Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) Array 模拟

    题目链接:http://codeforces.com/contest/572/problem/A 题意 就给你两个数组,问你能不能从A数组中取出k个,B数组中取出m个,使得这k个都大于这m个. 题解 ...

  8. codeforces 251 div2 C. Devu and Partitioning of the Array 模拟

    C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...

  9. Educational Codeforces Round 52D(ARRAY,模拟最短路)

    #include<bits/stdc++.h>using namespace std;int n,x;int chess[17*17];//记录棋盘上的numberarray<int ...

随机推荐

  1. 《鸟哥的Linux私房菜》学习笔记(0)——磁盘与文件系统管理

    一.Linux的登陆流程 login: 用户名:每个用户名都有一个用户ID(用户标识符),计算机处理的就是用户ID(数字)而不是用户名(字符),. 认证机制:Authentication,比如密码或者 ...

  2. C#串口扫描枪的简单实现

    原文:C#串口扫描枪的简单实现 串口扫描枪的简单实现 基于串口通讯的扫描枪的实现,主要借助SerialPort类,表示串行端口资源.实现很简单: 工具:usb转RS232转接头/个,扫描枪/套, 扫描 ...

  3. hadoop伪分布式集群的搭建

    集群配置: jdk1.8.0_161 hadoop-2.6.1 linux系统环境:Centos6.5 创建普通用户  dummy 设置静态IP地址 Hadoop伪分布式集群搭建: 为普通用户添加su ...

  4. C#入门篇6-1:字符串操作 char常用的函数

    //char 字符的常见操作 public static void FChar() { //判定字符的类别 char ch1 = 'a';//使用小引号 bool bl = true; bl = ch ...

  5. 设计模式之序章-UML类图那点事儿

    设计模式之序-UML类图那点事儿 序 打14年年底就像写那么一个系列,用于讲设计模式的,代码基于JAVA语言,最早接触设计模式是大一还是大二来着,那时候网上有人给推荐书,其中就有设计模式,当时给我推荐 ...

  6. 【Unique Paths】cpp

    题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  7. Bugku杂项-convert

    一进去就发现一堆二进制数,然后考虑怎么才能把这个和隐写扯上关系.首先,二进制我们肉眼就是看不懂再说什么的,这里就想到了转换,再联想上hex将原始数据转化为16进制.我们可以先把2进制转化为16进制,然 ...

  8. docker安装中附带安装的其他软件

    aufs-tools: Tools to manage aufs filesystems. aufs的全称是advanced multi-layered unification filesystem, ...

  9. c#委托使用

    public class StepArgs : EventArgs { public int m_IMax = 0; public int m_IStep = 0; public string m_S ...

  10. 学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用利用条件运算符的嵌套来完成此题:C表示。

    # -*- coding: utf8 -*- # Author:wxq #python 2.7 #题目:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用利用条件运算符 ...