結果

問題 No.1715 Dinner 2
コンテスト
ユーザー ygussany
提出日時 2021-10-10 09:48:51
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 811 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 189 ms
コンパイル使用メモリ 39,488 KB
最終ジャッジ日時 2026-02-22 08:03:53
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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