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. cf B. Dima and To-do List

    http://codeforces.com/contest/366/problem/B 从0到k枚举起点,然后i+k判断是不是i+k>=n如果是i=(i+k)%n;否则i=i+k; #inclu ...

  2. Cmake调用NSIS(一个可执行文件,其实就是一个编译器)编译NSIS脚本问题研究

    技术经理说,可以用Cmake当中的add_custom_command,add_custom_target命令来使用. 我初次研究了下,add_custom_command应该用官方文档中说明的第二种 ...

  3. [置顶] 【原创分享】嵌入式linux应用之内核移植定制篇-前篇(linux-3.8.12 mini2440)--20130824

    移植的话其实很早就做过了,不过那时用的友善定制的老版本2.6.32 驱动什么的全部弄好了,仅仅用默认配置而已.基本不用改动什么,很简单. 内核更新其实非常的快,今天我就用个3.8.12来移植. 当然, ...

  4. js实现编码,解码

    <p><script type="text/javascript">// <![CDATA[var decToHex = function(str) ...

  5. struct2(四)编写Struct2 的Action

    简介: 1.映射一个Action到一个类上面 2.把结果返回到view展示 3.编写Action对应的控制逻辑   1. Action Mapping <action name="he ...

  6. tyvj1038忠诚

    描述 Description 老管家是一个聪明能干的人.他为财主工作了整整10年,财主为了让自已账目更加清楚.要求管家每天记k次账,由于管家聪明能干,因而管家总是让财主十分满意.但是由于一些人的挑拨, ...

  7. ACM2036_改革春风吹满地(多边形面积计算公式)

    用到的知识点: 代码如下: /* Input 输入数据包含多个测试实例,每个测试实例占一行,每行的开始是一个整数n(3<=n<=100),它表示多边形的边数(当然也是顶点数),然后是按照逆 ...

  8. ZOJ3765---Lights (Splay伸展树)

    Lights Time Limit: 8 Seconds      Memory Limit: 131072 KB Now you have N lights in a line. Don't wor ...

  9. POJ 3378

    题目链接 查找长度为5的上升序列总数 用的树状数组+高精度 用树状数组求在i前面比i小的数有几个 用的4个树状数组,A[i][j]表示长度为i的以j为结尾的个数,A[i][j]=A[i-1][1... ...

  10. tab切换jquery代码

    http://immmmm.com/jquery-tab-switch-code-improved.html html <div id="sidebar-tab">   ...