#include<bits/stdc++.h>
#define INF 1e18
#define fi first
#define se second
#define FOR(i, k, n) for(ll i = k; i <= n; i++)
#define FOR1(i, k, n) for(ll i = k; i >= n; i--)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define vll vector<ll>
#define pll pair<ll, ll>
#define re return 0
#define mii map<int, int>
#define input "BESIEGE.inp"
#define output "BESIEGE.out"
#define rf freopen(input, "r", stdin); freopen(output, "w", stdout)
using namespace std;
const int maxn = 5e4 + 5;
const int mod = 1e9 + 7;
const int base = 998244353;
void add(int &a, int b)
{
a += b;
if(a >= mod) a -= mod;
if(a < 0) a += mod;
}
int n, a[15], b[15], c[15];
bool vis[15];
int ans = 1e9;
void inkq()
{
int nho = 0, lon = 0;
bool ok = 0;
FOR(i, 1, n * 2)
{
if(nho >= n || lon >= n)
{
ok = 1;
break;
}
if(b[i] <= n)
{
nho++;
lon = 0;
}
else
{
lon++;
nho = 0;
}
}
if(!ok)
return;
int maxx = 0;
FOR(i, 1, n * 2)
{
int id = b[i];
if(id > n)
{
maxx = max(maxx, abs(a[i] - c[id - n]));
}
else
{
maxx = max(maxx, abs(a[i] - b[id]));
}
}
ans = min(ans, maxx);
}
void try2(int i)
{
FOR(j, 1, 2 * n)
if(!vis[j])
{
b[i] = j;
vis[j] = 1;
if(i == n * 2)
inkq();
else
try2(i + 1);
vis[j] = 0;
}
}
int main()
{
fastio;
cin >> n;
FOR(i, 1, n * 2)
cin >> a[i];
FOR(i, 1, n)
cin >> b[i];
FOR(i, 1, n)
cin >> c[i];
try2(1);
cout << ans;
re;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
760 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
146 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |