結果

問題 No.343 手抜き工事のプロ
ユーザー しらっ亭しらっ亭
提出日時 2016-02-12 23:10:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,246 bytes
コンパイル時間 1,427 ms
コンパイル使用メモリ 160,260 KB
実行使用メモリ 4,604 KB
最終ジャッジ日時 2023-10-22 03:26:10
合計ジャッジ時間 2,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 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 2 ms
4,348 KB
testcase_21 AC 5 ms
4,348 KB
testcase_22 AC 6 ms
4,348 KB
testcase_23 AC 9 ms
4,348 KB
testcase_24 AC 11 ms
4,480 KB
testcase_25 AC 13 ms
4,604 KB
testcase_26 AC 13 ms
4,604 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:24:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |   scanf("%d", &L);
      |   ~~~~~^~~~~~~~~~
main.cpp:25:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |   REP(i, N-1) scanf("%d", X+i+1);
      |               ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
typedef long long ll;
// -------------------------------------

int N, L;
int X[100101];
int R[100101];

int main() {
  scanf("%d", &N);
  scanf("%d", &L);
  REP(i, N-1) scanf("%d", X+i+1);
  R[0] = X[0] = 0;

  /*
  puts("----");
  REP(i, N) {
    _P("X[%d]=%d\n", i, X[i]);
  }
  */

  REP(i, N-1) {
    int d = abs(X[i] - X[i+1]);
    if (d >= L) {
      puts("-1");
      return 0;
    }
    R[i+1] = R[i] + X[i+1];
  }
  /*
  REP(i, N) {
    _P("R[%d]=%d\n", i, R[i]);
  }
  */

  int ans = 0;
  FOR(i, 1, N) {
    double j = 1.0 * (R[N-1] - R[i-1]) / (N-i);
    //_P("j=%f\n", j);
    if (abs(X[i-1] - j) * 2 >= L ||
        abs(X[i] - j) * 2 >= L) ans++;
  }

  cout << ans << endl;

  return 0;
}
0