結果
| 問題 |
No.949 飲酒プログラミングコンテスト
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-12-12 21:55:52 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,226 bytes |
| コンパイル時間 | 908 ms |
| コンパイル使用メモリ | 29,952 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-25 17:48:05 |
| 合計ジャッジ時間 | 1,858 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 WA * 19 |
ソースコード
// yuki 949 飲酒プログラミングコンテスト
// 2019.12.12 bal4u
#include <stdio.h>
#include <ctype.h>
int getchar_unlocked(void);
#define gc() getchar_unlocked()
int in() { // 整数の入力
int n = 0; int c;
do c = gc();
while (isspace(c));
if (c == '-') { c = gc();
do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
return -n;
}
do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
return n;
}
void Qsort(int *a, int l, int r) {
int i, j, m, t;
i = l, j = r, m = a[(l+r) >> 1];
while (1) {
while (a[i] < m) i++;
while (m < a[j]) j--;
if (i >= j) break;
t = a[i], a[i] = a[j], a[j] = t;
i++, j--;
}
if (l+1 < i) Qsort(a, l, i-1);
if (j+1 < r) Qsort(a, j+1, r);
}
int N;
int A[3005], B[3005];
int D[3005];
int main()
{
int i, j, a, b, s, ans;
N = in();
for (i = 0; i <= N; ++i) A[i] = in();
for (i = 0; i <= N; ++i) B[i] = in();
for (i = 1; i <= N; ++i) D[i] = in();
Qsort(D, 1, N), D[0] = -200005;
j = N;
a = b = 0, ans = 0, A[N+1] = B[N+1] = -100002;
while (ans < N && a <= N && b <= N) {
if (A[a]+B[b+1] >= A[a+1]+B[b]) s = A[a]+B[++b];
else s = A[++a]+B[b];
while (s < D[j]) --j;
if (j == 0) break;
++ans, --j;
}
printf("%d\n", ans);
return 0;
}
bal4u