Skip to content

Commit

Permalink
ABC360C Move It
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Jul 15, 2024
1 parent a55e18a commit efd2630
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions atcoder/abc360c_move_it.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Vicfred
// https://atcoder.jp/contests/abc360/tasks/abc360_c
// greedy, sorting, data structures
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main() {
long long N;
cin >> N;
vector<long long> A(N), W(N);
for(int i = 0; i < N; ++i) {
cin >> A[i];
}
for(int i = 0; i < N; ++i) {
cin >> W[i];
}
map<long long, multiset<long long>> candies;
for(int i = 0; i < N; ++i) {
candies[A[i]].insert(W[i]);
}
long long cost = 0LL;
for(auto&[box, candy] : candies) {
while(candy.size() > 1) {
cost += *candy.begin();
candy.erase(candy.begin());
}
}
cout << cost << endl;
return 0;
}

0 comments on commit efd2630

Please sign in to comment.