結果

問題 No.33 アメーバがたくさん
ユーザー hotpepsihotpepsi
提出日時 2015-05-15 01:22:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 69,872 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:46:53
合計ジャッジ時間 1,179 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> LLLL;
typedef set<LLLL> LLLLSet;

int main(int argc, char *argv[])
{
	LL N, D, T;
	string s;
	getline(cin, s);
	stringstream sa(s);
	sa >> N >> D >> T;
	getline(cin, s);
	stringstream sb(s);
	LLLLSet y;
	LL ans = (T * 2 + 1) * N;
	for (LL i = 0; i < N; ++i) {
		LL x;
		sb >> x;
		LL a = x - D * T, b = x + D * T;
		LL c = ((a % D) + D) % D;
		for (LLLL r : y) {
			LL d = r.first;
			LL e = r.second;
			LL f = ((d % D) + D) % D;
			if (c == f) {
				if (a >= d && a <= e) {
					ans -= (e - a + D) / D;
					a = e + D;
				}
				if (b >= d && b <= e) {
					ans -= (d - b + D) / D;
					b = d - D;
				}
			}
		}
		y.insert(LLLL(a, b));
	}
	cout << ans << endl;
	return 0;
}
0