当前位置:网站首页>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;
}
边栏推荐
- 使用Electron开发桌面应用
- Download xftp7 and xshell7 (official website)
- Corridor and bridge distribution (csp-s-2021-t1) popular problem solution
- What is the agile proportion of PMP Exam? Dispel doubts
- Developing desktop applications with electron
- [speed pointer] 142 circular linked list II
- 26、 File system API (device sharing between applications; directory and file API)
- object serialization
- Sword finger offer 35 Replication of complex linked list
- 对象的序列化
猜你喜欢

Graduation project of game mall

Romance of programmers on Valentine's Day

SAP-修改系统表数据的方法
![[to be continued] [depth first search] 547 Number of provinces](/img/c4/b4ee3d936776dafc15ac275d2059cd.jpg)
[to be continued] [depth first search] 547 Number of provinces

Reader writer model

Pointnet++ learning

Support multi-mode polymorphic gbase 8C database continuous innovation and heavy upgrade

剑指 Offer 05. 替换空格

Sword finger offer 53 - ii Missing numbers from 0 to n-1

全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
随机推荐
读者写者模型
A misunderstanding about the console window
卷积神经网络简介
26、 File system API (device sharing between applications; directory and file API)
Annotation and reflection
全国中职网络安全B模块之国赛题远程代码执行渗透测试 //PHPstudy的后门漏洞分析
剑指 Offer 53 - I. 在排序数组中查找数字 I
Reader writer model
个人开发的渗透测试工具Satania v1.2更新
[allocation problem] 135 Distribute candy
服务熔断 Hystrix
剑指 Offer 09. 用两个栈实现队列
Add level control and logger level control of Solon logging plug-in
Palindrome (csp-s-2021-palin) solution
Haut OJ 1316: sister choice buys candy III
[es practice] use the native realm security mode on es
常见的最优化方法
Daily question - longest substring without repeated characters
Haut OJ 1347: addition of choice -- high progress addition
剑指 Offer 53 - II. 0~n-1中缺失的数字