ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#203121 | #3529. 新年的球棒侠 | cqzxz | 100 | 1397ms | 9328kb | C++11 | 1.3kb | 2024-02-19 11:20:36 | 2024-02-19 12:32:13 |
answer
#include<bits/stdc++.h>
#define int __int128
#define il inline
namespace things{
il int rd(){
int f = 1, x = 0;
char ch = getchar();
while(ch < '0' || ch > '9'){
if (ch == '-' ) f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9'){
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
il void wt(int x){
if (x < 0){
putchar('-');
x = -x;
}
if (x > 9) wt(x / 10);
putchar(x % 10 + '0');
return;
}
il int max(int x, int y){
return std::max(x, y);
}
il int min(int a, int b){
return std::min(a, b);
}
}
using namespace things;
using namespace std;
const int N = 20;
int n, a[N], b[N], f[1 << N][2];
int calc(int x, int i){
return a[i] * x + b[i] * ((x < 0) ? (-x) : x);
}
signed main(){
n = rd();
for (int i = 1; i <= n; i++){
a[i] = rd(), b[i] = rd();
}
f[0][0] = f[0][1] = 1;
for (int i = 1; i < (1 << n); i++){
f[i][0] = 1e25;
f[i][1] = -1e25;
}
for (int i = 1; i < (1 << n); i++){
for (int j = 1; j <= n; j++){
if (i & (1 << (j - 1))){
f[i][0] = min(min(f[i][0], calc(f[i - (1 << (j - 1))][0], j)), calc(f[i - (1 << (j - 1))][1], j));
f[i][1] = max(max(f[i][1], calc(f[i - (1 << (j - 1))][0], j)), calc(f[i - (1 << (j - 1))][1], j));
}
}
}
wt(f[(1 << n) - 1][1]);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 40
Accepted
Test #1:
score: 40
Accepted
time: 2ms
memory: 1164kb
input:
10 6 -6 -8 3 8 15 7 -14 9 8 3 -10 -10 4 -10 13 -9 14 1 7
output:
162625095360
result:
ok single line: '162625095360'
Test #2:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 -4 12 8 6 -2 -13 -2 -7 6 -4 15 10 -14 8 4 -10 0 -6 12 -13
output:
349272000000
result:
ok single line: '349272000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 -3 -10 2 -8 -7 2 -10 15 -3 12 13 -9 -5 1 10 7 9 4 -9 11
output:
94809000000
result:
ok single line: '94809000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 7 -5 12 -7 10 -4 7 -5 1 -2 7 -6 -3 2 -10 -4 -3 -7 12 13
output:
10456992000
result:
ok single line: '10456992000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 12 0 -11 1 -14 -11 -13 7 -9 -1 -5 -3 -6 1 -7 -1 -4 3 -4 3
output:
-1036800
result:
ok single line: '-1036800'
Test #6:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 4 2 9 -12 -2 11 8 -6 -8 6 -14 5 10 2 -2 5 -15 11 5 -1
output:
4032758016
result:
ok single line: '4032758016'
Test #7:
score: 0
Accepted
time: 0ms
memory: 1164kb
input:
10 -12 -9 12 1 -4 15 -13 -11 -13 -12 -12 -6 -13 3 -6 14 -10 -14 -7 9
output:
1328431104000
result:
ok single line: '1328431104000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 -14 -2 -9 -6 14 12 14 4 -14 13 2 -14 14 8 9 -5 7 -5 -2 -3
output:
672518246400
result:
ok single line: '672518246400'
Test #9:
score: 0
Accepted
time: 0ms
memory: 1164kb
input:
10 -12 -5 9 15 -12 2 -14 9 4 -11 7 7 9 -15 6 -5 5 -6 -2 -8
output:
801183398400
result:
ok single line: '801183398400'
Test #10:
score: 0
Accepted
time: 0ms
memory: 1164kb
input:
10 9 -6 -14 -10 -4 -3 -2 1 -4 -2 -7 3 -10 5 -7 -6 -6 4 -3 1
output:
-1920
result:
ok single line: '-1920'
Test #11:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 7 8 7 9 -1 -7 1 -4 8 -4 14 0 -4 -6 0 0 -9 -7 -14 3
output:
0
result:
ok single line: '0'
Test #12:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 -9 -12 -5 7 7 -11 10 6 -11 -4 8 -13 -9 5 -10 0 1 12 3 -8
output:
387272793600
result:
ok single line: '387272793600'
Test #13:
score: 0
Accepted
time: 0ms
memory: 1164kb
input:
10 9 12 -7 -3 6 12 -5 -15 11 12 14 -4 -7 15 -6 11 7 13 15 -13
output:
6555136896000
result:
ok single line: '6555136896000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 -11 -6 6 4 -5 7 -9 0 -4 14 3 -1 -8 3 3 5 -2 2 8 9
output:
3595622400
result:
ok single line: '3595622400'
Test #15:
score: 0
Accepted
time: 0ms
memory: 1168kb
input:
10 4 0 -14 -9 -13 -9 -10 -5 -10 3 -12 -6 -10 -3 -7 0 -5 1 -5 3
output:
-12230400
result:
ok single line: '-12230400'
Subtask #2:
score: 60
Accepted
Test #16:
score: 60
Accepted
time: 88ms
memory: 9328kb
input:
18 14 13 -9 2 -7 5 5 5 -15 -13 -3 6 -1 7 -7 9 8 15 -6 8 5 0 1 -14 0 6 6 -2 10 -9 -2 -11 1 -9 1 0
output:
1452282040103731200
result:
ok single line: '1452282040103731200'
Test #17:
score: 0
Accepted
time: 93ms
memory: 9324kb
input:
18 -2 -6 -3 -15 1 11 12 3 -7 -5 6 12 -2 8 -10 -4 -10 15 4 -11 -9 3 -11 14 -5 -1 10 4 -10 13 2 15 4 -...
output:
527104517022720000000
result:
ok single line: '527104517022720000000'
Test #18:
score: 0
Accepted
time: 97ms
memory: 9324kb
input:
18 3 -5 15 13 -8 -10 1 12 -15 -15 -2 -3 -4 -1 -15 -12 -12 -11 12 -9 -9 -4 -10 7 -9 5 8 -14 -11 1 -2 ...
output:
420945667294344192000
result:
ok single line: '420945667294344192000'
Test #19:
score: 0
Accepted
time: 94ms
memory: 9324kb
input:
18 -12 4 -5 -11 -4 12 8 15 9 -3 5 -11 4 -11 -10 -5 -3 -6 7 8 2 -12 10 -2 12 -12 -6 3 -5 9 -14 -15 -5...
output:
636002781836083200000
result:
ok single line: '636002781836083200000'
Test #20:
score: 0
Accepted
time: 97ms
memory: 9324kb
input:
18 13 10 -8 -2 -12 -3 -8 4 -6 4 -13 -2 -6 5 -1 0 -13 -8 -14 -9 -10 -1 -4 -1 -2 0 -5 4 -2 1 -7 -5 -11...
output:
-384912000
result:
ok single line: '-384912000'
Test #21:
score: 0
Accepted
time: 96ms
memory: 9328kb
input:
18 12 2 -2 -3 13 -3 4 10 1 7 -15 -14 -12 -9 -8 9 -7 -5 -3 -13 -9 5 -11 -8 5 -7 8 -14 9 -12 -14 7 -11...
output:
904917382090444800000
result:
ok single line: '904917382090444800000'
Test #22:
score: 0
Accepted
time: 91ms
memory: 9328kb
input:
18 14 -3 -11 12 6 -4 9 -15 5 -3 -5 -3 -14 -9 8 -5 15 2 -6 -14 -6 9 -7 10 5 9 2 11 -5 -4 -12 -2 0 -10...
output:
280520653187174400000
result:
ok single line: '280520653187174400000'
Test #23:
score: 0
Accepted
time: 92ms
memory: 9324kb
input:
18 -12 -11 3 -1 -15 -1 -8 4 0 -14 7 11 0 -1 -10 13 -5 -8 14 -9 -9 8 13 -7 15 -11 11 10 4 -6 4 -13 1 ...
output:
91776757015996416000
result:
ok single line: '91776757015996416000'
Test #24:
score: 0
Accepted
time: 93ms
memory: 9328kb
input:
18 -14 12 6 -5 13 8 5 6 15 0 8 -9 -5 0 -12 11 -1 4 -13 -1 -2 -11 -4 11 -11 -2 10 -1 -8 -11 -6 13 3 0...
output:
114675650041262310000
result:
ok single line: '114675650041262310000'
Test #25:
score: 0
Accepted
time: 92ms
memory: 9324kb
input:
18 11 5 -1 0 -13 2 -12 -9 -2 0 -6 5 -4 -3 -2 -1 -3 0 -11 0 -10 -9 -1 0 -2 1 -5 -2 -1 0 -10 -4 -9 3 -...
output:
-2822688
result:
ok single line: '-2822688'
Test #26:
score: 0
Accepted
time: 91ms
memory: 9324kb
input:
18 -2 -8 13 -13 -10 -15 4 2 -6 -4 -13 5 -11 -8 -1 11 -11 11 10 -6 -14 -15 0 8 -15 14 -7 -7 -13 -5 2 ...
output:
2491391834690863104000
result:
ok single line: '2491391834690863104000'
Test #27:
score: 0
Accepted
time: 94ms
memory: 9324kb
input:
18 -14 -5 4 -1 12 -7 0 10 -3 -10 -11 -2 6 6 12 -12 12 14 5 -12 -11 -1 -6 -1 5 3 -15 -9 -14 14 0 -5 -...
output:
116903080407859200000
result:
ok single line: '116903080407859200000'
Test #28:
score: 0
Accepted
time: 92ms
memory: 9324kb
input:
18 -3 -15 -11 -10 15 6 0 15 14 14 2 4 14 -15 -2 -4 3 -2 10 11 15 12 -6 -7 10 -11 -12 1 3 1 6 -6 -9 -...
output:
101605583404807372800
result:
ok single line: '101605583404807372800'
Test #29:
score: 0
Accepted
time: 93ms
memory: 9324kb
input:
18 -8 3 -13 12 -12 9 -5 -8 -10 0 -4 9 2 6 5 -13 7 12 13 7 -15 -6 14 13 -12 -10 -4 -14 -10 1 -2 -5 8 ...
output:
1625048846318177280000
result:
ok single line: '1625048846318177280000'
Test #30:
score: 0
Accepted
time: 92ms
memory: 9324kb
input:
18 4 2 -13 12 -13 -9 -1 0 -2 -1 -2 1 -8 2 -8 -3 -9 2 -9 8 -2 1 -13 -10 -4 1 -2 1 -1 0 -2 0 -8 3 -3 2
output:
-237600
result:
ok single line: '-237600'
Extra Test:
score: 0
Extra Test Passed