跳到正文

题解

P8086 『JROI-5』Music 题解

cff_0102约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P8086

版本

  1. v1当前

P8086 『JROI-5』Music 题解

原题传送门

这一道题其实还是挺水的,注意当 t=1t=1 时也不会计入记录。

用一个bool数组存下每一首歌是否被听过。

c++代码:

C++
#include<bits\stdc++.h>
using namespace std;
bool a[10000005];//每一首歌是否被听过
int main(){
	ios::sync_with_stdio(false);//手动加快
	int n;//题目里面的n
	long long s=0;//s存总时间,注意要开long long,虽然没试过int行不行,但是这个数据范围最好开一下
	cin>>n;
	for(int i=0;i<n;i++){
		int x,t;
		cin>>x>>t;//输入
		if(t<=1)continue;//时间太少,不会被计入
		else if(!a[x]){//如果a[x]==true那么就被听过了
			a[x]=1;//标记
			s+=t;//总时间增加
		}
	}
	cout<<s;//别忘了输出
	return 0;
}//不要抄题解

希望管理能过这篇题解。

原文