답안 #921417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921417 2024-02-03T19:54:20 Z AverageAmogusEnjoyer Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
297 ms 19532 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; }
template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; }
constexpr int nax = 200200;
pair<int,int> a[nax];
int b[nax];
int n;
ll ans[nax];
int main() {
    cin >> n;
    for (int i=0;i<=n;i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i=0;i<n;i++) {
        cin >> b[i];
    }
    sort(a,a+n+1);
    sort(b,b+n);
    multiset<ll> res;
    for (int i=0;i<n;i++) {
        res.insert(max(0,a[i+1].first-b[i]));
    }
    ans[a[0].second] = *res.rbegin();
    for (int i=1;i<=n;i++) {
        res.erase(res.find(max(0,a[i].first-b[i-1])));
        res.insert(max(0,a[i-1].first-b[i-1])); 
        ans[a[i].second] = *res.rbegin();
    }
    for (int i=0;i<=n;i++) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2484 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2484 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 2 ms 2396 KB Output is correct
25 Correct 3 ms 2652 KB Output is correct
26 Correct 2 ms 2648 KB Output is correct
27 Correct 2 ms 2648 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2392 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2484 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 2 ms 2396 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 2 ms 2396 KB Output is correct
20 Correct 2 ms 2396 KB Output is correct
21 Correct 2 ms 2396 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 2 ms 2396 KB Output is correct
25 Correct 3 ms 2652 KB Output is correct
26 Correct 2 ms 2648 KB Output is correct
27 Correct 2 ms 2648 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2392 KB Output is correct
30 Correct 2 ms 2396 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 2 ms 2652 KB Output is correct
33 Correct 267 ms 18296 KB Output is correct
34 Correct 227 ms 19024 KB Output is correct
35 Correct 225 ms 18280 KB Output is correct
36 Correct 224 ms 18772 KB Output is correct
37 Correct 247 ms 19532 KB Output is correct
38 Correct 226 ms 19300 KB Output is correct
39 Correct 268 ms 18080 KB Output is correct
40 Correct 257 ms 18144 KB Output is correct
41 Correct 265 ms 18260 KB Output is correct
42 Correct 264 ms 18256 KB Output is correct
43 Correct 254 ms 18184 KB Output is correct
44 Correct 214 ms 17772 KB Output is correct
45 Correct 217 ms 17692 KB Output is correct
46 Correct 201 ms 17744 KB Output is correct
47 Correct 208 ms 18212 KB Output is correct
48 Correct 211 ms 18000 KB Output is correct
49 Correct 277 ms 18692 KB Output is correct
50 Correct 272 ms 18780 KB Output is correct
51 Correct 278 ms 18616 KB Output is correct
52 Correct 297 ms 18772 KB Output is correct
53 Correct 280 ms 18968 KB Output is correct