Sale

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he has no desire to go to the sale for the second time. Please, help Bob find out the maximum sum of money that he can earn.

Input

The first line contains two space-separated integers n and m (1 ≤ m ≤ n ≤ 100) — amount of TV sets at the sale, and amount of TV sets that Bob can carry. The following line contains n space-separated integers ai ( - 1000 ≤ ai ≤ 1000) — prices of the TV sets.

Output

Output the only number — the maximum sum of money that Bob can earn, given that he can carry at most m TV sets.

Sample Input

Input
5 3
-6 0 35 -2 4
Output
8
Input
4 2
7 0 0 -7
Output
7
 #include <stdio.h>
#include <string.h>
int main()
{
int n;
int i,j,k;
while(scanf("%d",&n)!=EOF)
{
if(n%==)
{
printf("%d\n",n*n/);
for(i=;i<=n/;i++)
{
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
}
}
else
{
printf("%d\n",(n+)*(n+)/+(n-)*(n-)/);
for(i=;i<=n;i++)
{
if(i%==)
{
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
}
else
{
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
}
}
}
}
return ;
}

CodeForces 34B Sale的更多相关文章

  1. Codeforces Gym 100513I I. Sale in GameStore 暴力

    I. Sale in GameStore Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/p ...

  2. Shovel Sale CodeForces - 899D (数位dp)

    大意: n把铲子, 价格1,2,3,...n, 求有多少个二元组(x,y), 满足x+y末尾数字9的个数最多. 枚举最高位, 转化为从[1,n]中选出多少个二元组和为$x$, 枚举较小的数 若$n\g ...

  3. Codeforces 899D Shovel Sale

    题目大意 给定正整数 $n$($2\le n\le 10^9$). 考虑无序整数对 $(x, y)$($1\le x,y\le n, x\ne y$). 求满足 「$x+y$ 结尾连续的 9 最多」的 ...

  4. 【Codeforces Round #452 (Div. 2) D】Shovel Sale

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 让N乘2->a 然后看一下位数是多少. 假设有x位(x>=2) 则(0..(a%10-1) ) + (99..9)[x- ...

  5. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...

  6. Codeforces Gym 100571A A. Cursed Query 离线

    A. Cursed QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100571/problem ...

  7. codeforces edu round3

    B. The Best Gift  传送门:http://codeforces.com/problemset/problem/609/B Emily's birthday is next week a ...

  8. Codeforces Round #346 (Div. 2) C Tanya and Toys

    C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a ...

  9. Codeforces Round #415 (Div. 2)(A,暴力,B,贪心,排序)

    A. Straight «A» time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...

随机推荐

  1. 使用Graham扫描法求二维凸包的一个程序

    #include <iostream> #include <cstring> #include <cstdlib> #include <cmath> # ...

  2. zw版_Halcon图像库delphi接口文件

    zw版_Halcon图像库delphi接口文件 Halcon图像库delphi接口文件,根据安装时用户设置的文件目录不同,会有所差异,笔者一般安装在delphi的import目录下.     参见:& ...

  3. Android之自定义生成彩色二维码

    先导个zxing.jar包 下面是xml布局 activity_main.xml <RelativeLayout xmlns:android="http://schemas.andro ...

  4. FreeOnTerminate 的线程在线程管理类的Destroy释放时手工释放的问题

    这个问题折腾了我整整一天. 有一个线程管理类,集中管理所有新建的线程, 线程统一在创建时标识 FreeOnTerminate 为 True. 因为有的线程是不限次循环的,所以在管理类最后 Destro ...

  5. linux设备驱动归纳总结(八):2.总线、设备和驱动的关系【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-110295.html linux设备驱动归纳总结(八):2.总线.设备和驱动的关系 xxxxxxxxx ...

  6. TM1680主从I2C设置.

    TM1680的工作流程通常是: 1. 通电, 没啥可说 2. SYS DIS (主从), 1000-0000即0x80, 关闭系统时钟跟LED循环, 主机都从机地址都要发 3. COM设置 (主从), ...

  7. STM32模拟I2C

    之前为了测试, 拿最小板做了一个I2C的主发跟主读, 一开始当然是尝试用硬件I2C, 结果弄了很久, 时间紧迫, 只好用了模拟, 结果发现, 哎, 真特么挺好用的, 现在1片儿顶过去5片儿. 硬件I2 ...

  8. Java中的HashMap 浅析

    在Java的集合框架中,HashSet,HashMap是用的比较多的一种,顺序结构的ArrayList.LinkedList这种也比较多,而像那几个线程同步的容器就用的比较少,像Vector和Hash ...

  9. shell中读写mysql数据库

    本文介绍了如何在shell中读写mysql数据库.主要介绍了如何在shell 中连接mysql数据库,如何在shell中创建数据库,创建表,插入csv文件,读取mysql数据库,导出mysql数据库为 ...

  10. declare和typeset DEMO

    declare=typeset,用法完成相同. declare不指定变量:显示所有变量的值. -r选项,把指定变量定义为只读变量: [xiluhua@vm-xiluhua][~]$ declare - ...