Submission #532313

# Submission time Handle Problem Language Result Execution time Memory
532313 2022-03-02T17:14:28 Z Nanashi_Panda Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
148 ms 17160 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#define jizz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define ll long long
using namespace std;
ll ft[200005];
ll bk[200005];
ll b[200005];
ll n;
struct st{
	ll loc, v;
};
vector <st> ans;
st a[200005];
bool num(st a, st b){
	return a.v<b.v;
}
bool locate(st a, st b){
	return a.loc<b.loc;
}
int main() {
	scanf("%lld", &n);
	for(ll i = 1; i <= n+1; i++) scanf("%lld", &a[i].v),a[i].loc = i;
	for(ll i = 1; i <= n; i++) scanf("%lld", b+i);
	sort(a+1, a+n+2, num);
	sort(b, b+n+1);
	for(ll i = 1; i <= n; i++) ft[i]=max(ft[i-1], a[i].v-b[i]);
	for(ll i = n; i >= 1; i--) bk[i]=max(bk[i+1], a[i+1].v-b[i]);
	for(ll i = 1; i <= n+1; i++){
		if(i==1)
			ans.push_back({a[i].loc, bk[i]});
		else if(i==n+1)
			ans.push_back({a[i].loc, ft[i-1]});
		else
			ans.push_back({a[i].loc, max(ft[i-1], bk[i])});
//		printf("%lld %lld\n", ans.back().loc, ans.back().v );
	}
	sort(ans.begin(), ans.end(), locate);
	for(auto i:ans){
		printf("%lld ", i.v);
	}
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
ho_t1.cpp:25:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for(ll i = 1; i <= n+1; i++) scanf("%lld", &a[i].v),a[i].loc = i;
      |                               ~~~~~^~~~~~~~~~~~~~~~~
ho_t1.cpp:26:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  for(ll i = 1; i <= n; i++) scanf("%lld", b+i);
      |                             ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 444 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 448 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 448 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 2 ms 448 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 444 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 2 ms 448 KB Output is correct
18 Correct 2 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 2 ms 460 KB Output is correct
24 Correct 2 ms 448 KB Output is correct
25 Correct 2 ms 460 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 2 ms 448 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 2 ms 460 KB Output is correct
32 Correct 2 ms 448 KB Output is correct
33 Correct 122 ms 16056 KB Output is correct
34 Correct 124 ms 16616 KB Output is correct
35 Correct 148 ms 16148 KB Output is correct
36 Correct 123 ms 16696 KB Output is correct
37 Correct 138 ms 17132 KB Output is correct
38 Correct 126 ms 17160 KB Output is correct
39 Correct 120 ms 15984 KB Output is correct
40 Correct 119 ms 15832 KB Output is correct
41 Correct 126 ms 16120 KB Output is correct
42 Correct 120 ms 16044 KB Output is correct
43 Correct 137 ms 15860 KB Output is correct
44 Correct 116 ms 15580 KB Output is correct
45 Correct 118 ms 15704 KB Output is correct
46 Correct 124 ms 15628 KB Output is correct
47 Correct 100 ms 16172 KB Output is correct
48 Correct 108 ms 16184 KB Output is correct
49 Correct 125 ms 16408 KB Output is correct
50 Correct 122 ms 16388 KB Output is correct
51 Correct 130 ms 16324 KB Output is correct
52 Correct 128 ms 16380 KB Output is correct
53 Correct 123 ms 16344 KB Output is correct