-
Notifications
You must be signed in to change notification settings - Fork 3
/
任务安排.cpp
55 lines (52 loc) · 894 Bytes
/
任务安排.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
priority_queue <pair<int, int>, vector<pair<int, int> >, less<pair<int, int> > > q;
int n;
bool visit[10002];
int calculate()
{
int ddl, pen,sum=0;
while(!q.empty())
{
pen = q.top().first;
ddl = q.top().second;
q.pop();
if (!visit[ddl])
visit[ddl] = true;
else {
int flag = 0;
for (int j = ddl - 1; j >= 1; j--) {
if (!visit[j]) {
flag = 1;
visit[j] = true;
break;
}
}
if (!flag)
sum += pen;
}
}
return sum;
}
int main()
{
cin >> n;
int i;
int ddl[10002], pen[10002];
for (i = 0; i < n; i++)
cin >> ddl[i];
for (i = 0; i < n; i++)
cin >> pen[i];
for (i = 0; i < n; i++)
{
pair<int, int> temp;
temp = make_pair(pen[i], ddl[i]);
q.push(temp);
}
cout << calculate() << endl;
}