結果
問題 |
No.33 アメーバがたくさん
|
ユーザー |
![]() |
提出日時 | 2024-07-28 01:18:42 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 908 bytes |
コンパイル時間 | 1,496 ms |
コンパイル使用メモリ | 116,260 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-28 01:18:45 |
合計ジャッジ時間 | 2,823 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; #include<map> int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n,d,t; cin>>n>>d>>t; ll ans = 0; map<ll,vector<ll>> memo; for(int i = 0;i<n;i++){ ll x; cin>>x; ll now = x % d; if(now<0) now += d; memo[now].push_back(x); } for(auto&itr:memo){ auto now = itr.second; sort(now.begin(),now.end()); ll prev = -9e18; for(int i = 0;i<now.size();i++){ ll le = now[i] - d * t; ll ri = now[i] + d * t; if(prev<le){ ans += 2 * t + 1; prev = ri; continue; } le = prev; ll def = ri - le; ans += def / d; prev = ri; } } cout<<ans<<endl; }