답안 #545335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545335 2022-04-04T09:31:55 Z Aktan Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
319 ms 21708 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T>
using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define ft first
#define sc second
const int mod=1e9+7,INF=1e17,N=2e5+10;
vector<pair<int,int>> v;
multiset<int> s;
int ans[N];
main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> a,b;
	for(int i=1;i<=n+1;i++){
		int x;
		cin >> x;
		v.push_back({x,i});
	}
	for(int i=1;i<=n;i++){
		int x;
		cin >> x;
		b.push_back(x);
	}
	sort(v.begin(),v.end());
	sort(b.begin(),b.end());
	int mn=INF;
	for(int i=0;i<n;i++){
		s.insert(max(0ll,v[i+1].ft-b[i]));
	}
	ans[v[0].sc]=*--s.end();
	for(int i=1;i<=n;i++){
		s.erase(s.find(max(0ll,v[i].ft-b[i-1])));
		s.insert(max(0ll,v[i-1].ft-b[i-1]));
		ans[v[i].sc]=*--s.end();
	}
	for(int i=1;i<=n+1;i++){
		cout << ans[i] << " ";
	}
}



Compilation message

ho_t1.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
ho_t1.cpp: In function 'int main()':
ho_t1.cpp:33:6: warning: unused variable 'mn' [-Wunused-variable]
   33 |  int mn=INF;
      |      ^~
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 3 ms 472 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 404 KB Output is correct
21 Correct 2 ms 500 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 388 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 472 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 436 KB Output is correct
32 Correct 2 ms 468 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 3 ms 472 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 404 KB Output is correct
21 Correct 2 ms 500 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 388 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 472 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 2 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 2 ms 436 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 185 ms 20444 KB Output is correct
34 Correct 191 ms 21232 KB Output is correct
35 Correct 184 ms 20588 KB Output is correct
36 Correct 195 ms 21052 KB Output is correct
37 Correct 186 ms 21708 KB Output is correct
38 Correct 211 ms 21432 KB Output is correct
39 Correct 235 ms 20452 KB Output is correct
40 Correct 254 ms 20364 KB Output is correct
41 Correct 319 ms 20580 KB Output is correct
42 Correct 253 ms 20516 KB Output is correct
43 Correct 237 ms 20360 KB Output is correct
44 Correct 162 ms 19896 KB Output is correct
45 Correct 160 ms 19924 KB Output is correct
46 Correct 183 ms 19740 KB Output is correct
47 Correct 172 ms 20428 KB Output is correct
48 Correct 177 ms 20408 KB Output is correct
49 Correct 254 ms 21072 KB Output is correct
50 Correct 293 ms 21000 KB Output is correct
51 Correct 245 ms 21084 KB Output is correct
52 Correct 242 ms 21120 KB Output is correct
53 Correct 237 ms 21084 KB Output is correct