当前位置:网站首页>Temporary cramming before DFS examination
Temporary cramming before DFS examination
2022-07-05 15:26:00 【Xuanhong Zhou】
subject
It is suggested to use for Cycle through , I don't want to write now
Code
/* Because you can think about two problems in the same subject at the same time , Suppose it's divided into left right Left and right brain So for n questions , Yes 2^n Maybe , Generally, you can run in one second 4 * 10 ^ 8 Time The maximum range of this question is 4* 2^20 =4*1048576 It can be searched directly Think of the search of this topic as the search of a binary tree The left subtree is the left brain , The right subtree is the right brain And then it's normal dfs dfs Medium x Is how many questions have been done ,y Is the total number of topics in the current subject , If x Than y big , That's a plan */
#include<iostream>
#include<algorithm>
using namespace std;
const int N=30;
int hh[N][5];
int s[5];
int ans=0;
int l=0,r=0;
int mini;
void dfs(int x,int y){
// Recursive export
//dfs Medium x Is how many questions have been done ,y Is the total number of topics in the current subject
// If x Than y big , That's a plan
// Now update the minimum , You should take the maximum time in your left and right brain , Then and current mini Take a small value
if(x>s[y]){
mini=min(max(l,r),mini);
return ;
}
l+=hh[x][y];
dfs(x+1,y);// These two lines will cause all to be placed on the left brain
l-=hh[x][y];// Then go back
r+=hh[x][y];// Put it on the right brain
dfs(x+1,y);
r-=hh[x][y];
}
int main(){
cin>>s[1]>>s[2]>>s[3]>>s[4];
for(int i=1;i<=4;i++){
mini=19260816;
l=r=0;
for(int j=1;j<=s[i];j++)
cin>>hh[j][i];
dfs(1,i);
ans+=mini;
}
cout<<ans;
return 0;
}
边栏推荐
- episodic和batch的定义
- Visual task scheduling & drag and drop | scalph data integration based on Apache seatunnel
- CODING DevSecOps 助力金融企业跑出数字加速度
- What are the domestic formal futures company platforms in 2022? How about founder metaphase? Is it safe and reliable?
- Huiyuan, 30, is going to have a new owner
- OSI seven layer model
- 美团优选管理层变动:老将刘薇调岗,前阿里高管加盟
- SQL Server learning notes
- I spring and autumn blasting-1
- Creation and optimization of MySQL index
猜你喜欢

做研究无人咨询、与学生不交心,UNC助理教授两年教职挣扎史

MySQL之CRUD

1330:【例8.3】最少步数

Ctfshow web entry command execution

Fr exercise topic - simple question

Appium自动化测试基础 — APPium基础操作API(二)

爱可可AI前沿推介(7.5)

超越PaLM!北大碩士提出DiVeRSe,全面刷新NLP推理排行榜

Misc Basic test method and knowledge points of CTF

Ecotone technology has passed ISO27001 and iso21434 safety management system certification
随机推荐
The elimination strategy of redis
Can I pass the PMP Exam in 20 days?
SQL Server learning notes
sql server char nchar varchar和nvarchar的区别
爱可可AI前沿推介(7.5)
Database learning - Database Security
[recruitment position] Software Engineer (full stack) - public safety direction
Ctfshow web entry command execution
Mysql---- function
亿咖通科技通过ISO27001与ISO21434安全管理体系认证
Coding devsecops helps financial enterprises run out of digital acceleration
Bugku's Ping
I want to inquire about how to ensure data consistency when a MySQL transaction updates multiple tables?
Ionic Cordova project modification plug-in
Transfer the idea of "Zhongtai" to the code
机器学习笔记 - 灰狼优化
OSI 七层模型
1330:【例8.3】最少步数
Creation and use of thymeleaf template
Reconnaissance des caractères easycr