Please read our Rules and continue to report content that violates our rules on underage content. Uploaderanalogman, November 19, 2020; 20:50TagsEhsan, Kak_Ros, Upin_&_IpinSource LinkUnknownLockedNoInfo3508x2480 // 3.8MB // jpg February 16, 2021; 16:59 - Reply Anonymous1: kak ros kawaii February 27, 2021; 08:10 - Reply Anonymous2: tf? February 27, 2021; 08:14 - Reply Anonymous3(2): // https://codeforces.com/contest/1089/problem/L #include <bits/stdc++.h> const int M=1e5+7; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, k; std::cin>>n>>k; int j[M]; for(int i=1; i<=n; i++) { std::cin>>j[i]; } std::vector<int> a[M]; for(int i=1; i<=n; i++) { int t; std::cin>>t; a[j[i]].push_back(t); } int spare=0; std::vector<int> s; for(int i=1; i<=k; i++) { if(a[i].empty()) { spare++; continue; } std::sort(a[i].begin(),a[i].end()); a[i].pop_back(); for(auto x:a[i]) { s.push_back(x); } } std::sort(s.begin(),s.end()); long long kte=0; for(int i=0; i<spare; i++) { kte+=s[i]; } std::cout<<kte; return 0; } /* 8 7 1 1 3 1 5 3 7 1 5 7 4 8 1 3 5 2 */ March 20, 2022; 09:49 - Reply Anonymous4: More Kak Ros, please? March 24, 2022; 06:38 - Reply Anonymous5: 6/10,lumayan crot July 11, 2024; 12:14 - Reply Anonymous6: Kak Ros upin Report an ad? nproxy.org
#include <bits/stdc++.h>
const int M=1e5+7;
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, k;
std::cin>>n>>k;
int j[M];
for(int i=1; i<=n; i++)
{
std::cin>>j[i];
}
std::vector<int> a[M];
for(int i=1; i<=n; i++)
{
int t;
std::cin>>t;
a[j[i]].push_back(t);
}
int spare=0;
std::vector<int> s;
for(int i=1; i<=k; i++)
{
if(a[i].empty())
{
spare++;
continue;
}
std::sort(a[i].begin(),a[i].end());
a[i].pop_back();
for(auto x:a[i])
{
s.push_back(x);
}
}
std::sort(s.begin(),s.end());
long long kte=0;
for(int i=0; i<spare; i++)
{
kte+=s[i];
}
std::cout<<kte;
return 0;
}
/*
8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 3 5 2
*/