답안 #230628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230628 2020-05-10T16:20:46 Z AlexLuchianov Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
337 ms 18680 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <set>

using namespace std;

using ll = long long;

int const nmax = 200000;
pair<int,int> v[5 + nmax];
int b[5 + nmax], sol[5 + nmax];
multiset<int> myset;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n;
  cin >> n;
  for(int i = 1;i <= n + 1; i++) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v + 1, v + n + 1 + 1);
  for(int i = 1;i <= n; i++)
    cin >> b[i];
  sort(b + 1, b + n + 1);
  for(int i = 1; i <= n; i++)
    myset.insert(max(0,v[i + 1].first - b[i]));
  sol[v[1].second] = *myset.rbegin();

  for(int i = 2;i <= n + 1; i++){
    myset.erase(myset.find(max(0, v[i].first - b[i - 1])));
    myset.insert(max(0, v[i - 1].first - b[i - 1]));
    sol[v[i].second] = *myset.rbegin();
  }
  for(int i = 1;i <= n + 1; i++)
    cout << sol[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 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 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 5 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 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 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 5 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 7 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 6 ms 512 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 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 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 5 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 7 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 6 ms 512 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 223 ms 17528 KB Output is correct
34 Correct 244 ms 18296 KB Output is correct
35 Correct 215 ms 17656 KB Output is correct
36 Correct 231 ms 18168 KB Output is correct
37 Correct 241 ms 18680 KB Output is correct
38 Correct 230 ms 18424 KB Output is correct
39 Correct 311 ms 17616 KB Output is correct
40 Correct 306 ms 17400 KB Output is correct
41 Correct 337 ms 17784 KB Output is correct
42 Correct 299 ms 17536 KB Output is correct
43 Correct 308 ms 17528 KB Output is correct
44 Correct 193 ms 16840 KB Output is correct
45 Correct 192 ms 17020 KB Output is correct
46 Correct 194 ms 16916 KB Output is correct
47 Correct 184 ms 17272 KB Output is correct
48 Correct 193 ms 17272 KB Output is correct
49 Correct 314 ms 17988 KB Output is correct
50 Correct 307 ms 17912 KB Output is correct
51 Correct 306 ms 18040 KB Output is correct
52 Correct 333 ms 17912 KB Output is correct
53 Correct 318 ms 18040 KB Output is correct