ACWING 第 84 场周赛 ABC

来水一篇博客:)
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;
}
posted @ 2022-12-31 20:24  Vijurria  阅读(9)  评论(0编辑  收藏  举报