mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 15:18:46 +00:00
3379. [Usaco2004 Open]Turning in Homework 交作业
https://hydro.ac/d/bzoj/record/6322ae00bdf9bc31d1606239
This commit is contained in:
parent
320af422bd
commit
6b06184d03
54
BZOJ/3379/3379.cpp
Normal file
54
BZOJ/3379/3379.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
#include <limits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 1005;
|
||||||
|
|
||||||
|
int c, h, b, f[N][N][2], ans = std::numeric_limits<int>::max();
|
||||||
|
std::pair<int, int> a[N];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
memset(f, 0x3f, sizeof(f));
|
||||||
|
|
||||||
|
cin >> c >> h >> b;
|
||||||
|
|
||||||
|
for (int i = 1; i <= c; i++) {
|
||||||
|
cin >> a[i].first >> a[i].second;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(a + 1, a + 1 + c);
|
||||||
|
|
||||||
|
f[0][c][0] = f[0][c][1] = 0;
|
||||||
|
|
||||||
|
for (int i = 1; i <= c; i++) {
|
||||||
|
for (int j = c; j >= i; j--) {
|
||||||
|
f[i][j][0] = std::min({
|
||||||
|
std::max(f[i - 1][j][0] + a[i].first - a[i - 1].first, a[i].second),
|
||||||
|
std::max(f[i][j + 1][1] + a[j + 1].first - a[i].first, a[i].second),
|
||||||
|
});
|
||||||
|
|
||||||
|
f[i][j][1] = std::min({
|
||||||
|
std::max(f[i - 1][j][0] + a[j].first - a[i - 1].first, a[j].second),
|
||||||
|
std::max(f[i][j + 1][1] + a[j + 1].first - a[j].first, a[j].second),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= c; i++) {
|
||||||
|
ans = std::min(ans, std::min(f[i][i][0], f[i][i][1]) + std::abs(b - a[i].first));
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << ans << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
BZOJ/3379/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/11.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/11.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3379/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3379/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user