Submission #244236

# Submission time Handle Problem Language Result Execution time Memory
244236 2020-07-03T08:12:28 Z WhipppedCream Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
394 ms 19424 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 2e5+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

ii arr[maxn];

int b[maxn];

int cur[maxn];

int ans[maxn];

multiset<int> bst;

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i<= n+1; i++)
	{
		scanf("%d", &arr[i].f);
		arr[i].s = i;
	}
	sort(arr+1, arr+n+2);
	for(int i = 1; i<= n; i++)
	{
		scanf("%d", &b[i]);
	}
	sort(b+1, b+n+1);

	for(int i = 2; i<= n+1; i++)
	{
		cur[i-1] = arr[i].f;
		bst.insert(cur[i-1]-b[i-1]);
	}

	ans[arr[1].s] = *(--bst.end());

	for(int i = 1; i<= n; i++)
	{
		bst.erase(bst.find(cur[i]-b[i]));
		cur[i] = arr[i].f;
		bst.insert(cur[i]-b[i]);

		ans[arr[i+1].s] = *(--bst.end());
	}

	for(int i = 1; i<= n+1; i++) printf("%d ", ans[i]);
	printf("\n");
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
ho_t1.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &arr[i].f);
   ~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:49:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &b[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 7 ms 512 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
31 Correct 7 ms 512 KB Output is correct
32 Correct 7 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 7 ms 512 KB Output is correct
23 Correct 6 ms 384 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
31 Correct 7 ms 512 KB Output is correct
32 Correct 7 ms 640 KB Output is correct
33 Correct 293 ms 17272 KB Output is correct
34 Correct 265 ms 18936 KB Output is correct
35 Correct 265 ms 18424 KB Output is correct
36 Correct 262 ms 18808 KB Output is correct
37 Correct 298 ms 19424 KB Output is correct
38 Correct 258 ms 19192 KB Output is correct
39 Correct 360 ms 18296 KB Output is correct
40 Correct 331 ms 18168 KB Output is correct
41 Correct 322 ms 18296 KB Output is correct
42 Correct 321 ms 18296 KB Output is correct
43 Correct 367 ms 18168 KB Output is correct
44 Correct 236 ms 17784 KB Output is correct
45 Correct 235 ms 17784 KB Output is correct
46 Correct 240 ms 17656 KB Output is correct
47 Correct 199 ms 18168 KB Output is correct
48 Correct 196 ms 18040 KB Output is correct
49 Correct 353 ms 18804 KB Output is correct
50 Correct 394 ms 18680 KB Output is correct
51 Correct 355 ms 18680 KB Output is correct
52 Correct 356 ms 18748 KB Output is correct
53 Correct 350 ms 18808 KB Output is correct