From 1f959f4f49db2f883d30607811028c0cf5105055 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 5 Sep 2022 15:26:00 +0800 Subject: [PATCH] =?UTF-8?q?#1535.=20=E3=80=902022.09.05NOIP=E6=A8=A1?= =?UTF-8?q?=E6=8B=9F=E9=A2=98=E3=80=91=E8=AE=A2=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/55839 --- S2OJ/1535/1535.cpp | 40 +++++++++++++++++++++++++++++++++++++ S2OJ/1535/data/goods1.in | 3 +++ S2OJ/1535/data/goods1.out | 3 +++ S2OJ/1535/data/goods10.in | 3 +++ S2OJ/1535/data/goods10.out | 3 +++ S2OJ/1535/data/goods2.in | 3 +++ S2OJ/1535/data/goods2.out | 3 +++ S2OJ/1535/data/goods3.in | 3 +++ S2OJ/1535/data/goods3.out | 3 +++ S2OJ/1535/data/goods4.in | 3 +++ S2OJ/1535/data/goods4.out | 3 +++ S2OJ/1535/data/goods5.in | 3 +++ S2OJ/1535/data/goods5.out | 3 +++ S2OJ/1535/data/goods6.in | 3 +++ S2OJ/1535/data/goods6.out | 3 +++ S2OJ/1535/data/goods7.in | 3 +++ S2OJ/1535/data/goods7.out | 3 +++ S2OJ/1535/data/goods8.in | 3 +++ S2OJ/1535/data/goods8.out | 3 +++ S2OJ/1535/data/goods9.in | 3 +++ S2OJ/1535/data/goods9.out | 3 +++ S2OJ/1535/data/problem.conf | 3 +++ 22 files changed, 103 insertions(+) create mode 100644 S2OJ/1535/1535.cpp create mode 100644 S2OJ/1535/data/goods1.in create mode 100644 S2OJ/1535/data/goods1.out create mode 100644 S2OJ/1535/data/goods10.in create mode 100644 S2OJ/1535/data/goods10.out create mode 100644 S2OJ/1535/data/goods2.in create mode 100644 S2OJ/1535/data/goods2.out create mode 100644 S2OJ/1535/data/goods3.in create mode 100644 S2OJ/1535/data/goods3.out create mode 100644 S2OJ/1535/data/goods4.in create mode 100644 S2OJ/1535/data/goods4.out create mode 100644 S2OJ/1535/data/goods5.in create mode 100644 S2OJ/1535/data/goods5.out create mode 100644 S2OJ/1535/data/goods6.in create mode 100644 S2OJ/1535/data/goods6.out create mode 100644 S2OJ/1535/data/goods7.in create mode 100644 S2OJ/1535/data/goods7.out create mode 100644 S2OJ/1535/data/goods8.in create mode 100644 S2OJ/1535/data/goods8.out create mode 100644 S2OJ/1535/data/goods9.in create mode 100644 S2OJ/1535/data/goods9.out create mode 100644 S2OJ/1535/data/problem.conf diff --git a/S2OJ/1535/1535.cpp b/S2OJ/1535/1535.cpp new file mode 100644 index 00000000..c79f2023 --- /dev/null +++ b/S2OJ/1535/1535.cpp @@ -0,0 +1,40 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2e6 + 5; + +int n, a[N], b[N], ans; +std::deque q; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + + for (int i = 1; i <= n; i++) { + cin >> b[i]; + } + + for (int i = 1; i <= n; i++) { + while (!q.empty() && b[i] >= b[q.front()]) q.pop_front(); + q.push_front(i); + } + + for (int i = 1; i <= n; i++) { + while (!q.empty() && q.back() <= i) q.pop_back(); + if (!q.empty()) ans = std::max(ans, b[q.back()] - a[i]); + } + + cout << ans << endl; + + return 0; +} diff --git a/S2OJ/1535/data/goods1.in b/S2OJ/1535/data/goods1.in new file mode 100644 index 00000000..852f1389 --- /dev/null +++ b/S2OJ/1535/data/goods1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f1e1b43ffe2d879e640ea69938b9d485e8f1d24f752cd3ae987e07f679432a8 +size 2804 diff --git a/S2OJ/1535/data/goods1.out b/S2OJ/1535/data/goods1.out new file mode 100644 index 00000000..af040655 --- /dev/null +++ b/S2OJ/1535/data/goods1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f36fb05ec13b50c0cab68114db02bc8cf9d5ed9d6b19ab67b7fe1c9a6590cdeb +size 7 diff --git a/S2OJ/1535/data/goods10.in b/S2OJ/1535/data/goods10.in new file mode 100644 index 00000000..411c63e4 --- /dev/null +++ b/S2OJ/1535/data/goods10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e4cd64a4637907fc29643db540f2f7b240b8fd07b39abaaa48e62cf1a00ec511 +size 28000008 diff --git a/S2OJ/1535/data/goods10.out b/S2OJ/1535/data/goods10.out new file mode 100644 index 00000000..09ff7991 --- /dev/null +++ b/S2OJ/1535/data/goods10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:533a6901525d9765c4c8095af4c4f69cfa3cad495acd37a1f8117fdfb62b5e65 +size 7 diff --git a/S2OJ/1535/data/goods2.in b/S2OJ/1535/data/goods2.in new file mode 100644 index 00000000..a0b3c177 --- /dev/null +++ b/S2OJ/1535/data/goods2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2ce8ca3547ab349ed1f74f0984496c8680a18171cf623fcddfaceff98ac89f4 +size 2804 diff --git a/S2OJ/1535/data/goods2.out b/S2OJ/1535/data/goods2.out new file mode 100644 index 00000000..551f9440 --- /dev/null +++ b/S2OJ/1535/data/goods2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b80e48396ce9ec0be14e96d90dfd1bd64f23928fb79daf4c5ffee6b188a6b37e +size 7 diff --git a/S2OJ/1535/data/goods3.in b/S2OJ/1535/data/goods3.in new file mode 100644 index 00000000..bc155988 --- /dev/null +++ b/S2OJ/1535/data/goods3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d09d1f3e31e3e8f664183f107e2ed67cc2c93969ad8b6b305bf9b712e0646c3 +size 2804 diff --git a/S2OJ/1535/data/goods3.out b/S2OJ/1535/data/goods3.out new file mode 100644 index 00000000..9adaa668 --- /dev/null +++ b/S2OJ/1535/data/goods3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef3bf905c828851d84e93c7e43b350ba4adb600520de9229f7a66caa81bda5b8 +size 7 diff --git a/S2OJ/1535/data/goods4.in b/S2OJ/1535/data/goods4.in new file mode 100644 index 00000000..5bbb730a --- /dev/null +++ b/S2OJ/1535/data/goods4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:67884c3536a78e411cef409162dd37a09de42d42a4727aca5c816de0a6275427 +size 28005 diff --git a/S2OJ/1535/data/goods4.out b/S2OJ/1535/data/goods4.out new file mode 100644 index 00000000..5d58add9 --- /dev/null +++ b/S2OJ/1535/data/goods4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e5238491e098b183d112fc5edcd10e474563222d5034f7d0499ae0f3b9cee4e +size 5 diff --git a/S2OJ/1535/data/goods5.in b/S2OJ/1535/data/goods5.in new file mode 100644 index 00000000..0c5bd942 --- /dev/null +++ b/S2OJ/1535/data/goods5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76ead91983eb81c0640cbb31689f3c447c919b291e78976fd9750093b4d97e5c +size 28005 diff --git a/S2OJ/1535/data/goods5.out b/S2OJ/1535/data/goods5.out new file mode 100644 index 00000000..0c409578 --- /dev/null +++ b/S2OJ/1535/data/goods5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7b5050677d44f2bb4dc4101de1662e01cf132beb5fe4e8fdacae8d335193afd +size 7 diff --git a/S2OJ/1535/data/goods6.in b/S2OJ/1535/data/goods6.in new file mode 100644 index 00000000..01afc99d --- /dev/null +++ b/S2OJ/1535/data/goods6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01cf314da85a7a8ad3f8ad958967c97cdf773b3afc212c85bbb703dcdfb912ae +size 28005 diff --git a/S2OJ/1535/data/goods6.out b/S2OJ/1535/data/goods6.out new file mode 100644 index 00000000..5448f1e0 --- /dev/null +++ b/S2OJ/1535/data/goods6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d91d083d10400b448b7e9af17c33eab167951289dc0fcee2e5e1a1bfc851b3d2 +size 6 diff --git a/S2OJ/1535/data/goods7.in b/S2OJ/1535/data/goods7.in new file mode 100644 index 00000000..aac7ca64 --- /dev/null +++ b/S2OJ/1535/data/goods7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e1f5bc2eede2d5f0d9f1a40c945798b477bceb2d1c003f4931226ba9a8e2cb60 +size 2800007 diff --git a/S2OJ/1535/data/goods7.out b/S2OJ/1535/data/goods7.out new file mode 100644 index 00000000..34f94067 --- /dev/null +++ b/S2OJ/1535/data/goods7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af94ec1bdaf267ca50001a9c10c649225220eebf1ed93a1bf8116226731a52c0 +size 7 diff --git a/S2OJ/1535/data/goods8.in b/S2OJ/1535/data/goods8.in new file mode 100644 index 00000000..39723591 --- /dev/null +++ b/S2OJ/1535/data/goods8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abb1d8b8376284d133cb72ee2b488be279f9756088b4b84fe3ea57de23449604 +size 2800007 diff --git a/S2OJ/1535/data/goods8.out b/S2OJ/1535/data/goods8.out new file mode 100644 index 00000000..3e5511f2 --- /dev/null +++ b/S2OJ/1535/data/goods8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7662baac2e9ef0195a5d3da9195146f36e11ccecdb076c94271237a951a41426 +size 7 diff --git a/S2OJ/1535/data/goods9.in b/S2OJ/1535/data/goods9.in new file mode 100644 index 00000000..d87fdcc5 --- /dev/null +++ b/S2OJ/1535/data/goods9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b44180e4d6456cd1b12e8de8dafedcdd3c30124f803775c9ea142cf30168cf6c +size 2800007 diff --git a/S2OJ/1535/data/goods9.out b/S2OJ/1535/data/goods9.out new file mode 100644 index 00000000..4d42ab22 --- /dev/null +++ b/S2OJ/1535/data/goods9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac1b5cf56228b6040d2e605d3dc766cc4019d00722b1920225b99a049a9a40ca +size 7 diff --git a/S2OJ/1535/data/problem.conf b/S2OJ/1535/data/problem.conf new file mode 100644 index 00000000..541d06c1 --- /dev/null +++ b/S2OJ/1535/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:49a8c391f30019f1a2df6866cef7b8855e7cd35018fdf3047c896b4c1ff764ff +size 179