結果

問題 No.343 手抜き工事のプロ
ユーザー TatsunoTatsuno
提出日時 2016-02-13 01:32:36
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 857 bytes
コンパイル時間 1,323 ms
コンパイル使用メモリ 161,608 KB
実行使用メモリ 8,152 KB
最終ジャッジ日時 2023-10-22 04:02:09
合計ジャッジ時間 7,774 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 72 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 74 ms
4,348 KB
testcase_21 AC 775 ms
4,348 KB
testcase_22 AC 1,423 ms
4,348 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |                 ~~~~~^~~~~~~~~~

ソースコード

diff #

#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;
}
0