From 581447d2c4be19d4fbf62646404d6551cd45c722 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Tue, 16 Aug 2022 14:17:14 +0800 Subject: [PATCH] P3105 [USACO14OPEN]Fair Photography S https://www.luogu.com.cn/record/83996634 --- Luogu/P3105/P3105.cpp | 47 +++++++++++++++++++++++++++++++++++ Luogu/P3105/data/P3105_1.in | 3 +++ Luogu/P3105/data/P3105_1.out | 3 +++ Luogu/P3105/data/P3105_10.in | 3 +++ Luogu/P3105/data/P3105_10.out | 3 +++ Luogu/P3105/data/P3105_2.in | 3 +++ Luogu/P3105/data/P3105_2.out | 3 +++ Luogu/P3105/data/P3105_3.in | 3 +++ Luogu/P3105/data/P3105_3.out | 3 +++ Luogu/P3105/data/P3105_4.in | 3 +++ Luogu/P3105/data/P3105_4.out | 3 +++ Luogu/P3105/data/P3105_5.in | 3 +++ Luogu/P3105/data/P3105_5.out | 3 +++ Luogu/P3105/data/P3105_6.in | 3 +++ Luogu/P3105/data/P3105_6.out | 3 +++ Luogu/P3105/data/P3105_7.in | 3 +++ Luogu/P3105/data/P3105_7.out | 3 +++ Luogu/P3105/data/P3105_8.in | 3 +++ Luogu/P3105/data/P3105_8.out | 3 +++ Luogu/P3105/data/P3105_9.in | 3 +++ Luogu/P3105/data/P3105_9.out | 3 +++ 21 files changed, 107 insertions(+) create mode 100644 Luogu/P3105/P3105.cpp create mode 100644 Luogu/P3105/data/P3105_1.in create mode 100644 Luogu/P3105/data/P3105_1.out create mode 100644 Luogu/P3105/data/P3105_10.in create mode 100644 Luogu/P3105/data/P3105_10.out create mode 100644 Luogu/P3105/data/P3105_2.in create mode 100644 Luogu/P3105/data/P3105_2.out create mode 100644 Luogu/P3105/data/P3105_3.in create mode 100644 Luogu/P3105/data/P3105_3.out create mode 100644 Luogu/P3105/data/P3105_4.in create mode 100644 Luogu/P3105/data/P3105_4.out create mode 100644 Luogu/P3105/data/P3105_5.in create mode 100644 Luogu/P3105/data/P3105_5.out create mode 100644 Luogu/P3105/data/P3105_6.in create mode 100644 Luogu/P3105/data/P3105_6.out create mode 100644 Luogu/P3105/data/P3105_7.in create mode 100644 Luogu/P3105/data/P3105_7.out create mode 100644 Luogu/P3105/data/P3105_8.in create mode 100644 Luogu/P3105/data/P3105_8.out create mode 100644 Luogu/P3105/data/P3105_9.in create mode 100644 Luogu/P3105/data/P3105_9.out diff --git a/Luogu/P3105/P3105.cpp b/Luogu/P3105/P3105.cpp new file mode 100644 index 00000000..57d71e72 --- /dev/null +++ b/Luogu/P3105/P3105.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e5 + 5; + +int n, f[N << 1], ans; +std::pair 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; +} diff --git a/Luogu/P3105/data/P3105_1.in b/Luogu/P3105/data/P3105_1.in new file mode 100644 index 00000000..8f2a6ca2 --- /dev/null +++ b/Luogu/P3105/data/P3105_1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:288a3bf4e8f0373e903a9382b02108cfde55f9855514f3ea635346cfc341806b +size 24 diff --git a/Luogu/P3105/data/P3105_1.out b/Luogu/P3105/data/P3105_1.out new file mode 100644 index 00000000..f2baf931 --- /dev/null +++ b/Luogu/P3105/data/P3105_1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:10159baf262b43a92d95db59dae1f72c645127301661e0a3ce4e38b295a97c58 +size 2 diff --git a/Luogu/P3105/data/P3105_10.in b/Luogu/P3105/data/P3105_10.in new file mode 100644 index 00000000..b8aabc35 --- /dev/null +++ b/Luogu/P3105/data/P3105_10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e9255d52a58c17d1845fa357b27d936429382863993db183e28560206d8f149 +size 1184242 diff --git a/Luogu/P3105/data/P3105_10.out b/Luogu/P3105/data/P3105_10.out new file mode 100644 index 00000000..d7e382cc --- /dev/null +++ b/Luogu/P3105/data/P3105_10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4aa3e93b66d30794e6979701d16bdb9b29ad48e2f367ebd0cd84abd6357cf2cc +size 10 diff --git a/Luogu/P3105/data/P3105_2.in b/Luogu/P3105/data/P3105_2.in new file mode 100644 index 00000000..c37daaf8 --- /dev/null +++ b/Luogu/P3105/data/P3105_2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d37b26b302740d930f3d212c48e885033f728b4cb9e7bdd28feea6a19951a66 +size 1188 diff --git a/Luogu/P3105/data/P3105_2.out b/Luogu/P3105/data/P3105_2.out new file mode 100644 index 00000000..d256993d --- /dev/null +++ b/Luogu/P3105/data/P3105_2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d6c23c231003bb35b5716b7aac16d484d6b24e95283c59376a8b5968e18f485 +size 10 diff --git a/Luogu/P3105/data/P3105_3.in b/Luogu/P3105/data/P3105_3.in new file mode 100644 index 00000000..7ad294ff --- /dev/null +++ b/Luogu/P3105/data/P3105_3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:898020fc9c38c1281305957354cf2da62ae39b79c3f4bbe0b004199247172493 +size 6586 diff --git a/Luogu/P3105/data/P3105_3.out b/Luogu/P3105/data/P3105_3.out new file mode 100644 index 00000000..3e481f75 --- /dev/null +++ b/Luogu/P3105/data/P3105_3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb28b7aee076fc42ab8149841f81501248e81f6d0afc6caa07de58d629354121 +size 10 diff --git a/Luogu/P3105/data/P3105_4.in b/Luogu/P3105/data/P3105_4.in new file mode 100644 index 00000000..2381bc47 --- /dev/null +++ b/Luogu/P3105/data/P3105_4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:12dee89085b553eebf0a3bf43cd2f7503d5aba5331de2eb0a5d8496fdf417223 +size 119762 diff --git a/Luogu/P3105/data/P3105_4.out b/Luogu/P3105/data/P3105_4.out new file mode 100644 index 00000000..d33ff38f --- /dev/null +++ b/Luogu/P3105/data/P3105_4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:428036a41cb3f6ac5079a21cfd134fcb6bc6cded2923c911006c5488c831bfe5 +size 10 diff --git a/Luogu/P3105/data/P3105_5.in b/Luogu/P3105/data/P3105_5.in new file mode 100644 index 00000000..af494712 --- /dev/null +++ b/Luogu/P3105/data/P3105_5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33ad364902304311f6b3a7f50448bced97dce0ec065567eecf1233adfdff9168 +size 248647 diff --git a/Luogu/P3105/data/P3105_5.out b/Luogu/P3105/data/P3105_5.out new file mode 100644 index 00000000..0f890c33 --- /dev/null +++ b/Luogu/P3105/data/P3105_5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef987cc33b92d7b929dd0d499299eb5e5d1785228b721833d01462fe21676dea +size 10 diff --git a/Luogu/P3105/data/P3105_6.in b/Luogu/P3105/data/P3105_6.in new file mode 100644 index 00000000..780ce8ee --- /dev/null +++ b/Luogu/P3105/data/P3105_6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d13d2db61353d4e68fef484c017c7bc90019852b53f4eb0c4274ef34bde60f0 +size 912167 diff --git a/Luogu/P3105/data/P3105_6.out b/Luogu/P3105/data/P3105_6.out new file mode 100644 index 00000000..22dfa7b7 --- /dev/null +++ b/Luogu/P3105/data/P3105_6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4cf7a7f96f666c6a6be4f1b75201e4f5455c98c82f8c44a7c559bf73beed5d43 +size 10 diff --git a/Luogu/P3105/data/P3105_7.in b/Luogu/P3105/data/P3105_7.in new file mode 100644 index 00000000..4e6c9ff2 --- /dev/null +++ b/Luogu/P3105/data/P3105_7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00dea1a7d98ce2f16776bfaf1888c7929401c1f6dfadb65d4e89651050935c0b +size 1066051 diff --git a/Luogu/P3105/data/P3105_7.out b/Luogu/P3105/data/P3105_7.out new file mode 100644 index 00000000..194719e4 --- /dev/null +++ b/Luogu/P3105/data/P3105_7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:288fe497188b10f183241a265d48dc9d1a84a521678c3a4bff2b5239942c3c45 +size 10 diff --git a/Luogu/P3105/data/P3105_8.in b/Luogu/P3105/data/P3105_8.in new file mode 100644 index 00000000..5afefe3e --- /dev/null +++ b/Luogu/P3105/data/P3105_8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8194b97c9780bf8cc2555442d05b3858139f997cf8c2141a6b9e576d5c46d07d +size 1184330 diff --git a/Luogu/P3105/data/P3105_8.out b/Luogu/P3105/data/P3105_8.out new file mode 100644 index 00000000..0fb0ac1f --- /dev/null +++ b/Luogu/P3105/data/P3105_8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2b905e8b0239b1cf36c756486456b1a7806cbca9770e157729cb391ef97d3a3 +size 9 diff --git a/Luogu/P3105/data/P3105_9.in b/Luogu/P3105/data/P3105_9.in new file mode 100644 index 00000000..d9ae17c3 --- /dev/null +++ b/Luogu/P3105/data/P3105_9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4a62d8aff6f768b8776489e8a71a8476b05ae6442dfdea7d5185f4e307ec8d9b +size 1184499 diff --git a/Luogu/P3105/data/P3105_9.out b/Luogu/P3105/data/P3105_9.out new file mode 100644 index 00000000..e6daccd6 --- /dev/null +++ b/Luogu/P3105/data/P3105_9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc443a54cfa50405c3fc9d094e451de79c9db168dcafb584d4d3a91ca1903a18 +size 10