比赛 |
2024暑假C班集训5 |
评测结果 |
AWWTTTTTTT |
题目名称 |
任务 |
最终得分 |
10 |
用户昵称 |
彭欣越 |
运行时间 |
7.000 s |
代码语言 |
C++ |
内存使用 |
4.03 MiB |
提交时间 |
2024-07-05 11:51:23 |
显示代码纯文本
- #include <bits/stdc++.h>
- using namespace std;
- int n,ans=1e8+10;
- struct node {
- int x,y;
- }a[2010];
- bool cmp (node x,node y) {
- return x.x-x.y<y.x-y.y;
- }
- void dfs (int idx,int res1,int res2) {
- if (idx==n) {
- ans=min(ans,max(res1+a[idx].x,res2));
- ans=min(ans,max(res1,res2+a[idx].y));
- return;
- }
- if (res1+a[idx].x<ans) dfs(idx+1,res1+a[idx].x,res2);
- if (res2+a[idx].y<ans) dfs(idx+1,res1,res2+a[idx].y);
- return;
- }
- int main () {
- freopen("task.in","r",stdin);
- freopen("task.out","w",stdout);
- cin >> n;
- for (int i=1;i<=n;i++) cin >> a[i].x >> a[i].y;
- //sort(a+1,a+n+1,cmp);
- dfs(1,0,0);
- cout << ans <<endl;
- return 0;
- }