Best Coder #86 1001 Price List(大水题)

Price List

Accepts: 880

Submissions: 2184

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

Copy

1
3 3
2 5 4
1
7
10000

Sample Output

Copy

001
#include <iostream>
#include <stdio.h>
#include <string.h>
#define N (1<<12)+5
#define M 12
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    int t;
    long long a,b,n,m,s;
    scanf("%d",&t);
    while(t--)
    {
        s=0;
        scanf("%lld%lld",&n,&m);
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&a);
            s+=a;
        }
        for(int i=0;i<m;i++)
        {
            scanf("%lld",&b);
            if(b>s)
                printf("1");
            else
                printf("0");
        }
        printf("\n");
    }
    return 0;
}
时间: 2024-07-30 13:36:22

Best Coder #86 1001 Price List(大水题)的相关文章

PAT甲题题解-1101. Quick Sort (25)-大水题

快速排序有一个特点,就是在排序过程中,我们会从序列找一个pivot,它前面的都小于它,它后面的都大于它.题目给你n个数的序列,让你找出适合这个序列的pivot有多少个并且输出来. 大水题,正循环和倒着循环一次,统计出代码中的minnum和maxnum即可,注意最后一定要输出'\n',不然第三个测试会显示PE,格式错误. #include <iostream> #include <cstdio> #include <algorithm> #include <map&

大水题(water)

题目描述dzy 定义一个 $n^2$ 位的数的生成矩阵 $A$ 为一个大小为 $n \times n$ 且 Aij 为这个数的第 $i \times n+j-n$ 位的矩阵.现在 dzy 有一个数 $n^2$ 位的数 k,他想知道所有小于等于 k 的数的 $n \times n$ 生成矩阵有多少种.(如果不足 $n^2$ 位则补前缀零)输入输出格式输入格式第一行一个数 $n$,第二行一个 $n^2$ 位的数 $k$输出格式仅一行表示答案,答案可能很大,你只需输出答案对 $10^9 + 7$ 取模

[补档]两个奇怪的大水题

导引 这是两道由OSU(貌似是一个我没有听说过的游戏)引申出的大水题(淼到不行啊喂),壹佰万行代码哦. T1 OSU! 题目 osu 是一款群众喜闻乐见的休闲软件. 我们可以把osu的规则简化与改编成以下的样子: 一共有n次操作,每次操作只有成功与失败之分,成功对应1,失败对应0,n次操作对应为1个长度为n的01串.在这个串中连续的 X个1可以贡献X^3 的分数,这x个1不能被其他连续的1所包含(也就是极长的一串1,具体见样例解释) 现在给出n,以及每个操作的成功率,请你输出期望分数,输出四舍五

Pythagorean Triples CodeForces - 707C 推理题,大水题

给定一个数n(1 <= n <= 1e9),判断这个数是否是一个直角三角形的边长,如果是,则输出另外两条边(1 <= x <= 1e18),否则输出-1. 参考题解:http://blog.csdn.net/harlow_cheng/article/details/69055614 首先,当n <= 2 的时候无解,其他时候都有解 假设n是直角边,a是斜边,则n^2 + b^2 = a^2; n^2 = (a + b)*(a - b); ①假设n是偶数,则另(a - b) =

UVA12709 Falling Ants(超级大水题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4447 Ps:此题超级水,但是光看题目就会被吓一跳.确实题目很长,不过有用的语句少之又少,介绍一大堆与AC没有半毛钱关系的东西,汗颜. 此题告诉我们题目长不一定是最难得题,反而有时候是最简单的题,就看你有

UVA 100 The 3n + 1 problem(超级大水题)

The 3n + 1 problem Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Description Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you

BZOJ_1621_[Usaco2008_Open]_Roads_Around_The_Farm_分岔路口(模拟+大水题)

描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1621\(n\)头奶牛,刚开始在一起,每次分成\(x\)和\(x+m\)两部分,直到不能再分,问最后一共有几部分. 分析 可以知道当前奶牛数\(n=x+x+m\),所以可以继续分的必要条件是\(n-m>=2\),然后dfs就好了... 对于大数据,\(m=1000\)和\(m=1\)并没有什么区别,所以可以认为搜索时候一直是二分的,所以有\(log_2^n\)层,最下面一层有\(2^{log_

第三届山西省赛1004 一道大水题(scanf)

一道大水题 时间限制: C/C++ 2000ms; Java 4000ms 内存限制: 65535KB 通过次数: 44 总提交次数: 1020 问题描述 Dr. Pan作为上兰帝国ACM的总负责人,对队员的队员的训练也是日常关心,他要求每周要有一位队员出一道题目.不知过了多少年,终于轮到Shiyiliang出题了,他费尽脑汁,终于出了一道大水题 给定一个偶数n,n的取值范围为[-1e18,1e18],要求一对整数x,y满足以下条件: 1.x*y==n 2.x与n必须同号,即如果n>0则x>0

三道大水题

和sxd出的大水题,T1T2大样例连续出锅快被表死了. 题面在这里 这是完整的选手文件夹 题解在这儿 这里是数据 原文地址:https://www.cnblogs.com/pfypfy/p/9862808.html