Acwing第 60 场周赛【完结】

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

4494. 吃饭

#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    
    
    int a,b,c; cin>>a>>b>>c;
    if(b>=a&&c>=a) puts("Yes");
    else puts("No");
    return 0;
}

4495. 数组操作【模拟】

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const int N=1e5*4+10;
typedef long long int LL;
LL a[N],n,m,sum;
priority_queue<int,vector<int>,greater<int>>q;
int main(void)
{
    
    
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i],q.push(a[i]);
    while(m--)
    {
    
    
        while(q.size()&&q.top()-sum<=0) q.pop();
        if(q.size())
        {
    
    
            cout<<q.top()-sum<<endl;
            sum+=q.top()-sum;
        }else cout<<0<<endl;
    }
    return 0;
}

4496. 吃水果【DP】

在这里插入图片描述

#include<bits/stdc++.h>
using namespace std;
const int N=2010;
const int mod=998244353;  
typedef long long int LL;
LL f[N][N],n,m,k;
int main(void)
{
    
    
    cin>>n>>m>>k;
    f[1][0]=m;
    for(int i=2;i<=n;i++)
    {
    
    
        for(int j=0;j<=k&&j<i;j++)
        {
    
    
            f[i][j]=f[i-1][j];
            if(j) f[i][j]=(f[i][j]+f[i-1][j-1]*(m-1))%mod;
        }
    }
    cout<<f[n][k];
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_46527915/article/details/125839288
今日推荐