当前位置:网站首页>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;
}
边栏推荐
- Cluster script of data warehouse project
- 全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
- On-off and on-off of quality system construction
- How many checks does kubedm series-01-preflight have
- To be continued] [UE4 notes] L4 object editing
- sync.Mutex源码解读
- Sword finger offer 04 Search in two-dimensional array
- ssh免密登录设置及使用脚本进行ssh登录并执行指令
- Developing desktop applications with electron
- 浅谈JVM(面试常考)
猜你喜欢
Codeforces round 712 (Div. 2) d. 3-coloring (construction)
Pointnet++学习
剑指 Offer 06.从头到尾打印链表
Double pointer Foundation
远程升级怕截胡?详解FOTA安全升级
[turn to] MySQL operation practice (I): Keywords & functions
【Jailhouse 文章】Performance measurements for hypervisors on embedded ARM processors
用STM32点个灯
lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
浅谈JVM(面试常考)
随机推荐
Sword finger offer 35 Replication of complex linked list
SAP method of modifying system table data
Light a light with stm32
kubeadm系列-00-overview
YOLOv5添加注意力機制
远程升级怕截胡?详解FOTA安全升级
Double pointer Foundation
剑指 Offer 06.从头到尾打印链表
数仓项目的集群脚本
[turn]: OSGi specification in simple terms
YOLOv5添加注意力机制
【Jailhouse 文章】Jailhouse Hypervisor
Sword finger offer 58 - ii Rotate string left
利用HashMap实现简单缓存
Add level control and logger level control of Solon logging plug-in
Acwing 4300. Two operations
[binary search] 69 Square root of X
Solon 框架如何方便获取每个请求的响应时间?
Annotation and reflection
Pointnet++学习