Submission #136791

# Submission time Handle Problem Language Result Execution time Memory
136791 2019-07-26T09:00:04 Z ekrem Exhibition (JOI19_ho_t2) C++
100 / 100
157 ms 6656 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define coc g[node][i]
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)>>1)
#define mod 1000000007
#define inf 1000000009
#define N 1000005

using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, m, ind = 1, k, a[N], c[N], ne[N];
ii b[N];
set < ii > s;

int main(){
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&m);
	for(int i = 1; i <= n; i++){
		scanf("%d %d",&b[i].st ,&b[i].nd);
		// s.insert(mp(b[i].nd, i));
		// cout << b[i].nd << " ";
	}
	sort(b + 1, b + n + 1);
	for(int i = 1; i <= n; i++)
		s.insert(mp(b[i].nd, i));
	ind = n;
	for(int i = 1; i <= m; i++)
		scanf("%d",a + i);
	sort(a + 1, a + m + 1);
	// reverse(a + 1, a + m + 1);
	// cout << "geldi" << endl;
	for(int i = m; i >= 1; i--){
		while(ind >= 1 and b[ind].st > a[i]){
			// cout << "geldi " << b[ind].nd << endl;
			s.erase(mp(b[ind].nd, ind));
			ind--;
		}
		if(!s.empty()){
			ii ek = *s.rbegin();
			// cout << ek.st << " buldum" << endl;
			c[++k] = ek.st;
			s.erase(ek);
		}
	}
	printf("%d\n", k);
	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:26:7: 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:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&b[i].st ,&b[i].nd);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a + i);
   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 12 ms 352 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 6 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 12 ms 352 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 6 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 380 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 476 KB Output is correct
29 Correct 3 ms 380 KB Output is correct
30 Correct 3 ms 424 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 12 ms 352 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 380 KB Output is correct
17 Correct 6 ms 380 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 380 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 476 KB Output is correct
29 Correct 3 ms 380 KB Output is correct
30 Correct 3 ms 424 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 123 ms 6624 KB Output is correct
39 Correct 116 ms 6568 KB Output is correct
40 Correct 109 ms 6576 KB Output is correct
41 Correct 122 ms 6544 KB Output is correct
42 Correct 110 ms 6244 KB Output is correct
43 Correct 110 ms 6236 KB Output is correct
44 Correct 115 ms 6396 KB Output is correct
45 Correct 134 ms 6632 KB Output is correct
46 Correct 117 ms 6572 KB Output is correct
47 Correct 139 ms 6296 KB Output is correct
48 Correct 118 ms 6392 KB Output is correct
49 Correct 97 ms 4856 KB Output is correct
50 Correct 89 ms 4864 KB Output is correct
51 Correct 157 ms 6180 KB Output is correct
52 Correct 155 ms 6208 KB Output is correct
53 Correct 150 ms 6244 KB Output is correct
54 Correct 100 ms 6636 KB Output is correct
55 Correct 116 ms 6656 KB Output is correct
56 Correct 109 ms 5752 KB Output is correct
57 Correct 29 ms 760 KB Output is correct
58 Correct 74 ms 5752 KB Output is correct
59 Correct 120 ms 5840 KB Output is correct
60 Correct 29 ms 760 KB Output is correct
61 Correct 64 ms 2680 KB Output is correct
62 Correct 145 ms 6568 KB Output is correct
63 Correct 152 ms 6520 KB Output is correct
64 Correct 148 ms 6472 KB Output is correct
65 Correct 147 ms 6540 KB Output is correct
66 Correct 151 ms 6532 KB Output is correct
67 Correct 147 ms 6496 KB Output is correct
68 Correct 151 ms 6508 KB Output is correct
69 Correct 153 ms 6640 KB Output is correct
70 Correct 147 ms 6464 KB Output is correct
71 Correct 142 ms 6492 KB Output is correct
72 Correct 121 ms 6520 KB Output is correct
73 Correct 117 ms 6524 KB Output is correct