mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
3540. [Usaco2014 Open]Fair Photography
https://hydro.ac/d/bzoj/record/6322c4e1bdf9bc31d1607974
This commit is contained in:
parent
39e04e9b16
commit
b1f483a26d
47
BZOJ/3540/3540.cpp
Normal file
47
BZOJ/3540/3540.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
int n, f[N << 1], ans;
|
||||
std::pair<int, char> cows[N];
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
memset(f, 0x3f, sizeof(f));
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> cows[i].first >> cows[i].second;
|
||||
}
|
||||
|
||||
std::sort(cows + 1, cows + 1 + n);
|
||||
|
||||
f[n] = cows[1].first;
|
||||
for (int i = 2, x = n; i <= n; i++) {
|
||||
x += cows[i - 1].second == 'W' ? -1 : 1;
|
||||
f[x] = std::min(f[x], cows[i].first);
|
||||
}
|
||||
|
||||
for (int i = n << 1; i; i--) {
|
||||
f[i] = std::min(f[i], f[i + 2]);
|
||||
}
|
||||
|
||||
for (int i = 1, x = n; i <= n; i++) {
|
||||
x += cows[i].second == 'W' ? -1 : 1;
|
||||
ans = std::max(ans, cows[i].first - f[x]);
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/3540/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3540/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3540/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user