标签:scan empty return lld push amp print sum round
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\n", 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\n", sumA - sumB);
}
Codeforces Round #508 (Div. 2)
标签:scan empty return lld push amp print sum round
原文地址:https://www.cnblogs.com/KisekiPurin2019/p/12250501.html