結果

問題 No.343 手抜き工事のプロ
ユーザー h_nosonh_noson
提出日時 2016-06-01 23:51:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 696 ms
コンパイル使用メモリ 65,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 22:56:48
合計ジャッジ時間 2,201 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)
#define ESP 1e-9

typedef long long ll;

int main(void) {
    int i, n, l;
    int x[100010];
    cin >> n >> l;
    x[0] = 0;
    REP (i,1,n-1) cin >> x[i];

    int ans = 0;
    double m = 0;
    RREP (i,n-1,1) {
        if (abs(x[i] - x[i-1]) >= l) {
            cout << -1 << endl;
            return 0;
        }
        m = (m * (n-i-1) + x[i]) / (n-i);
        if (m-ESP <= x[i]-l/2.0 || x[i]+l/2.0 <= m+ESP || m-ESP <= x[i-1]-l/2.0 || x[i-1]+l/2.0 <= m+ESP)
            ans++;
    }
    cout << ans << endl;
    return 0;
}
0