Price List

Price List

Accepts: 880

Submissions: 2184

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

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

问题描述

在Byteland一共有nnn家商店,编号依次为111到nnn。每家商店只会卖一种物品,其中第iii家商店的物品单价为viv_iv?i??。

Byteasar每天都会进行一次购物,他会在每家商店购买最多一件物品,当然他也可以选择什么都不买。回家之后,Byteasar会把这一天购物所花的钱的总数记录在账本上。

Byteasar的数学不好,他可能会把花的钱记少,也可能记多。Byteasar并不介意记少,因为这样看上去显得自己没花很多钱。

请写一个程序,帮助Byteasar判断每条记录是否一定记多了。

输入描述

输入的第一行包含一个正整数T(1≤T≤10)T(1\leq T\leq 10)T(1≤T≤10),表示测试数据的组数。

对于每组数据,第一行包含两个正整数n,m(1≤n,m≤100000)n,m(1\leq n,m\leq 100000)n,m(1≤n,m≤100000),表示商店的个数和记录的个数。

第二行包含nnn个正整数vi(1≤vi≤100000)v_i(1\leq v_i\leq 100000)v?i??(1≤v?i??≤100000),依次表示每家商店的物品的单价。

接下来mmm行,每行包含一个整数q(0≤q≤1018)q(0\leq q\leq 10^{18})q(0≤q≤10?18??),表示一条记录。

输出描述

对于每组数据,输出一行mmm个字符,依次回答每个询问。如果一定记多了,请输出‘1‘,否则输出‘0‘。

输入样例

1
3 3
2 5 4
1
7
10000

输出样例

001

求出所有数的和sumsumsum,如果q>sumq > sumq>sum那么肯定记多了。

时间复杂度O(n)O(n)O(n)。

#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#define fi first
#define se second
#define pi pair<int,int>
#define md make_pair
#define ha pair<int,pair<int,pi> >
using namespace std;
const int maxn=5005;
long long  n,m,s[105540];

main()
{
    freopen("data.in","r",stdin);
    int t;
    scanf("%d",&t);
    while(t--){
        long long sum=0;
        scanf("%lld%lld",&n,&m);
        for(int i=0;i<n;i++)    {scanf("%lld",s+i); sum+=s[i];}
        while(m--){
            long long  x;
            scanf("%lld",&x);
            if(x>sum)   printf("1");
            else printf("0");
        }
        printf("\n");
    }

}
时间: 2024-12-17 08:25:13

Price List的相关文章

Price Control V or S in Material Type (Price control in material master )

When is it useful to use the price control V or S in Material Master?  Do I have to follow the SAP standard setting in the material type for the following material types: - ROH (Raw materials) -> moving average price - HALB (Semifinished products) ->

uva 10313 Pay the Price (DP)

uva 10313 Pay the Price 题目大意:现在有300种面额的硬币(1~300),给出一个金额数,问这300种面额的硬币组成该金额数的方式有多少种.注意:该题的输入有三种模式,1个数n:n为金额数:2个数n, a:n为金额数,a为硬币个数上限:3个数n, a,b:n为金额数,a b为硬币个数的下限和上限. 解题思路:dp[i][j]表示面额i的金额,在硬币数不超过j的情况下,有几种组成方式.这个题目涉及到一个结论,用不超过i个硬币凑出面值j的方案种数,是和用面值不超过i的硬币凑出

AMAZON PRICE TRACKER, AMAZON PRICE HISTORY, AMAZON PRICE DROP ALERT | DROPGG.COM

DropGG.com is the destination for savvy shoppers looking to save money by buying smart. DropGG.com allows you to easily view the recent price history of any product in our vast database and also lets you set email or Twitter price drop alerts for pro

Exercise 3.3 Calculate a discounted price

Exercise 3-3. Write a program that will calculate the price for a quantity entered from the keyboard, given that the unit price is $5 and there is a discount of 10 percent for quantities over 30 and a 15 percent discount for quantities over 50. 1 //

hdu-5804 Price List(水题)

题目链接: Price List Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 262144/131072 K (Java/Others) Problem Description There are n shops numbered with successive integers from 1 to n in Byteland. Every shop sells only one kind of goods, and the

PAT 1090. Highest Price in Supply Chain (25)(DFS啊 )

题目链接:http://www.patest.cn/contests/pat-a-practise/1090 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer. Starting from one root supplier, everyone o

how to update product listing price sale price and sale date using mobile App

Greetings from Amazon Seller Support, Thank you for writing back to us. I have reviewed our previous correspondence with you, and I offer my sincere apologies for any misunderstandings thus far. I understand that you would like to know how to update

Exercise 2.3 Calculating volume price of alternative products

// Exercise 2.3 Calculating volume price of alternative products // The only problem here is to devise a way to determine the price // for the product type. Here I used the product type value to do this. #include <stdio.h> int main(void) { double to

How to Simulate the Price Order or Price Line Function using API QP_PREQ_PUB.PRICE_REQUEST Includes

How to Simulate the Price Order or Price Line Function using API QP_PREQ_PUB.PRICE_REQUEST Includes Example Scripts (文档 ID 412545.1) 转究竟部 In this Document _afrLoop=270486812581593&id=412545.1&displayIndex=4&_afrWindowMode=0&_adf.ctrl-state