답안 #251887

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
251887 2020-07-22T20:22:35 Z ivandasfs Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
143 ms 10872 KB
#include <bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

pair <int, int> a[200005];
int b[200005];
int pref[200005];
int suff[200005];
int sol[200005];

int main() {
	int n;
	scanf("%d", &n);
	for (int i=1 ; i<=n+1 ; i++) {
		scanf("%d", &a[i].x);
		a[i].y = i;
	}
	sort(a+1, a+n+2);
	for (int i=1 ; i<=n ; i++) {
		scanf("%d", b+i);
	}
	sort(b+1, b+n+1);
	for (int i=1 ; i<=n ; i++) {
		pref[i] = max(pref[i-1], max(a[i].x-b[i], 0));
	}
	for (int i=n+1 ; i>=2 ; i--) {
		suff[i] = max(suff[i+1], max(a[i].x-b[i-1], 0));
	}
	for (int i=1 ; i<=n+1 ; i++) {
		sol[a[i].y] = max(pref[i-1], suff[i+1]);
	}
	for (int i=1 ; i<=n+1 ; i++) {
		printf("%d ", sol[i]);
	}
	printf("\n");
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
ho_t1.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i].x);
   ~~~~~^~~~~~~~~~~~~~~
ho_t1.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", b+i);
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 2 ms 476 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 2 ms 476 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 128 ms 10104 KB Output is correct
34 Correct 132 ms 10400 KB Output is correct
35 Correct 131 ms 10104 KB Output is correct
36 Correct 124 ms 10488 KB Output is correct
37 Correct 143 ms 10872 KB Output is correct
38 Correct 130 ms 10752 KB Output is correct
39 Correct 128 ms 9768 KB Output is correct
40 Correct 128 ms 9720 KB Output is correct
41 Correct 128 ms 9976 KB Output is correct
42 Correct 128 ms 9848 KB Output is correct
43 Correct 128 ms 9848 KB Output is correct
44 Correct 128 ms 9336 KB Output is correct
45 Correct 125 ms 9464 KB Output is correct
46 Correct 125 ms 9336 KB Output is correct
47 Correct 124 ms 9592 KB Output is correct
48 Correct 107 ms 9464 KB Output is correct
49 Correct 134 ms 10104 KB Output is correct
50 Correct 130 ms 10104 KB Output is correct
51 Correct 127 ms 10104 KB Output is correct
52 Correct 130 ms 10104 KB Output is correct
53 Correct 131 ms 10104 KB Output is correct