From beaef8d0d211323a57c33e007ec082f43e508e7a Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 5 Oct 2022 22:10:47 +0800 Subject: [PATCH] =?UTF-8?q?#1603.=20=E3=80=902022.10.5=20=E8=81=94?= =?UTF-8?q?=E8=80=83=E3=80=91=E5=8E=82=E5=B7=9E=E5=A1=94=EF=BC=88tower?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/59691 --- S2OJ/1603/1603.cpp | 62 ++++++++++++++++++++++++++++++++++++ S2OJ/1603/data/ex_tower1.in | 3 ++ S2OJ/1603/data/ex_tower1.out | 3 ++ S2OJ/1603/data/ex_tower2.in | 3 ++ S2OJ/1603/data/ex_tower2.out | 3 ++ S2OJ/1603/data/ex_tower3.in | 3 ++ S2OJ/1603/data/ex_tower3.out | 3 ++ S2OJ/1603/data/ex_tower4.in | 3 ++ S2OJ/1603/data/ex_tower4.out | 3 ++ S2OJ/1603/data/ex_tower5.in | 3 ++ S2OJ/1603/data/ex_tower5.out | 3 ++ S2OJ/1603/data/ex_tower6.in | 3 ++ S2OJ/1603/data/ex_tower6.out | 3 ++ S2OJ/1603/data/problem.conf | 3 ++ S2OJ/1603/data/std.cpp | 3 ++ S2OJ/1603/data/tower1.in | 3 ++ S2OJ/1603/data/tower1.out | 3 ++ S2OJ/1603/data/tower10.in | 3 ++ S2OJ/1603/data/tower10.out | 3 ++ S2OJ/1603/data/tower2.in | 3 ++ S2OJ/1603/data/tower2.out | 3 ++ S2OJ/1603/data/tower3.in | 3 ++ S2OJ/1603/data/tower3.out | 3 ++ S2OJ/1603/data/tower4.in | 3 ++ S2OJ/1603/data/tower4.out | 3 ++ S2OJ/1603/data/tower5.in | 3 ++ S2OJ/1603/data/tower5.out | 3 ++ S2OJ/1603/data/tower6.in | 3 ++ S2OJ/1603/data/tower6.out | 3 ++ S2OJ/1603/data/tower7.in | 3 ++ S2OJ/1603/data/tower7.out | 3 ++ S2OJ/1603/data/tower8.in | 3 ++ S2OJ/1603/data/tower8.out | 3 ++ S2OJ/1603/data/tower9.in | 3 ++ S2OJ/1603/data/tower9.out | 3 ++ S2OJ/1603/data/val.cpp | 3 ++ 36 files changed, 167 insertions(+) create mode 100644 S2OJ/1603/1603.cpp create mode 100644 S2OJ/1603/data/ex_tower1.in create mode 100644 S2OJ/1603/data/ex_tower1.out create mode 100644 S2OJ/1603/data/ex_tower2.in create mode 100644 S2OJ/1603/data/ex_tower2.out create mode 100644 S2OJ/1603/data/ex_tower3.in create mode 100644 S2OJ/1603/data/ex_tower3.out create mode 100644 S2OJ/1603/data/ex_tower4.in create mode 100644 S2OJ/1603/data/ex_tower4.out create mode 100644 S2OJ/1603/data/ex_tower5.in create mode 100644 S2OJ/1603/data/ex_tower5.out create mode 100644 S2OJ/1603/data/ex_tower6.in create mode 100644 S2OJ/1603/data/ex_tower6.out create mode 100644 S2OJ/1603/data/problem.conf create mode 100644 S2OJ/1603/data/std.cpp create mode 100644 S2OJ/1603/data/tower1.in create mode 100644 S2OJ/1603/data/tower1.out create mode 100644 S2OJ/1603/data/tower10.in create mode 100644 S2OJ/1603/data/tower10.out create mode 100644 S2OJ/1603/data/tower2.in create mode 100644 S2OJ/1603/data/tower2.out create mode 100644 S2OJ/1603/data/tower3.in create mode 100644 S2OJ/1603/data/tower3.out create mode 100644 S2OJ/1603/data/tower4.in create mode 100644 S2OJ/1603/data/tower4.out create mode 100644 S2OJ/1603/data/tower5.in create mode 100644 S2OJ/1603/data/tower5.out create mode 100644 S2OJ/1603/data/tower6.in create mode 100644 S2OJ/1603/data/tower6.out create mode 100644 S2OJ/1603/data/tower7.in create mode 100644 S2OJ/1603/data/tower7.out create mode 100644 S2OJ/1603/data/tower8.in create mode 100644 S2OJ/1603/data/tower8.out create mode 100644 S2OJ/1603/data/tower9.in create mode 100644 S2OJ/1603/data/tower9.out create mode 100644 S2OJ/1603/data/val.cpp diff --git a/S2OJ/1603/1603.cpp b/S2OJ/1603/1603.cpp new file mode 100644 index 00000000..aee06127 --- /dev/null +++ b/S2OJ/1603/1603.cpp @@ -0,0 +1,62 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +bool work() { + int n; + long long k; + std::vector> up, down; + + cin >> n >> k; + + for (int i = 1, a, b; i <= n; i++) { + cin >> a >> b; + + if (b - a >= 0) up.emplace_back(a, b); + else down.emplace_back(a, b); + } + + std::sort(up.begin(), up.end(), [&](const auto &a, const auto &b) { + return a.first < b.first; + }); + + std::sort(down.begin(), down.end(), [&](const auto &a, const auto &b) { + return a.second > b.second; + }); + + for (auto o : up) { + k -= o.first; + + if (k <= 0) return false; + + k += o.second; + } + + for (auto o : down) { + k -= o.first; + + if (k <= 0) return false; + + k += o.second; + } + + return true; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + int t; + + cin >> t; + + while (t--) cout << (work() ? "YES" : "NO") << endl; + + return 0; +} diff --git a/S2OJ/1603/data/ex_tower1.in b/S2OJ/1603/data/ex_tower1.in new file mode 100644 index 00000000..18b79a57 --- /dev/null +++ b/S2OJ/1603/data/ex_tower1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3522223889f023856bbca4fe1626b72dd485639a2db65f14db39356480d19abc +size 51 diff --git a/S2OJ/1603/data/ex_tower1.out b/S2OJ/1603/data/ex_tower1.out new file mode 100644 index 00000000..63e1c762 --- /dev/null +++ b/S2OJ/1603/data/ex_tower1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e29f7dfe16dab09e9930fa69c1c93a88b049ce519bc15d5595a9566feacf5da4 +size 11 diff --git a/S2OJ/1603/data/ex_tower2.in b/S2OJ/1603/data/ex_tower2.in new file mode 100644 index 00000000..c6b60403 --- /dev/null +++ b/S2OJ/1603/data/ex_tower2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbe1a35c9d487dab0fc33c015e8c97950953753018d220f3a61b57562f025328 +size 6521642 diff --git a/S2OJ/1603/data/ex_tower2.out b/S2OJ/1603/data/ex_tower2.out new file mode 100644 index 00000000..1f7db12d --- /dev/null +++ b/S2OJ/1603/data/ex_tower2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:299dab5aa26b1eef6fec46d607ea441636dcf2dbaa41aef4414f782b488bd106 +size 17 diff --git a/S2OJ/1603/data/ex_tower3.in b/S2OJ/1603/data/ex_tower3.in new file mode 100644 index 00000000..e5e3beb9 --- /dev/null +++ b/S2OJ/1603/data/ex_tower3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7f7a29a77040d719d688125a72fa03b68a99c95453374d32bbfe61487baaa85 +size 15 diff --git a/S2OJ/1603/data/ex_tower3.out b/S2OJ/1603/data/ex_tower3.out new file mode 100644 index 00000000..fc234d78 --- /dev/null +++ b/S2OJ/1603/data/ex_tower3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a115e91c2e84c3078fa06914eff28d07590ddfaa47a55fb4f31dd7c5b3566194 +size 4 diff --git a/S2OJ/1603/data/ex_tower4.in b/S2OJ/1603/data/ex_tower4.in new file mode 100644 index 00000000..c0b67286 --- /dev/null +++ b/S2OJ/1603/data/ex_tower4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3e13cf649d2fd953005bda2c9d7a5cb814cd1b06c5fbfc4a59b0d3fc9bedd20 +size 15 diff --git a/S2OJ/1603/data/ex_tower4.out b/S2OJ/1603/data/ex_tower4.out new file mode 100644 index 00000000..fc234d78 --- /dev/null +++ b/S2OJ/1603/data/ex_tower4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a115e91c2e84c3078fa06914eff28d07590ddfaa47a55fb4f31dd7c5b3566194 +size 4 diff --git a/S2OJ/1603/data/ex_tower5.in b/S2OJ/1603/data/ex_tower5.in new file mode 100644 index 00000000..b7604d83 --- /dev/null +++ b/S2OJ/1603/data/ex_tower5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15da18cf74e58c4b279fa45239418b79cdbeaf2aa65f7fc5c822db00cdd6d537 +size 20 diff --git a/S2OJ/1603/data/ex_tower5.out b/S2OJ/1603/data/ex_tower5.out new file mode 100644 index 00000000..81d868ef --- /dev/null +++ b/S2OJ/1603/data/ex_tower5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfe72034a9f298fb79a6c1f2302673bb449c826d446b3efafdde95e6c48dc3ca +size 3 diff --git a/S2OJ/1603/data/ex_tower6.in b/S2OJ/1603/data/ex_tower6.in new file mode 100644 index 00000000..24214916 --- /dev/null +++ b/S2OJ/1603/data/ex_tower6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f91b914f439afd3ba28071c752b0f74d9a6ff87514671b95d837a29ce23d8223 +size 27 diff --git a/S2OJ/1603/data/ex_tower6.out b/S2OJ/1603/data/ex_tower6.out new file mode 100644 index 00000000..fc234d78 --- /dev/null +++ b/S2OJ/1603/data/ex_tower6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a115e91c2e84c3078fa06914eff28d07590ddfaa47a55fb4f31dd7c5b3566194 +size 4 diff --git a/S2OJ/1603/data/problem.conf b/S2OJ/1603/data/problem.conf new file mode 100644 index 00000000..bec968d3 --- /dev/null +++ b/S2OJ/1603/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9aae62687bf83836d2dd4b8fa5e65dd1248ce5312516f319439f718180ce3383 +size 179 diff --git a/S2OJ/1603/data/std.cpp b/S2OJ/1603/data/std.cpp new file mode 100644 index 00000000..bccc94d5 --- /dev/null +++ b/S2OJ/1603/data/std.cpp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:febe7ab0cdd75f581bdb2ef3f06587093edaf8c152a0106af752054546eec79b +size 652 diff --git a/S2OJ/1603/data/tower1.in b/S2OJ/1603/data/tower1.in new file mode 100644 index 00000000..053ae1fe --- /dev/null +++ b/S2OJ/1603/data/tower1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eb49bbd5f757e7e5913ff9d3fb4e469ad1ade8207207f084f2c205b395c2bd9c +size 345 diff --git a/S2OJ/1603/data/tower1.out b/S2OJ/1603/data/tower1.out new file mode 100644 index 00000000..04cc01ee --- /dev/null +++ b/S2OJ/1603/data/tower1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08d5b742b294627a76d48ee7ded6c9b37e61f8573de19287b3f77a44f9ec7fb1 +size 13 diff --git a/S2OJ/1603/data/tower10.in b/S2OJ/1603/data/tower10.in new file mode 100644 index 00000000..4a04507a --- /dev/null +++ b/S2OJ/1603/data/tower10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:206f7058f0b0c6126f7eebabdf42ef2b988a267bb5910df6d24916350440d774 +size 150 diff --git a/S2OJ/1603/data/tower10.out b/S2OJ/1603/data/tower10.out new file mode 100644 index 00000000..e48de11d --- /dev/null +++ b/S2OJ/1603/data/tower10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:877573e7f324b9ad654d15ce702a16747e76f02061f5fe7689815ffa29769279 +size 15 diff --git a/S2OJ/1603/data/tower2.in b/S2OJ/1603/data/tower2.in new file mode 100644 index 00000000..ae750925 --- /dev/null +++ b/S2OJ/1603/data/tower2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3cb2e2242b7a710b4a385bbe6e38d68fd968da2d77ab510c99c9b02aca3fc762 +size 1415487 diff --git a/S2OJ/1603/data/tower2.out b/S2OJ/1603/data/tower2.out new file mode 100644 index 00000000..c9f708fe --- /dev/null +++ b/S2OJ/1603/data/tower2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1788a7b654479ee8e2c2d8cbd2e80c065201706085849003ae50fa40dfcc9800 +size 19 diff --git a/S2OJ/1603/data/tower3.in b/S2OJ/1603/data/tower3.in new file mode 100644 index 00000000..ea4665d2 --- /dev/null +++ b/S2OJ/1603/data/tower3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:82b2d839bfe9ba90f8cd24999033b21dba0d185e57d4e91b64b7fc09a0d765e4 +size 1498227 diff --git a/S2OJ/1603/data/tower3.out b/S2OJ/1603/data/tower3.out new file mode 100644 index 00000000..326041fe --- /dev/null +++ b/S2OJ/1603/data/tower3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:97f0aafcbe1786b9927ac4e88124d661497bf12cad2449bf443f81d9b96ce4e7 +size 20 diff --git a/S2OJ/1603/data/tower4.in b/S2OJ/1603/data/tower4.in new file mode 100644 index 00000000..1929c3db --- /dev/null +++ b/S2OJ/1603/data/tower4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:424aaea6580c758510aec87ee1a2bc850f42c001e3e160c37782cc2c82bcb7bf +size 1582499 diff --git a/S2OJ/1603/data/tower4.out b/S2OJ/1603/data/tower4.out new file mode 100644 index 00000000..67dc665e --- /dev/null +++ b/S2OJ/1603/data/tower4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4d1bcc87163d6fe88a2a57535498444c4233b180a296d1c1ed6f291603711b0 +size 16 diff --git a/S2OJ/1603/data/tower5.in b/S2OJ/1603/data/tower5.in new file mode 100644 index 00000000..ddb90da8 --- /dev/null +++ b/S2OJ/1603/data/tower5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c9cb57845c22180d7e11ae0d92f8201dee9eb10fee709768c9093c0ef097d1ba +size 618374 diff --git a/S2OJ/1603/data/tower5.out b/S2OJ/1603/data/tower5.out new file mode 100644 index 00000000..b643bfcb --- /dev/null +++ b/S2OJ/1603/data/tower5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da55582f2830da0976f4b00f68f2082d61387e6139433130c4c38d695d6867df +size 16 diff --git a/S2OJ/1603/data/tower6.in b/S2OJ/1603/data/tower6.in new file mode 100644 index 00000000..912e3bfd --- /dev/null +++ b/S2OJ/1603/data/tower6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:89eb19f72fd707a8b9bad0837ac866f25d5d652b768bc1fa57e89967ad01b509 +size 42705 diff --git a/S2OJ/1603/data/tower6.out b/S2OJ/1603/data/tower6.out new file mode 100644 index 00000000..93b0b6dd --- /dev/null +++ b/S2OJ/1603/data/tower6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:68914726cd0f71436eebce6bb2f390b75e38a3bb9ca1b969a27ff8066318e7e9 +size 16 diff --git a/S2OJ/1603/data/tower7.in b/S2OJ/1603/data/tower7.in new file mode 100644 index 00000000..ce1014fd --- /dev/null +++ b/S2OJ/1603/data/tower7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:efd84edab9602935443bf3a76ea763630cf977637eafa7aa79afc3108254741f +size 49011 diff --git a/S2OJ/1603/data/tower7.out b/S2OJ/1603/data/tower7.out new file mode 100644 index 00000000..df00ee63 --- /dev/null +++ b/S2OJ/1603/data/tower7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2632799bbf2bbecce65a6fbc48b694cf410ee16054b0b8e0f04ba14f0f379c53 +size 16 diff --git a/S2OJ/1603/data/tower8.in b/S2OJ/1603/data/tower8.in new file mode 100644 index 00000000..87b7c4f4 --- /dev/null +++ b/S2OJ/1603/data/tower8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6878cb9e7f0955d3e19c8a650b5a683178b9306365eeefffcc9ed4c144bbb32a +size 5506999 diff --git a/S2OJ/1603/data/tower8.out b/S2OJ/1603/data/tower8.out new file mode 100644 index 00000000..63b4e53f --- /dev/null +++ b/S2OJ/1603/data/tower8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ce112af901626bee1c98c45c803830778720789fabffddc48b904ddb7d2e927 +size 18 diff --git a/S2OJ/1603/data/tower9.in b/S2OJ/1603/data/tower9.in new file mode 100644 index 00000000..c6b60403 --- /dev/null +++ b/S2OJ/1603/data/tower9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbe1a35c9d487dab0fc33c015e8c97950953753018d220f3a61b57562f025328 +size 6521642 diff --git a/S2OJ/1603/data/tower9.out b/S2OJ/1603/data/tower9.out new file mode 100644 index 00000000..1f7db12d --- /dev/null +++ b/S2OJ/1603/data/tower9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:299dab5aa26b1eef6fec46d607ea441636dcf2dbaa41aef4414f782b488bd106 +size 17 diff --git a/S2OJ/1603/data/val.cpp b/S2OJ/1603/data/val.cpp new file mode 100644 index 00000000..f49396c5 --- /dev/null +++ b/S2OJ/1603/data/val.cpp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d02c2707337f5081baad6cfb4e44fa8f4b5acabe757499a971f0cda00714649 +size 541