Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define chmin(x, v) x = min(x, v)
- #define chmax(x, v) x = max(x, v)
- using namespace std;
- struct Employe
- {
- int tache, coutChangement;
- };
- int main()
- {
- int nbEmployes, nbTaches;
- cin >> nbEmployes >> nbTaches;
- bool fait[nbTaches];for (int i=0;i<nbTaches;++i)fait[i]=false;
- Employe p[nbEmployes];
- int cost[nbTaches];
- vector<int> sac;
- for (int i=0;i<nbEmployes;++i)
- {
- cin >> p[i].tache;p[i].tache--;}
- for (int i=0;i<nbEmployes;++i)
- cin >> p[i].coutChangement;
- for (int i=0;i<nbEmployes;++i)
- {
- if (!fait[p[i].tache])
- {
- fait[p[i].tache] = true;
- cost[p[i].tache] = p[i].coutChangement;
- }
- else if ( cost[p[i].tache] < p[i].coutChangement)
- {
- sac.push_back(cost[p[i].tache]);
- cost[p[i].tache] = p[i].coutChangement;
- }
- else
- {
- sac.push_back(p[i].coutChangement);
- }
- }
- sort(sac.begin(), sac.end());
- long long tot = 0;
- int pointeur = 0;
- for (int idTache = 0; idTache < nbTaches; ++idTache)
- {
- if ( !fait[idTache])
- {
- tot += sac[pointeur];
- pointeur++;
- }
- }
- cout << tot << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement