http://codeforces.com/contest/349/problem/B

贪心

 #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int inf=<<; int a[];
int v,k;
int main()
{
while(scanf("%d",&v)!=EOF)
{
int min1=inf;
k=;
for(int i=; i<=; i++)
{
scanf("%d",&a[i]);
if(a[i]<min1)
{
min1=a[i];
k=i;
}
else if(a[i]==min1&&k<i)
{
k=i;
}
}
if(v<min1)
{
printf("-1\n");
continue;
}
if(v%min1==)
{
int m=v/min1;
for(int i=; i<=m; i++)
{
printf("%d",k);
}
printf("\n");
}
else
{
int len=v/min1;
for(int j=len; j>=; j--)
{
for(int i=; i>=; i--)
{
int x=v-a[i];
if(x<) continue;
if(x/min1==j-)
{
printf("%d",i);
v-=a[i];
break;
}
}
}
printf("\n");
}
}
return ;
}

cf B. Color the Fence的更多相关文章

  1. ACM Color the fence

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

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

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

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

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

  4. 349B - Color the Fence

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

  5. nyoj Color the fence

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

  6. Codeforces 349B - Color the Fence

    349B - Color the Fence 贪心 代码: #include<iostream> #include<algorithm> #include<cstdio& ...

  7. nyoj 791——Color the fence——————【贪心】

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

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

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

  9. CF 484E - Sign on Fence

    E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...

随机推荐

  1. FILTER 哪里没展开改哪里

    SELECT * FROM F_PTY_INDIV_TMP O WHERE EXISTS (SELECT 1 FROM F_PTY_INDIV F WHERE O.PTY_ID = F.PTY_ID ...

  2. struct2(一)第一个struct程序

    说明:本系列是针对struct2学习过程,主要的目的: 1. 探索针对一个新的开源框架的学习过程. 2. 学习struct2,学习官方对struct2介绍的方法. 3.别把英语忘了. 1. 为了更加清 ...

  3. sqlite3 C API编程

    1,创建测试数据库,表;

  4. Spring 小示例

    通过一个简单的示例来初步理解Spring框架 1.创建java工程,导入相应Spring包,放在lib文件夹中 2.接口  IHelloMessage package com.jike.spring. ...

  5. #爬虫必备,解析html文档----beautifulsoup的简单用法

    #出处:http://mp.weixin.qq.com/s?__biz=MjM5NzU0MzU0Nw==&mid=201820961&idx=2&sn=b729466f334d ...

  6. HDOJ/HDU 2544 最短路---dijkstra算法

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 这题的思路可以见这里(同一类型):http://blog.csdn.net/xiaozhuaix ...

  7. 一个不错的PPT,扁平化设计,开放资源,要的进来

    开了那么多的博客,没做啥资源贡献,今天共享一个不错的PPT模板.例如以下图所看到的,须要的话留下邮箱 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGFp ...

  8. jsp filter登录限制过滤器

    http://www.cnblogs.com/hemingwang0902/archive/2012/01/09/2316956.html UserFilter.java package filter ...

  9. andorid 开发笔记 -- 问题与解决

    1. SQLiteDataBase 中 TimeStamp 转化为 Date 的问题:java.text.ParseException: Unparseable date: "Sun Jan ...

  10. oracle之case when

    oracle case when 的用法 http://www.cnblogs.com/xiaowu/archive/2011/08/17/2143445.html(转) http://www.cnb ...