COCR#1 T2-烦人の建交 题解
2025-03-01 20:03:16
发布于:江苏
17阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
unordered_map<int,int>mint;
long long sum=0;
for (int i=0;i<N;++i) {
int n,t;
cin>>n>>t;
auto it=mint.find(n);
if(it==mint.end()){
mint[n]=t;
sum+=t;
}
else if(t<it->second){
sum-=it->second;
sum+=t;
it->second=t;
}
}
cout<<sum<<endl;
return 0;
}
这里空空如也
有帮助,赞一个