結果

問題 No.33 アメーバがたくさん
ユーザー HaarHaar
提出日時 2016-05-31 15:39:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,194 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 174,256 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:18:18
合計ジャッジ時間 2,379 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define PF push_front
#define ALL(x) (x).begin(), (x).end()
#define C complex
#define CI complex< int >
#define CD complex< double >
using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, d, t, x;
	long int c = 0;
	map< int, vector< int > > mp;
	
	cin >> n >> d >> t;
	REP(i, n){
		cin >> x;
		
		int mod;
		if(x>=0 || x % d == 0) mod = x % d;
		else mod = d - ((-x) % d);
				
		if(mp.find(mod) != mp.end()){
			mp[mod].PB(x);
		}else{
			vector< int > temp;
			mp[mod] = temp;
			mp[mod].PB(x);
		}
	}
	
	for(map< int, vector< int > >::iterator it = mp.begin(); it != mp.end(); ++it){
		vector< int > v = it->second;
		
		REP(i, v.size()) v[i] = floor(1.0 * v[i] / d);
		
		sort(ALL(v));
		
		int cnt = t * 2 + 1;
		FOR(i, 1, v.size()){
			if(v[i-1] + t < v[i] - t){
				cnt += 2 * t + 1;
			}else{
				cnt += (v[i] - v[i-1]);
			}
		}
		c += cnt;
	}
	
	cout << c << endl;
	
	return 0;
}
0