結果
問題 | No.33 アメーバがたくさん |
ユーザー |
![]() |
提出日時 | 2020-03-22 12:58:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 543 bytes |
コンパイル時間 | 1,285 ms |
コンパイル使用メモリ | 87,436 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 17:17:56 |
合計ジャッジ時間 | 2,033 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#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; }