Codeforces Round #508 (Div. 2)
Posted kisekipurin2019
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #508 (Div. 2)相关的知识,希望对你有一定的参考价值。
A
char s[100005];
int cnt[26];
void test_case() {
int n, k;
scanf("%d%d%s", &n, &k, s + 1);
for(int i = 1; i <= n; ++i)
++cnt[s[i] - 'A'];
int minL = INF;
for(int i = 0; i < k; ++i)
minL = min(minL, cnt[i]);
printf("%d
", minL * k);
}
void test_case() {
int n;
scanf("%d", &n);
if(n <= 2) {
puts("No");
return;
}
puts("Yes");
printf("%d", (n + 1) / 2);
for(int i = 1; i <= n; i += 2)
printf(" %d", i);
puts("");
printf("%d", n / 2);
for(int i = 2; i <= n; i += 2)
printf(" %d", i);
puts("");
}
priority_queue<int> PQA, PQB;
void test_case() {
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
int x;
scanf("%d", &x);
PQA.push(x);
}
for(int i = 1; i <= n; ++i) {
int x;
scanf("%d", &x);
PQB.push(x);
}
ll sumA = 0, sumB = 0;
for(int i = 1; i <= n; ++i) {
if(PQA.empty())
PQB.pop();
else {
if(PQB.empty() || PQA.top() > PQB.top()) {
sumA += PQA.top();
PQA.pop();
} else
PQB.pop();
}
if(PQB.empty())
PQA.pop();
else {
if(PQA.empty() || PQB.top() > PQA.top()) {
sumB += PQB.top();
PQB.pop();
} else
PQA.pop();
}
}
printf("%lld
", sumA - sumB);
}
以上是关于Codeforces Round #508 (Div. 2)的主要内容,如果未能解决你的问题,请参考以下文章
题解——Codeforces Round #508 (Div. 2) T3 (贪心)
题解——Codeforces Round #508 (Div. 2) T2 (构造)
Codeforces Round #436 E. Fire(背包dp+输出路径)
[ACM]Codeforces Round #534 (Div. 2)