이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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].fs >> v[i].sc;
}
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++){
while(nw<m && p[nw]<v[i].fs){
nw++;
}
if(nw==m){
break;
}
//cout << nw << " " << p[nw] << endl;
auto h=upper_bound(z.begin(),z.end(),pair<int,int>(v[i].sc,-1))-z.begin();
//cout << h << endl;
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;
}
//nw++;
}
cout << z.size() << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:41: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]
41 | if(h==z.size()){
| ~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |