mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
P2672 [NOIP2015 普及组] 推销员
R64117019
This commit is contained in:
parent
074289c77d
commit
fdc6cacd68
40
Luogu/P2672/P2672.cpp
Normal file
40
Luogu/P2672/P2672.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
int n, now;
|
||||
long long ans;
|
||||
std::pair<int, int> a[100005];
|
||||
std::priority_queue<int> q;
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].first;
|
||||
}
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i].second;
|
||||
}
|
||||
q.push(0);
|
||||
for (int i = 1; i <= n; i++) {
|
||||
int max = q.top();
|
||||
int maxn = now;
|
||||
for (int j = now + 1; j <= n; j++) {
|
||||
if ((a[j].first - a[now].first) * 2 + a[j].second >= max) {
|
||||
max = (a[j].first - a[now].first) * 2 + a[j].second;
|
||||
maxn = j;
|
||||
}
|
||||
}
|
||||
if (maxn != now) q.push(max);
|
||||
for (int j = now + 1; j < maxn; j++) {
|
||||
q.push(a[j].second);
|
||||
}
|
||||
now = maxn;
|
||||
ans += q.top();
|
||||
q.pop();
|
||||
cout << ans << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
Luogu/P2672/data/salesman1.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman10.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman10.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman2.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman3.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman4.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman4.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman5.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman5.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman6.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman6.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman7.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman7.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman8.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman8.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman9.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2672/data/salesman9.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2672/data/salesman9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user