当前位置:网站首页>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;
}
边栏推荐
- PC寄存器
- 【Jailhouse 文章】Look Mum, no VM Exits
- [turn to] MySQL operation practice (III): table connection
- Pointnet++的改进
- object serialization
- lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- 剑指 Offer 09. 用两个栈实现队列
- Improvement of pointnet++
- What is the agile proportion of PMP Exam? Dispel doubts
- TF-A中的工具介绍
猜你喜欢
游戏商城毕业设计
【Jailhouse 文章】Jailhouse Hypervisor
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
[speed pointer] 142 circular linked list II
[turn to] MySQL operation practice (I): Keywords & functions
Sword finger offer 05 Replace spaces
剑指 Offer 35.复杂链表的复制
剑指 Offer 05. 替换空格
[turn]: OSGi specification in simple terms
读者写者模型
随机推荐
kubeadm系列-00-overview
Download xftp7 and xshell7 (official website)
[merge array] 88 merge two ordered arrays
Sword finger offer 58 - ii Rotate string left
Mysql database (I)
C language Essay 1
Developing desktop applications with electron
Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
用STM32点个灯
搭建完数据库和网站后.打开app测试时候显示服务器正在维护.
After setting up the database and website When you open the app for testing, it shows that the server is being maintained
Talking about JVM (frequent interview)
TF-A中的工具介绍
每日一题-搜索二维矩阵ps二维数组的查找
【ES实战】ES上的native realm安全方式使用
注解与反射
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
Cluster script of data warehouse project
Csp-j-2020-excellent split multiple solutions
Reflection summary of Haut OJ freshmen on Wednesday