Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题
不解释,题目过水
Code:
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 1000 + 3;
int A[maxn], n, odds[maxn], f[200][200],b;
int main()
{
scanf("%d%d",&n,&b);
for(int i = 1;i <= n; ++i)
{
scanf("%d",&A[i]);
if(A[i] % 2 == 1) odds[i] = 1;
odds[i] += odds[i - 1];
}
for(int i = 1;i <= n; ++i)
{
for(int k = 0;k <= b; ++k)
{
for(int j = 1;j < i; ++j)
{
int delta = abs(A[j] - A[j + 1]);
if((odds[i] - odds[j]) * 2 != i - j) continue;
if(k - delta >= 0) f[i][k] = max(f[i][k], f[j][k - delta] + 1);
}
}
}
printf("%d",f[n][b]);
return 0;
}
Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题的更多相关文章
- Codeforces Round #318 (Div. 2) A Bear and Elections (优先队列模拟,水题)
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main( ...
- Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax(思维题)
Problem Codeforces Round #539 (Div. 2) - C. Sasha and a Bit of Relax Time Limit: 2000 mSec Problem ...
- Codeforces Round #433 (Div. 2)【A、B、C、D题】
题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...
- Cutting Codeforces Round #493 (Div. 2)
Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...
- 【Codeforces Round #493 (Div. 2) B】Cutting
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...
- Codeforces Round #493 (Div 2) (A~E)
目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) C ...
- Codeforces Round #521 (Div. 3) D. Cutting Out 【二分+排序】
任意门:http://codeforces.com/contest/1077/problem/D D. Cutting Out time limit per test 3 seconds memory ...
- CodeForces Round #521 (Div.3) D. Cutting Out
http://codeforces.com/contest/1077/problem/D You are given an array ss consisting of nn integers. Yo ...
- Codeforces Round #493 (Div. 2)
C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1 要么把所有的 ...
随机推荐
- Javaee 方法的构建和调用
主类: package Szy02; public class Person { String name; int age; String sex; public Person(){ } public ...
- Linux常用命令速查
索引表格 命令 功能简述 目录与文件基本操作 pwd 显示当前目录 ls 列出目录和文件名称 cp 复制文件或目录 mv 移动或更名现有的文件或目录 rm 删除文件或目录 mkdir 新建目录 rmd ...
- nginx日志按日期自动切割脚本
#!/bin/bash #nginx日志切割脚本 #author:setevn #设置日志文件存放目录 logs_path="/usr/local/nginx/logs/" #设置 ...
- vue 上传图片到阿里云(前端直传:不推荐)
为何要这样做:减轻后端数据库压力(个人觉得于前端没啥用,谁返回来都行) 代码部分: <template> <div class="upLoad"> < ...
- 关于IP数据包首部校验字段的理解
关于IP数据包首部校验字段的理解 IP数据包格式及首部个字段: www.2cto.com 对上表的各个数据项就不一一解释了,这里具体关注以下几个数据项: 1.4位首部长度:这里的长度指的是4By ...
- python 协程 greenlet gevent
一.并发的本质 切换+保存状态 cpu正在运行一个任务,会在两种情况下切走去执行其他的任务(切换由操作系统强制控制),一种情况是该任务发生了阻塞,另外一种情况是该任务计算的时间过长时间片到了 二.协程 ...
- python第三周:集合、函数、编码、文件
1.集合: 集合的创建: list_1 = set([1,2,3,4,5]) list_2 = set([2,3,44,7,8]) 集合的特性:集合是无序的,集合可以去掉重复的元素 集合的操作:求交集 ...
- CCPC2018秦皇岛游记
Day1 27号晚上8点多的火车. 然后..第二天(28号)6点40左右的样子到了天津(中转站) 然后一顿乱拍. 看到宝葫芦了没:) 然后.看到了狗不理包子铺...不过当时没开门,就溜了. 然后去秦皇 ...
- OGG For Bigdata To Kafka同步问题处理
一.问题报错 -- :: ERROR OGG- Java or JNI exception: oracle.goldengate.util.GGException: Error detected ha ...
- [SharePoint][SharePoint 2013从入门到精通]Chapter 1 介绍 SharePoint2013
本章你讲学到 什么是SharePoint2013 SharePoint2013如何加强协作与共享 SharePoint2013中有什么用户权限 什么是SharePoint Online 本地部署与在线 ...