답안 #231784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231784 2020-05-14T18:08:37 Z Haunted_Cpp Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
297 ms 15096 KB
#include <bits/stdc++.h>
 
using namespace std;

#pragma GCC optimize ("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > a (n + 1);
  for (int i = 0; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  vector<int> pessoas (n);
  for (int i = 0; i < n; i++) cin >> pessoas[i];
  sort (a.begin(), a.end());
  sort (pessoas.begin(), pessoas.end());
  multiset<int> diff;
  for (int i = 0; i < n; i++) diff.insert( max (a[i].first - pessoas[i], 0) );
  vector<int> ans (n + 1, -1);
  ans[a[n].second] = *diff.rbegin();
  int last = a[n].first;
  for (int i = n - 1; i >= 0; i--) {
    int current = max (a[i].first - pessoas[i], 0);
    diff.erase(diff.lower_bound(current));
    diff.insert( max (last - pessoas[i], 0) );
    ans[a[i].second] = *diff.rbegin();
    last = a[i].first;
  }
  for (int i = 0; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 492 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 492 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 7 ms 472 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 492 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 6 ms 512 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 6 ms 512 KB Output is correct
22 Correct 7 ms 472 KB Output is correct
23 Correct 6 ms 512 KB Output is correct
24 Correct 6 ms 512 KB Output is correct
25 Correct 6 ms 512 KB Output is correct
26 Correct 6 ms 512 KB Output is correct
27 Correct 6 ms 512 KB Output is correct
28 Correct 6 ms 512 KB Output is correct
29 Correct 6 ms 512 KB Output is correct
30 Correct 6 ms 512 KB Output is correct
31 Correct 6 ms 512 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
33 Correct 229 ms 14208 KB Output is correct
34 Correct 227 ms 14584 KB Output is correct
35 Correct 205 ms 14200 KB Output is correct
36 Correct 221 ms 14712 KB Output is correct
37 Correct 237 ms 15096 KB Output is correct
38 Correct 230 ms 15000 KB Output is correct
39 Correct 270 ms 13980 KB Output is correct
40 Correct 281 ms 13944 KB Output is correct
41 Correct 262 ms 14072 KB Output is correct
42 Correct 265 ms 13944 KB Output is correct
43 Correct 259 ms 13944 KB Output is correct
44 Correct 197 ms 13432 KB Output is correct
45 Correct 196 ms 13564 KB Output is correct
46 Correct 195 ms 13432 KB Output is correct
47 Correct 184 ms 13688 KB Output is correct
48 Correct 201 ms 13692 KB Output is correct
49 Correct 297 ms 14328 KB Output is correct
50 Correct 275 ms 14456 KB Output is correct
51 Correct 267 ms 14328 KB Output is correct
52 Correct 293 ms 14432 KB Output is correct
53 Correct 276 ms 14328 KB Output is correct