結果

問題 No.472 平均順位
ユーザー bal4ubal4u
提出日時 2019-08-20 20:14:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 32,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 04:24:36
合計ジャッジ時間 2,025 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 9 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
testcase_12 AC 20 ms
5,376 KB
testcase_13 AC 78 ms
5,376 KB
testcase_14 AC 161 ms
5,376 KB
testcase_15 AC 78 ms
5,376 KB
testcase_16 AC 164 ms
5,376 KB
testcase_17 AC 192 ms
5,376 KB
testcase_18 AC 12 ms
5,376 KB
testcase_19 AC 45 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:9:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
    9 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:15:24: note: in expansion of macro 'gc'
   15 |         int n = 0, c = gc();
      |                        ^~

ソースコード

diff #

// yukicoder: No.472 平均順位
// bal4u 2019.8.20

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

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

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

int dp[2][15005];
		
int main()
{
	int i, j, k, p, q, ma, a[4], N, P;

	N = in(), P = in();
	memset(dp[0], 0x33, sizeof(dp[0]));
	ma = 0, dp[0][0] = 0, a[3] = 1;
	p = 0, q = 1;
	for (i = 0; i < N; i++) {
		memset(dp[q], 0x33, sizeof(dp[0]));
		for (j = 0; j <= 2; j++) a[j] = in();
		for (j = 0; j <= 3; j++) {
			for (k = ma; k >= 0; k--) {
				if (dp[p][k] + a[j] < dp[q][k+j]) dp[q][k+j] = dp[p][k] + a[j];
			}
		}
		if (ma < P) ma += 3;
		p = q, q = !q;
	}
	printf("%.8lf\n", (double)dp[p][P]/N);
	return 0;
}
0