Topic Links:
Price List
Time limit:2000/1000 MS (java/others)
Memory limit:262144/131072 K (java/others)
Problem Descriptionthere isNShops numbered with successive integers from1ToNIn Byteland. Every shop sells only one kind of goods, and the price of theI-th Shop ' s goods arevi.
Every day, Byteasar'll purchase some goods. He'll buy at the most one piece of goods from each shop. Of course, he can also choose to buy nothing. Back home, Byteasar would calculate the total amount of money he had 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 the he wrote down a smaller number, because it seems the He hadn ' t used too much money.
Byteasar judge whether each number are sure to be strictly larger than the actual value.
Inputthe first line of the input contains an integerT(1≤T≤) , denoting the number of test cases.
The first line of the input contains the integersn,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 containsNIntegersv1,v2,.. . ,vn (1≤vi≤100000) , denoting the price of theI-th Shop ' s goods.
Each of the nextm lines contains an integer q ( Span id= "mathjax-span-89" class= "mn" >0≤ q≤ 1018) , denoting each number on Byteasar's account book.
Outputfor each test case, print a line with m characters. If the i-th number is sure to being strictly larger than the actual value, then the i-th charact Er should be ' 1 '. Otherwise, it should be ' 0 '.
Sample Input13 32 5 41710000
Sample Output001 Test Instructions: Does it have to be a lot of memory? Idea: water problem; AC Code:
/************************************************┆┏┓┏┓┆┆┏┛┻━━━┛┻┓┆┆┃┃┆┆┃━┃┆┆┃┳┛┗┳┃┆┆┃┃ ┆┆┃┻┃┆┆┗━┓┏━┛┆┆┃┃┆┆┃┗━━━┓┆┆┃ac Horse ┣┓┆┆┃┏┛┆┆┗┓┓┏━┳┓┏┛┆┆┃┫┫┃┫┫┆ ┆┗┻┛┗┻┛┆************************************************ * * #include <iostream> #include <cstdio># Include <cstring> #include <algorithm> #include <cmath>//#include <bits/stdc++.h> #include <stack> using namespace std; #define for (i,j,n) for (int i=j;i<=n;i++) #define MST (SS,B) memset (ss,b,sizeof (ss)); typedef long Long LL; Template<class t> void Read (t&num) {char CH; bool F=false; For (Ch=getchar (); ch< ' 0 ' | | Ch> ' 9 '; f= ch== '-', Ch=getchar ()); for (num=0; ch>= ' 0 ' &&ch<= ' 9 '; num=num*10+ch-' 0 ', Ch=getchar ()); F && (num=-num);} int stk[70], tp;template<class t> inline void print (T p) {if (!p) {puts ("0"); return;} while (p) stk[++ TP] = p%10, p/=10; while (TP) Putchar (stk[tp--] + ' 0 '); Putchar (' \ n ');} Const LL Mod=1e9+7;const double Pi=acos ( -1.0); const int INF=1E9;CONST int N=1e6+10;const int Maxn=2e3+14;const double eps= 1e-12;int Main () {int t; Read (t); while (t--) {int n,m,x,mmax=0; LL sum=0,temp; Read (n); read (m); for (i,1,n) read (x), sum=sum+x; Sort (a+1,a+n+1); while (m--) {read (temp); if (temp>sum) printf ("1"); else printf ("0"); } printf ("\ n"); } return 0;}
hdu-5804 Price List (water problem)