首页 > 其他分享 >ACWING 第 84 场周赛 ABC

ACWING 第 84 场周赛 ABC

时间:2022-12-31 20:33:11浏览次数:55  
标签:周赛 typedef ABC cout int LL cin long 84

来水一篇博客:)
https://www.acwing.com/activity/content/competition/problem_list/2742/

难度偏低(三题都cf800的难度),就不写详解了

4788. 最大数量

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=4002;
//unordered_map<LL,LL> um[N];
//priority_queue<LL,vector<LL>,greater<LL>> pq;
//vector<LL> v;
LL a[N],b[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;
        map<PII,LL> mp;
        LL maxn=0;
        for(int i=1;i<=n;i++)
        {
            LL h,m;
            cin>>h>>m;
            mp[{h,m}]++;
            maxn=max(maxn,mp[{h,m}]);

        }
        cout<<maxn<<endl;
    }
    return 0;
}

4789. 前缀和序列

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=4002;
//unordered_map<LL,LL> um[N];
//priority_queue<LL,vector<LL>,greater<LL>> pq;
//vector<LL> v;
LL a[N],suma[N],b[N],sumb[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;
        for(int i=1;i<=n;i++)
            cin>>a[i];
        for(int i=1;i<=n;i++)
        {
            suma[i]=suma[i-1]+a[i];
        }
        sort(a+1,a+1+n);
        for(int i=1;i<=n;i++)
        {
            sumb[i]=sumb[i-1]+a[i];
        }
        LL q;
        cin>>q;
        while(q--)
        {
            LL op,x,y;
            cin>>op>>x>>y;
            if(op==1)
            {
                cout<<suma[y]-suma[x-1]<<endl;
            }
            else
            {
                cout<<sumb[y]-sumb[x-1]<<endl;
            }
        }
    }
    return 0;
}

4790. 买可乐

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=500200,M=4002;
//unordered_map<LL,LL> um[N];
//priority_queue<LL,vector<LL>,greater<LL>> pq;
//vector<LL> v;
LL a[N],suma[N],b[N],sumb[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL c,d;
        cin>>c>>d;
        LL n,m;
        cin>>n>>m;
        LL k;
        cin>>k;
        LL last=n*m-k;
        if(k>=n*m) cout<<"0"<<endl;
        else
        {
            LL sum=last/n;
            LL sum2=sum*c+(last)%n*d;
            if(last%n!=0) sum++;
            sum*=c;
            cout<<min({sum,sum2,last*d})<<endl;
        }
    }
    return 0;
}

标签:周赛,typedef,ABC,cout,int,LL,cin,long,84
From: https://www.cnblogs.com/Vivian-0918/p/17017153.html

相关文章

  • LeetCode第 94 场双周赛
    1.最多可以摧毁的敌人城堡数目题目最多可以摧毁的敌人城堡数目Solution可以第一重循环找到\(1\),然后从该位置分别向左和向又寻找\(-1\),寻找过程中遇到\(1\)则停止,不......
  • LeetCode周赛325
    到目标字符串的最短距离题目SolutionclassSolution{public:intclosetTarget(vector<string>&words,stringtarget,intstartIndex){intn=wo......
  • Codeforces Round #841 (Div. 2) and Divide by Zero 2022
    题目链接A核心思路:就是一个简单的找规律大胆去猜结论就好了。#include<iostream>#include<algorithm>usingnamespacestd;typedeflonglongLL;constintN=1e6......
  • Codeforces Round #841 (Div. 2) and Divide by Zero 2022(A-D)
    CodeforcesRound#841(Div.2)andDividebyZero2022(A-D)题目链接限制AJoeyTakesMoneystandardinput/output1s,256MBBKillDemodogsstandard......
  • [ABC221D] Online games
    [ABC221D]Onlinegames难度:\(832\)标签:差分离散化\(\mathtt{blog}\)有\(n\)个区间\([a_i,a_i+b_i)\),问各被\(1\simn\)个区间覆盖的数字个数有多少个。\(n\le......
  • 第323场周赛-第三题
    给你一个整数n,表示下标从0开始的内存数组的大小。所有内存单元开始都是空闲的。请你设计一个具备以下功能的内存分配器:分配一块大小为size的连续空闲内存单元并赋......
  • 第323场周赛-第二题
    给你一个整数数组nums。如果nums的子序列满足下述条件,则认为该子序列是一个方波:子序列的长度至少为2,并且将子序列从小到大排序之后,除第一个元素外,每个元素都是......
  • CF--840--E
    关键也就是按照连通块进行划分,然后对连通块的大小进行完全背包就行了代码#include<bits/stdc++.h>usingnamespacestd;constintM=1e6+5;intf1[M],f2[M];int......
  • 【题解】LOJ #6384. 「是男人就过8题——Pony.ai」SignLocation
    题意LOJ#6384.「是男人就过8题——Pony.ai」SignLocation给定\(n\)个整点\(p_1,...,p_n\)以及\(k\)次标记点的机会,定义\(c(i,j)\)为:第\(i\)个整点和第......
  • [Codeforces Round #841]
    [CodeforcesRound#841]CodeforcesRound#841(Div.2)andDividebyZero2022A.JoeyTakesMoneyJoeyTakesMoneProblem:给一个正整数序列\(a_1,a_2,…,a_n(n......