結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー bal4ubal4u
提出日時 2019-08-10 19:27:54
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 39 ms / 4,000 ms
コード長 1,470 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 29,608 KB
実行使用メモリ 7,784 KB
最終ジャッジ日時 2023-09-26 23:36:35
合計ジャッジ時間 4,807 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
7,168 KB
testcase_01 AC 34 ms
7,204 KB
testcase_02 AC 32 ms
6,992 KB
testcase_03 AC 35 ms
6,892 KB
testcase_04 AC 36 ms
6,868 KB
testcase_05 AC 33 ms
6,924 KB
testcase_06 AC 38 ms
7,784 KB
testcase_07 AC 32 ms
7,168 KB
testcase_08 AC 38 ms
7,632 KB
testcase_09 AC 37 ms
7,520 KB
testcase_10 AC 36 ms
7,108 KB
testcase_11 AC 39 ms
7,100 KB
testcase_12 AC 35 ms
6,832 KB
testcase_13 AC 36 ms
7,124 KB
testcase_14 AC 33 ms
6,788 KB
testcase_15 AC 35 ms
7,092 KB
testcase_16 AC 37 ms
7,076 KB
testcase_17 AC 39 ms
7,080 KB
testcase_18 AC 38 ms
7,024 KB
testcase_19 AC 36 ms
7,124 KB
testcase_20 AC 32 ms
6,712 KB
testcase_21 AC 37 ms
7,148 KB
testcase_22 AC 37 ms
7,108 KB
testcase_23 AC 38 ms
7,136 KB
testcase_24 AC 36 ms
7,160 KB
testcase_25 AC 37 ms
7,140 KB
testcase_26 AC 35 ms
7,132 KB
testcase_27 AC 37 ms
7,104 KB
testcase_28 AC 36 ms
7,140 KB
testcase_29 AC 36 ms
7,100 KB
testcase_30 AC 1 ms
5,780 KB
testcase_31 AC 1 ms
5,688 KB
testcase_32 AC 37 ms
6,832 KB
testcase_33 AC 38 ms
7,188 KB
testcase_34 AC 36 ms
7,524 KB
testcase_35 AC 1 ms
5,820 KB
testcase_36 AC 1 ms
5,692 KB
testcase_37 AC 2 ms
5,816 KB
testcase_38 AC 1 ms
5,804 KB
testcase_39 AC 1 ms
5,744 KB
testcase_40 AC 1 ms
5,708 KB
testcase_41 AC 4 ms
5,728 KB
testcase_42 AC 4 ms
5,812 KB
testcase_43 AC 4 ms
5,848 KB
testcase_44 AC 4 ms
5,792 KB
testcase_45 AC 2 ms
5,700 KB
testcase_46 AC 5 ms
5,828 KB
testcase_47 AC 6 ms
5,824 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:9:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    9 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:17:24: 備考: in expansion of macro ‘gc’
   17 |         int n = 0, c = gc();
      |                        ^~
main.c: 関数 ‘out’ 内:
main.c:10:15: 警告: 関数 ‘putchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   10 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:26:17: 備考: in expansion of macro ‘pc’
   26 |         if (!n) pc('0');
      |                 ^~

ソースコード

diff #

// yukicoder 433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
// 2019.8.10 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示(出力)
	int i;
	char b[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int N, K;
typedef struct { int id, s, p, u; } T;
T a[100005];
T b[100005]; int sz;
int f[1000005];

int cmpsp(const void *u, const void *v) {
	int t; if (t = ((T *)v)->s - ((T *)u)->s) return t;
	return ((T *)u)->p - ((T *)v)->p;
}

int cmpup(const void *u, const void *v) {
	int t; if (t = ((T *)u)->s - ((T *)v)->s) return t;
	return ((T *)u)->p - ((T *)v)->p;
}

int select(int s, int i) {
	int j;
	sz = 0;
	while (i < N && a[i].s == s) {
		b[sz].s = f[a[i].u]++, b[sz].p = a[i].p, b[sz].id = a[i].id;
		sz++, i++;
	}
	qsort(b, sz, sizeof(T), cmpup);
	for (j = 0; K && j < sz; j++) out(b[j].id), K--;
	return i;
}

int main()
{
	int i;
	
	N = in(), K = in();
	for (i = 0; i < N; i++) {
		a[i].id = i, a[i].s = in(), a[i].p = in(), a[i].u = in();
	}
	qsort(a, N, sizeof(T), cmpsp);
	i = 0; while (K) i = select(a[i].s, i);
	return 0;
}
0