当前位置:网站首页>F - Two Exam(AtCoder Beginner Contest 238)
F - Two Exam(AtCoder Beginner Contest 238)
2022-07-05 05:31:00 【solemntee】
First of all, in accordance with the P P P Attribute sort owner , according to P P P Select people in ascending order of attributes , You only need to consider Q Q Q Property size relationship .
set up D P DP DP Status as d p [ i ] [ j ] [ k ] dp[i][j][k] dp[i][j][k]
Before presentation i i i Personal choice j j j individual , The smallest of them has not been selected Q Q Q The attribute is k k k The number of solutions
Consider the i + 1 i+1 i+1 Choose or not
Such as fruit k > The first i individual people Of Q Belong to sex d p [ i ] [ j + 1 ] [ k ] = ( d p [ i ] [ j + 1 ] [ k ] + d p [ i − 1 ] [ j ] [ k ] ) no be d p [ i ] [ j ] [ m i n ( k , The first i individual people Of Q Belong to sex ) ] = ( d p [ i ] [ j ] [ m i n ( k , The first i individual people Of Q Belong to sex ) ] + d p [ i − 1 ] [ j ] [ k ] ) If k> The first i Individual Q attribute \\dp[i][j+1][k]=(dp[i][j+1][k]+dp[i-1][j][k])\\ otherwise \\dp[i][j][min(k, The first i Individual Q attribute )]=(dp[i][j][min(k, The first i Individual Q attribute )]+dp[i-1][j][k]) Such as fruit k> The first i individual people Of Q Belong to sex dp[i][j+1][k]=(dp[i][j+1][k]+dp[i−1][j][k]) no be dp[i][j][min(k, The first i individual people Of Q Belong to sex )]=(dp[i][j][min(k, The first i individual people Of Q Belong to sex )]+dp[i−1][j][k])
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct Stu
{
int p,q;
bool operator <(const Stu &ths)const
{
return p<ths.p;
}
}stu[305];
int dp[305][305][305];// front i individual , Yes j individual , The smallest one not selected is k Number of alternatives
const int mod=998244353;
int main()
{
int n,K;
scanf("%d%d",&n,&K);
for(int i=1;i<=n;i++)scanf("%d",&stu[i].p);
for(int i=1;i<=n;i++)scanf("%d",&stu[i].q);
sort(stu+1,stu+1+n);
dp[0][0][n+1]=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=i-1;j++)
{
for(int k=1;k<=n+1;k++)
{
dp[i][j][min(k,stu[i].q)]=(dp[i][j][min(k,stu[i].q)]+dp[i-1][j][k])%mod;
if(k>stu[i].q)dp[i][j+1][k]=(dp[i][j+1][k]+dp[i-1][j][k])%mod;
}
}
// for(int j=0;j<=i;j++)
// for(int k=1;k<=n+1;k++)printf("dp[%d][%d][%d]=%d\n",i,j,k,dp[i][j][k]);
}
ll ans=0;
for(int i=1;i<=301;i++)ans=(ans+dp[n][K][i])%mod;
printf("%lld",ans);
return 0;
}
边栏推荐
- [es practice] use the native realm security mode on es
- Sword finger offer 53 - I. find the number I in the sorted array
- Pointnet++的改进
- Daily question - longest substring without repeated characters
- 二十六、文件系统API(设备在应用间的共享;目录和文件API)
- Talking about JVM (frequent interview)
- A new micro ORM open source framework
- Detailed explanation of expression (csp-j 2021 expr) topic
- 服务熔断 Hystrix
- 个人开发的渗透测试工具Satania v1.2更新
猜你喜欢
服务熔断 Hystrix
Hang wait lock vs spin lock (where both are used)
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
远程升级怕截胡?详解FOTA安全升级
游戏商城毕业设计
YOLOv5添加注意力機制
[merge array] 88 merge two ordered arrays
Gbase database helps the development of digital finance in the Bay Area
【实战技能】非技术背景经理的技术管理
[to be continued] [UE4 notes] L2 interface introduction
随机推荐
Pointnet++ learning
Haut OJ 1350: choice sends candy
Download xftp7 and xshell7 (official website)
利用HashMap实现简单缓存
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
Summary of Haut OJ 2021 freshman week
YOLOv5-Shufflenetv2
FVP和Juno平台的Memory Layout介绍
[to be continued] [UE4 notes] L2 interface introduction
The number of enclaves
质量体系建设之路的分分合合
Gbase database helps the development of digital finance in the Bay Area
sync. Interpretation of mutex source code
个人开发的渗透测试工具Satania v1.2更新
Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
Under the national teacher qualification certificate in the first half of 2022
SAP-修改系统表数据的方法
软件测试 -- 0 序
Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade
Haut OJ 1243: simple mathematical problems