牛客小白月赛69 ABCDE

发布时间 2023-03-24 22:10:28作者: 高尔赛凡尔娟

https://ac.nowcoder.com/acm/contest/52441

这场小白我给打的,我愿称之为年度喜剧片

A-蛋挞

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN;
const LL N=2e6+10,M=4004;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        LL a,b;
        cin>>a>>b;
        LL sum1=a/b;
        LL sum2=a%b;
        if(sum2>sum1) cout<<"niuniu eats more than others"<<endl;
        else if(sum2<sum1) cout<<"niuniu eats less than others"<<endl;
        else cout<<"same"<<endl;
    }
    return 0;
}

B-玩具

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN;
const LL N=2e6+10,M=4004;
#define endl '\n'
LL a[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        LL n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        sort(a+1,a+1+n);
        LL sum=0;
        if(n%2==0)
        {
            for(int i=2;i<=n;i+=2)
            {
                sum+=a[i];
            }
        }
        else
        {
            for(int i=1;i<=n;i+=2)
            {
                sum+=a[i];
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

C-开题顺序

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN;
const LL N=2e6+10,M=4004;
#define endl '\n'
LL n,t,p;
LL maxn=0,idx[N];
LL a[N],b[N],c[N],x[N],y[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>t>>p;
        for(int i=1;i<=n;i++)
        {
            idx[i]=i;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>a[i]>>b[i]>>c[i]>>x[i]>>y[i];
        }
        do
        {
            LL sum=0;
            LL time=0;
            for(int i=1;i<=n;i++)
            {
                time+=x[idx[i]];
                if(time<=t)
                {
                    sum+=max(c[idx[i]],a[idx[i]]-time*b[idx[i]]-y[idx[i]]*p);
                }
                else break;
            }
            maxn=max(maxn,sum);
        }
        while(next_permutation(idx+1,idx+1+n));
        cout<<maxn<<endl;
    }
    return 0;
}

D-旅游

输入 
4 6 7
1 2 3
1 3 4
1 4 6
2 3 2
2 4 1
3 4 5
输出 
1

说实话这题我好像很久很久之前做过一个类似的,思路也差不多
就是先把修复的价钱按照从小到大排个序
前面几个如果n个点都已经在了的话,就选取前面几个价钱就行
然后这几个价钱从大到小加起来,哪里超过了牛牛的承受范围就停止丢给国家去修
(谁能想到一条语句放错了位置我写了一个半小时,人生疑惑)
妥妥 年度喜剧片

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN;
const LL N=2e6+10,M=2023;
const LL mod=998244353;
const double PI=3.1415926535;
#define endl '\n'
LL father[N],siz[N];
LL n,m,k,cnt=0;
struct node
{
    LL x,y,z;
}flag[N];
LL sum[N];
bool cmp(node l,node r)
{
    return l.z<r.z;
}
void init()
{
    for(int i=1;i<=n;i++)
    {
        father[i]=i;
        siz[i]=1;
    }
}
LL find(LL x)
{
    if(father[x]!=x) father[x]=find(father[x]);
    return father[x];
}
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>m>>k;
        init();
        for(int i=1;i<=m;i++)
        {
            cin>>flag[i].x>>flag[i].y>>flag[i].z;
        }
        sort(flag+1,flag+1+m,cmp);
        for(int i=1;i<=m;i++)
        {
            LL fx=find(flag[i].x);
            LL fy=find(flag[i].y);
            if(fx!=fy)
            {
                father[max(fx,fy)]=min(fx,fy);
                siz[min(fx,fy)]+=siz[max(fx,fy)];
                sum[++cnt]=flag[i].z;
            }
            //cout<<siz[min(fx,fy)]<<endl;
            if(siz[min(fx,fy)]==n) break;
        }
        LL idx=-1;
        LL res=0;
        sum[0]=0;
        for(int i=cnt;i>=1;i--)
        {
            //cout<<sum[i]<<" ";
            res+=(cnt-i+1)*sum[i];
            if(res>k)
            {
                idx=i;
                break;
            }
        }
        if(idx==-1) cout<<"0"<<endl;
        else cout<<sum[idx]<<endl;
    }
    return 0;
}

E-等腰三角形(easy)

真的会有人连两边之和大于第三边都忘记吗?
真的吗真的吗真的有人吗?
是我了┭┮﹏┭┮(傻狗爆哭)

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18,MINN=-MAXN;
const LL N=2e6+10,M=2023;
const LL mod=998244353;
const double PI=3.1415926535;
#define endl '\n'
LL n;
double a[N],b[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i]>>b[i];
        }
        LL sum=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                for(int k=j+1;k<=n;k++)
                {
                    if((a[i]==a[j]&&a[j]==a[k])||(b[i]==b[j]&&b[j]==b[k])) continue;
                    //AB∣=√ [ (x1-x2)²+ (y1-y2)²]
                    double num1=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j]));
                    double num2=sqrt((a[i]-a[k])*(a[i]-a[k])+(b[i]-b[k])*(b[i]-b[k]));
                    double num3=sqrt((a[k]-a[j])*(a[k]-a[j])+(b[k]-b[j])*(b[k]-b[j]));
                    //cout<<num1<<" "<<num2<<" "<<num3<<endl;
                    if(num1+num2>num3&&num1+num3>num2&&num2+num3>num1)
                    {
                        if(num1==num2||num2==num3||num1==num3) sum++;
                    }
                }
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}