hdu Price List

Price List

Accepts: 1029

Submissions: 2020

Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 262144/131072 K (Java/Others)

Problem Description

There are nnn
shops numbered with successive integers from 111
to nnn
in Byteland. Every shop sells only one kind of goods, and the price of the
iii-th
shop‘s goods is viv_iv?i??.

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 TTT
(1≤T≤10)(1\leq T\leq 10)(1≤T≤10),
denoting the number of test cases.

In each test case, the first line of the input contains two integers n,mn,mn,m
(1≤n,m≤100000)(1\leq n,m\leq 100000)(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 nnn
integers v1,v2,...,vnv_1, v_2, ..., v_nv?1??,v?2??,...,v?n??
(1≤vi≤100000)(1\leq v_i\leq 100000)(1≤v?i??≤100000),
denoting the price of the iii-th
shop‘s goods.

Each of the next mmm
lines contains an integer qqq
(0≤q≤1018)(0\leq q\leq 10^{18})(0≤q≤10?18??),
denoting each number on Byteasar‘s account book.

Output

For each test case, print a line with mmm
characters. If the iii-th
number is sure to be strictly larger than the actual value, then the iii-th
character should be ‘1‘. Otherwise, it should be ‘0‘.

Sample Input

1
3 3
2 5 4
1
7
10000

Sample Output

001

水题,如果输入的数比总和大输出1  否则输出0

/************************************************
┆  ┏┓   ┏┓ ┆
┆┏┛┻━━━┛┻┓ ┆
┆┃       ┃ ┆
┆┃   ━   ┃ ┆
┆┃ ┳┛ ┗┳ ┃ ┆
┆┃       ┃ ┆
┆┃   ┻   ┃ ┆
┆┗━┓    ┏━┛ ┆
┆  ┃    ┃  ┆      
┆  ┃    ┗━━━┓ ┆
┆  ┃  AC代马   ┣┓┆
┆  ┃           ┏┛┆
┆  ┗┓┓┏━┳┓┏┛ ┆
┆   ┃┫┫ ┃┫┫ ┆
┆   ┗┻┛ ┗┻┛ ┆
************************************************ */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#define ll long long
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            ll a;
            scanf("%lld",&a);
            sum+=a;
        }
        for(int i=0;i<m;i++)
        {
            ll a;
            scanf("%lld",&a);
            if(a<=sum) printf("0");
            else printf("1");
        }
        printf("\n");
    }
}
时间: 2024-08-20 16:45:52

hdu Price List的相关文章

HDU 5804 Price List

只需和总和比较即可. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue>

HDU 2639 01背包(分解)

http://acm.hdu.edu.cn/showproblem.php?pid=2639 01背包第k优解,把每次的max分步列出来即可 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 struct Node 6 { 7 int price; 8 int val; 9 }node[1005]; 10 int main() 11 { 12 i

HDU 2546 饭卡(0-1背包)

http://acm.hdu.edu.cn/showproblem.php?pid=2546 题意: 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够).所以大家都希望尽量使卡上的余额最少. 某天,食堂中有n种菜出售,每种菜可购买一次.已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少. 思路:我们先用一个背包容量为price-5的背包去装菜,背包里

HDU 4122 Alice&#39;s mooncake shop 单调队列优化dp

Alice's mooncake shop Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4122 Description The Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu Festival is a popular harvest festival celebrated by Ch

hdu 1059 (多重背包) Dividing

这里;http://acm.hdu.edu.cn/showproblem.php?pid=1059 题意是有价值分别为1,2,3,4,5,6的商品各若干个,给出每种商品的数量,问是否能够分成价值相等的两份. 联想到多重背包,稍微用二进制优化一下.(最近身体不适,压力山大啊) 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #define inf 70000 5 using namespace s

HDU 1535 &amp;&amp; POJ 1511 Invitation Cards (SPFA 模板 + 反向建图)

Invitation Cards HDU: Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) POJ: Time Limit: 8000 MS     Memory Limit: 262144 K       Problem Description In the age of television, not many people attend theater performa

贪心/hdu 1009 FatMouse&#39; Trade

题意 有n种物品,每一种需要不同的消费,现在手里有m块钱,求问最多可以买多少 分析 贪心 把每一种物品的价格算出来,然后sort一下,按照价格从便宜到贵排序,能买多少买多少,买买买! Accepted Code 1 /* 2 PROBLEM:hdu1009 3 AUTHER:Nicole Lam 4 MEMO:贪心 5 */ 6 7 #include<cstdio> 8 #include<algorithm> 9 using namespace std; 10 11 12 stru

HDU 5023 A Corrupt Mayor&#39;s Performance Art (线段树)

A Corrupt Mayor's Performance Art Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others) Total Submission(s): 255    Accepted Submission(s): 114 Problem Description Corrupt governors always find ways to get dirty money.

hdu 2546 饭卡

0-1背包问题 i = 1,扫所有上限价钱只购买一件物品的最大消费(price[1]) i = 2,更新一遍,此时是购买两件物品的最大消费(price[2]) 以此类推~有n件物品 但是只进行到n-1,是因为最大的那件物品留至最后才减 价值最高上限为m-5 1 #include<iostream> 2 #include<memory.h> 3 #include<algorithm> 4 using namespace std; 5 int price[1010]; 6