# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
109694 | ffresh | Matryoshka (JOI16_matryoshka) | C++17 | 3 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int R[N],H[N];
void solve() {
int n,q;
scanf("%d%d",&n,&q);
for(int i=0;i<n;++i) {
scanf("%d%d",&R[i],&H[i]);
}
for(int i=0;i<q;++i) {
vector<pair<int,int> > in;
int a,b;
scanf("%d%d",&a,&b);
for(int j = 0;j<n;++j) {
if(R[j]>=a && H[j]<=b) {
in.push_back(make_pair(R[j],H[j]));
}
}
sort(in.begin(),in.end());
multiset<pair<int,int> >s;
int ret = 0;
for(int j = 0;j<in.size();++j) {
s.insert(make_pair(in[j].second,in[j].first));
}
for(int j = in.size()-1;j>=0;) {
int k;
for(k = j;k>=0;--k) {
if(in[j].first!= in[k].first) {
break;
}
//cout<<in[k].first<<endl;
if(s.count(make_pair(in[k].second,in[k].first))){
++ret;
multiset<pair<int,int> > ::iterator it = s.find(make_pair(in[k].second,in[k].first));
s.erase(it);
}
}
for(k = j;k>=0;--k) {
if(in[j].first != in[k].first) {
break;
}
int g = in[k].second;
multiset<pair<int,int> >::iterator it = s.lower_bound(make_pair(g,0));
if(it != s.begin()) {
it = prev(it);
s.erase(it);
}
}
j = k;
}
printf("%d\n", ret);
}
}
int main()
{
//freopen("input.txt","r",stdin);
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |