답안 #548067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548067 2022-04-12T10:31:02 Z marlen7 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
247 ms 10180 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define sz size()
#define push_ push_back
vector <int> a,b;
int sf[200005];
int pr[200005];
signed main(){
	int n,x;
	sf[0]=0;
	cin>>n;
	a.push_back(0);
	b.push_back(0);
	for (int i=1; i<=n+1; i++){
		cin>>x;
		a.push_back(x);
	}	
	auto c = a;
	for (int i=1; i<=n; i++){
		cin>>x;
		b.push_back(x);
	}
	sort (a.begin(),a.end());
	sort (b.begin(),b.end());
	sf[n+1]=0;
	for (int i=b.size()-1; i>0; i--){
		int h=(a[i+1]-b[i]);
		sf[i]=max(sf[i+1],max(0,h));
	}
	
	pr[0]=0;
	for (int i=1; i<=n; i++){
		pr[i]=max(pr[i-1],max(0,(a[i]-b[i])));
	}
//	for (int i=1; i<=n; i++){
//		cout<<pr[i]<<" ";
//	}cout << "\n";
//	for (int i = 1; i <= n; i++) {
//		cout << sf[i] << " ";
//	}cout << "\n";
	for (int i=0; i<=n; i++){
		int p = lower_bound(a.begin(), a.end(), c[i + 1]) - a.begin();
		cout<<max(pr[p-1],sf[p])<<" ";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 360 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 360 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 352 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 352 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 3 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 2 ms 360 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 360 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 352 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 2 ms 352 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 324 KB Output is correct
33 Correct 231 ms 9356 KB Output is correct
34 Correct 232 ms 9628 KB Output is correct
35 Correct 215 ms 9328 KB Output is correct
36 Correct 231 ms 9852 KB Output is correct
37 Correct 220 ms 10180 KB Output is correct
38 Correct 237 ms 10008 KB Output is correct
39 Correct 217 ms 9136 KB Output is correct
40 Correct 247 ms 9028 KB Output is correct
41 Correct 222 ms 9176 KB Output is correct
42 Correct 223 ms 9188 KB Output is correct
43 Correct 220 ms 9128 KB Output is correct
44 Correct 214 ms 8800 KB Output is correct
45 Correct 223 ms 8796 KB Output is correct
46 Correct 209 ms 8632 KB Output is correct
47 Correct 228 ms 8712 KB Output is correct
48 Correct 191 ms 8772 KB Output is correct
49 Correct 230 ms 9336 KB Output is correct
50 Correct 228 ms 9356 KB Output is correct
51 Correct 223 ms 9384 KB Output is correct
52 Correct 237 ms 9412 KB Output is correct
53 Correct 227 ms 9264 KB Output is correct