답안 #305839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305839 2020-09-24T02:26:22 Z T0p_ Exhibition (JOI19_ho_t2) C++14
100 / 100
105 ms 2424 KB
#include<bits/stdc++.h>
using namespace std;
 
struct picture
{
	int s, v;
	bool operator < (const picture & o) const
	{
		return (v == o.v) ? s < o.s : v < o.v;	
	}
};
 
picture p[100100];
int f[100100], arr[100100];
stack<int> stk;
 
int main()
{
	int n, m;
	scanf(" %d %d",&n,&m);
	for(int i=1 ; i<=n ; i++)
		scanf(" %d %d",&p[i].s,&p[i].v);
	for(int i=1 ; i<=m ; i++)
		scanf(" %d",&f[i]);
	sort(p+1, p+n+1);
	sort(f+1, f+m+1);
	for(int i=1 ; i<=n ; i++)
	{	
		int l = 1, r = m+1;
		while(l != r)
		{
			int mid = (l+r)>>1;
			(p[i].s <= f[mid]) ? r = mid : l = mid+1;
		}
		arr[i] = l;
	}
	for(int i=n ; i>=1 ; i--)
	{
		if(arr[i] == m+1) continue ;
		if(stk.empty()) stk.push(m);
		else if(arr[i] < stk.top())
		{
			stk.push(stk.top()-1);
		}
	}
	printf("%d\n",stk.size());
	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:46:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   46 |  printf("%d\n",stk.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::stack<int>::size_type {aka long unsigned int}
      |          %ld
joi2019_ho_t2.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf(" %d %d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf(" %d %d",&p[i].s,&p[i].v);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf(" %d",&f[i]);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 79 ms 2296 KB Output is correct
39 Correct 73 ms 2296 KB Output is correct
40 Correct 67 ms 2296 KB Output is correct
41 Correct 80 ms 2300 KB Output is correct
42 Correct 78 ms 1912 KB Output is correct
43 Correct 77 ms 1912 KB Output is correct
44 Correct 81 ms 2060 KB Output is correct
45 Correct 85 ms 2296 KB Output is correct
46 Correct 77 ms 2424 KB Output is correct
47 Correct 78 ms 2040 KB Output is correct
48 Correct 69 ms 2040 KB Output is correct
49 Correct 68 ms 1784 KB Output is correct
50 Correct 63 ms 1912 KB Output is correct
51 Correct 75 ms 1912 KB Output is correct
52 Correct 75 ms 1912 KB Output is correct
53 Correct 92 ms 1912 KB Output is correct
54 Correct 60 ms 2296 KB Output is correct
55 Correct 76 ms 2296 KB Output is correct
56 Correct 48 ms 1528 KB Output is correct
57 Correct 28 ms 760 KB Output is correct
58 Correct 44 ms 1528 KB Output is correct
59 Correct 56 ms 1656 KB Output is correct
60 Correct 28 ms 768 KB Output is correct
61 Correct 48 ms 1272 KB Output is correct
62 Correct 88 ms 2168 KB Output is correct
63 Correct 89 ms 2168 KB Output is correct
64 Correct 89 ms 2180 KB Output is correct
65 Correct 91 ms 2168 KB Output is correct
66 Correct 90 ms 2168 KB Output is correct
67 Correct 88 ms 2176 KB Output is correct
68 Correct 90 ms 2168 KB Output is correct
69 Correct 105 ms 2124 KB Output is correct
70 Correct 89 ms 2168 KB Output is correct
71 Correct 89 ms 2168 KB Output is correct
72 Correct 82 ms 2168 KB Output is correct
73 Correct 82 ms 2296 KB Output is correct