当前位置:网站首页>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;
}
边栏推荐
- Sword finger offer 04 Search in two-dimensional array
- [merge array] 88 merge two ordered arrays
- [interval problem] 435 Non overlapping interval
- [turn to] MySQL operation practice (III): table connection
- Download xftp7 and xshell7 (official website)
- Service fusing hystrix
- 剑指 Offer 53 - I. 在排序数组中查找数字 I
- Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
- [turn]: OSGi specification in simple terms
- 剑指 Offer 53 - II. 0~n-1中缺失的数字
猜你喜欢

一个新的微型ORM开源框架
![[to be continued] [UE4 notes] L3 import resources and project migration](/img/81/6f75f8fbe60e037b45db2037d87bcf.jpg)
[to be continued] [UE4 notes] L3 import resources and project migration

Service fusing hystrix
![[depth first search] 695 Maximum area of the island](/img/08/cfff4aec667216e4f146205a12c13f.jpg)
[depth first search] 695 Maximum area of the island

Sword finger offer 53 - I. find the number I in the sorted array

lxml. etree. XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8

object serialization

Pointnet++ learning
![[turn to] MySQL operation practice (III): table connection](/img/70/20bf9b379ce58761bae9955982a158.png)
[turn to] MySQL operation practice (III): table connection

剑指 Offer 53 - II. 0~n-1中缺失的数字
随机推荐
Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
Hang wait lock vs spin lock (where both are used)
远程升级怕截胡?详解FOTA安全升级
SAP method of modifying system table data
一个新的微型ORM开源框架
个人开发的渗透测试工具Satania v1.2更新
Time complexity and space complexity
Daily question - Search two-dimensional matrix PS two-dimensional array search
Zzulioj 1673: b: clever characters???
Yolov5 ajouter un mécanisme d'attention
[sum of two numbers] 169 sum of two numbers II - enter an ordered array
动漫评分数据分析与可视化 与 IT行业招聘数据分析与可视化
[turn]: OSGi specification in simple terms
卷积神经网络——卷积层
Haut OJ 1218: maximum continuous sub segment sum
Reflection summary of Haut OJ freshmen on Wednesday
剑指 Offer 35.复杂链表的复制
Introduction to tools in TF-A
Educational Codeforces Round 107 (Rated for Div. 2) E. Colorings and Dominoes
Developing desktop applications with electron