답안 #389067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
389067 2021-04-13T15:05:27 Z keta_tsimakuridze Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
552 ms 21688 KB
#include<bits/stdc++.h>
#define f first
#define int long long
#define s second
using namespace std;
const int N=2e5+5,mod=1e9+7;
int t,b[N],n,ans[N];
pair<int,int> a[N];
multiset<int>s;

 main(){
	// t=1;
	cin>>n;
	for(int i=1;i<=n+1;i++){
		cin>>a[i].f;
		a[i].s=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++){
		s.insert(-b[i]+a[i+1].f);
	}
	ans[a[1].s] = max(0ll,*--s.end());
	for(int i=2;i<=n+1;i++){
		s.erase(s.find(-b[i-1]+a[i].f));
		s.insert(-b[i-1]+a[i-1].f);
		ans[a[i].s] = max(0ll,*--s.end());
	}
	for(int i=1;i<=n+1;i++){
		cout<<ans[i]<<" ";
	} 
}

Compilation message

ho_t1.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 |  main(){
      |       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 460 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 3 ms 460 KB Output is correct
18 Correct 3 ms 356 KB Output is correct
19 Correct 3 ms 444 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 4 ms 460 KB Output is correct
22 Correct 4 ms 460 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 4 ms 444 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 3 ms 444 KB Output is correct
30 Correct 3 ms 444 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 3 ms 460 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 3 ms 460 KB Output is correct
18 Correct 3 ms 356 KB Output is correct
19 Correct 3 ms 444 KB Output is correct
20 Correct 4 ms 460 KB Output is correct
21 Correct 4 ms 460 KB Output is correct
22 Correct 4 ms 460 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 4 ms 444 KB Output is correct
26 Correct 3 ms 460 KB Output is correct
27 Correct 3 ms 460 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 3 ms 444 KB Output is correct
30 Correct 3 ms 444 KB Output is correct
31 Correct 3 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 355 ms 20312 KB Output is correct
34 Correct 379 ms 21204 KB Output is correct
35 Correct 351 ms 20604 KB Output is correct
36 Correct 354 ms 21144 KB Output is correct
37 Correct 391 ms 21688 KB Output is correct
38 Correct 349 ms 21460 KB Output is correct
39 Correct 456 ms 20420 KB Output is correct
40 Correct 423 ms 20236 KB Output is correct
41 Correct 438 ms 20572 KB Output is correct
42 Correct 414 ms 20420 KB Output is correct
43 Correct 441 ms 20344 KB Output is correct
44 Correct 330 ms 19652 KB Output is correct
45 Correct 333 ms 19924 KB Output is correct
46 Correct 329 ms 19652 KB Output is correct
47 Correct 322 ms 20352 KB Output is correct
48 Correct 308 ms 20380 KB Output is correct
49 Correct 424 ms 20876 KB Output is correct
50 Correct 437 ms 21060 KB Output is correct
51 Correct 428 ms 21056 KB Output is correct
52 Correct 552 ms 20912 KB Output is correct
53 Correct 427 ms 20952 KB Output is correct