diff --git a/S2OJ/1516/1516.cpp b/S2OJ/1516/1516.cpp new file mode 100644 index 00000000..52510b4c --- /dev/null +++ b/S2OJ/1516/1516.cpp @@ -0,0 +1,69 @@ +#include +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 2505; + +int n, k, l[N], r[N], w[N]; +long long sum, f[N << 1]; +std::vector nums; +std::vector> g[N << 1]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> k; + + for (int i = 1; i <= n; i++) { + cin >> l[i] >> r[i] >> w[i]; + + nums.emplace_back(l[i]); + nums.emplace_back(r[i]); + sum += w[i]; + } + + std::sort(nums.begin(), nums.end()); + nums.erase(std::unique(nums.begin(), nums.end()), nums.end()); + + for (int i = 1; i <= n; i++) { + l[i] = std::lower_bound(nums.begin(), nums.end(), l[i]) - nums.begin() + 1; + r[i] = std::lower_bound(nums.begin(), nums.end(), r[i]) - nums.begin() + 1; + + g[l[i]].emplace_back(r[i], w[i]); + } + + for (int i = 1; i <= nums.size(); i++) { + std::priority_queue, std::greater<>> q; + long long res = 0; + + for (int j = i; j; j--) { + for (auto e : g[j]) { + if (e.first <= i) { + if (q.size() < k) { + q.emplace(e.second); + res += e.second; + } else if (q.top() < e.second) { + res -= q.top(); + q.pop(); + q.emplace(e.second); + res += e.second; + } + } + } + + f[i] = std::max(f[i], f[j - 1] + res); + } + } + + cout << sum - f[nums.size()] << endl; + + return 0; +} diff --git a/S2OJ/1516/data/ex_range1.ans b/S2OJ/1516/data/ex_range1.ans new file mode 100644 index 00000000..2eb7b22f --- /dev/null +++ b/S2OJ/1516/data/ex_range1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:24ba1e99dc06b19351323aae0d7370243d586475a634b7f6ff7927fbc72cfaed +size 3 diff --git a/S2OJ/1516/data/ex_range1.in b/S2OJ/1516/data/ex_range1.in new file mode 100644 index 00000000..f3d0fe94 --- /dev/null +++ b/S2OJ/1516/data/ex_range1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8865084a036d1ba0f78dfb7787d73575849e0627393d19ab12ba51ecd484e2f7 +size 42 diff --git a/S2OJ/1516/data/ex_range2.ans b/S2OJ/1516/data/ex_range2.ans new file mode 100644 index 00000000..869dbe3e --- /dev/null +++ b/S2OJ/1516/data/ex_range2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9034e02f193cb34f95719e55d99fb987a54e0ba293fe7b4fa7f08b7ca9a5ee5a +size 13 diff --git a/S2OJ/1516/data/ex_range2.in b/S2OJ/1516/data/ex_range2.in new file mode 100644 index 00000000..d5fe1b7d --- /dev/null +++ b/S2OJ/1516/data/ex_range2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e931a2aaef53d0f4f31e384f340e02e0a68bedf147face21b2f1822526ebf5f +size 3067 diff --git a/S2OJ/1516/data/problem.conf b/S2OJ/1516/data/problem.conf new file mode 100644 index 00000000..d856d9f2 --- /dev/null +++ b/S2OJ/1516/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a231486563d16fabc853e6b08be7cb11c2704a8e5f340f2120823764229798c +size 179 diff --git a/S2OJ/1516/data/range1.ans b/S2OJ/1516/data/range1.ans new file mode 100644 index 00000000..b227cf4c --- /dev/null +++ b/S2OJ/1516/data/range1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d860a9249f0bfbc20f94d68f95cb7f343f44c230cd6d08a7d192396d8c9a2e9 +size 11 diff --git a/S2OJ/1516/data/range1.in b/S2OJ/1516/data/range1.in new file mode 100644 index 00000000..aac23a17 --- /dev/null +++ b/S2OJ/1516/data/range1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5685302b39405974a25b4f6cb136dd85d2912509c0ba8a96802ad11708e343d3 +size 595 diff --git a/S2OJ/1516/data/range10.ans b/S2OJ/1516/data/range10.ans new file mode 100644 index 00000000..fbee8017 --- /dev/null +++ b/S2OJ/1516/data/range10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69ec6c523c10318c3f28eb2df7281d985dbe2ffd6d31626e772e0423b1ea555f +size 12 diff --git a/S2OJ/1516/data/range10.in b/S2OJ/1516/data/range10.in new file mode 100644 index 00000000..f306d2e7 --- /dev/null +++ b/S2OJ/1516/data/range10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2643929b4031a995f703c72846f70dc61d173cdd3c43c329d4a064f7b5c55745 +size 2873 diff --git a/S2OJ/1516/data/range11.ans b/S2OJ/1516/data/range11.ans new file mode 100644 index 00000000..274a8dd6 --- /dev/null +++ b/S2OJ/1516/data/range11.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b115dec97db5e6effaab88c7931154dcf12bf5b10b92e5de0bd91916a87aa524 +size 12 diff --git a/S2OJ/1516/data/range11.in b/S2OJ/1516/data/range11.in new file mode 100644 index 00000000..61e60211 --- /dev/null +++ b/S2OJ/1516/data/range11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2b806891e496f8e26c4756fc875fa5df84570c564cb53745d767309df580352e +size 14569 diff --git a/S2OJ/1516/data/range12.ans b/S2OJ/1516/data/range12.ans new file mode 100644 index 00000000..054eea9b --- /dev/null +++ b/S2OJ/1516/data/range12.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8a1257b45470470a1c641c6b2a9e209244cf183458b180ba0e75e18063fbdae +size 13 diff --git a/S2OJ/1516/data/range12.in b/S2OJ/1516/data/range12.in new file mode 100644 index 00000000..d3175622 --- /dev/null +++ b/S2OJ/1516/data/range12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1910fd7288265ade18837e889b1ca9150ca39a0fba89bd96f21549ec63091fa8 +size 14559 diff --git a/S2OJ/1516/data/range13.ans b/S2OJ/1516/data/range13.ans new file mode 100644 index 00000000..636d90bb --- /dev/null +++ b/S2OJ/1516/data/range13.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:925f4633fcbe2b47178ca19b168fc2c15c5ee8888fc77c030f07321e7b031b05 +size 13 diff --git a/S2OJ/1516/data/range13.in b/S2OJ/1516/data/range13.in new file mode 100644 index 00000000..81251790 --- /dev/null +++ b/S2OJ/1516/data/range13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33dffd33db70f02ade31f69489e8dfccd3c2723dde4b47002f21991eff413707 +size 14328 diff --git a/S2OJ/1516/data/range14.ans b/S2OJ/1516/data/range14.ans new file mode 100644 index 00000000..33b2f568 --- /dev/null +++ b/S2OJ/1516/data/range14.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:847c25012723af5900c21e2b4df9b26e9cc49227b3abe47d045799e64e56edf0 +size 13 diff --git a/S2OJ/1516/data/range14.in b/S2OJ/1516/data/range14.in new file mode 100644 index 00000000..907b04b9 --- /dev/null +++ b/S2OJ/1516/data/range14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8962b56cba0b53f9152bfb5d7cc420c3919aba359b3649aca17a75543611a964 +size 14370 diff --git a/S2OJ/1516/data/range15.ans b/S2OJ/1516/data/range15.ans new file mode 100644 index 00000000..5cb099a4 --- /dev/null +++ b/S2OJ/1516/data/range15.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d245250208ee90786dcfd9c51f47aaa237a237c2a37b76fdff7b453070a3e16 +size 13 diff --git a/S2OJ/1516/data/range15.in b/S2OJ/1516/data/range15.in new file mode 100644 index 00000000..32265aa4 --- /dev/null +++ b/S2OJ/1516/data/range15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:163a10c2ab1c15d3a7208ba13ece905141af060805705c71fb1f28bfc4615149 +size 73928 diff --git a/S2OJ/1516/data/range16.ans b/S2OJ/1516/data/range16.ans new file mode 100644 index 00000000..c52b4c26 --- /dev/null +++ b/S2OJ/1516/data/range16.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d92e2a076abe6ad60c19baf337612180f81d3c212887e517fcfb640e374d1cc +size 13 diff --git a/S2OJ/1516/data/range16.in b/S2OJ/1516/data/range16.in new file mode 100644 index 00000000..ef2a9785 --- /dev/null +++ b/S2OJ/1516/data/range16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d68fb7fb41e0be8d9c78bb2ac3566d83e078967bb3e89d40c92950c3f93322ff +size 73508 diff --git a/S2OJ/1516/data/range17.ans b/S2OJ/1516/data/range17.ans new file mode 100644 index 00000000..942952a4 --- /dev/null +++ b/S2OJ/1516/data/range17.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eea88bfdb4ac62f6bb25794f7d0b1d21a8b93f709adc7781ad3c15ad3a7948a9 +size 13 diff --git a/S2OJ/1516/data/range17.in b/S2OJ/1516/data/range17.in new file mode 100644 index 00000000..fba1186d --- /dev/null +++ b/S2OJ/1516/data/range17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3ce4391cbfa71151ce87ed5923a0113882a1bc739c5ff5b5a72dab9ef0056ec0 +size 73868 diff --git a/S2OJ/1516/data/range18.ans b/S2OJ/1516/data/range18.ans new file mode 100644 index 00000000..dce899bd --- /dev/null +++ b/S2OJ/1516/data/range18.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:deabbb4f38d4f89c232a1bb7e20514bd3ca956025c1f41cb8bf0f2b021fa1119 +size 13 diff --git a/S2OJ/1516/data/range18.in b/S2OJ/1516/data/range18.in new file mode 100644 index 00000000..73579bfb --- /dev/null +++ b/S2OJ/1516/data/range18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8aa5e13dff2a6d37af295dac93e1d62673b4d8cdc0ff97c0b142495df8696926 +size 73805 diff --git a/S2OJ/1516/data/range19.ans b/S2OJ/1516/data/range19.ans new file mode 100644 index 00000000..6304114c --- /dev/null +++ b/S2OJ/1516/data/range19.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bcd91f8d4f04c341b1c0c7761ada5069056cae87925a89d2116cb55fffe248c +size 13 diff --git a/S2OJ/1516/data/range19.in b/S2OJ/1516/data/range19.in new file mode 100644 index 00000000..877d92a4 --- /dev/null +++ b/S2OJ/1516/data/range19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e33cc491875e9c85a3676a7186dd59bdacfc87e7b649ab3bcf4da196c1c8f2d9 +size 73437 diff --git a/S2OJ/1516/data/range2.ans b/S2OJ/1516/data/range2.ans new file mode 100644 index 00000000..fac0b470 --- /dev/null +++ b/S2OJ/1516/data/range2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:651e284377311cb6f5885481188104988577c94f10f40512fe4cafda0c5c2df2 +size 11 diff --git a/S2OJ/1516/data/range2.in b/S2OJ/1516/data/range2.in new file mode 100644 index 00000000..f7855843 --- /dev/null +++ b/S2OJ/1516/data/range2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3c5e6c4fa760c42154dc655e48192e2464a5524aeca4ef5a59e63030ef3028c +size 594 diff --git a/S2OJ/1516/data/range20.ans b/S2OJ/1516/data/range20.ans new file mode 100644 index 00000000..37d5eeaf --- /dev/null +++ b/S2OJ/1516/data/range20.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5b2e25d1335aa275edab56f1c581e93a0a99750621286ff643eeefc9af96ed32 +size 13 diff --git a/S2OJ/1516/data/range20.in b/S2OJ/1516/data/range20.in new file mode 100644 index 00000000..ddce11f1 --- /dev/null +++ b/S2OJ/1516/data/range20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b53c3a7ce4cd1d5b7952caeae718f5054653ff63f60d84a8ade635bc303fd2c2 +size 73752 diff --git a/S2OJ/1516/data/range3.ans b/S2OJ/1516/data/range3.ans new file mode 100644 index 00000000..887f93e6 --- /dev/null +++ b/S2OJ/1516/data/range3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2967fc789b9476770fd8f5d430840ca11e8e5e298f22992aa645aaa19d5d3b43 +size 11 diff --git a/S2OJ/1516/data/range3.in b/S2OJ/1516/data/range3.in new file mode 100644 index 00000000..21122fb1 --- /dev/null +++ b/S2OJ/1516/data/range3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe478afe274d5782e151b64000e71767529a642ca7926cd8ba158c244bf931d5 +size 592 diff --git a/S2OJ/1516/data/range4.ans b/S2OJ/1516/data/range4.ans new file mode 100644 index 00000000..1ca0dd5b --- /dev/null +++ b/S2OJ/1516/data/range4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f294cf4f50b155093defe45bf96b0aca051dc2f151d4527c664395aa622a853 +size 12 diff --git a/S2OJ/1516/data/range4.in b/S2OJ/1516/data/range4.in new file mode 100644 index 00000000..8e10cfc6 --- /dev/null +++ b/S2OJ/1516/data/range4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fe9788335fd8d4bfc1bbf66390652ce88689d1247a7210df78023f4bda45b40 +size 2723 diff --git a/S2OJ/1516/data/range5.ans b/S2OJ/1516/data/range5.ans new file mode 100644 index 00000000..1e3f203c --- /dev/null +++ b/S2OJ/1516/data/range5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dde4296cc9b9f4c83c1b97db76c2b51f36480345fe081f14b1c21d38317fe407 +size 12 diff --git a/S2OJ/1516/data/range5.in b/S2OJ/1516/data/range5.in new file mode 100644 index 00000000..29fef257 --- /dev/null +++ b/S2OJ/1516/data/range5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17560f5edc29a37070b9be1d8aee1ca407c1a404e9e6f7c3594bd84e461158bb +size 2818 diff --git a/S2OJ/1516/data/range6.ans b/S2OJ/1516/data/range6.ans new file mode 100644 index 00000000..ded25125 --- /dev/null +++ b/S2OJ/1516/data/range6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b0ed682a737638118697adbf27a176f124b991c26d7d3683f09624db030dea5 +size 12 diff --git a/S2OJ/1516/data/range6.in b/S2OJ/1516/data/range6.in new file mode 100644 index 00000000..6237bafe --- /dev/null +++ b/S2OJ/1516/data/range6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5abb2fd9c682a0538052dffbf36e06decadc47cb6e72fe685d5ee699df32e435 +size 2950 diff --git a/S2OJ/1516/data/range7.ans b/S2OJ/1516/data/range7.ans new file mode 100644 index 00000000..7ab19547 --- /dev/null +++ b/S2OJ/1516/data/range7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb32cfaeb556b22f52221fdcaba1e1e51f6f9945fb2243267b56513d47490520 +size 12 diff --git a/S2OJ/1516/data/range7.in b/S2OJ/1516/data/range7.in new file mode 100644 index 00000000..c5dd6c64 --- /dev/null +++ b/S2OJ/1516/data/range7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:04ab659a050eef9595881015ecb739c2d0d97491bf403657e111c2983f2cb28a +size 2903 diff --git a/S2OJ/1516/data/range8.ans b/S2OJ/1516/data/range8.ans new file mode 100644 index 00000000..e6a73281 --- /dev/null +++ b/S2OJ/1516/data/range8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b04eec50549d244238c4f96801570e9a79c9a196ad153ca4c2ecd7958df74519 +size 12 diff --git a/S2OJ/1516/data/range8.in b/S2OJ/1516/data/range8.in new file mode 100644 index 00000000..517ba690 --- /dev/null +++ b/S2OJ/1516/data/range8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9d3dbb502fbbfc1b6fe9086e811f1e297893a260b86d8263478913860d7a8f6 +size 2906 diff --git a/S2OJ/1516/data/range9.ans b/S2OJ/1516/data/range9.ans new file mode 100644 index 00000000..4c933b6b --- /dev/null +++ b/S2OJ/1516/data/range9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b855ad2eabb5f20fdd56ca0e09677f7c75bf01236d5a2515100026bd759cce34 +size 12 diff --git a/S2OJ/1516/data/range9.in b/S2OJ/1516/data/range9.in new file mode 100644 index 00000000..292d1ee5 --- /dev/null +++ b/S2OJ/1516/data/range9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f9b07a3742554b008fa76beaec032735575efc1c90e8ce4ca78548d69b445d31 +size 2956