当前位置:网站首页>【暑期每日一题】洛谷 P8086 『JROI-5』Music
【暑期每日一题】洛谷 P8086 『JROI-5』Music
2022-08-09 04:32:00 【AC_Dragon】
题目链接:P8086 『JROI-5』Music - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
题目背景
小 C 每年都要给丁总氪钱。
题目描述
请注意到并不正常的时间限制。
本题读入量较大,建议使用较快的读入方式,可以参考 赛时公告板。
小 C 喜欢在网易云听歌,她希望你能帮助她计算一下她的网易云的听歌时间。
小 C 有 n 条听歌记录,每条形如 x t,表示小 C 听了编号为 x 的音乐 t 分钟。听歌时间为所有有效记录的 t 的总和。
首先,如果某条记录的 t<=1,那么这条记录是无效的。
其次对于某一首歌,只有第一条有效记录会被计算,之后重复听这首歌的记录将不会被累计到听歌时间中。
输入格式
第一行一个正整数 n,同题意。
接下来 n 行每行两个正整数 x, t,表示一条听歌记录。
输出格式
一行一个整数,表示听歌时间。
样例 #1
样例输入 #1
5
1 114514
2 1
2 1919180
1 10
3 2
样例输出 #1
2033696
样例 #2
样例输入 #2
见附件
样例输出 #2
见附件
提示
【样例解释】
第一条记录:1 114514,有效记录,可以累计。
第二条记录:2 1,t<=1,无效记录。
第三条记录:2 1919180,有效记录,可以累计。
第四条记录:1 10,编号为 1 的音乐在第一条记录已经累计,本条记录有效,但不能累计。
第五条记录:3 2,有效记录,可以累计。
答案即为 114514+1919180+2=2033696。
对于 40% 的数据,保证 1<=x<=n<=10^4。
对于 100% 的数据,保证 1<=n<=10^7,1<=x,ti<=10^7。
附件下载
big_sample (2).zip (581.37KB)
AC code:
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e7 + 10;
bool book[N];
typedef long long ll;
ll sum;
int main()
{
int n;
cin>>n;
while(n--)
{
int x,t;
cin>>x>>t;
if(book[x]==0 && t>1)
{
sum+=t;
book[x]=1;
}
}
cout<<sum;
return 0;
}
边栏推荐
- 必须指定GDAL API版本。提供一个路径使用GDAL_CONFIG gdal-config环境
- 自动化测试-图片中添加文字注释,添加到allure测试报告中
- 数量遗传学遗传力计算1:亲子回归方法
- 安装pytorch和cuda
- pytorch implementation of Poly1CrossEntropyLoss
- 【服务器数据恢复】Ext4文件系统fsck后mount不上并报错的数据修复案例
- Grid 布局介绍
- 分布式数据库怎样才能“叫好又卖座”
- Query the size of the total points obtained in a certain time period to sort
- 2022 High Voltage Electrician Exam Questions and Answers
猜你喜欢
随机推荐
MySQL:已提交读和可重复读的实现原理 | MVCC(多版本并发控制)——笔记自用
[math] dot product and cross product
Device Reliability vs. Temperature
LeetCode - remove consecutive nodes with a sum of zero from a linked list
Flask框架实现异步处理请求
Polygon zkEVM Prover
供应商对接Chewy的EDI需求
The influence law of genes for disease - read the paper
Introduction to JVM garbage collection mechanism
维护RAC日志轮转
【服务器数据恢复】Ext4文件系统fsck后mount不上并报错的数据修复案例
配置网络接口的“IP“命令
2022 Security Officer-B Certificate Exam Practice Questions and Online Mock Exam
简单的数学公式计算
Alibaba Cloud Tianchi Contest Question (Machine Learning) - Prediction of Industrial Steam Volume (Complete Code)
Gopacket source code analysis
2022高处安装、维护、拆除考试练习题及模拟考试
Grid 布局介绍
pr22.5最新版下载地址
Detailed explanation of Oracle's windowing function