結果
| 問題 |
No.343 手抜き工事のプロ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-13 01:32:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 857 bytes |
| コンパイル時間 | 1,361 ms |
| コンパイル使用メモリ | 160,500 KB |
| 実行使用メモリ | 13,888 KB |
| 最終ジャッジ日時 | 2024-09-22 05:24:17 |
| 合計ジャッジ時間 | 7,550 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 TLE * 1 -- * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | int n, l; scanf("%d", &n); scanf("%d", &l);
| ~~~~~^~~~~~~~~~
main.cpp:6:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | int n, l; scanf("%d", &n); scanf("%d", &l);
| ~~~~~^~~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, l; scanf("%d", &n); scanf("%d", &l);
if (n == 1)
{
cout << 0 << endl;
return 0;
}
vector<int> xs(n-1);
for (auto &x : xs)
{
scanf("%d", &x);
}
int m = 0;
for (int i = 0; i < n-1; i++)
{
if (i == 0 && abs(xs[i]) >= l)
{
cout << -1 << endl;
return 0;
}
if (i != 0)
{
if (abs(xs[i - 1] - xs[i]) >= l)
{
cout << -1 << endl;
return 0;
}
}
m++;
}
for (int i = 0; i < n-1; i++)
{
double g = 0;
for (int j = i; j < n - 1; j++)
{
g += xs[j];
}
if (n - 1 - i != 0)
g /= n - 1 - i;
if (xs[i] - l / 2.0 < g && g < xs[i] + l / 2.0)
{
if (i == 0)
{
if (-1 * l / 2.0 < g && g < l / 2.0)
m--;
}
else if (xs[i - 1] - l / 2.0 < g && g < xs[i - 1] + l / 2.0)
m--;
}
}
cout << m << endl;
return 0;
}