当前位置:网站首页>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;
}
边栏推荐
- Find a good teaching video for Solon framework test (Solon, lightweight application development framework)
- Haut OJ 1347: addition of choice -- high progress addition
- MySQL数据库(一)
- The number of enclaves
- 【ES实战】ES上的native realm安全方式使用
- Yolov5 adds attention mechanism
- Haut OJ 1241: League activities of class XXX
- National teacher qualification examination in the first half of 2022
- How many checks does kubedm series-01-preflight have
- kubeadm系列-00-overview
猜你喜欢

Pointnet++学习
![[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

Hang wait lock vs spin lock (where both are used)

【Jailhouse 文章】Look Mum, no VM Exits

Codeforces round 712 (Div. 2) d. 3-coloring (construction)

利用HashMap实现简单缓存

Pointnet++ learning

sync.Mutex源码解读

浅谈JVM(面试常考)

Graduation project of game mall
随机推荐
Gbase database helps the development of digital finance in the Bay Area
[to be continued] [UE4 notes] L3 import resources and project migration
Haut OJ 1350: choice sends candy
Codeforces Round #715 (Div. 2) D. Binary Literature
剑指 Offer 06.从头到尾打印链表
【Jailhouse 文章】Look Mum, no VM Exits
个人开发的渗透测试工具Satania v1.2更新
【ES实战】ES上的native realm安全方式使用
Solon Logging 插件的添加器级别控制和日志器的级别控制
Sword finger offer 04 Search in two-dimensional array
二十六、文件系统API(设备在应用间的共享;目录和文件API)
[to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
[to be continued] [depth first search] 547 Number of provinces
Zheng Qing 21 ACM is fun. (3) part of the problem solution and summary
SSH password free login settings and use scripts to SSH login and execute instructions
[to be continued] [UE4 notes] L1 create and configure items
Haut OJ 1352: string of choice
Remote upgrade afraid of cutting beard? Explain FOTA safety upgrade in detail
Under the national teacher qualification certificate in the first half of 2022
Solution to the palindrome string (Luogu p5041 haoi2009)