首页 > 其他分享 >AcWing 第 86 场周赛 ABC

AcWing 第 86 场周赛 ABC

时间:2023-01-14 21:36:12浏览次数:61  
标签:周赛 typedef ABC const int LL cin 86 sum

https://www.acwing.com/activity/content/competition/problem_list/2794/

4794. 健身

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=1000200,M=4002;
LL a[N],sum[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n;
        cin>>n;
        LL sum1=0,sum2=0,sum3=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            if(i%3==1) sum1+=a[i];
            else if(i%3==2) sum2+=a[i];
            else sum3+=a[i];
        }
        if(sum1>sum2&&sum1>sum3) cout<<"chest"<<endl;
        else if(sum2>sum1&&sum2>sum3) cout<<"biceps"<<endl;
        else cout<<"back"<<endl;
    }
    return 0;
}

4795. 安全区域

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=1000200,M=4002;
LL a[N],sum[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n,m;
        cin>>n>>m;
        LL sum=n*n;
        map<LL,LL> r,c;
        LL sumr=0,sumc=0;
        for(int i=1;i<=m;i++)
        {
            LL x,y;
            cin>>x>>y;
            if(r[x]==0)
            {
                r[x]++;
                sumr++;
                sum-=(n-sumc);
            }
            if(c[y]==0)
            {
                c[y]++;
                sumc++;
                sum-=(n-sumr);
            }
            cout<<sum<<" ";
        }
    }
    return 0;
}

4796. 删除序列

先压缩数字 在进行状态机dp的计算

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=100020,M=4002;
LL a[N],sum[N],f[N][2];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n;
        cin>>n;
        map<LL,LL> mp;
        vector<LL> v;
        v.push_back(0);
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            mp[a[i]]++;
            if(mp[a[i]]==1) v.push_back(a[i]);
        }
        sort(v.begin(),v.end());
        //for(int i=0;i<v.size();i++)
        //    cout<<v[i]<<" ";
        //cout<<endl;
        f[0][0]=f[1][0]=0;
        LL maxn=0;
        for(int i=1;i<v.size();i++)
        {
            f[i][0]=max(f[i-1][1],f[i-1][0]);
            if(v[i-1]+1<v[i]) f[i][1]=max(f[i-1][1],f[i-1][0])+v[i]*mp[v[i]];
            else f[i][1]=f[i-1][0]+v[i]*mp[v[i]];
            maxn=max({maxn,f[i][0],f[i][1]});
        }
        cout<<maxn<<endl;
    }
    return 0;
}

标签:周赛,typedef,ABC,const,int,LL,cin,86,sum
From: https://www.cnblogs.com/Vivian-0918/p/17052421.html

相关文章

  • ABC242 E - (∀x∀)
    题目连接:https://atcoder.jp/contests/abc242/tasks/abc242_e翻译一下题目大意就是给定一个只包含大写字母的字符串S,输出所有字典序比S小且是回文串的字符串的数量这道题......
  • 最完美WIN10_Pro_22H2.19045.2486软件选装纯净版VIP38.5
    【系统简介】=============================================================1.本次更新母盘来WIN10_Pro_22H2.19045.2486。进一步优化调整。2.不支持更新,更新后精简版更新......
  • 第 319 场周赛
    1温度转换温度转换SolutionclassSolution{public:vector<double>convertTemperature(doublecelsius){doublekelvin=celsius+273.15;......
  • abc254 F - Rectangle GCD
    题意:给定等长的正整数组\(a[],b[]\),它们确定了一个矩阵\(A_{i,j}=a_i+b_j\)。\(q\)次询问,回答矩阵中一个矩形区域内所有数的\(\gcd\)\(n,q\le2e5\)思路:差分,绝对......
  • LeetCode刷题(59)~使数组中所有元素相等的最小操作数【第202场周赛:题目二】
    题目描述存在一个长度为n的数组arr,其中arr[i]=(2*i)+1(0<=i<n)。一次操作中,你可以选出两个下标,记作x和y(0<=x,y<n)并使arr[x]减去1、arr[y]......
  • 澳洲纽扣电池、硬币电池IEC60086-4标准
    虽然新法规还未正式强制执行,但是亚马逊澳大利亚站早已发布了对含有纽扣电池或硬币电池的商品的相关要求。要求内容<<<<根据亚马逊政策,通过亚马逊网站销售的含有纽扣电池或硬......
  • AT2282 [ABC051C] Back and Forth 题解
    Description在一个平面直角坐标系内,有一点\(A(x_1,y_1)\)和点\(B(x_2,y_2)\)你需要从\(A\)点走到\(B\)点,再走到\(A\)点,再走到\(B\)点,再回到\(A\)点。期间,你......
  • abc258 G - Triangle
    题意:给定图的邻接矩阵,问三元环的数量\(n\le3000\)思路:\(O(n^3)\)的最naive的暴力,用bitset优化到\(O(n^3/64)\)暴力搜\((i,j)\),则另外两个点\((i,k),(j,k)\)在......
  • 沉寂22年的开源操作系统鼻祖386BSD再获更新!
    10月9日消息,386BSD操作系统的开发者之一LynneJolitz在星期三通过GitHub更新了该系统的1.0和2.0版本源代码。这款开源操作系统的鼻祖此前已经沉寂了22年!386BSD是基......
  • abc--263--E
    E-Sugoroku3关键其实也就是正常的投色子问题,从后面转移到前面,只是需要用一个后缀和进行优化,懂期望dp后还是挺好写的。代码#include<bits/stdc++.h>usingnamespac......