結果

問題 No.1715 Dinner 2
ユーザー 👑 ygussany
提出日時 2021-10-10 09:48:51
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 811 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-09-23 03:51:46
合計ジャッジ時間 1,257 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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