Price List

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Others)

Total Submission(s): 731    Accepted Submission(s): 417

Problem Description
There are n shops
numbered with successive integers from 1 to n in
Byteland. Every shop sells only one kind of goods, and the price of the i-th
shop's goods is vi.



Every day, Byteasar will purchase some goods. He will buy at most one piece of goods from each shop. Of course, he can also choose to buy nothing. Back home, Byteasar will calculate the total amount of money he has costed that day and write it down on his account
book.



However, due to Byteasar's poor math, he may calculate a wrong number. Byteasar would not mind if he wrote down a smaller number, because it seems that he hadn't used too much money.



Please write a program to help Byteasar judge whether each number is sure to be strictly larger than the actual value.
 
Input
The first line of the input contains an integer T (1≤T≤10),
denoting the number of test cases.



In each test case, the first line of the input contains two integers n,m (1≤n,m≤100000),
denoting the number of shops and the number of records on Byteasar's account book.



The second line of the input contains n integers v1,v2,...,vn (1≤vi≤100000),
denoting the price of the i-th
shop's goods.



Each of the next m lines
contains an integer q (0≤q≤1018),
denoting each number on Byteasar's account book.
 
Output
For each test case, print a line with m characters.
If the i-th
number is sure to be strictly larger than the actual value, then the i-th
character should be '1'. Otherwise, it should be '0'.
 
Sample Input
1
3 3
2 5 4
1
7
10000
 
Sample Output
001

解题思路:超过商品总价值就是用超了

源代码:

<span style="font-size:18px;">#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<ctime>
using namespace std; typedef long long ll; ll ans[100001]; int main()
{
int t;
int n,m;
int i;
ll sum;
ll temp;
char s[100001];
scanf("%d",&t);
while(t--)
{
memset(ans,0,sizeof(ans));
memset(s,0,sizeof(s));
sum = 0;
scanf("%d%d",&n,&m);
for(i = 0; i < n; i++)
{
scanf("%lld",&ans[i]);
sum+=ans[i];
}
for(i = 0; i < m; i++)
{
scanf("%lld",&temp);
if(temp <= sum)
s[i]='0';
else
s[i]='1';
}
printf("%s\n",s);
}
return 0;
}
</span>

HDU5804--Price List的更多相关文章

  1. hdu-5804 Price List(水题)

    题目链接: Price List Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 262144/131072 K (Java/Othe ...

  2. HDU5804 Price List (BestCoder Round #86 A)水题

    分析:大于总和输出1 #include <cstdio> #include <cstring> #include <algorithm> using namespa ...

  3. 简明外贸报价单(Price List)范本

    简明外贸报价单(Price List)范本 简明外贸报价单(Price List)范本 报价单 Price List 报价日期:年 月   日 Supplier Address 供应商 公司地址 Co ...

  4. Price List

    Price List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/131072 K (Java/Others)Tota ...

  5. CodeForces 219B Special Offer! Super Price 999 Bourles!

    Special Offer! Super Price 999 Bourles! Time Limit:1000MS     Memory Limit:262144KB     64bit IO For ...

  6. graph-tool文档(一)- 快速开始使用Graph-tool - 2.属性映射、图的IO和Price网络

    目录: 属性映射 -- 内部属性映射 图的I/O 构建一个 Price网络(例) 名词解释: Property maps:属性映射 PropertyMap:一个类 scalar value types ...

  7. 在magneto系统中输出tier price的最小值

    2012年6月16日星期六 Asia/Shanghai上午11时39分22秒 有的时候,我们想输出产品的tier price 的最小值!如图: 下面是解决的办法: 1. 在catalog/produc ...

  8. Amazon教程:刚买就降价!避免损失,申请PRICE MATCH(价格保护)的方法

    Amazon的商品价格波动频繁,虽然老白通常都在价格较低的时机向大家推荐,但是经常有降了又降的情况,刚下的单还没到手就又降价了,这种滋味肯定不好受.Amazon客服明确告诉老白一周内降价都可以申请PR ...

  9. VKP5 Price Calculation – List Variant & KZPBL (Delete site level)

    List Variant: Configuration in Logistic General –> Retail Pricing –> Sales Price Calculation – ...

  10. 1106. Lowest Price in Supply Chain (25)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

随机推荐

  1. Linux crontab定时器设置(定期执行java程序)(转)

    Crontab 语法 Crontab语法一个crontab文件用五个段来定义:天,日期和时间,和一个要定期执行的命令代码. *    *  *  *   *  command to be execut ...

  2. myeclipse自动保存修改代码

    当你修改过代码后,myeclipse往往要你手动的保存代码才能运行这个修改后的代码,要是不保存就会一直运行修改前的代码.只要修改myeclipse中这两项,就可以让它编译运行修改后的代码: Windo ...

  3. javascript中数组与字符串之间的转换以及字符串的替换

    数组转化为字符串: var a=['aa','bb','cc']; var b=a.join('-'); console.log(b)----->'aa-bb-cc' 字符串中的替换: 1.re ...

  4. gulp learning note

    为啥写这一片文章呢? 主要是为了温故而知新和分享,也是为了更加促进自己的学习! 前端自动化工具很多  有grunt  gulp  webpack 等 这次主要分享下gulp的学习经验,让自己更好的总结 ...

  5. 基于HTML5 Canvas的CSG构造实体几何书架

    CSG 构造实体几何这个概念在工业水利水电施工上.游戏上已经有很多人使用了,最简单的实体表示叫作体元,通常是形状简单的物体,如立方体.圆柱体.棱柱.棱锥.球体.圆锥等.根据每个软件包的不同这些体元也有 ...

  6. C#递归查询

    一.sql --构造测试数据: 只作演示用 CREATE TABLE [dbo].[Tim_LinqTable]( [Id] int PRIMARY KEY IDENTITY(1,1) NOT NUL ...

  7. windows下配置wampserver

    第一,打开局域网访问 配置文件:点击右下角的WAMP 服务器小托盘,选择Apache>httpd.conf 搜索关键字 "deny from ",会发现一处 "de ...

  8. JavaScript系列----一切皆是对象

    1.判断对象类型 1.1.typeof 运算符 首先要认识到,typepof是一个运算符,其运算需要一个参数,返回值是参数的类型. typeof使用方法 typeof parameter //使用方法 ...

  9. 【Python】Non-ASCII character '\xe6' 错误解决方法

    刚刚在写Python程序的时候遇到了一个问题,无论是在程序中什么地方出现中文字符,都会出现如下错误 SyntaxError: Non-ASCII character '\xe6' 网上查阅了一下这应该 ...

  10. 数据库(概念、语法、DBMS、SQL语言:创建数据库、表格,添加、修改、删除数据记录)

    关系型数据库:以表作为实体,以主键和外键关系作为联系的一种数据结构. 主键:在关系型数据库中,用一个唯一的标识符来标志每一行,这个标识符就是主键.主键有两个特点:非空和不能重复. 外键:在关系型数据库 ...