Educational Codeforces Round 112 (Rated for Div. 2)(A-D)

Problem - A - CodeforcesCodeforces. Programming competitions and contests, programming communityhttps://codeforces.com/contest/1555/problem/A

A. PizzaForces

题意:需要n块披萨,做一个块数为6,8,10的披萨分别要15,20,25分钟,问做n块披萨最少要多久

思路:没想明白就挺恶心的.小于6的块数都只能按照做六块的时间处理.稍微枚举找点规律就会发现,大于6块的偶数都可以被6,8,10组合出来.而且每一块披萨所需的时间都是2.5min,所以对技术进行
+1处理后直接计算.

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N =5e5+10,mod=998244353;
void solve()
{
    int n,ans;
    cin>>n;
    cout<<max(6LL,(n+1))/2*5<<"\n";
    return ;
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
       solve();
    return 0;
}

B. Two Tables

Problem - B - Codeforcesicon-default.png?t=M5H6https://codeforces.com/contest/1555/problem/B题意,给你一个大桌子的宽度与长度,上面给你一个一直左上和右下两个点的长方形木板,问最少移动多大距离可以放下另一块木板.

思路:分类讨论,模拟(注意精度)

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N =5e5+10,mod=998244353;
void solve()
{
    double W,L,l1,w1;
    double x1,x2,y1,y2;
    double ans=100000000.0;
    cin>>W>>L>>x1>>y1>>x2>>y2>>w1>>l1;
    double w2=fabs(x1-x2),l2=fabs(y1-y2);
    if(L<l1+l2&&W<w1+w2)
    {
        cout<<"-1\n";
        return ;
    }
    int z1=1e9,z2=1e9,z3=1e9,z4=1e9;
    if(L>=l1+l2)
    {
        z4=l1-(L-y2);
        z1=l1-y1;
    }
    if(W>=w1+w2)
    {
        z2=w1-x1;
        z3=w1-(W-x2);
    }
    if(z1<=0||z2<=0||z3<=0||z4<=0)
    {
        printf("0.000000\n");
        return ;
    }
    ans=min(z1,min(z2,min(z3,z4)));
    printf("%.6lf\n",ans);
    return;
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
       solve();
    return 0;
}

C. Coin Rows

Problem - C - CodeforcesCodeforces. Programming competitions and contests, programming communityhttps://codeforces.com/contest/1555/problem/C题意:A,B从(1,1)出发,走到(2,m).A会尽量让B得分最小,B尽量让自己得分最大.A先走.每个人走到一块路上就会得到相应的分数,但是A走过来B就不能得到了.问B最高多少分.

思路:我们知道A走的路线一定是分三段,第一层路径长度为(i),然后改完到下一层,下一层长度为从i走到最右边.所以我们枚举A向下拐弯的那条路径的编号为i,那么第一层的0-i和第二层的i-m都被拿走了分数.那么B能走的并且得到最大份数的只有两种选择,走从第一层的i+1到m或者从第二层的0到第二层的i-1(对应着A走的两种情况)我们直接枚举这两端的长度,每次取这两段的最大值(因为B尽量让自己得分高),然后在这些最大值中选最小的(A尽量让B得分少).

枚举前缀和最值即可

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N =5e5+10,mod=998244353;
int a[100005][2];
void solve()
{
    int n,res=1e18;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][0];
        a[i][0]+=a[i-1][0];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][1];
        a[i][1]+=a[i-1][1];
    }
    for(int i=1;i<=n;i++)
    {
        res=min(res,max(a[i-1][1],a[n][0]-a[i][0]));
    }
    cout<<res<<"\n";
    return ;
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
       solve();
    return 0;
}

D. Say No to Palindromes

Problem - D - CodeforcesCodeforces. Programming competitions and contests, programming communityhttps://codeforces.com/contest/1555/problem/D题意:我们有一个只含有abc三个字母的字符串,m次询问,询问每个区间至少需要多少次修改让这个区间不是回文.
思路:枚举找到规律,只有将abc的全排列作为循环节进行循环的字符串才不会形成回文串.直接枚举记录{abc,acb,bca,bac,cba,cab}这六种字符串作为循环节的字符串的修改次数的前缀和即可.
 

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N =5e5+10,mod=998244353;
int a[100005][2];
void solve()
{
    int n,res=1e18;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][0];
        a[i][0]+=a[i-1][0];
    }
    for(int i=1;i<=n;i++)
    {
        cin>>a[i][1];
        a[i][1]+=a[i-1][1];
    }
    for(int i=1;i<=n;i++)
    {
        res=min(res,max(a[i-1][1],a[n][0]-a[i][0]));
    }
    cout<<res<<"\n";
    return ;
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
       solve();
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值