Educational Codeforces Round 112 (Rated for Div. 2)(毒瘤掉分场)

在这里插入图片描述

写在前面的话:
一个半小时才把A过了;虽然很毒瘤,但是还是因为自己菜,所以才掉分

比赛链接

· Problem A

  • 题意

在这里插入图片描述

你需要 n n n 块蛋糕块,有三种蛋糕,分别是:15分钟搞6块、20分钟搞8块、25分钟搞10块。问你最短的搞的时间。

  • 思路

毒瘤。直接看代码吧。稍微解释一下下: 15 / 6 = 20 / 8 = 25 / 10 = 5 / 2 15/6=20/8=25/10=5/2 15/6=20/8=25/10=5/2,所以只要不浪费,用哪种蛋糕都一样;所以优先采用 15 − 6 15-6 156 的,(别问我为啥知道,我要是知道,就不会一个半小时才过了),那么会余 0 − 5 0-5 05——当余 1 , 2 1,2 1,2时,你再花时间搞一块 15 − 6 15-6 156 的蛋糕不如采用把这两块 15 − 6 15-6 156 的蛋糕,换成 20 − 8 20-8 208 的;当余 3 , 4 3,4 3,4时,你再花时间搞一块 15 − 6 15-6 156 的蛋糕不如采用把这两块 15 − 6 15-6 156 的蛋糕,换成 25 − 10 25-10 2510 的;余 5 5 5 的话,你就搞一块 15 − 6 15-6 156 的吧。可以看代码更清晰

  • 代码
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2e5+10,mod=1e9+7;

