Codeforces Round #404 (Div. 2) A&B

偏偏晚上11点开始…有点醉
果然还是只能写两题的水平。
先来一个小目标,两个月内换一个颜色啊!!!

讲道理这两题纯粹靠的手速啊。
A
根本没仔细看题意,总之就是一个形状对应几个面,给出几个形状,求面的总和。
A题好像总在卡int的范围。
下次我一定试试hack

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>

using namespace std;
#define inf 0x3f3f3f3f
map<string,int> ss;

int main()
{
    ss["Tetrahedron"] = 4;
    ss["Cube"] = 6;
    ss["Octahedron"] = 8;
    ss["Dodecahedron"] = 12;
    ss["Icosahedron"] = 20;
    int n;
    scanf("%d",&n);
    long long ans = 0;
    while(n--)
    {
        char s[20];
        scanf("%s",s);
        ans += ss[s];
    }
    cout<<ans<<endl;
    return 0;
}

B

有个同学想要去上chess课,又想去program课,给出几个选择时段的可能,求中间最长能休息多久。

很明显,我们只需要知道chess课最早结束和program课最迟开始的差值, 以及chess课最迟开始和prograss最早结束的差值,取最大,如果都<=0 输出0

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>

using namespace std;
#define inf 0x3f3f3f3f
#define maxn 200005


int main()
{
    int n1,n2;
    int a;int b;
    scanf("%d",&n1);
    int bmin = inf,amax = 0;
    for(int i = 0; i < n1 ; i ++)
    {
        scanf("%d%d",&a,&b);
        if(a > amax) amax = a;
        if(b < bmin) bmin = b;
    }
    scanf("%d",&n2);
    int j,k;
    int kmin = inf, jmax = 0;
    for(int i = 0; i < n2; i++)
    {
        scanf("%d%d",&j,&k);

        if(j > jmax) jmax = j;
        if(k < kmin) kmin = k;

    }

    int aa = jmax - bmin;
    int bb = amax - kmin;

    if(aa <= 0 && bb <= 0)
        printf("%d\n",0);
    else
        printf("%d\n",max(aa,bb));

    return 0;
}

写到第三题的时候,感觉是题数学题,但是自己就是没办法推…
想想自己的写法绝对会tle….哎
希望自己能快点能写第三题。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值