比赛 |
2024暑假C班集训5 |
评测结果 |
AWWTTTTTTT |
题目名称 |
任务 |
最终得分 |
10 |
用户昵称 |
wzh0425 |
运行时间 |
7.000 s |
代码语言 |
C++ |
内存使用 |
4.03 MiB |
提交时间 |
2024-07-05 11:33:37 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n,ta[3005],tb[3005],ans=INT_MAX;
void dfs(int cs,int sum1,int sum2){
if (cs==n+1){
ans=min(ans,max(sum1,sum2));
return;
}
for (int i=1;i<=2;i++){
if (i==1){
dfs(cs+1,sum1+ta[cs],sum2);
}else{
dfs(cs+1,sum1,sum2+tb[cs]);
}
}
}
int main(){
freopen("task.in","r",stdin);
freopen("task.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d%d",&ta[i],&tb[i]);
}
dfs(1,0,0);
printf("%d",ans);
/*fa[1]=ta[1],fb[1]=tb[1];
for (int i=2;i<=n;i++){
fa[i][0]=min(fa[i-1][0]+ta[i],fa[i-1][1]+ta[i]);
fa[i][1]=min(min(fa[i-1][0]+ta[i],fa[i-1][1]+ta[i]),min(max(ta[i],fb[i-1][0]),INT_MAX));
fb[i][0]=min(fb[i-1][0]+tb[i],fb[i-1][1]+tb[i]);
fb[i][1]=min(min(fb[i-1][0]+tb[i],fb[i-1][1]+tb[i]),min(max(tb[i],fa[i-1][0]),INT_MAX));
//fa[i]=min(fa[i-1]+ta[i],max(fb[i-1],ta[i]+fa[i-2]));//max(ta[i]+fa[i-2][0],fb[i-1][1])
//fb[i]=min(fb[i-1]+tb[i],max(fa[i-1],tb[i]+fb[i-2]));//max(tb[i]+fb[i-2][0],fa[i-1][1])
}
int ans=min(fa[n],fb[n]);*/
return 0;
}