結果

問題 No.2559 眩しい数直線
ユーザー tnakao0123tnakao0123
提出日時 2023-12-03 17:58:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 41,792 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-03 17:58:25
合計ジャッジ時間 1,625 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 3 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2559.cc:  No.2559 眩しい数直線 - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_X = 1000;

/* typedef */

/* global variables */

int cs[MAX_X];

/* subroutines */

/* main */

int main() {
  int n, x;
  scanf("%d%d", &n, &x);

  for (int i = 0; i < n; i++) {
    int ai, bi;
    scanf("%d%d", &ai, &bi), ai--;

    int j0 = max(0, ai - bi + 1), j1 = min(x - 1, ai + bi - 1);
    for (int j = j0; j <= j1; j++)
      cs[j] = max(cs[j], bi - abs(j - ai));
  }

  for (int i = 0; i < x; i++)
    printf("%d%c", cs[i], (i + 1 < x) ? ' ' : '\n');

  return 0;
}
0