답안 #545009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545009 2022-04-03T10:11:26 Z Asymmetry Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
98 ms 10824 KB
//Autor: Bartłomiej Czarkowski
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif

const int N = 201000;
int n;
int B[N];
int odp[N];
int pref[N];
int suff[N];
pair<int, int> sr[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n + 1; ++i) {
		scanf("%d", &sr[i].first);
		sr[i].second = i;
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &B[i]);
	}
	sort(sr + 1, sr + 2 + n);
	sort(B + 1, B + 1 + n);
	for (int i = 1; i <= n; ++i) {
		pref[i] = max(pref[i - 1], max(0, sr[i].first - B[i]));
	}
	for (int i = n + 1; i > 1; --i) {
		suff[i] = max(suff[i + 1], max(0, sr[i].first - B[i - 1]));
	}
	for (int i = 1; i <= n + 1; ++i) {
		odp[sr[i].second] = max(pref[i - 1], suff[i + 1]);
	}
	for (int i = 1; i <= n + 1; ++i) {
		printf("%d ", odp[i]);
	}
	printf("\n");
	return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
ho_t1.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |   scanf("%d", &sr[i].first);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d", &B[i]);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 91 ms 9992 KB Output is correct
34 Correct 93 ms 10336 KB Output is correct
35 Correct 93 ms 10064 KB Output is correct
36 Correct 94 ms 10524 KB Output is correct
37 Correct 95 ms 10824 KB Output is correct
38 Correct 95 ms 10640 KB Output is correct
39 Correct 94 ms 9768 KB Output is correct
40 Correct 89 ms 9628 KB Output is correct
41 Correct 91 ms 9776 KB Output is correct
42 Correct 93 ms 9812 KB Output is correct
43 Correct 91 ms 9708 KB Output is correct
44 Correct 90 ms 9268 KB Output is correct
45 Correct 89 ms 9544 KB Output is correct
46 Correct 88 ms 9292 KB Output is correct
47 Correct 87 ms 9420 KB Output is correct
48 Correct 90 ms 9400 KB Output is correct
49 Correct 98 ms 10032 KB Output is correct
50 Correct 92 ms 10004 KB Output is correct
51 Correct 92 ms 9984 KB Output is correct
52 Correct 98 ms 10092 KB Output is correct
53 Correct 92 ms 10060 KB Output is correct