답안 #919745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919745 2024-02-01T15:12:41 Z ByeWorld Just Long Neckties (JOI20_ho_t1) C++14
9 / 100
117 ms 9424 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#define bupol __builtin_popcount
#define int long long 
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 1e5+10;
const int MAXK = 2010;
const int LOG = 20;
const int MOD = 1e9+7;
const int SQRT = 520;
const int INF = 1e9+10;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;

int n;
int a[MAXN], b[MAXN], ans[MAXN];
vector <pii> vec;

bool cek(int x, int p){
    int j = n, mx = 0;
    for(int i=n-1; i>=0; i--){
        if(vec[j].se==p) j--;
        mx = max(mx, vec[j].fi-b[i]);
        j--;
    }
    return (mx <= x);
}
int bin(int p){
    int l=0, r = INF, mid=0, cnt=0;
    while(l<=r){
        mid = md;
        if(cek(mid, p)){
            r = mid-1; cnt = mid;
        } else l = mid+1;
    } 
    //cout << p << ' ' << cnt << " p\n";
    return cnt;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i=0; i<=n; i++){
        cin >> a[i]; vec.pb({a[i], i});
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<n; i++) cin >> b[i];
    sort(b+0, b+n);

    for(int i=0; i<n+1; i++){
        ans[vec[i].se] = bin(vec[i].se);
    }

    for(int i=0; i<n+1; i++) cout << ans[i] << " \n"[i==n];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2404 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2404 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 21 ms 2392 KB Output is correct
15 Correct 61 ms 2600 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 89 ms 2396 KB Output is correct
18 Correct 70 ms 2396 KB Output is correct
19 Correct 73 ms 2392 KB Output is correct
20 Correct 71 ms 2600 KB Output is correct
21 Correct 79 ms 2604 KB Output is correct
22 Correct 72 ms 2592 KB Output is correct
23 Correct 69 ms 2392 KB Output is correct
24 Correct 75 ms 2592 KB Output is correct
25 Correct 102 ms 2616 KB Output is correct
26 Correct 94 ms 2392 KB Output is correct
27 Correct 91 ms 2392 KB Output is correct
28 Correct 99 ms 2396 KB Output is correct
29 Correct 75 ms 2392 KB Output is correct
30 Correct 92 ms 2392 KB Output is correct
31 Correct 103 ms 2392 KB Output is correct
32 Correct 117 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2404 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 2 ms 2392 KB Output is correct
14 Correct 21 ms 2392 KB Output is correct
15 Correct 61 ms 2600 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 89 ms 2396 KB Output is correct
18 Correct 70 ms 2396 KB Output is correct
19 Correct 73 ms 2392 KB Output is correct
20 Correct 71 ms 2600 KB Output is correct
21 Correct 79 ms 2604 KB Output is correct
22 Correct 72 ms 2592 KB Output is correct
23 Correct 69 ms 2392 KB Output is correct
24 Correct 75 ms 2592 KB Output is correct
25 Correct 102 ms 2616 KB Output is correct
26 Correct 94 ms 2392 KB Output is correct
27 Correct 91 ms 2392 KB Output is correct
28 Correct 99 ms 2396 KB Output is correct
29 Correct 75 ms 2392 KB Output is correct
30 Correct 92 ms 2392 KB Output is correct
31 Correct 103 ms 2392 KB Output is correct
32 Correct 117 ms 2392 KB Output is correct
33 Runtime error 13 ms 9424 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -