結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-06-15 04:04:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,927 bytes |
| コンパイル時間 | 918 ms |
| コンパイル使用メモリ | 93,132 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 10:11:37 |
| 合計ジャッジ時間 | 1,311 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 7 |
ソースコード
#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;
}
ty70