답안 #99730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99730 2019-03-06T10:27:45 Z Fasho Exhibition (JOI19_ho_t2) C++14
100 / 100
87 ms 2812 KB
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int  
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i];
#define fo(i,x,y) for(int i=x;i<=y;i++)
using namespace std;

ll n,ar[N],sum,m;

lli p[N];

bool check(int x)
{
	if(x==0)
		return 1;

	int q=m;

	for(int i=n;i>=1 && q>m-x;i--)
	{
		if(p[i].se<=ar[q])
			q--;
		// cout<<q<<sp<<p[i].se<<sp<<ar[q]<<endl;
	}
	// cout<<q<<sp;
	if(q==m-x)
		return true;
	return false;
}


int main()
{
  fast;
  cin>>n>>m;
  fo(i,1,n)
    cin>>p[i].se>>p[i].fi;
  sort(p+1,p+n+1);
  fs(ar,m)
  // cout<<endl;
  sort(ar+1,ar+m+1);
  // fo(i,1,m)
  // 	cout<<ar[i]<<sp;
  // 	cout<<endl;
  int l=0,r=min(m,n);
  // fo(i,1,n)
  // cout<<p[i].se<<sp;
  // cout<<endl;
  while(l<r)
  {
    if(r-l==1)
    {
      if(check(r))
        l=r;

      break;
    }
    // cout<<endl;
    int mid=(l+r)/2;
    // cout<<mid<<sp<<check(mid)<<endl;
    if(check(mid))
      l=mid;
    else
      r=mid-1;
  }
  cout<<l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 380 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 56 ms 2720 KB Output is correct
39 Correct 56 ms 2680 KB Output is correct
40 Correct 49 ms 2680 KB Output is correct
41 Correct 59 ms 2680 KB Output is correct
42 Correct 63 ms 2808 KB Output is correct
43 Correct 64 ms 2560 KB Output is correct
44 Correct 87 ms 2680 KB Output is correct
45 Correct 59 ms 2808 KB Output is correct
46 Correct 86 ms 2680 KB Output is correct
47 Correct 57 ms 2424 KB Output is correct
48 Correct 54 ms 2424 KB Output is correct
49 Correct 42 ms 2176 KB Output is correct
50 Correct 55 ms 2296 KB Output is correct
51 Correct 58 ms 2680 KB Output is correct
52 Correct 67 ms 2680 KB Output is correct
53 Correct 57 ms 2680 KB Output is correct
54 Correct 52 ms 2680 KB Output is correct
55 Correct 72 ms 2680 KB Output is correct
56 Correct 35 ms 1912 KB Output is correct
57 Correct 22 ms 1152 KB Output is correct
58 Correct 34 ms 1912 KB Output is correct
59 Correct 42 ms 1912 KB Output is correct
60 Correct 22 ms 1152 KB Output is correct
61 Correct 39 ms 1660 KB Output is correct
62 Correct 57 ms 2680 KB Output is correct
63 Correct 75 ms 2680 KB Output is correct
64 Correct 62 ms 2652 KB Output is correct
65 Correct 67 ms 2680 KB Output is correct
66 Correct 58 ms 2680 KB Output is correct
67 Correct 60 ms 2780 KB Output is correct
68 Correct 60 ms 2680 KB Output is correct
69 Correct 67 ms 2652 KB Output is correct
70 Correct 77 ms 2680 KB Output is correct
71 Correct 61 ms 2652 KB Output is correct
72 Correct 56 ms 2680 KB Output is correct
73 Correct 62 ms 2812 KB Output is correct