0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-11 22:46:28 +00:00

#1516. 【2022 正睿 NOIP 十连测 Day 1】区间 (range)

https://sjzezoj.com/submission/60321
This commit is contained in:
Baoshuo Ren 2022-10-13 08:21:13 +08:00
parent a2c574292e
commit 8e7043f788
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
46 changed files with 204 additions and 0 deletions

69
S2OJ/1516/1516.cpp Normal file
View File

@ -0,0 +1,69 @@
#include <iostream>
#include <algorithm>
#include <functional>
#include <queue>
#include <utility>
#include <vector>
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<int> nums;
std::vector<std::pair<int, int>> 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<int, std::vector<int>, 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;
}

BIN
S2OJ/1516/data/ex_range1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/ex_range1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/ex_range2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/ex_range2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range13.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range14.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range15.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range16.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range17.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range18.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range19.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range20.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1516/data/range9.in (Stored with Git LFS) Normal file

Binary file not shown.