mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:08:47 +00:00
P3105 [USACO14OPEN]Fair Photography S
https://www.luogu.com.cn/record/83996634
This commit is contained in:
parent
76473772cf
commit
581447d2c4
47
Luogu/P3105/P3105.cpp
Normal file
47
Luogu/P3105/P3105.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
Luogu/P3105/data/P3105_1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_1.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_10.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_10.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_2.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_3.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_4.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_4.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_5.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_5.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_6.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_6.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_7.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_7.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_8.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_8.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_9.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P3105/data/P3105_9.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P3105/data/P3105_9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user