답안 #762983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762983 2023-06-22T02:03:01 Z trucmai Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
1 ms 340 KB
//#i_love_aisukiuwu#9998

#include <bits/stdc++.h>
using namespace std;

void open(){
  // if(fopen("i.inp","r")){
  //   freopen("i.inp","r",stdin);
  //   freopen("o.out","w",stdout);
  // }
}

#define ll long long
#define all(a) (a).begin(), (a).end()
#define vi vector<ll>
#define pi pair<ll,ll>
#define pii pair<ll,pair<ll,ll>>
#define fi first
#define se second
#define gcd __gcd
#define mset(a,v) memset(a, v, sizeof(a))
#define endl '\n'
#define spc " "

const int MN1 = 1e6 + 5,MN2 = 1e4 + 5,LOG = 27;
const ll MOD = 1e9 + 7,INF = 1e9;
ll n,b[MN1],pf[MN1],sf[MN1],res[MN1];
pi a[MN1]; 
void solve(){
	cin>>n;
	for(ll i = 1;i <= n + 1;++i){
		cin>>a[i].fi; 
		a[i].se = i; 
	}
	for(ll i = 1;i <= n;++i) cin>>b[i];
	sort(a+1,a+n+2);
	sort(b+1,b+n+1);
	for(ll i = 1;i <= n;++i)
		pf[i] = max(pf[i-1],a[i].fi - b[i]);
	for(ll i = n;i >= 2;--i)
		sf[i] = max(sf[i+1],a[i].fi - b[i-1]);	
	for(ll i = 1;i <= n+1;++i)
		res[a[i].se] = max(pf[i-1],sf[i+1]);
	for(ll i = 1;i <= n+1;++i) cout<<res[i]<<spc;
}

signed main(){
  cin.tie(0) -> sync_with_stdio(0);
  open();
  ll t = 1; //cin>>t;
  while(t--) solve(); 
  // cerr << "\n" << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 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 Incorrect 1 ms 340 KB Output isn't correct
7 Halted 0 ms 0 KB -