Submission #1075592

# Submission time Handle Problem Language Result Execution time Memory
1075592 2024-08-26T07:55:58 Z quangminh412 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
224 ms 18676 KB
#include <bits/stdc++.h>
using namespace std;

/*
  John Watson
  https://codeforces.com/profile/quangminh98

  Mua Code nhu mua Florentino !!
*/

#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

const int maxn = 2e5 + 9;

int n;
int b[maxn], ans[maxn];
pair<int, int> a[maxn];

signed main()
{
	if (fopen("test.inp", "r"))
	{
		freopen("test.inp", "r", stdin);
		freopen("test.out", "w", stdout);
	}
	faster();

	cin >> n;
	for (int i = 1; i <= n + 1; i++) cin >> a[i].first, a[i].second = i;
	for (int i = 1; i <= n; i++) cin >> b[i];
	
	sort(a + 1, a + n + 2);
	sort(b + 1, b + n + 1);
	
	multiset<int> se;
	for (int i = 2; i <= n + 1; i++)
		se.insert(max(0, a[i].first - b[i - 1]));
	ans[a[1].second] = *se.rbegin();
	for (int i = 2; i <= n + 1; i++)
	{
		se.insert(max(0, a[i - 1].first - b[i - 1]));
		se.erase(se.find(max(0, a[i].first - b[i - 1])));
		ans[a[i].second] = *se.rbegin();
	}
	
	for (int i = 1; i <= n + 1; i++)
		cout << ans[i] << ' ';

	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:24:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   freopen("test.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   freopen("test.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 480 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 516 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 1 ms 852 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 480 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 1 ms 516 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 139 ms 17484 KB Output is correct
34 Correct 170 ms 18276 KB Output is correct
35 Correct 141 ms 17488 KB Output is correct
36 Correct 148 ms 18016 KB Output is correct
37 Correct 160 ms 18676 KB Output is correct
38 Correct 175 ms 18380 KB Output is correct
39 Correct 199 ms 17492 KB Output is correct
40 Correct 203 ms 17368 KB Output is correct
41 Correct 197 ms 17492 KB Output is correct
42 Correct 194 ms 17532 KB Output is correct
43 Correct 224 ms 17472 KB Output is correct
44 Correct 119 ms 16856 KB Output is correct
45 Correct 123 ms 16980 KB Output is correct
46 Correct 120 ms 16856 KB Output is correct
47 Correct 155 ms 17196 KB Output is correct
48 Correct 126 ms 17324 KB Output is correct
49 Correct 197 ms 18000 KB Output is correct
50 Correct 195 ms 17948 KB Output is correct
51 Correct 198 ms 18004 KB Output is correct
52 Correct 193 ms 18004 KB Output is correct
53 Correct 197 ms 17932 KB Output is correct