349B - Color the Fence

贪心

代码:

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int N=1e6+;
const int INF=0x7f7f7f7f;
int a[];
int main()
{
int n;
int MIN=INF;
int index=;
cin>>n;
for(int i=;i<=;i++)
{
cin>>a[i];
if(a[i]<=MIN)
{
MIN=a[i];
index=i;
}
}
if(n<MIN)
{
cout<<-<<endl;
return ;
}
int mod=n%MIN;
for(int i=;i<n/MIN;i++)
{
for(int j=;j>=index;j--)
{
if(mod+a[index]-a[j]>=)
{
cout<<j;
mod-=a[j]-a[index];
break;
}
}
}
cout<<endl;
return ;
}

Codeforces 349B - Color the Fence的更多相关文章

  1. codeforces 349B Color the Fence 贪心,思维

    1.codeforces 349B    Color the Fence 2.链接:http://codeforces.com/problemset/problem/349/B 3.总结: 刷栅栏.1 ...

  2. 【贪心】Codeforces 349B.Color the Fence题解

    题目链接:http://codeforces.com/problemset/problem/349/B 题目大意 小明要从9个数字(1,2,--,9)去除一些数字拼接成一个数字,是的这个数字最大. 但 ...

  3. CodeForces 349B Color the Fence (DP)

    题意:给出1~9数字对应的费用以及一定的费用,让你输出所选的数字所能组合出的最大的数值. 析:DP,和01背包差不多的,dp[i] 表示费用最大为 i 时,最多多少位,然后再用两个数组,一个记录路径, ...

  4. 349B - Color the Fence

    Color the Fence Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Su ...

  5. Codeforces D. Color the Fence(贪心)

    题目描述: D. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  6. codeforces B. Color the Fence 解题报告

    题目链接:http://codeforces.com/problemset/problem/349/B 题目意思:给定v升的颜料和9个需要花费ad 升的颜料,花费ad 升的颜料意味着得到第d个数字,现 ...

  7. ACM Color the fence

    Color the fence 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has fallen in love with Mary. Now Tom w ...

  8. Codeforces 484E Sign on Fence(是持久的段树+二分法)

    题目链接:Codeforces 484E Sign on Fence 题目大意:给定给一个序列,每一个位置有一个值,表示高度,如今有若干查询,每次查询l,r,w,表示在区间l,r中, 连续最长长度大于 ...

  9. NYOJ-791 Color the fence (贪心)

    Color the fence 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 Tom has fallen in love with Mary. Now Tom w ...

随机推荐

  1. redis桌面管理工具 redis-desktop-manager使用指南(转)

    版权声明:转自 http://blog.csdn.net/li396864285/article/details/54629898     概要:一款好用的Redis桌面管理工具,支持命令控制台操作, ...

  2. LINUX环境变量(一)

    Linux 的变量可分为两类:环境变量和本地变量 环境变量,或者称为全局变量,存在与所有的shell 中,在你登陆系统的时候就已经有了相应的系统定义的环境变量了.Linux 的环境变量具有继承性,即子 ...

  3. 【百度统计】设置页面元素点击事件转化pv、uv

    html元素点击事件内添加代码:_hmt.push(['_trackEvent', category, action, opt_label, opt_value]); 1. '_trackEvent' ...

  4. mysql count group by统计条数方法

    mysql count group by统计条数方法 mysql 分组之后如何统计记录条数? gourp by 之后的 count,把group by查询结果当成一个表再count一次select c ...

  5. php header utf8 插入header("Content-type: text/html; charset=utf-8");

    PHP文件插入header("Content-type: text/html; charset=utf-8"); 相当于页面里面的<meta http-equiv=" ...

  6. Django框架----render函数和redirect函数的区别

    render函数和redirect函数的区别: render:只会返回页面内容,但是未发送第二次请求 redirect:发挥了第二次请求,url更新 具体实例说明 render: redirect:

  7. 20145216《网络对抗》逆向及BOF基础实践

    20145216<网络对抗>逆向及BOF基础实践 1 逆向及Bof基础实践说明 实践目标 本次实践的对象是一个名为pwn1的linux可执行文件.该程序正常执行流程是:main调用foo函 ...

  8. 20165211 2017-2018-2 《Java程序设计》第2周学习总结

    20165211 2017-2018-2 <Java程序设计>第2周学习总结 教材学习内容总结 本周,我学习了书本上二三两章的内容,以下是我整理的主要知识 第二章 基本数据类型与数 标识符 ...

  9. FSMC(STM32)

    (一)FSMC:Flexible Static Memory Controller,可变(灵活)静态存储控制器 小容量产品是指闪存存储器容量在1 6K至32K 字节之间的STM32F101xx.STM ...

  10. soapUi在调用过程中日期参数

    中间加个T 2012-11-05T16:38:30 相关描述: