結果
問題 | No.343 手抜き工事のプロ |
ユーザー |
|
提出日時 | 2016-02-27 13:49:25 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 63,212 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 11:34:57 |
合計ジャッジ時間 | 1,978 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) using namespace std; const double eps = 1e-12; int main() { int n; double l; cin >> n >> l; vector<double> x(n); x[0] = 0; repeat (i,n-1) cin >> x[i+1]; reverse(x.begin(), x.end()); int ans = 0; double acc = 0; repeat (i,n-1) { if (l - eps < abs(x[i+1] - x[i])) { ans = -1; break; } acc += x[i]; if (l/2 - eps < abs(x[i] - acc/(i+1)) or l/2 - eps < abs(x[i+1] - acc/(i+1))) { ans += 1; } } cout << ans << endl; return 0; }