Submission #1114640

# Submission time Handle Problem Language Result Execution time Memory
1114640 2024-11-19T09:49:01 Z AdamGS Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
158 ms 7132 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int tr[1<<19];
int odp[200000];
void zm(int ind,int val){
    tr[ind]=val;
    ind/=2;
    while (ind>0){
        tr[ind]=max(tr[ind*2],tr[ind*2+1]);
        ind/=2;
    }
}
int main()
{
    int n,dltr=1;
    cin >> n;
    while (dltr<n) dltr*=2;
    vector<pair<int,int>> a(n+1);
    vector<int> b(n);
    for (int i=0; i<n+1; i++){
        cin >> a[i].first;
        a[i].second=i;
    }
    for (int i=0; i<n; i++) cin >> b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    //for (int i=0; i<n+1; i++) cout << a[i].first << ' ' << a[i].second << '\n';
    for (int i=0; i<n; i++) tr[dltr+i]=max(a[i+1].first-b[i],0);
    for (int i=dltr-1; 0<i; i--) tr[i]=max(tr[i*2],tr[i*2+1]);
    //for (int i=0; i<dltr*2; i++) cout << tr[i] <<' ';
    //cout << '\n';
    odp[a[0].second]=tr[1];
    for (int i=0; i<n; i++){
        zm(i+dltr,a[i].first-b[i]);
        //for (int i=0; i<dltr*2; i++) cout << tr[i] <<' ';
        //cout << '\n';
        odp[a[i+1].second]=tr[1];
    }
    for (int i=0; i<n+1; i++) cout << odp[i] << ' ';
    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 2 ms 2552 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 3 ms 2384 KB Output is correct
18 Correct 2 ms 2512 KB Output is correct
19 Correct 2 ms 2384 KB Output is correct
20 Correct 2 ms 2384 KB Output is correct
21 Correct 3 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 3 ms 2384 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 2 ms 2384 KB Output is correct
26 Correct 3 ms 2384 KB Output is correct
27 Correct 2 ms 2384 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
29 Correct 2 ms 2384 KB Output is correct
30 Correct 3 ms 2384 KB Output is correct
31 Correct 2 ms 2384 KB Output is correct
32 Correct 2 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 2 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 2 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 2 ms 2384 KB Output is correct
14 Correct 2 ms 2384 KB Output is correct
15 Correct 2 ms 2552 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 3 ms 2384 KB Output is correct
18 Correct 2 ms 2512 KB Output is correct
19 Correct 2 ms 2384 KB Output is correct
20 Correct 2 ms 2384 KB Output is correct
21 Correct 3 ms 2384 KB Output is correct
22 Correct 2 ms 2384 KB Output is correct
23 Correct 3 ms 2384 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 2 ms 2384 KB Output is correct
26 Correct 3 ms 2384 KB Output is correct
27 Correct 2 ms 2384 KB Output is correct
28 Correct 2 ms 2384 KB Output is correct
29 Correct 2 ms 2384 KB Output is correct
30 Correct 3 ms 2384 KB Output is correct
31 Correct 2 ms 2384 KB Output is correct
32 Correct 2 ms 2384 KB Output is correct
33 Correct 142 ms 6524 KB Output is correct
34 Correct 142 ms 6728 KB Output is correct
35 Correct 136 ms 6728 KB Output is correct
36 Correct 137 ms 6984 KB Output is correct
37 Correct 147 ms 7132 KB Output is correct
38 Correct 146 ms 7104 KB Output is correct
39 Correct 137 ms 6216 KB Output is correct
40 Correct 138 ms 6308 KB Output is correct
41 Correct 143 ms 6216 KB Output is correct
42 Correct 151 ms 6316 KB Output is correct
43 Correct 136 ms 6216 KB Output is correct
44 Correct 138 ms 6008 KB Output is correct
45 Correct 143 ms 5960 KB Output is correct
46 Correct 141 ms 5960 KB Output is correct
47 Correct 152 ms 5864 KB Output is correct
48 Correct 143 ms 5864 KB Output is correct
49 Correct 148 ms 6476 KB Output is correct
50 Correct 142 ms 6376 KB Output is correct
51 Correct 148 ms 6380 KB Output is correct
52 Correct 147 ms 6472 KB Output is correct
53 Correct 158 ms 6372 KB Output is correct