Submission #120135

# Submission time Handle Problem Language Result Execution time Memory
120135 2019-06-23T14:09:59 Z Just_Solve_The_Problem Exhibition (JOI19_ho_t2) C++11
100 / 100
114 ms 6712 KB
#include <bits/stdc++.h>

#define ll long long
#define ok puts("OK");

using namespace std;

const int N = (int)3e5 + 7;

int n, m;
int s[N], v[N], c[N], pos[N];

main() {
  iota(pos, pos + N, 0);
  scanf("%d %d", &n, &m);
  vector <int> vec;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &s[i], &v[i]);
    vec.push_back(s[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &c[i]);
    vec.push_back(c[i]);
  }
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  for (int i = 1; i <= n; i++) {
    s[i] = lower_bound(vec.begin(), vec.end(), s[i]) - vec.begin() + 1;
  }
  for (int i = 1; i <= m; i++) {
    c[i] = lower_bound(vec.begin(),vec.end(), c[i]) - vec.begin() + 1;
  }
  sort(pos + 1, pos + n + 1, [&](const int &A, const int &B) {
    if (v[A] == v[B]) {
      return s[A] < s[B];
    }
    return v[A] < v[B];
  });
  sort(c + 1, c + m + 1);
  int cur = n;
  int ans = 0;
  for (int i = m; i >= 1 && cur > 0; i--) {
    while (cur > 0 && s[pos[cur]] > c[i]) {
      cur--;
    }
    ans += (cur > 0);
    cur--;
  }
  cout << ans;
}

Compilation message

joi2019_ho_t2.cpp:13:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &s[i], &v[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &c[i]);
     ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1536 KB Output is correct
