結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー | akakimidori |
提出日時 | 2019-06-07 02:38:26 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 2,796 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 31,616 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-02 09:56:35 |
合計ジャッジ時間 | 3,095 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,820 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,820 KB |
testcase_08 | AC | 1 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 1 ms
6,816 KB |
testcase_11 | AC | 2 ms
6,820 KB |
testcase_12 | AC | 1 ms
6,820 KB |
testcase_13 | AC | 1 ms
6,816 KB |
testcase_14 | AC | 1 ms
6,820 KB |
testcase_15 | AC | 1 ms
6,816 KB |
testcase_16 | AC | 1 ms
6,820 KB |
testcase_17 | AC | 1 ms
6,816 KB |
testcase_18 | AC | 1 ms
6,816 KB |
testcase_19 | AC | 1 ms
6,816 KB |
testcase_20 | AC | 1 ms
6,816 KB |
testcase_21 | AC | 1 ms
6,816 KB |
testcase_22 | AC | 1 ms
6,820 KB |
testcase_23 | AC | 1 ms
6,816 KB |
testcase_24 | AC | 2 ms
6,816 KB |
testcase_25 | AC | 1 ms
6,816 KB |
testcase_26 | AC | 1 ms
6,816 KB |
testcase_27 | AC | 1 ms
6,820 KB |
testcase_28 | AC | 1 ms
6,816 KB |
testcase_29 | AC | 1 ms
6,820 KB |
testcase_30 | AC | 1 ms
6,816 KB |
testcase_31 | AC | 1 ms
6,820 KB |
testcase_32 | AC | 1 ms
6,820 KB |
testcase_33 | AC | 5 ms
6,820 KB |
testcase_34 | AC | 2 ms
6,816 KB |
testcase_35 | AC | 2 ms
6,816 KB |
testcase_36 | AC | 4 ms
6,816 KB |
testcase_37 | AC | 2 ms
6,816 KB |
testcase_38 | AC | 5 ms
6,820 KB |
testcase_39 | AC | 2 ms
6,816 KB |
testcase_40 | AC | 3 ms
6,820 KB |
testcase_41 | AC | 3 ms
6,816 KB |
testcase_42 | AC | 4 ms
6,820 KB |
testcase_43 | AC | 4 ms
6,816 KB |
testcase_44 | AC | 33 ms
6,816 KB |
testcase_45 | AC | 33 ms
6,816 KB |
testcase_46 | AC | 34 ms
6,820 KB |
testcase_47 | AC | 35 ms
6,820 KB |
testcase_48 | AC | 33 ms
6,816 KB |
testcase_49 | AC | 5 ms
6,820 KB |
testcase_50 | AC | 5 ms
6,816 KB |
testcase_51 | AC | 5 ms
6,816 KB |
testcase_52 | AC | 5 ms
6,816 KB |
testcase_53 | AC | 34 ms
6,820 KB |
testcase_54 | AC | 35 ms
6,816 KB |
testcase_55 | AC | 34 ms
6,816 KB |
testcase_56 | AC | 33 ms
6,820 KB |
testcase_57 | AC | 34 ms
6,820 KB |
testcase_58 | AC | 34 ms
6,820 KB |
testcase_59 | AC | 33 ms
6,816 KB |
testcase_60 | AC | 33 ms
6,816 KB |
testcase_61 | AC | 34 ms
6,820 KB |
testcase_62 | AC | 33 ms
6,816 KB |
testcase_63 | AC | 39 ms
6,816 KB |
testcase_64 | AC | 39 ms
6,820 KB |
testcase_65 | AC | 29 ms
6,820 KB |
testcase_66 | AC | 38 ms
6,820 KB |
ソースコード
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> #include<string.h> typedef int32_t i32; typedef uint64_t u64; typedef u64 radix_type; #define RADIX_WIDTH 15 const uint32_t radix_type_max = 60; const uint32_t radix_type_begin = 0; const uint32_t radix_width = RADIX_WIDTH; const uint32_t radix_mask = (1 << RADIX_WIDTH) - 1; #undef RADIX_WIDTH static inline uint32_t radix_get_bit (radix_type v, uint32_t shift) { return v >> shift & radix_mask; } void radix_sort (radix_type *a, uint32_t n) { radix_type * const array = (radix_type *) calloc (4 * n, sizeof (radix_type)); radix_type **bucket = (radix_type **) calloc (1 << radix_width, sizeof (radix_type *)); uint32_t *len = (uint32_t *) calloc (2 << radix_width, sizeof (uint32_t)); uint32_t *max_len = len + (1 << radix_width); for (uint32_t shift = radix_type_begin; shift < radix_type_max; shift += radix_width) { radix_type *p = array; memset (len, 0, sizeof (uint32_t) << (radix_width + 1)); for (uint32_t i = 0; i < n; ++i) { uint32_t bit = radix_get_bit (a[i], shift); if (len[bit] == max_len[bit]) { for (uint32_t j = 0; j < len[bit]; ++j) { p[j] = bucket[bit][j]; } max_len[bit] = 2 * max_len[bit] + 1; bucket[bit] = p; p += max_len[bit]; } bucket[bit][len[bit]++] = a[i]; } for (uint32_t bit = 0, i = 0; bit < (1 << radix_width); ++bit) { for (uint32_t j = 0; j < len[bit]; ++j, ++i) { a[i] = bucket[bit][j]; } } } free (array); free (bucket); free (len); } i32 max (i32 a, i32 b) { return a > b ? a : b; } void update (i32 *bit, i32 x, i32 v) { i32 n = bit[0]; for (i32 i = x; i <= n; i += i & -i) { bit[i] = max (bit[i], v); } } i32 find (i32 *bit, i32 x) { i32 res = 0; for (i32 i = x; i > 0; i -= i & -i) { res = max (res, bit[i]); } return res; } void run (void) { i32 n; scanf ("%" SCNi32, &n); u64 *p = (u64 *) calloc (n, sizeof (u64)); for (i32 i = 0; i < n; ++i) { i32 a, b, c; scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &a, &b, &c); a++; b++; c++; p[i] = ((u64) a << 45) + ((u64) b << 31) + ((u64) c << 17) + i; } radix_sort (p, n); uint8_t *ok = (uint8_t *) calloc (n, sizeof (uint8_t)); const i32 m = 10000 + 1; i32 *bit = (i32 *) calloc (m + 1, sizeof (i32)); bit[0] = m; for (i32 i = n - 1; i >= 0; --i) { i32 b = (p[i] >> 31) & ((1 << 14) - 1); i32 c = (p[i] >> 17) & ((1 << 14) - 1); i32 index = p[i] & ((1 << 17) - 1); i32 k = m + 1 - b; if (find (bit, k) >= c) continue; ok[index] = 1; update (bit, k, c); } for (i32 i = 0; i < n; ++i) { if (ok[i]) { printf ("%" PRIi32 "\n", i + 1); } } } int main (void) { run(); return 0; }