Educational Codeforces Round 112 (Rated for Div. 2)

A. PizzaForces

打表就会神奇的发现规律(当时想错了错好几发)

#include "bits/stdc++.h"
#define pll __builtin_popcount
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
using ll = long long ;
inline void solve()
{
    ll n;cin>>n;
    if(n<=6){
        cout<<15<<"\n";
    }else{
        if(n%2==0)n--;
        n-=4;
        n=n/2+1;
        cout<<n*5+10<<"\n";
    }
}
int main()
{
    //freopen("out.txt","w",stdout);
    //int a[]={15,15,15,15,15,15,20,20,25,25,30,30,35,35,40,40,45,45,50,50,55,55,60,60,65,65,70,70,75,75,80,80,85,85,90,90,95,95,100,100,105,105,110,110,115,115,120,120,125,125,130,130,135,135,140,140,145,145,150,150,155,155,160,160,165,165,170,170,175,175,180,180,185,185,190,190,195,195,200,200,205,205,210,210,215,215,220,220,225,225,230,230,235,235,240,240,245,245,250,250,255,255,260,260,265,265,270,270,275,275,280,280,285,285,290,290,295,295,300,300,305,305,310,310,315,315,320,320,325,325};
    //for(int i=1;i<=130;i++)mp[i]=a[i-1];
    ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

B. Two Tables

尽可能把能移动的对称到右上角不能移动的放左下角

#include "bits/stdc++.h"
#define pll __builtin_popcount
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
using ll = long long ;
void solve()
{
    int w,h;
    cin>>w>>h;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a<w-c){
        int p=w-c-a;
        a+=p;
        c+=p;
    }
    if(b<h-d){
        int p=h-d-b;
        b+=p;
        d+=p;
    }
    int u,v;
    cin>>u>>v;
    if(a<u&&b<v){
        int ans=0x3f3f3f3f;
        int p=u-a;
        if(c+p<=w)ans=p;
        p=v-b;
        if(d+p<=h)ans=min(ans,p);
        if(ans==0x3f3f3f3f){
            cout<<"-1\n";return ;
        }
        cout<<(double)ans<<"\n";
        return ;
    }
    cout<<(double)0<<"\n";
}
int main()
{
    cout<<fixed<<setprecision(9);
    ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

C. Coin Rows

题意Alice和Bob想走到2,m且Alice走过的路的权值都会变成0,Alice想让Bob走的权值的和最小,Bob与之相反问答案在二者最优的情况是多少(前缀和模拟下就行了)

#include "bits/stdc++.h"
#define pll __builtin_popcount
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
using ll = long long ;
ll a[3][100002];
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)cin>>a[i][j];
    for(int i=1;i<=2;i++)
        for(int j=1;j<=n;j++)
        a[i][j]+=a[i][j-1];
    ll ans=1e18;
    for(int i=1;i<=n;i++){
        ans=min(ans,max(a[1][n]-a[1][i],a[2][i-1]-a[2][0]));
    }
    cout<<ans<<"\n";
}
int main()
{
    //cout<<fixed<<setprecision(9);
    ios::sync_with_stdio(false);
    int T=1;
    cin>>T;
    while(T--)
        solve();
    return 0;
}
上一篇:牛客多校五


下一篇:MindSpore源码编译安装(CPU版)