#define PII pair<int,int>
#define x first
#define y second
#define PB push_back
void solve()
{
	ll n;cin>>n;
    ll ans=ll(n/6)*15;
    //cout<<ans<<": "<<endl;
    if(n<=6){
        cout<<15<<endl;return;
    }
    ll xx=n%6;
    if(!xx){
        cout<<ans<<endl;
    }
    else if(xx<=2){
        ans+=5;
        cout<<ans<<endl;
    }
    else if(xx<=4){
        ans+=10;cout<<ans<<endl;
    }
    else {
        ans+=15;cout<<ans<<endl;
    }
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("a.txt", "r", stdin);
	freopen("aout.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
}

· Problem B

  • 题意
    在这里插入图片描述

给你一个大矩形,和一个位置已知的小矩形,和另一个随意的小矩形,问你把后者放进去,不和第一个小矩形重叠,需要把第一个小矩形移动的最短的距离。

  • 思路

毒瘤。直接看代码吧。稍微解释一下下:
一开始想傻了,还以为要勾股定理,长的移动勾股上宽的移动,后来想想不用啊,只需要在长的移动上和宽的移动上取个最小值就行了题面毒瘤,错误引导。所以你要做的工作就是分类讨论(毒瘤)。
建议自己画图,仔细分类讨论,以后遇见这题,一定要耐心分类讨论,别怕慢。

  • 代码
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2e5+10,mod=1e9+7;

#define PII pair<int,int>
#define x first
#define y second
#define PB push_back
void solve()
{
	double W,H,w,h;
    double x1,x2,y1,y2;
    cin>>W>>H;
    cin>>x1>>y1>>x2>>y2;
    cin>>w>>h;
    double xw=x2-x1,yh=y2-y1;
    if(xw+w>W&&yh+h>H){
        cout<<-1<<endl;return;
    }
    double ans=max(H,W);
    //先讨论是否可以不移动
    if(w<=x1||w<=(W-x2)){
        cout<<0.000000000<<endl;return;//
    }
    if(h<=y1||h<=(H-y2)){
        cout<<0.000000000<<endl;return;
    }
    //如果不能移动高
    if(h+yh>H){
        ans=min(ans,w-x1);
        ans=min(ans,x2-(W-w));
        ans=max(ans,0.0);cout<<fixed<<setprecision(8)<<ans<<endl;return;
    }
    //如果不能移动宽
    if(w+xw>W){
        ans=min(ans,h-y1);
        ans=min(ans,y2-(H-h));
        ans=max(ans,0.0);cout<<fixed<<setprecision(8)<<ans<<endl;return;
    }    
	那就没限制了随便移动好了
    ans=min(ans,w-x1);
    ans=min(ans,x2-(W-w));
    ans=max(ans,0.0);
    ans=min(ans,h-y1);
    ans=min(ans,y2-(H-h));
    ans=max(ans,0.0);
    cout<<fixed<<setprecision(8)<<ans<<endl;//return;
   	这里就不删了,让你们看看我有多煞笔。
    //if(xw+w)
    // if(w>=x2){
    //     double yd=max(h-y1,0.0);
    //     yd=min(yd,max(0.0,h+y2-H));
    //     ans=yd;
    //     if(w+xw<=W){
    //         ans=min(ans,w-x1);
    //         ans=min(ans,x2-(W-w));
    //         ans=max(ans,0.0);
    //     }
    //     cout<<fixed<<setprecision(8)<<ans<<endl;return;
    // }
    // else if(w>=x1){
    //     // double xd=max(w-x1,0.0);
    //     // xd=min(xd,max(0.0,w+x2-W));
    //     // double yd=max(h-y1,0.0);
    //     // yd=min(yd,max(0.0,h+y2-H));
    //     // ans=min(yd,xd);
    //     // cout<<fixed<<setprecision(8)<<ans<<endl;return;
    //     if(h>=y2){
    //         double xd=max(w-x1,0.0);
    //         xd=min(xd,max(0.0,w+x2-W));
    //         ans=xd;
    //         if(h+yh<=H){
    //             ans=min(ans,h-y1);
    //             ans=min(ans,y2-(H-h));
    //             ans=max(ans,0.0);
    //         }
    //         cout<<fixed<<setprecision(8)<<ans<<endl;return;
    //     }
    //     else if(h>=y1){
    //         double xd=max(w-x1,0.0);
    //         xd=min(xd,max(0.0,w+x2-W));
    //         double yd=max(h-y1,0.0);
    //         yd=min(yd,max(0.0,h+y2-H));
    //         ans=min(yd,xd);
    //         cout<<fixed<<setprecision(8)<<ans<<endl;return;
    //     }
        
    // }
    
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("b.txt", "r", stdin);
	freopen("bout.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
}

· Problem C

  • 题意
    在这里插入图片描述

2*n 的方格,每个方格都有一个值,Alice 和 Bob 玩游戏,两个人都从 (1,1)走到(2,n),只能向下走或者向右走;Alice 先走一遍,把经过的路径上的值加到自己的分数上;Bob 然后再走,但是他只能把 Alice 没走过的加到自己的分数上;Alice 想要 Bob 的分数最小,Bob 当然想要自己的分数最大,问你 如果双方都采取最优策略,那么最后 Bob 能够拿到多少分。
样例解释
在这里插入图片描述

  • 思路

毒瘤。这题其实还行,不算毒瘤,可是,,,可是,,,没在比赛时做出来呀,赛后想出来了。。。
因为只能向下走和向右走,所以就只会出现一个下拐线,所以可以枚举这个下拐线。
那么Bob能够取得只有这个拐线左边第二排的,和右边第一排的,用一个前缀和维护一下,可以 O ( n ) O(n) O(n)

  • 代码
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=2e5+10,mod=1e9+7;
ll a[5][N];
#define PII pair<int,int>
#define x first
#define y second
#define PB push_back
ll dp1[N],dp2[N];
void solve()
{
    memset(dp1,0,sizeof(dp1));
    memset(dp2,0,sizeof(dp2));
	int n;cin>>n;
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    dp1[n]=a[1][n];
    for(int i=n-1;i>=1;i--){
        dp1[i]=dp1[i+1]+a[1][i];
    }
    dp2[1]=a[2][1];
    for(int i=2;i<=n;i++){
        dp2[i]=dp2[i-1]+a[2][i];
    }
    ll minn=min(dp1[2],dp2[n-1]);
    for(int i=2;i<n;i++){
        minn=min(minn,max(dp1[i+1],dp2[i-1]));
    }
    cout<<minn<<endl;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("a.txt", "r", stdin);
	freopen("aout.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
}
  • 后记
    D题等待更新吧,毒瘤,自己菜还是,哪能咋办,总不能因为自己菜就不活了吧,慢慢来吧,总有一天会变强的(会接受自己菜的 呜呜)。
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

疯狂的码泰君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值