当前位置:网站首页>Walking "daily question" and "DP"
Walking "daily question" and "DP"
2022-06-12 04:38:00 【Yang tree Yang tree】
Walk - subject - Daimayuan Online Judge
Ideas :
The first thing I thought of was DFS, however 2^100 necessarily TLE;
And then I think I can't , Have to use DP,DP Always consider the previous state 「 Have you ever walked ?」&&「 Is that enough? I'll go 」
AC Code :
#include <iostream>
#include <string.h>
using namespace std;
const int N = 1e5+10;
int A[N],B[N];
int ans[101][N];
int main() {
int n,m;
memset(ans, 0, sizeof(ans));
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>A[i]>>B[i];
ans[1][A[1]]=1;
ans[1][B[1]]=1;
ans[0][0]=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
if( j>=A[i] && ans[i-1][j-A[i]] ) ans[i][j]=1;
if( j>=B[i] && ans[i-1][j-B[i]] ) ans[i][j]=1;
}
for(int i=0;i<=m;i++)
{
if(ans[n][i]==1) cout<<"1";
else cout<<"0";
}
return 0;
}边栏推荐
- one billion one hundred and eleven million one hundred and eleven thousand one hundred and eleven
- 疫情数据分析平台工作报告【7】阿里云相关
- Work report of epidemic data analysis platform [42] codenet
- mysqld: Can‘t create directory ‘D: oftinstall\mysql57 (Errcode: 2 - No such file or directory)
- kali_ Nat mode, bridging Internet / host only_ detailed
- SQL injection upload one sentence Trojan horse (turn)
- Enterprise Architect v16
- Question for the 3D printing lattice?
- SQL注入上传一句话木马(转)
- C# Task. Waitall method
猜你喜欢

疫情数据分析平台工作报告【6.5】疫情地图

@What happens if bean and @component are used on the same class?
![[fpga+fft] design and implementation of FFT frequency meter based on FPGA](/img/f9/e985bd9aed332982d936b5d4e0d42b.png)
[fpga+fft] design and implementation of FFT frequency meter based on FPGA

Zabbix6.0 new feature GEOMAP map marker can you use it?

Notes on relevant knowledge points such as original code / inverse code / complement code, size end, etc

Solid programming concepts

Esp32c3 remote serial port
![Work report of epidemic data analysis platform [6] visual drawing](/img/cc/9eaff451068d0efb174b58719c700e.png)
Work report of epidemic data analysis platform [6] visual drawing

2.28 (defect filling) data type conversion exception handling part multi threading

Illustrating the use of Apache skywalking UI
随机推荐
L1-064 AI core code valued at 100 million (20 points)
Work report of epidemic data analysis platform [1] data collection
2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
LabVIEW關於TDMS和Binary存儲速度
[issue 31] 360 background development practice experience - two rounds of technical aspects
Please calculate the value of the following function recursively: PX (x, n) =x-x^2 +x^3- x^4+... (-1) n-1) (xn) n > 0 * * input format requirements: "%lf%d" prompt: "enter X and n:"
D1 Nezha development board power on record
Smart Panel wifi Linkage Technology, esp32 wireless chip module, Internet of Things WiFi Communication Application
SqEL简单上手
QT compiling security video monitoring system 43- picture playback
kali下安装pycharm并创建快捷访问
L1-066 cat is liquid (5 points)
图解 Apache SkyWalking UI 的使用
2022-02-28 WPF upper computer 126 understand mqtt
Work report of epidemic data analysis platform [6] visual drawing
New year news of osdu open underground data space Forum
Summary of common interview questions in redis
Some points needing attention about thread pool
Report on the current market situation and future development trend of adhesive industry for radar and ultrasonic sensors in the world and China 2022 ~ 2028
[fpga+gps receiver] detailed design introduction of dual frequency GPS receiver based on FPGA