CodeForces 34B 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
5 3
-6 0 35 -2 4
8
4 2
7 0 0 -7
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的更多相关文章
- 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 ...
- Shovel Sale CodeForces - 899D (数位dp)
大意: n把铲子, 价格1,2,3,...n, 求有多少个二元组(x,y), 满足x+y末尾数字9的个数最多. 枚举最高位, 转化为从[1,n]中选出多少个二元组和为$x$, 枚举较小的数 若$n\g ...
- 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 最多」的 ...
- 【Codeforces Round #452 (Div. 2) D】Shovel Sale
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 让N乘2->a 然后看一下位数是多少. 假设有x位(x>=2) 则(0..(a%10-1) ) + (99..9)[x- ...
- 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 ...
- Codeforces Gym 100571A A. Cursed Query 离线
A. Cursed QueryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100571/problem ...
- codeforces edu round3
B. The Best Gift 传送门:http://codeforces.com/problemset/problem/609/B Emily's birthday is next week a ...
- 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 ...
- 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 ...
随机推荐
- zw版【转发·台湾nvp系列Delphi例程】HALCON BinThreshold
zw版[转发·台湾nvp系列Delphi例程]HALCON BinThreshold unit Unit1;interfaceuses Windows, Messages, SysUtils, Var ...
- Objective-C语言的面向对象特性
Objective-C作为一种面向对象的编程语言,具有面向对象的基本特征,即:封装.继承和多态.主要介绍Objective-C中有关面向对象基本概念:类.对象.方法和属性等. 类是Objective- ...
- 6.1:SportStore:一个真实的应用
之前的小例子让我们演示了AngularJS的一些特性,但他们缺少上下文.要解决这个问题,作者要创建一个简单单真实的电子商务应用. 作者将创建一个在线产品分类,客户可以通过分类和页面浏览,一个购物车用户 ...
- js命名空间笔记
在量比较大或者多人编写的情况下,命名冲突就很有可能发生,同一个页面引用了两个命名相同功能不同的文件,调用的时候就会出问题.因此使用JS命名空间很重要. 1.采用字面量方法创建命名空间: var a={ ...
- 【转】MYSQL入门学习之五:MYSQL的字符集
转载地址:http://www.2cto.com/database/201212/175541.html MySQL的字符集支持(Character Set Support)有两个方面:字符集(Cha ...
- asp.net c# 打开新页面或页面跳转
1.最常用的页面跳转(原窗口被替代):Response.Redirect("XXX.aspx"); 2.利用url地址打开本地网页或互联网:Respose.Write(" ...
- PIGS 分类: POJ 图论 2015-08-10 09:15 3人阅读 评论(0) 收藏
PIGS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18209 Accepted: 8277 Description Mir ...
- {A} + {B} 分类: HDU 2015-07-11 18:06 6人阅读 评论(0) 收藏
{A} + {B} Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- 山东理工大学第七届ACM校赛-飞花的线代 分类: 比赛 2015-06-26 10:29 10人阅读 评论(0) 收藏
飞花的线代 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 飞花壕的线代一直非常的壕(好),线代考试每次都是全班第一.一次,飞花壕在预习 ...
- js获取url值
// 获取地址栏的参数数组 function getUrlParams() { var search = window.location.search; // 写入数据字典 var tmparray ...