답안 #819978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
819978 2023-08-10T16:44:41 Z denniskim Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
94 ms 15480 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())

ll n;
pll a[200010];
ll b[200010];
ll nu1[200010], nu2[200010];
ll ans[200010];

int main(void)
{
	fastio
	
	cin >> n;
	
	for(ll i = 1 ; i <= n + 1 ; i++)
	{
		cin >> a[i].fi;
		a[i].se = i;
	}
	
	for(ll i = 1 ; i <= n ; i++)
		cin >> b[i];
	
	sort(a + 1, a + 2 + n);
	sort(b + 1, b + 1 + n);
	
	for(ll i = 1 ; i <= n ; i++)
		nu1[i] = max(nu1[i - 1], max(0LL, a[i].fi - b[i]));
	
	for(ll i = n ; i >= 1 ; i--)
		nu2[i] = max(nu2[i + 1], max(0LL, a[i + 1].fi - b[i]));
	
	for(ll i = 1 ; i <= n + 1 ; i++)
		ans[a[i].se] = max(nu1[i - 1], nu2[i]);
	
	for(ll i = 1 ; i <= n + 1 ; i++)
		cout << ans[i] sp;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 476 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 396 KB Output is correct
28 Correct 1 ms 476 KB Output is correct
29 Correct 1 ms 476 KB Output is correct
30 Correct 1 ms 396 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 472 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 476 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 396 KB Output is correct
28 Correct 1 ms 476 KB Output is correct
29 Correct 1 ms 476 KB Output is correct
30 Correct 1 ms 396 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 72 ms 14420 KB Output is correct
34 Correct 86 ms 15040 KB Output is correct
35 Correct 79 ms 14548 KB Output is correct
36 Correct 71 ms 15012 KB Output is correct
37 Correct 91 ms 15480 KB Output is correct
38 Correct 73 ms 15336 KB Output is correct
39 Correct 72 ms 14304 KB Output is correct
40 Correct 70 ms 14196 KB Output is correct
41 Correct 71 ms 14472 KB Output is correct
42 Correct 72 ms 14420 KB Output is correct
43 Correct 70 ms 14248 KB Output is correct
44 Correct 68 ms 13828 KB Output is correct
45 Correct 70 ms 13952 KB Output is correct
46 Correct 72 ms 13800 KB Output is correct
47 Correct 66 ms 14164 KB Output is correct
48 Correct 94 ms 14156 KB Output is correct
49 Correct 82 ms 14756 KB Output is correct
50 Correct 75 ms 14764 KB Output is correct
51 Correct 73 ms 14764 KB Output is correct
52 Correct 74 ms 14644 KB Output is correct
53 Correct 74 ms 14640 KB Output is correct