# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
364637 | 2021-02-09T15:42:48 Z | cpp219 | Just Long Neckties (JOI20_ho_t1) | C++14 | 606 ms | 21484 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 2e5 + 6; const ll inf = 1e9 + 7; typedef pair<int,int> LL; LL A[N]; ll n,b[N],a[N],ans[N],init,diff[N],Dec,cur; bool chk(ll m,ll st){ for (ll i = 1;i <= n;i++){ ll nxt = upper_bound(a + 1,a + n + 2,b[i] + m) - a - 1; if (nxt >= st) nxt--; if (nxt < i) return 0; } return 1; } ll bs(ll st){ ll l,m,h; l = 0; h = inf; while(l <= h){ m = (l + h)/2; if (chk(m,st)) h = m - 1; else l = m + 1; } return l; } set<LL> s; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n; for (ll i = 1;i <= n + 1;i++) cin>>A[i].fs,A[i].sc = i; sort(A + 1,A + n + 2); for (ll i = 1;i <= n + 1;i++) a[i] = A[i].fs; for (ll i = 1;i <= n;i++) cin>>b[i]; sort(b + 1,b + n + 1); init = cur = bs(1); ans[A[1].sc] = cur; for (ll i = 1;i <= n;i++) diff[i] = b[i] - a[i + 1] + init,s.insert({diff[i],i}); for (ll i = 2;i <= n + 1;i++){ s.erase({diff[i - 1],i - 1}); diff[i - 1] = b[i - 1] - a[i - 1] + init; s.insert({diff[i - 1],i - 1}); LL t = *s.begin(); cur -= t.fs - Dec; Dec = t.fs; ans[A[i].sc] = cur; } for (ll i = 1;i <= n + 1;i++) cout<<ans[i]<<" "; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 3 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 4 ms | 620 KB | Output is correct |
18 | Correct | 3 ms | 492 KB | Output is correct |
19 | Correct | 4 ms | 620 KB | Output is correct |
20 | Correct | 3 ms | 620 KB | Output is correct |
21 | Correct | 4 ms | 620 KB | Output is correct |
22 | Correct | 3 ms | 492 KB | Output is correct |
23 | Correct | 4 ms | 620 KB | Output is correct |
24 | Correct | 3 ms | 492 KB | Output is correct |
25 | Correct | 4 ms | 620 KB | Output is correct |
26 | Correct | 6 ms | 620 KB | Output is correct |
27 | Correct | 4 ms | 620 KB | Output is correct |
28 | Correct | 5 ms | 620 KB | Output is correct |
29 | Correct | 3 ms | 492 KB | Output is correct |
30 | Correct | 4 ms | 620 KB | Output is correct |
31 | Correct | 5 ms | 620 KB | Output is correct |
32 | Correct | 4 ms | 620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 3 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 4 ms | 620 KB | Output is correct |
18 | Correct | 3 ms | 492 KB | Output is correct |
19 | Correct | 4 ms | 620 KB | Output is correct |
20 | Correct | 3 ms | 620 KB | Output is correct |
21 | Correct | 4 ms | 620 KB | Output is correct |
22 | Correct | 3 ms | 492 KB | Output is correct |
23 | Correct | 4 ms | 620 KB | Output is correct |
24 | Correct | 3 ms | 492 KB | Output is correct |
25 | Correct | 4 ms | 620 KB | Output is correct |
26 | Correct | 6 ms | 620 KB | Output is correct |
27 | Correct | 4 ms | 620 KB | Output is correct |
28 | Correct | 5 ms | 620 KB | Output is correct |
29 | Correct | 3 ms | 492 KB | Output is correct |
30 | Correct | 4 ms | 620 KB | Output is correct |
31 | Correct | 5 ms | 620 KB | Output is correct |
32 | Correct | 4 ms | 620 KB | Output is correct |
33 | Correct | 445 ms | 20076 KB | Output is correct |
34 | Correct | 446 ms | 21100 KB | Output is correct |
35 | Correct | 477 ms | 20224 KB | Output is correct |
36 | Correct | 410 ms | 20744 KB | Output is correct |
37 | Correct | 484 ms | 21484 KB | Output is correct |
38 | Correct | 448 ms | 21084 KB | Output is correct |
39 | Correct | 535 ms | 20124 KB | Output is correct |
40 | Correct | 564 ms | 20076 KB | Output is correct |
41 | Correct | 586 ms | 20456 KB | Output is correct |
42 | Correct | 577 ms | 20136 KB | Output is correct |
43 | Correct | 575 ms | 20076 KB | Output is correct |
44 | Correct | 484 ms | 19552 KB | Output is correct |
45 | Correct | 526 ms | 19628 KB | Output is correct |
46 | Correct | 482 ms | 19564 KB | Output is correct |
47 | Correct | 346 ms | 20228 KB | Output is correct |
48 | Correct | 334 ms | 20204 KB | Output is correct |
49 | Correct | 569 ms | 20748 KB | Output is correct |
50 | Correct | 606 ms | 20716 KB | Output is correct |
51 | Correct | 574 ms | 20752 KB | Output is correct |
52 | Correct | 590 ms | 20792 KB | Output is correct |
53 | Correct | 575 ms | 20588 KB | Output is correct |