#include <stdio.h>
#include <string.h>
#define N 150000
#define K 400
int main() {
static int aa[N + K];
static char used[N + K];
int n, m, l, r, i, j, s, cnt;
scanf("%d%d", &n, &m);
for (i = 0; i < n + m; i++)
scanf("%d", &aa[i]);
for (l = 0; l <= m; l++)
for (r = n + m - 1; r >= l && r >= n - 1; r--) {
memset(used, 0, (n + m) * sizeof *used);
s = aa[l] + aa[r], i = l, j = r, cnt = n;
while (i < j && cnt > 0)
if (aa[i] + aa[j] < s)
i++;
else if (aa[i] + aa[j] > s)
j--;
else
used[i] = used[j] = 1, i++, j--, cnt -= 2;
if (cnt == 0) {
for (i = 0; i < n + m; i++)
if (used[i])
printf("%d ", i + 1);
printf("\n");
return 0;
}
}
return 0;
}
Compilation message
tabletennis.c: In function 'main':
tabletennis.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d%d", &n, &m);
| ^~~~~~~~~~~~~~~~~~~~~
tabletennis.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d", &aa[i]);
| ^~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
596 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
3284 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
292 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |