結果

問題 No.33 アメーバがたくさん
ユーザー kotatsugamekotatsugame
提出日時 2020-02-27 22:35:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 543 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 18:56:57
合計ジャッジ時間 1,639 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int N;
long D,T;
main()
{
	cin>>N>>D>>T;
	map<long,vector<long> >M;
	for(int i=0;i<N;i++)
	{
		long X;cin>>X;
		M[(X%D+D)%D].push_back(X);
	}
	long ans=0;
	for(map<long,vector<long> >::iterator it=M.begin();it!=M.end();it++)
	{
		vector<long>tmp=it->second;
		sort(tmp.begin(),tmp.end());
		long pre=-2e18;
		for(long x:tmp)
		{
			long L=x-D*T,R=x+D*T;
			if(pre>=L)
			{
				ans-=(pre-L+D)/D;
			}
			ans+=2*T+1;
			pre=R;
		}
	}
	cout<<ans<<endl;
}
0