2 Correct 3 ms 1536 KB Output is correct
3 Correct 4 ms 1536 KB Output is correct
4 Correct 3 ms 1536 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 3 ms 1536 KB Output is correct
7 Correct 3 ms 1536 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 3 ms 1536 KB Output is correct
10 Correct 3 ms 1536 KB Output is correct
11 Correct 3 ms 1536 KB Output is correct
12 Correct 2 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 4 ms 1536 KB Output is correct
15 Correct 3 ms 1536 KB Output is correct
16 Correct 3 ms 1536 KB Output is correct
17 Correct 3 ms 1536 KB Output is correct
18 Correct 3 ms 1536 KB Output is correct
19 Correct 3 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1536 KB Output is correct
2 Correct 3 ms 1536 KB Output is correct
3 Correct 4 ms 1536 KB Output is correct
4 Correct 3 ms 1536 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 3 ms 1536 KB Output is correct
7 Correct 3 ms 1536 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 3 ms 1536 KB Output is correct
10 Correct 3 ms 1536 KB Output is correct
11 Correct 3 ms 1536 KB Output is correct
12 Correct 2 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 4 ms 1536 KB Output is correct
15 Correct 3 ms 1536 KB Output is correct
16 Correct 3 ms 1536 KB Output is correct
17 Correct 3 ms 1536 KB Output is correct
18 Correct 3 ms 1536 KB Output is correct
19 Correct 3 ms 1536 KB Output is correct
20 Correct 4 ms 1536 KB Output is correct
21 Correct 4 ms 1536 KB Output is correct
22 Correct 6 ms 1536 KB Output is correct
23 Correct 4 ms 1536 KB Output is correct
24 Correct 4 ms 1536 KB Output is correct
25 Correct 4 ms 1536 KB Output is correct
26 Correct 4 ms 1536 KB Output is correct
27 Correct 4 ms 1536 KB Output is correct
28 Correct 5 ms 1536 KB Output is correct
29 Correct 4 ms 1536 KB Output is correct
30 Correct 4 ms 1536 KB Output is correct
31 Correct 3 ms 1536 KB Output is correct
32 Correct 4 ms 1536 KB Output is correct
33 Correct 4 ms 1536 KB Output is correct
34 Correct 4 ms 1536 KB Output is correct
35 Correct 4 ms 1536 KB Output is correct
36 Correct 4 ms 1536 KB Output is correct
37 Correct 4 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1536 KB Output is correct
2 Correct 3 ms 1536 KB Output is correct
3 Correct 4 ms 1536 KB Output is correct
4 Correct 3 ms 1536 KB Output is correct
5 Correct 3 ms 1536 KB Output is correct
6 Correct 3 ms 1536 KB Output is correct
7 Correct 3 ms 1536 KB Output is correct
8 Correct 3 ms 1536 KB Output is correct
9 Correct 3 ms 1536 KB Output is correct
10 Correct 3 ms 1536 KB Output is correct
11 Correct 3 ms 1536 KB Output is correct
12 Correct 2 ms 1536 KB Output is correct
13 Correct 3 ms 1536 KB Output is correct
14 Correct 4 ms 1536 KB Output is correct
15 Correct 3 ms 1536 KB Output is correct
16 Correct 3 ms 1536 KB Output is correct
17 Correct 3 ms 1536 KB Output is correct
18 Correct 3 ms 1536 KB Output is correct
19 Correct 3 ms 1536 KB Output is correct
20 Correct 4 ms 1536 KB Output is correct
21 Correct 4 ms 1536 KB Output is correct
22 Correct 6 ms 1536 KB Output is correct
23 Correct 4 ms 1536 KB Output is correct
24 Correct 4 ms 1536 KB Output is correct
25 Correct 4 ms 1536 KB Output is correct
26 Correct 4 ms 1536 KB Output is correct
27 Correct 4 ms 1536 KB Output is correct
28 Correct 5 ms 1536 KB Output is correct
29 Correct 4 ms 1536 KB Output is correct
30 Correct 4 ms 1536 KB Output is correct
31 Correct 3 ms 1536 KB Output is correct
32 Correct 4 ms 1536 KB Output is correct
33 Correct 4 ms 1536 KB Output is correct
34 Correct 4 ms 1536 KB Output is correct
35 Correct 4 ms 1536 KB Output is correct
36 Correct 4 ms 1536 KB Output is correct
37 Correct 4 ms 1536 KB Output is correct
38 Correct 106 ms 6484 KB Output is correct
39 Correct 86 ms 6568 KB Output is correct
40 Correct 71 ms 6508 KB Output is correct
41 Correct 107 ms 6464 KB Output is correct
42 Correct 105 ms 6520 KB Output is correct
43 Correct 107 ms 6508 KB Output is correct
44 Correct 112 ms 6508 KB Output is correct
45 Correct 109 ms 6712 KB Output is correct
46 Correct 101 ms 6480 KB Output is correct
47 Correct 97 ms 6000 KB Output is correct
48 Correct 87 ms 6048 KB Output is correct
49 Correct 90 ms 5616 KB Output is correct
50 Correct 82 ms 5616 KB Output is correct
51 Correct 106 ms 6504 KB Output is correct
52 Correct 108 ms 6512 KB Output is correct
53 Correct 105 ms 6508 KB Output is correct
54 Correct 56 ms 6508 KB Output is correct
55 Correct 108 ms 6508 KB Output is correct
56 Correct 63 ms 4720 KB Output is correct
57 Correct 44 ms 3324 KB Output is correct
58 Correct 48 ms 4720 KB Output is correct
59 Correct 64 ms 4728 KB Output is correct
60 Correct 45 ms 3352 KB Output is correct
61 Correct 70 ms 5104 KB Output is correct
62 Correct 108 ms 6508 KB Output is correct
63 Correct 110 ms 6508 KB Output is correct
64 Correct 110 ms 6508 KB Output is correct
65 Correct 110 ms 6508 KB Output is correct
66 Correct 111 ms 6528 KB Output is correct
67 Correct 109 ms 6480 KB Output is correct
68 Correct 111 ms 6508 KB Output is correct
69 Correct 103 ms 6508 KB Output is correct
70 Correct 114 ms 6568 KB Output is correct
71 Correct 91 ms 6508 KB Output is correct
72 Correct 102 ms 6480 KB Output is correct
73 Correct 79 ms 6528 KB Output is correct