Submission #362804

# Submission time Handle Problem Language Result Execution time Memory
362804 2021-02-04T11:59:17 Z Pety Exhibition (JOI19_ho_t2) C++14
100 / 100
918 ms 9668 KB
#include <bits/stdc++.h>


using namespace std;

int n, m;
struct painting {
  int s, value;
  bool operator < (const painting &a) const {
    return s < a.s;
  }
} v[100002];
int pref[100002], c[100002];

bool check (int x) {
  int p = 1;
  multiset<int>s;
  int last = 0;
  for (int i = x; i >= 1; i--) {
    while (p <= pref[i]) {
      s.insert(v[p].value);
      p++;
    }
    if (s.empty())
      return 0;
    else {
      auto it = s.lower_bound(last);
      if (it == s.end())
        return 0;
      last = *it;
      s.erase(it);
    }
  }
  return 1;
}

int main ()
{
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> v[i].s >> v[i].value;
  }
  sort(v + 1, v + n + 1);
  for (int i = 1; i <= m; i++)
    cin >> c[i];
  sort(c + 1, c + m + 1, greater<int>());
  int p = 1;
  for (int i = m; i >= 1; i--) {
    while (p <= n && v[p].s <= c[i])
      p++;
    pref[i] = p - 1;
  }
  int st = 1, dr = m, ans = 0;
  while (st <= dr) {
    int mij = (st + dr) / 2;
    if (check(mij)) {
      st = mij + 1;
      ans = mij;
    }
    else
      dr = mij - 1;
  }
  cout << ans;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 3 ms 364 KB Output is correct
21 Correct 4 ms 364 KB Output is correct
22 Correct 3 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 3 ms 364 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 4 ms 364 KB Output is correct
30 Correct 3 ms 364 KB Output is correct
31 Correct 3 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 5 ms 364 KB Output is correct
37 Correct 3 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 3 ms 364 KB Output is correct
21 Correct 4 ms 364 KB Output is correct
22 Correct 3 ms 364 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 3 ms 364 KB Output is correct
25 Correct 3 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 2 ms 364 KB Output is correct
29 Correct 4 ms 364 KB Output is correct
30 Correct 3 ms 364 KB Output is correct
31 Correct 3 ms 364 KB Output is correct
32 Correct 2 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 2 ms 364 KB Output is correct
36 Correct 5 ms 364 KB Output is correct
37 Correct 3 ms 364 KB Output is correct
38 Correct 321 ms 7340 KB Output is correct
39 Correct 317 ms 7276 KB Output is correct
40 Correct 540 ms 7696 KB Output is correct
41 Correct 304 ms 7276 KB Output is correct
42 Correct 140 ms 4844 KB Output is correct
43 Correct 144 ms 4844 KB Output is correct
44 Correct 398 ms 7148 KB Output is correct
45 Correct 802 ms 8856 KB Output is correct
46 Correct 658 ms 8940 KB Output is correct
47 Correct 825 ms 7948 KB Output is correct
48 Correct 704 ms 7944 KB Output is correct
49 Correct 527 ms 6764 KB Output is correct
50 Correct 516 ms 6764 KB Output is correct
51 Correct 144 ms 4844 KB Output is correct
52 Correct 150 ms 4816 KB Output is correct
53 Correct 141 ms 4716 KB Output is correct
54 Correct 918 ms 9668 KB Output is correct
55 Correct 313 ms 7276 KB Output is correct
56 Correct 107 ms 5356 KB Output is correct
57 Correct 50 ms 2028 KB Output is correct
58 Correct 333 ms 7788 KB Output is correct
59 Correct 571 ms 7788 KB Output is correct
60 Correct 51 ms 2284 KB Output is correct
61 Correct 288 ms 4204 KB Output is correct
62 Correct 677 ms 7276 KB Output is correct
63 Correct 685 ms 7224 KB Output is correct
64 Correct 768 ms 7276 KB Output is correct
65 Correct 722 ms 7404 KB Output is correct
66 Correct 688 ms 7276 KB Output is correct
67 Correct 708 ms 7240 KB Output is correct
68 Correct 680 ms 7148 KB Output is correct
69 Correct 701 ms 7276 KB Output is correct
70 Correct 673 ms 7372 KB Output is correct
71 Correct 680 ms 7276 KB Output is correct
72 Correct 655 ms 7276 KB Output is correct
73 Correct 705 ms 7428 KB Output is correct