Submission #217105

# Submission time Handle Problem Language Result Execution time Memory
217105 2020-03-29T01:23:34 Z jamielim Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
343 ms 20216 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	pair<int,int> arr[n+1];
	pair<int,int> brr[n];
	for(int i=0;i<n+1;i++){scanf("%d",&arr[i].first);arr[i].second=i;}
	for(int i=0;i<n;i++){scanf("%d",&brr[i].first);brr[i].second=i;}
	sort(arr,arr+n+1);sort(brr,brr+n);
	long long ans[n+1];
	multiset<long long> cur;
	for(int i=1;i<n+1;i++){
		cur.insert(max(arr[i].first-brr[i-1].first,0));
	}
	ans[arr[0].second]=(*(--cur.end()));
	for(int i=1;i<n+1;i++){
		cur.erase(cur.find(max(arr[i].first-brr[i-1].first,0)));
		cur.insert(max(arr[i-1].first-brr[i-1].first,0));
		ans[arr[i].second]=(*(--cur.end()));
	}
	for(int i=0;i<n+1;i++){
		printf("%lld ",ans[i]);
	}
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
ho_t1.cpp:9:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n+1;i++){scanf("%d",&arr[i].first);arr[i].second=i;}
                         ~~~~~^~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:10:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++){scanf("%d",&brr[i].first);brr[i].second=i;}
                       ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 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 512 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 512 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 6 ms 512 KB Output is correct
23 Correct 6 ms 512 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 6 ms 512 KB Output is correct
32 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 256 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 256 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 512 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 512 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 6 ms 512 KB Output is correct
23 Correct 6 ms 512 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 6 ms 512 KB Output is correct
32 Correct 7 ms 512 KB Output is correct
33 Correct 237 ms 18936 KB Output is correct
34 Correct 260 ms 19704 KB Output is correct
35 Correct 248 ms 19108 KB Output is correct
36 Correct 251 ms 19576 KB Output is correct
37 Correct 261 ms 20216 KB Output is correct
38 Correct 260 ms 19960 KB Output is correct
39 Correct 326 ms 18872 KB Output is correct
40 Correct 320 ms 18856 KB Output is correct
41 Correct 320 ms 19064 KB Output is correct
42 Correct 324 ms 19064 KB Output is correct
43 Correct 313 ms 18808 KB Output is correct
44 Correct 215 ms 18552 KB Output is correct
45 Correct 218 ms 18424 KB Output is correct
46 Correct 213 ms 18300 KB Output is correct
47 Correct 209 ms 18808 KB Output is correct
48 Correct 217 ms 18808 KB Output is correct
49 Correct 340 ms 19576 KB Output is correct
50 Correct 328 ms 19448 KB Output is correct
51 Correct 334 ms 19576 KB Output is correct
52 Correct 336 ms 19448 KB Output is correct
53 Correct 343 ms 19544 KB Output is correct