# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
833052 | 2023-08-21T21:11:18 Z | jae | Just Long Neckties (JOI20_ho_t1) | C++17 | 222 ms | 18588 KB |
#include <bits/stdc++.h> #define SIZE 200005 using namespace std; typedef pair <int,int> P; int ans[SIZE]; int main() { int n; scanf("%d",&n); vector <int> A; vector <P> B; for(int i=0;i<n+1;i++) { int b; scanf("%d",&b); B.push_back(P(b,i)); } for(int i=0;i<n;i++) { int a; scanf("%d",&a); A.push_back(a); } sort(A.begin(),A.end()); sort(B.begin(),B.end()); multiset <int> st; multiset <int>::iterator it; for(int i=0;i<n;i++) { int d=max(0,B[i+1].first-A[i]); st.insert(d); } for(int i=0;i<=n;i++) { it=st.end();it--; ans[B[i].second]=*it; if(i==n) break; int d=max(0,B[i+1].first-A[i]); it=st.lower_bound(d); st.erase(it); d=max(0,B[i].first-A[i]); st.insert(d); } for(int i=0;i<=n;i++) { if(i!=0) printf(" "); printf("%d",ans[i]); }puts(""); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 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 | 316 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 316 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 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 | 316 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 316 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 312 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 444 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 456 KB | Output is correct |
21 | Correct | 2 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 452 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 2 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 | 2 ms | 448 KB | Output is correct |
30 | Correct | 2 ms | 368 KB | Output is correct |
31 | Correct | 2 ms | 448 KB | Output is correct |
32 | Correct | 1 ms | 452 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 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 | 316 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 316 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 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 | 312 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 444 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 456 KB | Output is correct |
21 | Correct | 2 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 452 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 2 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 | 2 ms | 448 KB | Output is correct |
30 | Correct | 2 ms | 368 KB | Output is correct |
31 | Correct | 2 ms | 448 KB | Output is correct |
32 | Correct | 1 ms | 452 KB | Output is correct |
33 | Correct | 165 ms | 17332 KB | Output is correct |
34 | Correct | 166 ms | 18108 KB | Output is correct |
35 | Correct | 157 ms | 17556 KB | Output is correct |
36 | Correct | 160 ms | 17972 KB | Output is correct |
37 | Correct | 171 ms | 18588 KB | Output is correct |
38 | Correct | 157 ms | 18360 KB | Output is correct |
39 | Correct | 193 ms | 17396 KB | Output is correct |
40 | Correct | 196 ms | 17212 KB | Output is correct |
41 | Correct | 205 ms | 17632 KB | Output is correct |
42 | Correct | 209 ms | 17464 KB | Output is correct |
43 | Correct | 204 ms | 17220 KB | Output is correct |
44 | Correct | 138 ms | 16736 KB | Output is correct |
45 | Correct | 140 ms | 16856 KB | Output is correct |
46 | Correct | 139 ms | 16760 KB | Output is correct |
47 | Correct | 138 ms | 17248 KB | Output is correct |
48 | Correct | 142 ms | 17300 KB | Output is correct |
49 | Correct | 222 ms | 17864 KB | Output is correct |
50 | Correct | 198 ms | 17876 KB | Output is correct |
51 | Correct | 207 ms | 17852 KB | Output is correct |
52 | Correct | 206 ms | 17796 KB | Output is correct |
53 | Correct | 206 ms | 17776 KB | Output is correct |