이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define N 100000
#define M 100000
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int ss[N], vv[N], cc[N];
int compare_i(int i1, int i2) {
return vv[i1] != vv[i2] ? vv[i1] - vv[i2] : ss[i1] - ss[i2];
}
int compare_j(int j1, int j2) {
return cc[j1] - cc[j2];
}
int (*compare)(int, int);
void sort(int *ii, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
while (j < k) {
int c = compare(ii[j], i_);
if (c == 0)
j++;
else if (c < 0) {
tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
i++, j++;
} else {
k--;
tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
}
}
sort(ii, l, i);
l = k;
}
}
int main() {
static int ii[N], jj[M];
int n, m, i, j;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++)
scanf("%d%d", &ss[i], &vv[i]);
for (i = 0; i < n; i++)
ii[i] = i;
compare = compare_i, sort(ii, 0, n);
for (j = 0; j < m; j++)
scanf("%d", &cc[j]);
for (j = 0; j < m; j++)
jj[j] = j;
compare = compare_j, sort(jj, 0, m);
for (i = n - 1, j = m - 1; j >= 0; j--) {
while (i >= 0 && ss[ii[i]] > cc[jj[j]])
i--;
if (i < 0)
break;
i--;
}
printf("%d\n", m - 1 - j);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t2.c: In function 'main':
joi2019_ho_t2.c:50:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
50 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.c:52:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%d%d", &ss[i], &vv[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.c:57:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
57 | scanf("%d", &cc[j]);
| ^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |