結果

問題 No.33 アメーバがたくさん
ユーザー yuki2006yuki2006
提出日時 2014-10-04 15:53:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 854 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 78,928 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 17:41:04
合計ジャッジ時間 1,192 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%lld%lld%lld",&n,&d,&t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:26:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |                 scanf("%lld",&x);
      |                 ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <queue>

using namespace std;

/*
正解してたら匿名でも問題投稿ができる(実現度さらにアップ)!!!
 
またコンパイルエラーでてないのにCE

入力かいてなかった

*/
 
int main(){
	long long n,d,t,x;
	scanf("%lld%lld%lld",&n,&d,&t);
	map<long long,long long> mp;
	vector<long long> ps;
	for(int i=0;i<n;i++){
		scanf("%lld",&x);
		ps.push_back(x);
	}
	sort(ps.begin(),ps.end());
	
	long long diff[101];
	long long inc=1+t+t;
	mp[0]=t*d;
	long long ans=inc;
	for(int i=1;i<n;i++){
		diff[i]=ps[i]-ps[0];
		if(mp[diff[i]%d]==0||mp[diff[i]%d]<diff[i]-t*d)ans+=inc;
		else ans+=inc-((mp[diff[i]%d]-(diff[i]-t*d))/d+1);
		mp[diff[i]%d]=diff[i]+t*d;
	} 
	printf("%lld\n",ans);
	
	return 0;
} 
0