HDU5804--Price List
Price List
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)
Total Submission(s): 731 Accepted Submission(s): 417
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.
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.
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'.
1
3 3
2 5 4
1
7
10000
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的更多相关文章
- hdu-5804 Price List(水题)
题目链接: Price List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Othe ...
- HDU5804 Price List (BestCoder Round #86 A)水题
分析:大于总和输出1 #include <cstdio> #include <cstring> #include <algorithm> using namespa ...
- 简明外贸报价单(Price List)范本
简明外贸报价单(Price List)范本 简明外贸报价单(Price List)范本 报价单 Price List 报价日期:年 月 日 Supplier Address 供应商 公司地址 Co ...
- Price List
Price List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/131072 K (Java/Others)Tota ...
- CodeForces 219B Special Offer! Super Price 999 Bourles!
Special Offer! Super Price 999 Bourles! Time Limit:1000MS Memory Limit:262144KB 64bit IO For ...
- graph-tool文档(一)- 快速开始使用Graph-tool - 2.属性映射、图的IO和Price网络
目录: 属性映射 -- 内部属性映射 图的I/O 构建一个 Price网络(例) 名词解释: Property maps:属性映射 PropertyMap:一个类 scalar value types ...
- 在magneto系统中输出tier price的最小值
2012年6月16日星期六 Asia/Shanghai上午11时39分22秒 有的时候,我们想输出产品的tier price 的最小值!如图: 下面是解决的办法: 1. 在catalog/produc ...
- Amazon教程:刚买就降价!避免损失,申请PRICE MATCH(价格保护)的方法
Amazon的商品价格波动频繁,虽然老白通常都在价格较低的时机向大家推荐,但是经常有降了又降的情况,刚下的单还没到手就又降价了,这种滋味肯定不好受.Amazon客服明确告诉老白一周内降价都可以申请PR ...
- VKP5 Price Calculation – List Variant & KZPBL (Delete site level)
List Variant: Configuration in Logistic General –> Retail Pricing –> Sales Price Calculation – ...
- 1106. Lowest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
随机推荐
- Vim - 常用配置
基本配置 不用任何插件的情况下,先按如下配置: set nu syntax on set hlsearch set tabstop=4 set shiftwidth=4 set expandtab s ...
- 微信小程序之页面下拉刷新
如果需要给单个页面设置下拉刷新功能,不需要写在""window"对象里面,直接在 文件名称.json 里面设置即可 { "enablePullDownRefr ...
- SSM框架中的注解,配置和控制器相关笔记
常规SSM实例 探索SSM理论的前提,应该是在对框架基础的运作方式有一定了解,以下是个人Android后台项目,用SSM框架快速搭建,以下是代码,主要 观察结构. 代码结构: model实体类 Ida ...
- 最长上升子序列(NlogN)总结
最长上升子序列总结 最开始的知道最长上升子序列的时候,简单DP的时候,但是后来遇到很多最长上升子序列的问题就没法用DP来解决,时间复杂度和空间复杂度都不允许.
- Paint the Grid Again (隐藏建图+优先队列+拓扑排序)
Leo has a grid with N × N cells. He wants to paint each cell with a specific color (either black or ...
- HDU X mod f(x)(题解注释)
X mod f(x) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- C#语言支持的特性,.NET却不支持,那么C#不被.NET支持的部分又是如何在.NET上运行的呢?
阅读<C#高级编程>系列丛书中,介绍C#与.NET的关系,提到C#是语言,.NET是平台(C#不是.NET的一部分),说".NET支持的一些特性,C#并不支持",这个可 ...
- Even Tree 小议
原题链接:https://www.hackerrank.com/challenges/even-tree/problem 思路:把树还原出来,对每个结点,计算以该结点为根的子树结点数.子树结点数为偶数 ...
- linq 在查询表达式中处理异常
在查询表达式的上下文中可以调用任何方法. 但是,我们建议避免在查询表达式中调用任何会产生副作用(如修改数据源内容或引发异常)的方法. 此示例演示在查询表达式中调用方法时如何避免引发异常,而不违反有关异 ...
- Problem B: 大整数的加法运算 升级版
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> ...