Submission #927723

# Submission time Handle Problem Language Result Execution time Memory
927723 2024-02-15T09:21:37 Z weakweakweak Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
215 ms 19792 KB
/*
5:05開始,也不算是virtual,因為我已經知道幾個人的分數了,也在去年資芽時聽過p4的題敘並想過。
所以就只是計時練習,應該會寫到19:05,然後等家長買晚餐回來吃後再把剩下的兩小時用一用,衝到div2就打div2
目標日本選訓!!
*/
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fs first 
#define sc second

pii nec[310000];
int a[310000], ans[310000];

int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        cin >> nec[i].fs;
        nec[i].sc = i;
    }
    sort (nec, nec + n + 1);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort (a, a + n);
    
    multiset<int>mst;
    for (int i = 0; i < n; i++) mst.insert(max(nec[i+1].fs - a[i], 0));
    ans[nec[0].sc] = *mst.rbegin();
    for (int i = 1; i <= n; i++) {
        auto it = mst.find( max(nec[i].fs - a[i-1], 0) );
        if (it != mst.end())  mst.erase(it);
        mst.insert( max(nec[i-1].fs - a[i-1], 0) );
        ans[nec[i].sc] = *mst.rbegin();
    }   

    for (int i = 0; i <= n; i++) cout << ans[i] << ' ';
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 2 ms 4440 KB Output is correct
20 Correct 2 ms 4444 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 2 ms 4444 KB Output is correct
25 Correct 2 ms 4696 KB Output is correct
26 Correct 2 ms 4700 KB Output is correct
27 Correct 2 ms 4592 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 2 ms 4696 KB Output is correct
31 Correct 2 ms 4700 KB Output is correct
32 Correct 2 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4556 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 2 ms 4700 KB Output is correct
18 Correct 2 ms 4444 KB Output is correct
19 Correct 2 ms 4440 KB Output is correct
20 Correct 2 ms 4444 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 2 ms 4444 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 2 ms 4444 KB Output is correct
25 Correct 2 ms 4696 KB Output is correct
26 Correct 2 ms 4700 KB Output is correct
27 Correct 2 ms 4592 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 2 ms 4696 KB Output is correct
31 Correct 2 ms 4700 KB Output is correct
32 Correct 2 ms 4700 KB Output is correct
33 Correct 147 ms 18616 KB Output is correct
34 Correct 148 ms 19304 KB Output is correct
35 Correct 132 ms 18768 KB Output is correct
36 Correct 147 ms 19280 KB Output is correct
37 Correct 144 ms 19792 KB Output is correct
38 Correct 137 ms 19760 KB Output is correct
39 Correct 181 ms 18516 KB Output is correct
40 Correct 183 ms 18520 KB Output is correct
41 Correct 185 ms 18772 KB Output is correct
42 Correct 185 ms 18816 KB Output is correct
43 Correct 202 ms 18580 KB Output is correct
44 Correct 123 ms 18000 KB Output is correct
45 Correct 126 ms 18236 KB Output is correct
46 Correct 128 ms 18120 KB Output is correct
47 Correct 126 ms 18316 KB Output is correct
48 Correct 140 ms 18480 KB Output is correct
49 Correct 195 ms 18996 KB Output is correct
50 Correct 215 ms 19008 KB Output is correct
51 Correct 192 ms 19000 KB Output is correct
52 Correct 201 ms 19136 KB Output is correct
53 Correct 192 ms 19028 KB Output is correct