답안 #762948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762948 2023-06-22T01:39:18 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
86 ms 13220 KB
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("bmi,bmi2,lzcnt,popcnt")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
//#pragma expected_value
//#pragma isolated_call
//#pragma disjoint

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;
using namespace std;

#define int long long
//#define double long double
#define Fi first
#define Se second
#define Rep(i,a,b) for (int i=a;i<=b;++i)
#define Repu(i,b,a) for (int i=b;i>=a;--i)
#define pb push_back
#define ms(a,i) memset(a,i,sizeof(a))
#define sz size()
#define mp make_pair
#define endl '\n'
#define sef setprecision(12)<<fixed
#define cer cout<<"cak"<<endl;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<double> va;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<va> vva;

//const double EPS=1e-9;
const double PI=acos(-1);
//const int oo=1e18;
const int MN=2e5+5;
const int mod=1e9+7;

using cd=complex<double>;

//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> index_set;

int n;
int a[MN];
int b[MN];

int Max(int x,int y) {
	if(x>=y) return x;
	return y;
}

int doc[MN], cheo[MN];

ii A[MN];

int ans[MN];

signed main() {
	//freopen(".inp","r",stdin); freopen(".out","w",stdout);

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin>>n;
	Rep(i,1,n+1) cin>>a[i];
	Rep(i,1,n) cin>>b[i];
	sort(b+1,b+n+1);

	/*if(n<=2000) {
		Rep(i,1,n+1) {
			multiset<int> s;
			Rep(j,1,n+1) if(i!=j) s.insert(a[j]);
			int c=0;
			auto itr = s.begin();
			Rep(j,1,n) {
				c = Max(c,Max(*itr-b[j],0));
				//cout<<*itr<<" ";
				itr++;
			}
			cout<<c<<" ";
		}
		return 0;
	}*/

	Rep(i,1,n+1) {
		A[i] = mp(a[i],i);
	}

	sort(A+1, A+n+2);

	Rep(i,1,n) {
		doc[i] = Max(doc[i-1], Max(A[i].Fi-b[i],0));
	}

	Repu(i,n,1) {
		cheo[i] = Max(cheo[i+1], Max(A[i+1].Fi-b[i],0));
	}

	Rep(i,1,n+1) {
		int id = A[i].Se;
		ans[id] = Max(doc[i-1], cheo[i]);
	}

	Rep(i,1,n+1) cout<<ans[i]<<" ";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 288 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 288 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 264 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 288 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 264 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 2 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 81 ms 12248 KB Output is correct
34 Correct 73 ms 12764 KB Output is correct
35 Correct 71 ms 12276 KB Output is correct
36 Correct 72 ms 12776 KB Output is correct
37 Correct 73 ms 13220 KB Output is correct
38 Correct 73 ms 12984 KB Output is correct
39 Correct 83 ms 12068 KB Output is correct
40 Correct 72 ms 12096 KB Output is correct
41 Correct 78 ms 12172 KB Output is correct
42 Correct 70 ms 12108 KB Output is correct
43 Correct 84 ms 12156 KB Output is correct
44 Correct 81 ms 11576 KB Output is correct
45 Correct 80 ms 11684 KB Output is correct
46 Correct 69 ms 11656 KB Output is correct
47 Correct 69 ms 11704 KB Output is correct
48 Correct 66 ms 11716 KB Output is correct
49 Correct 73 ms 12400 KB Output is correct
50 Correct 86 ms 12424 KB Output is correct
51 Correct 78 ms 12404 KB Output is correct
52 Correct 73 ms 12412 KB Output is correct
53 Correct 73 ms 12400 KB Output is correct