結果

問題 No.1715 Dinner 2
ユーザー 👑 ygussanyygussany
提出日時 2021-10-10 09:48:51
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 30,488 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 11:32:35
合計ジャッジ時間 1,395 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 6 ms
4,348 KB
testcase_33 AC 6 ms
4,348 KB
testcase_34 AC 6 ms
4,348 KB
testcase_35 AC 6 ms
4,348 KB
testcase_36 AC 1 ms
4,348 KB
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void chmin(int* a, int b)
{
	if (*a > b) *a = b;
}

void chmax(int* a, int b)
{
	if (*a < b) *a = b;
}

int main()
{
	int i, N, D, P[1001], Q[1001];
	scanf("%d %d", &N, &D);
	for (i = 1; i <= N; i++) scanf("%d %d", &(P[i]), &(Q[i]));

	int j, k, ans = -(1 << 30), tmp, tmpp;
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) {
			if (j == i) continue;
			tmp = Q[i] + Q[j] - P[i] - P[j];
			if (tmp >= 0) {
				tmpp = -P[i];
				chmin(&tmpp, -P[i] + Q[i] - P[j]);
				chmax(&ans, tmpp);
			} else if (D % 2 == 0) {
				tmpp = tmp * (D / 2) - Q[j];
				chmin(&tmpp, tmp * (D / 2 - 1) - P[i]);
				chmax(&ans, tmpp);
			} else {
				tmpp = tmp * (D / 2) - P[i];
				chmin(&tmpp, tmp * (D / 2) - Q[j]);
				chmax(&ans, tmpp);
			}
		}
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}
0