Submission #201271

# Submission time Handle Problem Language Result Execution time Memory
201271 2020-02-10T05:48:36 Z arnold518 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
152 ms 7032 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 C[MAXN+10], D[MAXN+10], ans[MAXN+10];

int main()
{
	int i, j;

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

	sort(A+1, A+N+2);
	sort(B+1, B+N+1);
	
	for(i=1; i<=N; i++) C[i]=max(C[i-1], A[i].first-B[i]);
	for(i=N; i>=1; i--) D[i]=max(D[i+1], A[i+1].first-B[i]);

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

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:17:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
ho_t1.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
ho_t1.cpp:20:48: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N+1; i++) scanf("%d", &A[i].first), A[i].second=i;
                        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
ho_t1.cpp:21:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1; i<=N; i++) scanf("%d", &B[i]);
                      ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 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 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 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 5 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 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 5 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 376 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 376 KB Output is correct
27 Correct 6 ms 376 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 6 ms 376 KB Output is correct
33 Correct 138 ms 6368 KB Output is correct
34 Correct 144 ms 6648 KB Output is correct
35 Correct 139 ms 6392 KB Output is correct
36 Correct 143 ms 6776 KB Output is correct
37 Correct 152 ms 7032 KB Output is correct
38 Correct 145 ms 6904 KB Output is correct
39 Correct 143 ms 6008 KB Output is correct
40 Correct 139 ms 6008 KB Output is correct
41 Correct 140 ms 6136 KB Output is correct
42 Correct 141 ms 6136 KB Output is correct
43 Correct 141 ms 6008 KB Output is correct
44 Correct 138 ms 5752 KB Output is correct
45 Correct 138 ms 5752 KB Output is correct
46 Correct 145 ms 5752 KB Output is correct
47 Correct 126 ms 5568 KB Output is correct
48 Correct 127 ms 5624 KB Output is correct
49 Correct 146 ms 6264 KB Output is correct
50 Correct 146 ms 6208 KB Output is correct
51 Correct 144 ms 6264 KB Output is correct
52 Correct 149 ms 6264 KB Output is correct
53 Correct 148 ms 6136 KB Output is correct