답안 #1110236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110236 2024-11-09T03:06:17 Z vjudge1 Growing Vegetables is Fun 5 (JOI24_vegetables5) C++17
4 / 100
5000 ms 592 KB
#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], d[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(d[i] <= n)
		{
			nho++;
			lon = 0;
		}
		else
		{
			lon++;
			nho = 0;
		}
	}
	if(!ok)
		return;
	int maxx = 0;
	FOR(i, 1, n * 2)
	{
		int id = d[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])
		{
			d[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 Correct 164 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 166 ms 336 KB Output is correct
7 Correct 162 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 163 ms 444 KB Output is correct
10 Correct 172 ms 444 KB Output is correct
11 Correct 163 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 164 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 166 ms 336 KB Output is correct
7 Correct 162 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 163 ms 444 KB Output is correct
10 Correct 172 ms 444 KB Output is correct
11 Correct 163 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 5060 ms 336 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 164 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 166 ms 336 KB Output is correct
7 Correct 162 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 163 ms 444 KB Output is correct
10 Correct 172 ms 444 KB Output is correct
11 Correct 163 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 5060 ms 336 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 164 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 166 ms 336 KB Output is correct
7 Correct 162 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 163 ms 444 KB Output is correct
10 Correct 172 ms 444 KB Output is correct
11 Correct 163 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 5060 ms 336 KB Time limit exceeded
14 Halted 0 ms 0 KB -