답안 #533604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533604 2022-03-06T15:35:39 Z alvingogo Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define cd complex<double>
#define p_q priority_queue
using namespace std;


int main(){
	AquA;
	int n,m;
	cin >> n >> m;
	vector<pair<int,int> > v(n);
	vector<int> p(m);
	for(int i=0;i<n;i++){
		cin >> v[i].sc >> v[i].fs;
	}
	sort(v.begin(),v.end());
	for(int i=0;i<m;i++){
		cin >> p[i];
	}
	sort(p.begin(),p.end());
	int nw=0;
	vector<pair<int,int> > z;
	for(int i=0;i<n;i++){
		nw=lower_bound(p.begin(),p.end(),v[i].sc)-p.begin();
		if(nw==m){
			continue;
		}
		auto h=upper_bound(z.begin(),z.end(),pair<int,int>(v[i].sc,1e9+7))-z.begin();
		int a=h==0?nw:max(z[h-1].sc+1,nw);
		if(a>=m){
			continue;
		}
		if(h==z.size()){
			z.push_back({v[i].sc,a});
		}
		else{
			z[h].fs=v[i].sc;
			z[h].sc=a;
		}
	}
	cout << z.size() << "\n";
	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:37:7: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   if(h==z.size()){
      |      ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -