結果
問題 | No.343 手抜き工事のプロ |
ユーザー |
![]() |
提出日時 | 2016-02-19 21:35:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 593 bytes |
コンパイル時間 | 1,282 ms |
コンパイル使用メモリ | 162,388 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 12:22:22 |
合計ジャッジ時間 | 2,254 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n) for(int i=0;i<(int)(n);i++)#define ALL(x) (x).begin(),(x).end()using namespace std;typedef long double ld;const ld eps = 1e-9;int main() {int N; ld L; cin >> N >> L;vector<int> X(N);REP(i,N-1) cin >> X[i+1];ld sum = 0, cnt = 0, res = 0;for (int i = N-1; i >= 1; --i) {sum += X[i] + L / 2; ++cnt;ld g = sum / cnt;if (g < X[i] + eps || X[i] + L < g + eps ||g < X[i-1] + eps || X[i-1] + L < g + eps) ++res;}REP(i,N-1) if (abs(X[i] - X[i+1]) > L - eps) res = -1;cout << res << endl;return 0;}