Submission #202289

# Submission time Handle Problem Language Result Execution time Memory
202289 2020-02-15T07:15:43 Z lukameladze Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
551 ms 17984 KB
# include <bits/stdc++.h>
using namespace std;
long long n,ans[200005],b[200005];
pair <long long, long long > a[200005];
multiset <long long > ms;
int main()
{
	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);
	for (int i=1; i<=n; i++)
	{
		ms.insert(a[i].first-b[i]);
	}
	for (int i=n+1; i>=1; i--)
	{
		ans[a[i].second]=*(--ms.end());
		if (i>1)
		{
			ms.erase(ms.find(a[i-1].first-b[i-1]));
			ms.insert(a[i].first-b[i-1]);
		}
	}
	for (int i=1; i<=n+1; i++)
	{
		cout<<ans[i]<<" ";
	}
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 8 ms 504 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 8 ms 504 KB Output is correct
22 Correct 8 ms 504 KB Output is correct
23 Correct 8 ms 504 KB Output is correct
24 Correct 8 ms 504 KB Output is correct
25 Correct 9 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 10 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 8 ms 504 KB Output is correct
31 Correct 8 ms 480 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 248 KB Output is correct
8 Correct 5 ms 248 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 7 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 8 ms 504 KB Output is correct
18 Correct 8 ms 504 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 8 ms 504 KB Output is correct
21 Correct 8 ms 504 KB Output is correct
22 Correct 8 ms 504 KB Output is correct
23 Correct 8 ms 504 KB Output is correct
24 Correct 8 ms 504 KB Output is correct
25 Correct 9 ms 504 KB Output is correct
26 Correct 8 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 10 ms 504 KB Output is correct
29 Correct 7 ms 504 KB Output is correct
30 Correct 8 ms 504 KB Output is correct
31 Correct 8 ms 480 KB Output is correct
32 Correct 8 ms 504 KB Output is correct
33 Correct 418 ms 16888 KB Output is correct
34 Correct 444 ms 17400 KB Output is correct
35 Correct 451 ms 16912 KB Output is correct
36 Correct 421 ms 17400 KB Output is correct
37 Correct 464 ms 17984 KB Output is correct
38 Correct 537 ms 17656 KB Output is correct
39 Correct 472 ms 16760 KB Output is correct
40 Correct 526 ms 16736 KB Output is correct
41 Correct 484 ms 16892 KB Output is correct
42 Correct 474 ms 16732 KB Output is correct
43 Correct 483 ms 16708 KB Output is correct
44 Correct 462 ms 16248 KB Output is correct
45 Correct 448 ms 16356 KB Output is correct
46 Correct 440 ms 16120 KB Output is correct
47 Correct 396 ms 16504 KB Output is correct
48 Correct 393 ms 16632 KB Output is correct
49 Correct 551 ms 17272 KB Output is correct
50 Correct 515 ms 17144 KB Output is correct
51 Correct 506 ms 17144 KB Output is correct
52 Correct 486 ms 17292 KB Output is correct
53 Correct 497 ms 17272 KB Output is correct