Codeforces Round #334 (Div. 2)

http://codeforces.com/contest/604

A:

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <ctype.h>
#include <time.h>
#include <queue>
#include <map>
#include <set>

using namespace std;

int m[6];
int w[6];
int hs,hu;
int a[10] = {0,500, 1000, 1500, 2000, 2500};

int main()
{
    cin>>m[1]>>m[2]>>m[3]>>m[4]>>m[5];
    cin>>w[1]>>w[2]>>w[3]>>w[4]>>w[5];
    cin>>hs>>hu;
    int ans =0;
    for(int i=1;i<=5;i++)
        ans += max(a[i]/10*3,a[i] - a[i]/250*m[i] - 50*w[i]);

    ans += 100*hs;
    ans += -50*hu;
    cout<<ans<<endl;
    return 0;
}

B:

#include <iostream>
#include <set>
#include <string>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>

using namespace std;

int n, k;
long long a[100010];

int main()
{
    while (cin >> n >> k)
    {
        for (int i = 1;i <= n;i++)
            cin >> a[i];

        long long ans = a[n];

        int num = n - k;

        for (int i = 1;i <= num;i++)
        {
            ans = max(ans, a[i] + a[2 * num - i + 1]);
        }

        cout << ans << endl;
    }
    return 0;
}

C:

#include <iostream>
#include <set>
#include <string>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>

using namespace std;

int n;
char s[100010];

int main()
{
    while (cin >> n)
    {
        cin >> s;

        int pos = 0;
        int len = strlen(s);
        int cnt1 = 0, cnt2 = 0;

        while (pos < len)
        {
            if (s[pos] == s[pos + 1])
            {
                cnt2++;
            }
            else
            {
                cnt1++;
            }
            pos++;
        }

        //cout << cnt1 << " " << cnt2 << endl;

        int ans = cnt1 + min(2, cnt2);

        cout << ans << endl;

    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值