Submission #202722

# Submission time Handle Problem Language Result Execution time Memory
202722 2020-02-17T20:54:59 Z achibasadzishvili Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
366 ms 18040 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,b[200005],an[200005];
pair<ll,ll>a[200005];
multiset<ll>st;
multiset<ll>::iterator it;
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    
    for(int i=1; i<=n + 1; i++){
        cin >> a[i].f;
        a[i].s = i;
    }
    
    sort(a + 1 , a + n + 2);
    
    for(int i=1; i<=n; i++){
        cin >> b[i];
    }
    
    sort(b + 1 , b + n + 1);
    
    for(int i=1; i<=n; i++){
        st.insert(max(0LL , a[i + 1].f - b[i]));
    }
    it = st.end();
    it--;
    an[a[1].s] = (*it);
    
    for(int i=2; i<=n + 1; i++){
        st.erase(st.find(max(0LL , a[i].f - b[i - 1])));
        st.insert(max(0LL , a[i - 1].f - b[i - 1]));
        it = st.end();
        it--;
        an[a[i].s] = (*it);
    }
    
    for(int i=1; i<=n + 1; i++)
        cout << an[i] << " ";
    
    
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 7 ms 504 KB Output is correct
18 Correct 6 ms 508 KB Output is correct
19 Correct 7 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 6 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 7 ms 504 KB Output is correct
18 Correct 6 ms 508 KB Output is correct
19 Correct 7 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 6 ms 504 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 6 ms 504 KB Output is correct
27 Correct 8 ms 504 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 7 ms 504 KB Output is correct
32 Correct 6 ms 508 KB Output is correct
33 Correct 234 ms 16760 KB Output is correct
34 Correct 272 ms 17412 KB Output is correct
35 Correct 222 ms 16888 KB Output is correct
36 Correct 254 ms 17400 KB Output is correct
37 Correct 266 ms 18040 KB Output is correct
38 Correct 243 ms 17784 KB Output is correct
39 Correct 339 ms 16764 KB Output is correct
40 Correct 339 ms 16632 KB Output is correct
41 Correct 335 ms 16888 KB Output is correct
42 Correct 345 ms 16888 KB Output is correct
43 Correct 331 ms 16632 KB Output is correct
44 Correct 199 ms 16248 KB Output is correct
45 Correct 202 ms 16376 KB Output is correct
46 Correct 201 ms 16248 KB Output is correct
47 Correct 196 ms 16504 KB Output is correct
48 Correct 208 ms 16504 KB Output is correct
49 Correct 349 ms 17144 KB Output is correct
50 Correct 347 ms 17352 KB Output is correct
51 Correct 366 ms 17272 KB Output is correct
52 Correct 340 ms 17148 KB Output is correct
53 Correct 355 ms 17272 KB Output is correct