답안 #227363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227363 2020-04-27T07:11:15 Z bharat2002 Exhibition (JOI19_ho_t2) C++14
100 / 100
387 ms 24552 KB
/*input
8 8
15 1
12 3
14 4
22 6
23 10
5 16
18 19
13 20
11
24
2
21
8
9
17
7
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second 
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl 
//Trace prints the name of the variable and the value.
int n, m, arr[N];
struct comp
{
	bool operator()(pii a, pii b)
	{
		if(a.f==b.f) return a.s<=b.s;return a.f<b.f;
	}
};
priority_queue< pii, vector< pii>, comp > pq;
bool sf(int a, int b)
{
	return a>b;
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;map<int, int> vals;
	for(int i=1;i<=n;i++)
	{
		int ss, v;cin>>ss>>v;pq.push(mp(v, ss));vals[ss]=vals[v]=0;
	}
	for(int i=1;i<=m;i++) {cin>>arr[i];vals[arr[i]]=0;}
/*	int ct=1;
	for(auto &it:vals) it.s=ct++;
	while(!pq.empty())
	{
		cout<<vals[pq.top().s]<<" "<<vals[pq.top().f]<<endl;pq.pop();
	}
	for(int i=1;i<=m;i++) cout<<vals[arr[i]]<<endl;return 0;*/
	sort(arr+1, arr+m+1, sf);;
	
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		while(!pq.empty()&&pq.top().s>arr[i]) pq.pop();
		if(pq.empty()) break;
		ans++;pq.pop();
	}
	cout<<ans;
}

Compilation message

joi2019_ho_t2.cpp: In member function 'bool comp::operator()(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
joi2019_ho_t2.cpp:38:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(a.f==b.f) return a.s<=b.s;return a.f<b.f;
   ^~
joi2019_ho_t2.cpp:38:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(a.f==b.f) return a.s<=b.s;return a.f<b.f;
                                ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 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 6 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 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 6 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 6 ms 640 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 640 KB Output is correct
27 Correct 6 ms 640 KB Output is correct
28 Correct 7 ms 640 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 384 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 6 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 7 ms 640 KB Output is correct
37 Correct 6 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 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 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 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 6 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 6 ms 512 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 6 ms 640 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 640 KB Output is correct
27 Correct 6 ms 640 KB Output is correct
28 Correct 7 ms 640 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 384 KB Output is correct
32 Correct 6 ms 512 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 6 ms 512 KB Output is correct
35 Correct 6 ms 512 KB Output is correct
36 Correct 7 ms 640 KB Output is correct
37 Correct 6 ms 640 KB Output is correct
38 Correct 352 ms 18148 KB Output is correct
39 Correct 115 ms 5900 KB Output is correct
40 Correct 86 ms 5776 KB Output is correct
41 Correct 186 ms 11620 KB Output is correct
42 Correct 272 ms 24420 KB Output is correct
43 Correct 269 ms 24420 KB Output is correct
44 Correct 257 ms 18148 KB Output is correct
45 Correct 328 ms 24540 KB Output is correct
46 Correct 143 ms 11876 KB Output is correct
47 Correct 247 ms 21988 KB Output is correct
48 Correct 137 ms 9556 KB Output is correct
49 Correct 214 ms 19556 KB Output is correct
50 Correct 116 ms 8936 KB Output is correct
51 Correct 384 ms 24424 KB Output is correct
52 Correct 387 ms 24420 KB Output is correct
53 Correct 306 ms 24268 KB Output is correct
54 Correct 117 ms 11876 KB Output is correct
55 Correct 272 ms 18148 KB Output is correct
56 Correct 191 ms 16356 KB Output is correct
57 Correct 73 ms 8376 KB Output is correct
58 Correct 46 ms 3964 KB Output is correct
59 Correct 221 ms 16488 KB Output is correct
60 Correct 78 ms 8440 KB Output is correct
61 Correct 121 ms 11928 KB Output is correct
62 Correct 317 ms 24420 KB Output is correct
63 Correct 297 ms 24420 KB Output is correct
64 Correct 293 ms 24420 KB Output is correct
65 Correct 302 ms 24316 KB Output is correct
66 Correct 309 ms 24420 KB Output is correct
67 Correct 292 ms 24420 KB Output is correct
68 Correct 318 ms 24552 KB Output is correct
69 Correct 191 ms 12260 KB Output is correct
70 Correct 233 ms 18408 KB Output is correct
71 Correct 172 ms 12132 KB Output is correct
72 Correct 123 ms 7140 KB Output is correct
73 Correct 111 ms 7144 KB Output is correct