1282B1. K for the Price of One (Easy Version)
B1. K for the Price of One (Easy Version):题目
两种情况,前面取一或者前面不取
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> a((int)6e5);
vector<int> b((int)6e5), c((int)6e5);
const int mod = 1e9 + 7;
string s;
signed main()
{int t;cin >> t;while (t--){int n, p, k;cin >> n >> p >> k;for (int i = 0; i < n; i++)cin >> a[i];sort(a.begin(), a.begin() + n);a[n] = (int)2e9;int res = 0;int np = p;for (int i = 0; i < n; i += 2){if (a[i + 1] <= p){p -= a[i + 1];res += 2;}else if (a[i] <= p){p -= a[i];res++;}}int nres = 0;if (np >= a[0]){np -= a[0];nres = 1;}for (int i = 1; i < n; i += 2){if (a[i + 1] <= np){np -= a[i + 1];nres += 2;}else if (a[i] <= p){np -= a[i];nres++;}}cout << max(res, nres) << endl;}
}
1282B1. K for the Price of One (Easy Version)相关推荐
- K for the Price of One(EASY HARD)
This is the easy version of this problem. The only difference is the constraint on k - the number of ...
- CodeForces - 1543D1 RPD and Rap Sheet (Easy Version)(异或+交互)
题目链接:点击查看 题目大意:交互题猜密码,设原密码为 xxx,猜的密码为 yyy,如果没猜到,密码会自适应变成 zzz,满足 x⊕z=yx \oplus z=yx⊕z=y ,最多猜 nnn 次 题目 ...
- CF1497E1 Square-free division (easy version)
CF1497E1 Square-free division (easy version) 题意: 这是简单版,此题中 k=0 给出一串长为 n 的序列 a1,a2,a3...ana_1,a_2,a_3 ...
- 1560F1. Nearest Beautiful Number (easy version)
F1. Nearest Beautiful Number (easy version) 预处理加二分 #include <bits/stdc++.h> using namespace st ...
- 【CodeForces 1255E1 --- Send Boxes to Alice [Easy Version]】
[CodeForces 1255E1 --- Send Boxes to Alice [Easy Version]] Description This is the easier version of ...
- 1706D1 - Chopping Carrots (Easy Version)
原题链接: Problem - 1706D1 - Codeforces 题目描述: This is the easy version of the problem. The only differen ...
- CodeForces Round #730 D1. RPD and Rap Sheet (Easy Version)题解
Codeforces Round #730 (Div. 2) 题意: t组数据,每组给一个n和k,(easy version里面k=2) 每一次系统会输入一个初始的密码(初始密码是一个在[0,n−1] ...
- 智乃的数字积木(easy version)<每日一题>
题目: 题目链接: 登录-专业IT笔试面试备考平台_牛客网 题目思路(easy version): 封装一个能够在相同颜色交换位置 并将字符串转换成数字 的自定义函数 再每次改变颜色后 只需修改颜色值 ...
- Social Network (easy version)
Social Network (easy version) CodeForces 1234B1 这是一道我曾经训练时做过的一道题,为了应对上面的要求指标我不得不把它掏了出来(doge),这道题还是有点 ...
最新文章
- log parser 微软iis 日志分析
- Service Mesh 和 API Gateway 关系深度探讨
- 第三次学JAVA再学不好就吃翔(part106)--字符流
- 什么是 RedCap?一文详解!
- go语言的安装、环境变量配置及简单使用
- heartbeat V2实现MySQL+NFS高可用
- 运行maven项目整合ssm时的错误笔记
- lazy-list C 代码详解
- 电脑今天关机,第二天重启 解决方案
- 你需要了解的App经济学基础 转
- 计算机基础作业3考试客户端答案,2015年12月份考试作业计算机基础第3次作业满分答案...
- kubernetesv1.17集群生态搭建笔记
- java中graphics_在java中如何绘图?Graphics类是什么意思?
- 夏日汽车保养 雨季汽车保养
- 怎么设置计算机显示列表格式,(怎样显示excel的文件后缀名)excle后缀格式怎么显示...
- MySQL日志之错误日志(errorlog)
- 硬实时系统的语言构造和转换----普渡大学
- 基于STM32的煤矿井下探测系统
- 13、撤回(撤销)、驳回(退回)、作废(终止)、挂起(中止)
- 快速扩展在线文档产品特性的9个开源项目
热门文章
- mybatis BindingException: Invalid bound statement (not found)
- svn在linux下的使用(转)
- php 获取流文件大小,php获取文件大小详解
- mysql 4 中文模糊查询_解决MySQL中文模糊查询问题
- JS - JSON对象与JSON字符串相互转换的几种方法
- delphi android动态权限,DELPHI安卓动态权限申请
- Jsp传值方式(乱码问题的解决)
- 1017 A除以B (20分)
- 1065. 单身狗(25)
- 创业冲突的五种解决方法是_失眠原因不同,中医五种调理方法解决问题!