cf C Milking cows
题意:输入n,然后输入n个数,在n个数中0或1,0代表这头牛向左看,1代表这头牛向右看,问最后最少损失多少牛奶。
思路;贪心,连着的0可以不损失,一旦插入1就会损失牛奶。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll __int64
using namespace std; int a[];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
ll ans=,cnt=;
for(int i=; i<=n; i++)
{
scanf("%d",&a[i]);
cnt+=a[i];
if(!a[i]) ans+=cnt;
}
printf("%I64d\n",ans);
}
return ;
}
cf C Milking cows的更多相关文章
- Milking Cows
Milking Cows Three farmers rise at 5 am each morning and head for the barn to milk three cows. The f ...
- 洛谷P1204 [USACO1.2]挤牛奶Milking Cows
P1204 [USACO1.2]挤牛奶Milking Cows 474通过 1.4K提交 题目提供者该用户不存在 标签USACO 难度普及- 提交 讨论 题解 最新讨论 请各位帮忙看下程序 错误 ...
- codeforce ---A. Milking cows
A. Milking cows time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 【题解】Luogu P1204 [USACO1.2]挤牛奶Milking Cows
原题传送门:P1204 [USACO1.2]挤牛奶Milking Cows 实际是道很弱智的题目qaq 但窝还是觉得用珂朵莉树写会++rp(窝都初二了,还要考pj) 前置芝士:珂朵莉树 窝博客里对珂朵 ...
- Milking Cows 挤牛奶
1.2.1 Milking Cows 挤牛奶 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 554 Solved: 108[Submit][Status ...
- 【洛谷P1204】【USACO1.2】挤牛奶Milking Cows
P1204 [USACO1.2]挤牛奶Milking Cows 题目描述 三个农民每天清晨5点起床,然后去牛棚给3头牛挤奶.第一个农民在300秒(从5点开始计时)给他的牛挤奶,一直到1000秒.第二个 ...
- Milking Cows 挤牛奶 USACO 排序 模拟
1005: 1.2.1 Milking Cows 挤牛奶 时间限制: 1 Sec 内存限制: 128 MB提交: 15 解决: 9[提交] [状态] [讨论版] [命题人:外部导入] 题目描述 1 ...
- 【USACO】Milking Cows
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer b ...
- USACO Section 1.2 Milking Cows 解题报告
题目 题目描述 有3个农夫每天早上五点钟便起床去挤牛奶,现在第一个农夫挤牛奶的时刻为300(五点钟之后的第300个分钟开始),1000的时候结束.第二个农夫从700开始,1200结束.最后一个农夫从1 ...
随机推荐
- 搜索框中“请输入搜索keyword”
$(function(){ $("#ctl00_txtKey").val("请输入搜索keyword").addClass("search&qu ...
- STL 六大组件 功能与运用
STL 提供六大组件,彼此可以组合套用: 1 容器(containers):各种数据结构,如vector,list,deque,set,map,用来存放数据,从实现的角度来看,STL容器是一种clas ...
- [转] React同构思想
React比较吸引我的地方在于其客户端-服务端同构特性,服务端-客户端可复用组件,本文来简单介绍下这一架构思想. 出于篇幅原因,本文不会介绍React基础,所以,如果你还不清楚React的state/ ...
- [转] 用实例给新手讲解RSA加密算法
http://www.cfca.com.cn/zhishi/wz-012.htm PS: 通常公钥对数据加密,私钥对数据解密:私钥对数据签名,公钥对数据签名进行认证 RSA加密算法是最常用的非对称加密 ...
- json-lib-2.4-jdk15.jar maven
最近自己将一个web项目装换到使用mevan自动管理. 遇到了一个json包导入的问题.最终解决如下: <!-- https://mvnrepository.com/artifact/net.s ...
- eclipse4.3 kepler中安装maven
1.软件准备 a:Eclipse 4.3 http://www.eclipse.org/downloads/ b:maven http://maven.apache.org/download.cgi ...
- 过滤掉html 标签
/// <summary> /// 过滤掉html标签 /// </summary> /// <param name="Htmlstring"> ...
- HTML特效代码大全
1)贴图:<img src="图片地址">2)加入连接:<a href="所要连接的相关地址">写上你想写的字</a>1)贴 ...
- C#超时处理(转载)
/// <summary> /// 超时处理 /// /// /// </summary> public class TimeoutChecker ...
- 利用反射把数据集合转换成List
---ResultSet数据集 public static List toList(ResultSet rs, Class cls) { List list = new ArrayList(); tr ...