結果

問題 No.33 アメーバがたくさん
ユーザー ty70ty70
提出日時 2015-06-15 04:04:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,927 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 93,588 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:47:34
合計ジャッジ時間 1,233 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

/*
	No.33 アメーバがたくさん	

	N 個のうち 2個のアメーバ間の距離を格納。N*(N-1)/2 個

	このうち
	|xi - xj | % d != 0 なら xi と xj のアメーバは重ならないから
	時間 t まで増え続ける

	|xi - xj| % d == 0 なら xi と xj のアメーバは |xi - xj|/(2d) 秒後に 重なる。
	重なる前までの増え方と重なった後での増え方がちがうので場合分け。
 
	計算量:O(N^2)
*/

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	int N, D, T; cin >> N >> D >> T;
	vector<int> X(N, 0 );
	rep (i, N ) cin >> X[i];
	sort (ALL (X ) );

	vector<int> diff (N*(N-1)/2, 0 );

	int k = 0;
	rep (i, N )
		for (int j = i+1; j < N; j++ )
			diff[k++] = (X[j] - X[i] );
		
	ll res = (ll)N;
	rep (k, N*(N-1)/2 ){
		if (diff[k] % D != 0 ){
			res += 2LL*2LL*(ll)T;
		}else{
			ll ct = (ll)diff[k]/(2LL*D );	// 衝突時間
 			res += 2LL*2LL*ct;
			if (T >= ct ){
				res--;					// 衝突した
				res += 2LL*((ll)T-ct);		// 衝突後の増え方
			} // end if
		} // end if
	} // end rep

	cout << res << endl;

	return 0;
}
0