Submission #286862

# Submission time Handle Problem Language Result Execution time Memory
286862 2020-08-31T05:55:26 Z arnold518 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
169 ms 10872 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;

int N, B[MAXN+10];
pii A[MAXN+10];
int ans[MAXN+10];

int P[MAXN+10], Q[MAXN+10];

int main()
{
	scanf("%d", &N);
	for(int i=1; i<=N+1; i++) scanf("%d", &A[i].first), A[i].second=i;
	for(int i=1; i<=N; i++) scanf("%d", &B[i]);

	sort(A+1, A+N+2);
	sort(B+1, B+N+1);

	for(int i=1; i<=N; i++) P[i]=max(P[i-1], A[i].first-B[i]);
	for(int i=N; i>=1; i--) Q[i]=max(Q[i+1], A[i+1].first-B[i]);

	for(int i=1; i<=N+1; i++) ans[A[i].second]=max(P[i-1], Q[i]);
	for(int i=1; i<=N+1; i++) printf("%d ", ans[i]);
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
ho_t1.cpp:19:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  for(int i=1; i<=N+1; i++) scanf("%d", &A[i].first), A[i].second=i;
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~
ho_t1.cpp:20:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  for(int i=1; i<=N; i++) scanf("%d", &B[i]);
      |                          ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory 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 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory 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 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 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 1 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 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 1 ms 384 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 512 KB Output is correct
27 Correct 2 ms 512 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory 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 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 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 1 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 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 1 ms 384 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 512 KB Output is correct
27 Correct 2 ms 512 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 145 ms 10004 KB Output is correct
34 Correct 140 ms 10488 KB Output is correct
35 Correct 136 ms 10104 KB Output is correct
36 Correct 133 ms 10488 KB Output is correct
37 Correct 139 ms 10872 KB Output is correct
38 Correct 150 ms 10872 KB Output is correct
39 Correct 169 ms 9848 KB Output is correct
40 Correct 150 ms 9780 KB Output is correct
41 Correct 137 ms 10044 KB Output is correct
42 Correct 141 ms 9848 KB Output is correct
43 Correct 136 ms 9720 KB Output is correct
44 Correct 133 ms 9336 KB Output is correct
45 Correct 133 ms 9464 KB Output is correct
46 Correct 132 ms 9340 KB Output is correct
47 Correct 118 ms 9464 KB Output is correct
48 Correct 118 ms 9464 KB Output is correct
49 Correct 144 ms 10104 KB Output is correct
50 Correct 140 ms 10104 KB Output is correct
51 Correct 141 ms 10104 KB Output is correct
52 Correct 139 ms 10104 KB Output is correct
53 Correct 141 ms 10104 KB Output is correct