Codeforces Round #609 (Div. 2) D. Domino for Young
链接:
https://codeforces.com/contest/1269/problem/D
题意:
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a1,a2,…,an (a1≥a2≥…≥an≥1).
Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you can draw inside of this histogram, a domino is a 1×2 or 2×1 rectangle.
思路:
黑白染色,让整个图形变成黑白交错,这样选颜色较少的那个就可以了
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n, v[2];
int main()
{
scanf("%lld", &n);
v[0] = v[1] = 0;
int a;
for (int i = 1;i <= n;i++)
{
scanf("%d", &a);
v[0] += a/2;
v[1] += a/2;
if (a&1)
v[i%2]++;
}
printf("%lld\n", min(v[0], v[1]));
return 0;
}
Codeforces Round #609 (Div. 2) D. Domino for Young的更多相关文章
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- Codeforces Round #609 (Div. 2) A-E简要题解
contest链接:https://codeforces.com/contest/1269 A. Equation 题意:输入一个整数,找到一个a,一个b,使得a-b=n,切a,b都是合数 思路:合数 ...
- Codeforces Round #609 (Div. 2) 题解
Equation Modulo Equality Long Beautiful Integer Domino for Young K Integers Equation \[ Time Limit: ...
- Codeforces Round #609 (Div. 2) C. Long Beautiful Integer
链接: https://codeforces.com/contest/1269/problem/C 题意: You are given an integer x of n digits a1,a2,- ...
- Codeforces Round #609 (Div. 2)
A题 给出n,求大于n的两个合数a和b,并且a-b = n 直接输出n的倍数即可 int n; int main() { cin >> n; cout << 9*n <& ...
- Codeforces Round #609 (Div. 2) A到C题
签到,乘以两个相邻的合数 #include<bits/stdc++.h> using namespace std; int main(int argc, char const *argv[ ...
- Codeforces Round #609 (Div. 2) 【A,B,C】
题意:给一个n<=1e7,找两个合数a和b使得a-b的差为n. 构造a=3n,b=2n,必含有公因子n,只有当n是1的时候是特例. #include<bits/stdc++.h> u ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- [BJOI2019] 删数 [dp转贪心结论+线段树]
题面 传送门 思路 dp部分 以下称合法序列为原题面中可以删空的序列 这个是我在模拟考场上的思路 一开始我是觉得,这个首先可以写成一个dp的形式:$dp[i][j]$表示用$j$个数字填满了目标序列的 ...
- 微信小程序之 语言特点
主页面的CSS样式默认为index.wxss,无需引入
- start use webpack
Demo0操作手册 本Demo演示不使用配置文件的入门级使用 准备环境 初始化环境, cd到demo目录之后, 执行如下命令: npm init -y npm install webpack webp ...
- [转帖]商用数据库之死:Oracle 面临困境
商用数据库之死:Oracle 面临困境 投递人 itwriter 发布于 2019-10-20 08:22 评论(1) 有238人阅读 原文链接 [收藏] « » https://news.cnblo ...
- WCF-方法重载
一.服务端重载 一般写法直接重载,但是会报错,如下. [ServiceContract] public interface IService1 { [OperationContract] string ...
- STL源码剖析——iterators与trait编程#1 尝试设计一个迭代器
STL的中心思想在于:将数据容器与算法分开,独立设计,再用一帖粘着剂将它们撮合在一起.而扮演粘着剂这个角色的就是迭代器.容器和算法泛型化,从技术角度来看并不困难,C++的模板类和模板函数可分别达成目标 ...
- Pygame01之游戏开发
一.Pygame库 Pygame是一个利用SDL库写的游戏库,SDL库全名:Simple DirectMedia Layer,据说是SamLantinga写的大牛写的为了让Loki(公司)更好的向li ...
- python 之 并发编程(进程池与线程池、同步异步阻塞非阻塞、线程queue)
9.11 进程池与线程池 池子使用来限制并发的任务数目,限制我们的计算机在一个自己可承受的范围内去并发地执行任务 池子内什么时候装进程:并发的任务属于计算密集型 池子内什么时候装线程:并发的任务属于I ...
- 14 windows下安装pygame模块
pycharm安装-推荐 file->setting->project->project interpreter->右边的+号,搜索pygame,点击下方的install pa ...
- RT-Flash imxrt 系列rt1052 rt1060量产神器宣传
转载: 恩智浦半导体2017年10月正式发布了业内首款跨界处理器—i.MX RT系列,超强的性能.超高的性价比使得i.MX RT系列火遍大江南北,一度成为基于MCU的产品主控首选,尤其是那些对于性能有 ...