码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #508 (Div. 2)

时间:2020-02-01 23:20:04      阅读:61      评论:0      收藏:0      [点我收藏+]

标签:scan   empty   return   lld   push   amp   print   sum   round   

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\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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!