mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:28:48 +00:00
Compare commits
2 Commits
bfaa878ec3
...
813aade458
Author | SHA1 | Date | |
---|---|---|---|
813aade458 | |||
e8b22ef5df |
113
Luogu/CF730I/CF730I.cpp
Normal file
113
Luogu/CF730I/CF730I.cpp
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
|
#include <queue>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 2e5 + 5;
|
||||||
|
|
||||||
|
int n, p, s, sum, op[N];
|
||||||
|
std::pair<int, int> a[N], b[N];
|
||||||
|
std::priority_queue<std::pair<int, int>> q1, q2, q3;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n >> p >> s;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> a[i].first;
|
||||||
|
a[i].second = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> b[i].first;
|
||||||
|
b[i].second = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(a + 1, a + 1 + n, [](auto a, auto b) {
|
||||||
|
return a.first > b.first;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int i = 1; i <= p; i++) {
|
||||||
|
sum += a[i].first;
|
||||||
|
op[a[i].second] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(a + 1, a + 1 + n, [](auto a, auto b) {
|
||||||
|
return a.second < b.second;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
q1.push(a[i]);
|
||||||
|
q2.push(b[i]);
|
||||||
|
q3.emplace(b[i].first - a[i].first, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= s; i++) {
|
||||||
|
int val = std::numeric_limits<int>::min(),
|
||||||
|
id1 = 0,
|
||||||
|
id2 = 0,
|
||||||
|
opt = 0;
|
||||||
|
|
||||||
|
while (!q2.empty() && op[q2.top().second] != 0) q2.pop();
|
||||||
|
|
||||||
|
if (!q2.empty() && q2.top().first > val) {
|
||||||
|
val = q2.top().first;
|
||||||
|
id1 = q2.top().second;
|
||||||
|
opt = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!q1.empty() && op[q1.top().second] != 0) q1.pop();
|
||||||
|
while (!q3.empty() && op[q3.top().second] != 1) q3.pop();
|
||||||
|
|
||||||
|
if (!q1.empty() && !q3.empty()) {
|
||||||
|
int sum = q1.top().first + q3.top().first;
|
||||||
|
|
||||||
|
if (sum > val) {
|
||||||
|
val = sum;
|
||||||
|
id1 = q3.top().second;
|
||||||
|
id2 = q1.top().second;
|
||||||
|
opt = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sum += val;
|
||||||
|
|
||||||
|
if (opt == 1) {
|
||||||
|
q2.pop();
|
||||||
|
op[id1] = 2;
|
||||||
|
} else {
|
||||||
|
q1.pop();
|
||||||
|
q3.pop();
|
||||||
|
op[id1] = 2;
|
||||||
|
op[id2] = 1;
|
||||||
|
q3.emplace(b[id2].first - a[id2].first, id2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << sum << endl;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
if (op[i] == 1) {
|
||||||
|
cout << a[i].second << ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
if (op[i] == 2) {
|
||||||
|
cout << a[i].second << ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
58
S2OJ/1453/1453.cpp
Normal file
58
S2OJ/1453/1453.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 1e5 + 5;
|
||||||
|
const int mod = 998244353;
|
||||||
|
|
||||||
|
int t, n, m, fac[N], inv[N], fac_inv[N];
|
||||||
|
|
||||||
|
inline int binpow(int a, int b) {
|
||||||
|
a %= mod;
|
||||||
|
|
||||||
|
int res = 1;
|
||||||
|
|
||||||
|
while (b) {
|
||||||
|
if (b & 1) res = static_cast<long long>(res) * a % mod;
|
||||||
|
a = static_cast<long long>(a) * a % mod;
|
||||||
|
b >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int C(int n, int m) {
|
||||||
|
return static_cast<long long>(fac[n]) * fac_inv[m] % mod * fac_inv[n - m] % mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
fac[0] = 1;
|
||||||
|
for (int i = 1; i < N; i++) {
|
||||||
|
fac[i] = static_cast<long long>(fac[i - 1]) * i % mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
inv[0] = inv[1] = 1;
|
||||||
|
for (int i = 2; i < N; i++) {
|
||||||
|
inv[i] = static_cast<long long>(mod - mod / i) * inv[mod % i] % mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
fac_inv[0] = fac_inv[1] = 1;
|
||||||
|
for (int i = 2; i < N; i++) {
|
||||||
|
fac_inv[i] = static_cast<long long>(fac_inv[i - 1]) * inv[i] % mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
cin >> t;
|
||||||
|
|
||||||
|
while (t--) {
|
||||||
|
cin >> n >> m;
|
||||||
|
|
||||||
|
cout << static_cast<long long>(binpow(2, n - m)) * C(n, m) % mod << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1453/data/data1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/data9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/data9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1453/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1453/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user