이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define pb push_back
#define fi first
#define se second
#define debug(x) cout << #x << " => " << x << endl
#define all(x) x.begin(),x.end()
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n,m;cin>>n>>m;
pii a[n];
int b[m];
for(int i=0;i<n;i++) cin>>a[i].se>>a[i].fi;
for(int i=0;i<m;i++) cin>>b[i];
sort(a,a+n);
sort(b,b+m);
vector<int> v,idx;
for(int i=0;i<n;i++)
{
int x1=lower_bound(b,b+m,a[i].se)-b,x2=x1;
int y1=lower_bound(all(v),a[i].se)-v.begin(),y2=upper_bound(all(v),a[i].se)-v.begin();
if(y1>0) x1=max(x1,idx[y1-1]+1);
if(y1!=v.size() && idx[y1]>x1)
{
v[y1]=a[i].se;
idx[y1]=x1;
continue;
}
if(y2>0) x2=max(x2,idx[y2-1]+1);
if(x2==m) continue;
if(y2==v.size())
{
v.pb(a[i].se);
idx.pb(x2);
}
else
{
v[y2]=a[i].se;
idx[y2]=x2;
}
// for(auto j : v) cout<<j<<' ';cout<<'\n';
// for(auto j : idx) cout<<j<<' ';cout<<'\n';
}
cout<<v.size();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(y1!=v.size() && idx[y1]>x1)
| ~~^~~~~~~~~~
joi2019_ho_t2.cpp:40:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | if(y2==v.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... |