当前位置: 首页 > news >正文

AtCoder Weekday Contest 0022 Beta题解(AWC 0022 Beta A-E)

A - Battery Level and Charger Arrival

【题目来源】

AtCoder:A - Battery Level and Charger Arrival (atcoder.jp)

【题目描述】

Takahashi manages \(N\) smartphones. The current battery level of the \(i\)-th smartphone is \(W_i\) percent.
高桥管理着 \(N\) 部智能手机。第 \(i\) 部手机的当前电量为 \(W_i\) 百分比。

The battery of a smartphone decreases by \(D\) percentage points per day if not charged.
如果不充电,手机的电池电量每天下降 \(D\) 个百分点。

Takahashi is considering ordering from an online charger store. If he places an order, the charger will arrive in exactly \(K\) days. Since Takahashi currently has no charger, he cannot charge any smartphone during the \(K\) days until it arrives.
高桥正在考虑从一家在线充电器商店下单。如果他下单,充电器将在恰好 \(K\) 天后送达。由于高桥目前没有充电器,在充电器送达前的 \(K\) 天内,他无法为任何手机充电。

After \(K\) days, when the charger arrives, the battery level of the \(i\)-th smartphone is considered to be \(W_i - D \times K\) percent. A smartphone with this value being \(1\) or more is still usable, while a smartphone with this value less than \(1\) has powered off and become unusable.
\(K\) 天后,当充电器送达时,第 \(i\) 部手机的电量被视为 \(W_i - D \times K\) 百分比。此值大于等于 \(1\) 的手机仍可使用,而此值小于 \(1\) 的手机将关机并无法使用。

Determine the number of smartphones among the \(N\) that are still usable after \(K\) days.
确定 \(K\) 天后仍可使用的手机数量。

【输入】

\(N\) \(D\) \(K\)
\(W_1\) \(W_2\) \(\ldots\) \(W_N\)

  • The first line contains the integer \(N\) representing the number of smartphones, the integer \(D\) representing the daily battery decrease, and the integer \(K\) representing the number of days until the charger arrives, separated by spaces.
  • The second line contains the integers \(W_1, W_2, \ldots, W_N\) representing the current battery levels of each smartphone, separated by spaces.

【输出】

Output in one line the number of smartphones that are still usable after \(K\) days.

【输入样例】

3 10 5
100 50 30

【输出样例】

1

【解题思路】

image

【代码详解】

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, d, k, ans;  // n: 总数量,d: 每天消耗量,k: 天数,ans: 结果计数signed main()
{cin >> n >> d >> k;  // 读入n, d, kfor (int i = 1; i <= n; i++)  // 遍历每个物品{int w; cin >> w;  // 读入当前物品的初始重量w = w - d * k;  // 计算经过k天后的剩余重量if (w >= 1)  // 如果剩余重量大于等于1{ans++;  // 计数加1}}cout << ans << endl;  // 输出满足条件的物品数量return 0;
}

【运行结果】

3 10 5
100 50 30
1
http://www.jsqmd.com/news/481097/

相关文章:

  • 华为OD机考双机位C卷 - 执行任务赚积分 (Java)
  • 真空气密连接器好用品牌有哪些,低温气密性同轴连接器推荐 - 工业品网
  • 华为OD机考双机位C卷 - 挑选字符串 (Java)
  • 讲讲航拍无人机模拟器APP品牌,傲睿尔科技产品值得了解 - myqiye
  • 华为OD机考双机位C卷 - 挑选宝石 (Java)
  • 盘点2026年上海新房室内设计公司,铂空间设计排名靠前 - 工业品网
  • 探讨2026年浙江诚信的Geo优化机构,哪家服务更靠谱 - mypinpai
  • 聊聊宁波推荐手工西服定制哪家好,这些品牌值得关注 - myqiye
  • 基于SpringBoot和PostGIS的云南与缅甸的千里边境线实战
  • 2026年用户口碑实证:五大瀑布管理软件系统稳定性与服务对比推荐 - 品牌推荐
  • 2026年用户口碑实证:五大瀑布管理平台功能覆盖与稳定性全面对比 - 品牌推荐
  • 第三部分 商谈伦理与价值原语化:共识达成的两种路径
  • 2026年家用七座MPV购车指南:关注空间、能耗与安全的平衡之道 - 速递信息
  • 江苏设备钣金制造商哪家比较靠谱,常州布恩实力见证 - 工业推荐榜
  • 深度剖析巨宇科技GEO优化,其在行业口碑排名如何值得关注 - mypinpai
  • 2026年用户口碑领先的项目集管理工具推荐:五款系统实战效果全面对比 - 品牌推荐
  • 2026年浙江靠谱的数字孪生工厂系统软件公司推荐,哪家性价比高 - 工业设备
  • 靠谱的GEO优化企业推荐,性价比高的品牌有哪些? - 工业推荐榜
  • 探讨东莞GEO优化排名服务商费用,看哪家收费合理? - 工业品牌热点
  • NMN牌子怎么选?抗衰品牌推荐,W+端粒塔破解日本临床研究关键 - 速递信息
  • 2026年家用七座MPV选购指南:用“家庭场景价值”框架,找到你的理想座驾 - 速递信息
  • 2026年项目集管理系统权威榜单发布:五大平台技术实力与战略价值深度评测 - 品牌推荐
  • 作业实践一:网络攻防环境搭建,20252911
  • 2026年项目集管理软件深度测评:基于战略协同与AI决策的四维对比 - 品牌推荐
  • 好用的数字孪生工厂系统公司怎么选,有什么选购技巧? - 工业设备
  • 图解缓存淘汰算法 LRU、LFU | 最近最少使用、最不经常使用算法 | go语言实现
  • 埃斯顿协作机器人推荐,常州哪家加工厂售后靠谱 - 工业品牌热点
  • 2026年宁波靠谱的婚礼高档西服定制选购指南 - myqiye
  • 2026年大型企业选型必看:项目集管理软件评测与战略级场景适配指南 - 品牌推荐
  • 聊聊2026年深圳靠谱的脆鲩鱼片供应企业,新鲜美味有保障 - 工业推荐榜