首页 > 试题广场 >

支付宝消费打折

[编程题]支付宝消费打折
  • 热度指数:8362 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
众所周知,在一些消费支付的场合中,往往有“支付宝九五折”的优惠。
这天小苯来到了超市购买物品,一共有 n 种物品,每种物品只能购买一个,但有的物品支持优惠活动,有的并不支持。恰好本超市的结账是有“支付宝九五折”优惠的,小苯的支付宝余额还剩 k 元,他想知道他仅使用支付宝进行支付的话,最多能买几件物品?

输入描述:
输入包含三行。
第一行两个正整数 n, k\ (1 \leq n \leq 10^5), \ (1 \leq k \leq 10^9)
第二行包含 n 个正整数 a_i (1 \leq a_i \leq 10^4) 表示每个物品的价格。
第三行一个长度为 n 的只含有 01 的字符串,表示每个物品是否支持优惠。(如果是 1 代表第 i 个物品支持优惠,否则不支持。)


输出描述:
输出一行一个整数表示答案。
示例1

输入

5 9
3 4 2 3 1
11101

输出

4

说明

选择买第 1,3,4,5 个物品。
头像 呆瓜不呆
发表于 2025-08-06 01:47:13
#include <algorithm> #include <cstdint> #include <iostream> #include <vector> using namespace std; int main() { long long 展开全文
头像 我是芭芭拉的狗
发表于 2025-12-26 14:35:50
n, k = map(int,input().split()) jia = list(map(int, input().split())) b = input() hao = [] for i in b: hao.append(int(i)) zu = list(zip(jia,hao)) 展开全文
头像 be_flyling
发表于 2025-10-23 01:05:18
l = input().split(' ') n, k = int(l[0]), int(l[1]) n_list = [int(i) for i in input().split(' ')] p_list = [int(i) for i in list(input())] for ind, i i 展开全文
头像 立花泷之介
发表于 2026-02-17 15:57:46
#include <algorithm> #include <iostream> #include <vector> using namespace std; // 要想买到最多东西,言外之意就是买最便宜的东西 int main() { int n,k; 展开全文
头像 zhenghahahawda
发表于 2025-07-29 21:16:49
#include <iostream> #include <algorithm> using namespace std; int main() { int n;double k;cin>>n>>k; double a[n]; 展开全文
头像 Xiettt
发表于 2026-02-12 18:42:49
#include<bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; using i128=__int128_t; using u128=__uint128_t; u 展开全文
头像 牛客253847561号
发表于 2026-03-12 10:17:00
n,k=map(int,input().split()) l1=list(map(int,input().split())) l2=list(map(int,input())) h=[] t=0 c=0 for i in range(n): if l2[i]==1: h.ap 展开全文
头像 Vermouth贝尔摩德
发表于 2026-01-11 22:59:27
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { ios::sync_with_stdio(false);//缩短运行 展开全文
头像 Naruse
发表于 2025-07-30 10:57:22
n,k = map(int,input().split()) g = list(map(int,input().split())) z = str(input()) f = [] for i in range(n): if z[i] == '1': f.append(g[i] 展开全文
头像 Danzo123
发表于 2026-02-05 13:17:45
import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new S 展开全文