当前位置:网站首页>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;
}边栏推荐
- D1 Nezha development board power on record
- 路灯照明物联网技术方案,ESP32-S3芯片通信应用,智能WiFi远程控制
- Install/Remove of the Service Denied!
- [软件工具][原创]voc数据集类别名批量修改工具使用教程
- CCF access control system
- SQL注入上传一句话木马(转)
- Encapsulation manuelle d'un foreach et d'une carte
- 疫情数据分析平台工作报告【8.5】额外的爬虫和绘图
- Esp32c3 remote serial port
- Smart panel WiFi linkage technology, esp32 wireless chip module, Internet of things WiFi communication application
猜你喜欢

Operation of simulated examination platform for 2022 safety officer-b certificate examination questions

Jwt Learning and use

Brief introduction to 44 official cases of vrtk3.3 (combined with steamvr)

Detailed explanation of software testing process

存储器的保护

智能面板WiFi聯動技術,ESP32無線芯片模組,物聯網WiFi通信應用

What are the black box test case design methods in software testing methods?

QT compiling security video monitoring system 43- picture playback

Raspberry pie 4B uses Intel movidius NCS 2 for inference acceleration

Let me tell you the benefits of code refactoring
随机推荐
What are the black box test case design methods in software testing methods?
L1-066 cat is liquid (5 points)
路灯照明物联网技术方案,ESP32-S3芯片通信应用,智能WiFi远程控制
Create a new table in the database. There was no problem before. Today
疫情数据分析平台工作报告【42】CodeNet
Operation of simulated examination platform for 2022 safety officer-b certificate examination questions
Introduction to distributed locks
疫情数据分析平台工作报告【2】接口API
Raspberry pie 4B uses Intel movidius NCS 2 for inference acceleration
图解 Apache SkyWalking UI 的使用
1. Mx6ull learning notes (II) - uboot migration
MySQL master-slave construction and Django implementation of read-write separation
[issue 31] 360 background development practice experience - two rounds of technical aspects
How to make datasets, train them into models and deploy them based on yolov5
【高效】最强开发工具Ctool编译踩坑
How to use union all in LINQ- How to use union all in LINQ?
Work report of epidemic data analysis platform [42] codenet
Simple Tetris
MFC General dialog color dialog
PostgreSQL age XID maintenance prevents the database from being read-only