news 2026/4/30 1:44:27

题解:AtCoder AT_awc0005_b Updating the Report Card

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
题解:AtCoder AT_awc0005_b Updating the Report Card

本文分享的必刷题目是从蓝桥云课洛谷AcWing等知名刷题平台精心挑选而来,并结合各平台提供的算法标签和难度等级进行了系统分类。题目涵盖了从基础到进阶的多种算法和数据结构,旨在为不同阶段的编程学习者提供一条清晰、平稳的学习提升路径。

欢迎大家订阅我的专栏:算法题解:C++与Python实现!

附上汇总贴:算法竞赛备考冲刺必刷题(C++) | 汇总


【题目来源】

AtCoder:B - Updating the Report Card

【题目描述】

Takahashi is managing student grades as the homeroom teacher of a school class. There areN NNstudents in the class, numbered from1 11toN NN. The initial score of thei ii-th student isS i S_iSipoints.
高桥担任学校班级的班主任,负责管理学生成绩。班级中共有N NN名学生,编号从1 11N NN。第i ii名学生的初始分数为S i S_iSi分。

At the end of the term, it is time to update the report cards. A total ofM MMupdates are performed. In thej jj-th update, the score of studentP j P_jPjis changed toV j V_jVjpoints. The same student may be updated multiple times, in which case their score is overwritten with each update.
学期末,到了更新成绩单的时候。总共执行M MM次更新。在第j jj次更新中,学生P j P_jPj的分数被改为V j V_jVj分。同一名学生可能被多次更新,这种情况下,每次更新都会覆盖其之前的分数。

After all updates are completed, students with a score strictly less thanK KKpoints are required to attend supplementary lessons. For Takahashi’s sake, determine the number of students who are required to attend supplementary lessons. Note that students with exactlyK KKpoints are not included.
所有更新完成后,分数严格小于K KK分的学生需要参加补习课程。为帮助高桥,请确定需要参加补习课程的学生人数。注意,分数恰好为K KK分的学生不包含在内。

【输入】

N NNM MMK KK
S 1 S_1S1S 2 S_2S2⋯ \cdotsS N S_NSN
P 1 P_1P1V 1 V_1V1
P 2 P_2P2V 2 V_2V2
⋮ \vdots
P M P_MPMV M V_MVM

  • The first line containsN NNrepresenting the number of students,M MMrepresenting the number of updates, andK KKrepresenting the threshold score for supplementary lessons, separated by spaces.
  • The second line contains the initial scoresS 1 , S 2 , … , S N S_1, S_2, \ldots, S_NS1,S2,,SNof each student, separated by spaces.
  • S i S_iSirepresents the initial score of thei ii-th student.
  • Lines3 33through2 + M 2 + M2+Mcontain the details of the updates (ifM = 0 M = 0M=0, this part does not exist).
  • Line2 + j 2 + j2+jcontains the student numberP j P_jPjwhose score is changed in thej jj-th update and the new scoreV j V_jVj, separated by a space.

【输出】

After all updates are completed, output in a single line the number of students whose score is strictly less thanK KKpoints and are therefore required to attend supplementary lessons.

【输入样例】

5 3 60 45 72 58 81 39 1 65 3 62 5 55

【输出样例】

1

【解题思路】

【算法标签】

#模拟#

【代码详解】

#include<bits/stdc++.h>usingnamespacestd;constintN=100005;intn,m,k,ans;// n: 学生数量,m: 操作次数,k: 分数线,ans: 不达标人数ints[N];// 学生分数数组intmain(){cin>>n>>m>>k;// 读入学生数量、操作次数、分数线for(inti=1;i<=n;i++){cin>>s[i];// 读入学生初始分数}for(inti=1;i<=m;i++){intp,v;// p: 学生编号,v: 新分数cin>>p>>v;// 读入修改操作s[p]=v;// 更新学生分数}for(inti=1;i<=n;i++){if(s[i]<k)// 如果学生分数低于分数线{ans++;// 计数加1}}cout<<ans<<endl;// 输出不达标人数return0;}

【运行结果】

5 3 60 45 72 58 81 39 1 65 3 62 5 55 1
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/30 1:43:41

开源轻量监控工具openclaw-monitor:Agent-Server架构与高效部署指南

1. 项目概述&#xff1a;一个开源、轻量的服务器监控利器最近在折腾自己的几台服务器&#xff0c;从云上的VPS到家里吃灰的树莓派&#xff0c;总想找个趁手的工具来盯着它们的“健康状态”。CPU、内存、磁盘这些基础指标还好说&#xff0c;但想看看实时的网络连接、特定进程的资…

作者头像 李华
网站建设 2026/4/30 1:43:39

4D毫米波雷达在恶劣环境中的感知与处理技术

1. 4D毫米波雷达在恶劣环境感知中的独特优势在工业与地下环境中&#xff0c;感知系统面临着粉尘、烟雾、金属反射等多重挑战。传统光学传感器&#xff08;如摄像头、LiDAR&#xff09;的性能在这些条件下会急剧下降——摄像头在低能见度下完全失效&#xff0c;LiDAR则因颗粒物散…

作者头像 李华
网站建设 2026/4/30 1:41:17

WarcraftHelper终极指南:三分钟解决魔兽争霸3现代兼容性问题

WarcraftHelper终极指南&#xff1a;三分钟解决魔兽争霸3现代兼容性问题 【免费下载链接】WarcraftHelper Warcraft III Helper , support 1.20e, 1.24e, 1.26a, 1.27a, 1.27b 项目地址: https://gitcode.com/gh_mirrors/wa/WarcraftHelper 还在为魔兽争霸3在现代系统上…

作者头像 李华
网站建设 2026/4/30 1:40:20

caj2pdf终极指南:快速免费转换CAJ为PDF的完整解决方案

caj2pdf终极指南&#xff1a;快速免费转换CAJ为PDF的完整解决方案 【免费下载链接】caj2pdf Convert CAJ (China Academic Journals) files to PDF. 转换中国知网 CAJ 格式文献为 PDF。佛系转换&#xff0c;成功与否&#xff0c;皆是玄学。 项目地址: https://gitcode.com/gh…

作者头像 李华
网站建设 2026/4/30 1:40:19

【YOLOv11】068、YOLOv11联邦学习:分布式数据下的隐私保护训练

一、从一次数据合规审查说起 上个月,客户突然要求我们提供YOLOv11在医疗影像数据上的训练日志和原始数据分布报告——因为他们的数据压根不能离开医院内网。实验室里顿时安静了,我们意识到:传统的集中式训练模式,在隐私敏感场景下根本走不通。 这让我想起了三年前做安防项…

作者头像 李华