이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 400005
using namespace std;
int n, m, M = 1e9, sz, b[N], ans[N];
struct str {
int r, h, z, num;
} a[N];
bool comp(str p, str q) {
if (p.h != q.h) return p.h < q.h;
else if (p.r != q.r) return p.r > q.r;
else return p.z < q.z;
}
int main() {
int i, j, x, t;
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (i = 0; i < n; i++) {
cin >> a[i].r >> a[i].h;
a[i].z = a[i].num = 0;
}
for (i = 0; i < m; i++) {
cin >> a[n + i].r >> a[n + i].h;
a[n + i].z = 1;
a[n + i].num = i;
}
sort(a, a + n + m, comp);
for (i = 0; i < n + m; i++) {
x = M - a[i].r;
t = upper_bound(b, b + sz, x) - b;
if (a[i].z == 1) {
ans[a[i].num] = t;
} else {
b[t] = x;
if (t == sz) sz++;
}
}
for (i = 0; i < m; i++) {
printf("%d\n", ans[i]);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
matryoshka.cpp: In function 'int main()':
matryoshka.cpp:19:12: warning: unused variable 'j' [-Wunused-variable]
19 | int i, j, x, t;
| ^
# | 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... |