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 ...
随机推荐
- LeetCode 476. Number Complement (数的补数)
Given a positive integer, output its complement number. The complement strategy is to flip the bits ...
- 浅析C#中单点登录的原理和使用
什么是单点登录?我想肯定有一部分人"望文生义"的认为一个用户只能在一处登录.其实这是错误的理解(我记得我第一次也是这么理解的).单点登录指的是多个子系统只需要登录一个,其他系统不需 ...
- java调用oracle数据库发布WebService
package com.hyan.service; import java.io.FileInputStream;import java.sql.Connection;import java.sql. ...
- winfrom窗体加载控制台程序,可以自定义输出语句颜色
winfrom窗体加载控制台程序,可以自定方输出语句颜色,如下图所示 怎么实现的此功能,网上有大把的方法,我这里已经把方法打包成了一个类,只需要引用调用就可以使用了,写的比较粗糙,如有发现需要改进的地 ...
- 数据结构中,几种树的结构表示方法(C语言实现)
//***************************************** //树的多种结构定义 //***************************************** # ...
- Strange fuction
Problem Description Now, here is a fuction: F(x) = 6 * x^7+8*x^6+7*x^3+5*x^2-y*x (0 <= x <=1 ...
- js中的事件缓存机制
异步任务指的是,不进入主线程.而进入"任务队列"(task queue)的任务,只有"任务队列"通知主线程,某个异步任务可以执行了,该任务才会进入主线程执行. ...
- java线程池ThreadPool
package com.java.concurrent; import java.util.concurrent.ExecutorService; import java.util.concurren ...
- Android 开发笔记___SQLite__优化记住密码功能
package com.example.alimjan.hello_world; /** * Created by alimjan on 7/4/2017. */ import com.example ...
- C# 面向对象基础&封装&继承&多态&加深一下冒泡排序写法
(一)面向对象是什么? 面向对象是一种编程思想 (二)为什么要用面向对象? 1.结构清晰 2.易于维护 3.方便扩展 (三)new一个对象是什么过程? 实例化构造函数创建对象的过程就是将类实例化的过程 ...