Codeforces Round #264 (Div. 2) | ABCD

A. Caisa and Sugar

这题简直坑,题目中没描述清楚究竟是买一个,还是买一种。坑到最后还是没弄出来,我一直以为是一种可以买多个。

#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
typedef long long ll;
using namespace std;
int n, s;
int main()
{
        cin>>n>>s;
        int yy = s*100, x, y;
        int res = -1;
        for(int i = 0;i < n; i++)
        {
                cin>>x>>y;
                int tmp = x*100+y;
                if(tmp > yy)    continue;
                res = max(res, (yy-tmp)%100);
        }
        cout<<res<<endl;
        return 0;
}


B. Caisa and Pylons

每当走到下一根柱子时,能量值要变为负值就最终结果就加上该负值的绝对值。不够就加,顶合理的!

#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;
const int MAXN = 1e5+5;
int a[MAXN];
int main()
{
        long long res = 0;
        int n;
        cin>>n;
        for(int i = 1;i <= n; i++)
                cin>>a[i];
        res += a[1];
        int cv = 0;
        for(int i = 1;i <= n-1; i++)
        {
                int tmp = cv + a[i]-a[i+1];
                if(tmp < 0)
                        res += -tmp, cv = 0;
                else
                        cv += a[i]-a[i+1];
        }
        cout<<res<<endl;
        return 0;
}

C. Gargari and Bishops

D. Gargari and Permutations

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值