結果

問題 No.710 チーム戦
ユーザー bal4ubal4u
提出日時 2019-08-04 10:30:34
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 27 ms / 3,000 ms
コード長 856 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 29,708 KB
実行使用メモリ 41,680 KB
最終ジャッジ日時 2023-09-22 04:34:12
合計ジャッジ時間 2,812 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
41,604 KB
testcase_01 AC 13 ms
41,568 KB
testcase_02 AC 24 ms
41,584 KB
testcase_03 AC 24 ms
41,612 KB
testcase_04 AC 25 ms
41,604 KB
testcase_05 AC 24 ms
41,560 KB
testcase_06 AC 24 ms
41,624 KB
testcase_07 AC 25 ms
41,664 KB
testcase_08 AC 25 ms
41,576 KB
testcase_09 AC 23 ms
41,552 KB
testcase_10 AC 22 ms
41,564 KB
testcase_11 AC 25 ms
41,672 KB
testcase_12 AC 24 ms
41,608 KB
testcase_13 AC 24 ms
41,604 KB
testcase_14 AC 24 ms
41,580 KB
testcase_15 AC 23 ms
41,596 KB
testcase_16 AC 24 ms
41,616 KB
testcase_17 AC 22 ms
41,560 KB
testcase_18 AC 23 ms
41,628 KB
testcase_19 AC 24 ms
41,544 KB
testcase_20 AC 23 ms
41,660 KB
testcase_21 AC 24 ms
41,548 KB
testcase_22 AC 18 ms
41,628 KB
testcase_23 AC 13 ms
41,576 KB
testcase_24 AC 27 ms
41,580 KB
testcase_25 AC 13 ms
41,548 KB
testcase_26 AC 13 ms
41,680 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:8:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    8 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:14:24: 備考: in expansion of macro ‘gc’
   14 |         int n = 0, c = gc();
      |                        ^~

ソースコード

diff #

// yukicoder: No.710 チーム戦
// 2019.8.4 bal4u

#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[102][100005];

int main()
{
	int i, j, N, ma, a, b;
	int *p;
	
	memset(dp, -1, sizeof(dp));
	N = in();
	dp[0][0] = 0, ma = 0;
	for (i = 1; i <= N; i++) {
		a = in(), b = in();
		for (j = ma; j >= 0; j--) if (dp[i-1][j] >= 0) {
			p = &dp[i][j+a];
			if (*p < 0 || *p > dp[i-1][j]) *p = dp[i-1][j];
			if (j+a > ma) ma = j+a;
				
			p = &dp[i][j];
			if (*p < 0 || *p > dp[i-1][j]+b) *p = dp[i-1][j]+b;
		}
	}
	a = 100005;
	for (i = 0; i <= ma; i++) if ((b = dp[N][i]) >= 0) {
		if (i > b) b = i;
		if (b < a) a = b;
	}
	printf("%d\n", a);
	return 0;
}
0