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. java笔记02

    一,编写一个方法,使用以上算法生成指定数目(比如1000个)的随机整数 /** * */ package 课堂2; import java.util.Random; /** * @author 信16 ...

  2. 学习Identity Server 4的预备知识

    我要使用asp.net core 2.0 web api 搭建一个基础框架并立即应用于一个实际的项目中去. 这里需要使用identity server 4 做单点登陆. 下面就简单学习一下相关的预备知 ...

  3. java对象类型转换和多态性

    html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...

  4. 关于session共享的解决方法

    当网站业务规模和访问量的逐步增大,原本由单台服务器.单个域名组成的网站架构可能已经无法满足发展需要 此时会购买更多的服务器,并且以频道化的方式启用多个二级子域名,然后根据业务功能将网站分别部署在独立的 ...

  5. Ant 基本语法的使用示列

    ant -f build.xml  执行你的build.xml文件   <?xml version = "1.0"?> <project name = " ...

  6. 状压DP小结

    看了一个多星期状压DP,总算有点明白,大概可以分为两种:数据是在矩阵中的,数据是线性的,在矩阵中的一般就是排兵布阵这一种的,还有一种线性结构中给定条件让你求最大权值,比如求最大权值路线,TSP问题等, ...

  7. SharePoint Server 2013 安装篇 - 如何解决无法找到 .net 4.5 的问题

    SharePoint Server 2013 在安装前,是不能安装 VS 等会自动安装 .net 4.5.x 以上版本的 .net Framework 的软件的.因为安装了 .net Framewor ...

  8. window10下的eclipse用java连接hadoop执行mapreduce任务

    一.准备工作 1.eclipse连接hadoop的插件,需要版本匹配,这有几个常用的 2 版本的插件 hadoop2x-eclipse-plugin-master 密码:feg1 2.hadoop-c ...

  9. 记录下 Markdown 语法

    github上常用markdown语法:Mastering Markdown 目录 0. 目录 1. 锚点 2.标题 3.超链接 3.1.行内式 3.2.自动链接 4.列表 4.1.有序列表 4.2. ...

  10. Node.js 常用工具

    Node.js 常用工具 util 是一个Node.js 核心模块,提供常用函数的集合,用于弥补核心JavaScript 的功能 过于精简的不足. util.inherits util.inherit ...