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
  1. 5 3
    -6 0 35 -2 4
Output
  1. 8
Input
  1. 4 2
    7 0 0 -7
Output
  1. 7
  1. #include <stdio.h>
  2. #include <string.h>
  3. int main()
  4. {
  5. int n;
  6. int i,j,k;
  7. while(scanf("%d",&n)!=EOF)
  8. {
  9. if(n%==)
  10. {
  11. printf("%d\n",n*n/);
  12. for(i=;i<=n/;i++)
  13. {
  14. for(j=;j<=n;j++)
  15. if(j%==)
  16. printf("C");
  17. else
  18. printf(".");
  19. printf("\n");
  20. for(j=;j<=n;j++)
  21. if(j%==)
  22. printf("C");
  23. else
  24. printf(".");
  25. printf("\n");
  26. }
  27. }
  28. else
  29. {
  30. printf("%d\n",(n+)*(n+)/+(n-)*(n-)/);
  31. for(i=;i<=n;i++)
  32. {
  33. if(i%==)
  34. {
  35. for(j=;j<=n;j++)
  36. if(j%==)
  37. printf("C");
  38. else
  39. printf(".");
  40. printf("\n");
  41. }
  42. else
  43. {
  44. for(j=;j<=n;j++)
  45. if(j%==)
  46. printf("C");
  47. else
  48. printf(".");
  49. printf("\n");
  50. }
  51. }
  52. }
  53. }
  54. return ;
  55. }

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. 如何在真机上调试Android应用程序(图文详解)(zz)

    http://www.cnblogs.com/lanxuezaipiao/archive/2013/03/11/2953564.html   1.首先将手机设置为调试模式 方法:设置——应用程序——开 ...

  2. 使用php模拟post的几种方法

    <?phpfunction file_get_contents_post($url,$post){$options=array('http'=>array('method'=>'PO ...

  3. Eclipse帮助文档配置

    Force Eclipse To Use Local Javadocs For Context-Sensitive Help 转自:http://www.gnostice.com/nl_article ...

  4. 给MD5加上salt随机盐值加密算法实现密码安全的php实现

    给MD5加上salt随机盐值加密算法实现密码安全的php实现 如果直接对密码进行散列,那么黑客可以对通过获得这个密码散列值,然后通过查散列值字典(例如MD5密码破解网站),得到某用户的密码.加上sal ...

  5. datatables条件判断列显示还是隐藏

    定义一个状态变量status根据条件取值true或者false,然后在datatables参数设置中相应的columns属性的data后面加上"visible":status,该列 ...

  6. linux问题汇总---如何生成密钥对

    准备:2台机器,ip分别为:192.168.0.195     192.168.1.210目的:通过195ssh远程访问210.无需输入密码 1.首先在195上生成密钥对.#cd /root/.ssh ...

  7. 使用ActionFilterAttribute 记录 WebApi Action 请求和返回结果记录

    使用ActionFilterAttribute 记录 WebApi Action 请求和返回结果记录 C#进阶系列——WebApi 异常处理解决方案 [ASP.NET Web API教程]4.3 AS ...

  8. linux man

    man能够为除命令之外的配置文件.系统调用.库调用等都能提供帮助手册,他们分别位于不同的章节中: 1.用户命令 2.系统调用 3.库调用 4.设备文件 5.配置文件 6.游戏 7.杂项 8.管理命令

  9. JavaEE基础(十三)

    1.常见对象(StringBuffer类的概述) A:StringBuffer类概述 通过JDK提供的API,查看StringBuffer类的说明 线程安全的可变字符序列 B:StringBuffer ...

  10. MyBatis 判断条件为等于的问题

    在用MyBatis操作数据库的时候相信很多人都用到,当在判断null, 大于,大于等于,小于,小于等于,不等于时估计很多都用到,比较容易实现了,这里就省略了,但唯独判断条件为等于时估计蛮多人遇到坑了, ...