結果

問題 No.343 手抜き工事のプロ
ユーザー tnakao0123tnakao0123
提出日時 2016-04-07 16:47:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,160 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 84,060 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 22:23:52
合計ジャッジ時間 1,949 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 343.cc: No.343 手抜き工事のプロ - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

int xs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, l;
  cin >> n >> l;

  xs[0] = 0;
  for (int i = 1; i < n; i++) cin >> xs[i];

  int cnt = 0;
  double lh = (double)l / 2, gcsum = 0.0;
  for (int i = n - 1; i > 0; i--) {
    gcsum += lh + xs[i];
    double gc = gcsum / (n - i);
    int ul0 = xs[i], ul1 = ul0 + l;
    int ll0 = xs[i - 1], ll1 = ll0 + l;
    //printf("gc[%d]=%lf\n", i, gc);
    //printf("  [%d-%d]-[%d-%d]\n", ul0, ul1, ll0, ll1);

    if (min(ul1, ll1) - max(ul0, ll0) < 1) {
      cnt = -1;
      break;
    }

    if (gc <= ul0 || gc >= ul1 || gc <= ll0 || gc >= ll1) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}
0