QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#484628 | #8768. Arrested Development | Los_Medonhos# | TL | 0ms | 3832kb | C++17 | 1.1kb | 2024-07-19 20:40:58 | 2024-07-19 20:40:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5+5;
const long long INF = 0x3f3f3f3f;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0), cin.tie(nullptr);
int n;
cin >> n;
vector<pair<int, int> > v(n);
for(int i=0; i<n; i++){
cin >> v[i].first >> v[i].second;
}
int mid = n/2;
if(n&1) mid++;
int resp1 = INF, resp2 = INF;
for(int i=0; i<(1<<mid); i++){
int sum = 0, sum2 = 0;
for(int j=0; j<mid; j++){
if(i & (1<<j)) sum += v[j].first;
else sum2+=v[j].second;
}
//cout << sum << ' ' << sum2 << endl;
resp1 = min(resp1, max(sum, sum2));
}
int mask = (1<<mid);
if(n&1) mask = (1<<(mid-1));
for(int i=0; i<mask; i++){
int sum = 0, sum2 = 0;
for(int j=mid; j<n; j++){
if(i & (1<<(j-mid))) sum += v[j].first;
else sum2+=v[j].second;
}
//cout << sum << ' ' << sum2 << endl;
resp2 = min(resp2, max(sum, sum2));
}
cout << resp1+resp2 << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
4 100 1 1 90 1 20 1 20
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
2 314 1 592 6
output:
7
result:
ok single line: '7'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 1 1
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
1 100000 1
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
1 1 100000
output:
1
result:
ok single line: '1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 100000 100000
output:
100000
result:
ok single line: '100000'
Test #7:
score: -100
Time Limit Exceeded
input:
50 78681 95291 22639 1538 12119 52253 50430 63757 66133 92826 61048 40069 33506 30382 96049 50134 42895 62735 86943 16955 9667 61843 49647 9320 29082 16909 69601 68436 19892 34306 29822 79462 73262 14568 1693 35040 89757 61888 56993 48750 89611 77773 54159 21067 32520 41091 52501 92770 36530 17589 5...