本文主要是介绍【HDU5804 BestCoder Round 86A】【水题】Price List,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Price List
Accepts: 880
Submissions: 2184
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 262144/131072 K (Java/Others)
问题描述
在Byteland一共有n家商店,编号依次为1到n。每家商店只会卖一种物品,其中第i家商店的物品单价为vi。Byteasar每天都会进行一次购物,他会在每家商店购买最多一件物品,当然他也可以选择什么都不买。回家之后,Byteasar会把这一天购物所花的钱的总数记录在账本上。Byteasar的数学不好,他可能会把花的钱记少,也可能记多。Byteasar并不介意记少,因为这样看上去显得自己没花很多钱。请写一个程序,帮助Byteasar判断每条记录是否一定记多了。
输入描述
输入的第一行包含一个正整数T(1≤T≤10),表示测试数据的组数。对于每组数据,第一行包含两个正整数n,m(1≤n,m≤100000),表示商店的个数和记录的个数。第二行包含n个正整数vi(1≤vi≤100000),依次表示每家商店的物品的单价。接下来m行,每行包含一个整数q(0≤q≤1018),表示一条记录。
输出描述
对于每组数据,输出一行m个字符,依次回答每个询问。如果一定记多了,请输出'1',否则输出'0'。
输入样例
1 3 3 2 5 4 1 7 10000
输出样例
001
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
const int N = 100010, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
int n, m;
char ans[N];
int main()
{scanf("%d", &casenum);for (casei = 1; casei <= casenum; ++casei){scanf("%d%d", &n, &m);int x; LL sum = 0;for (int i = 1; i <= n; ++i)scanf("%d", &x), sum += x;for (int i = 1; i <= m; ++i){LL y; scanf("%lld", &y);ans[i] = '0' + (y > sum);}ans[m + 1] = 0;puts(ans + 1);}return 0;
}
这篇关于【HDU5804 BestCoder Round 86A】【水题】Price List的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!