結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-22 17:34:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 987 bytes |
| コンパイル時間 | 4,056 ms |
| コンパイル使用メモリ | 267,188 KB |
| 最終ジャッジ日時 | 2025-01-28 10:59:37 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
ll n,d,t;
vector<ll> x;
using P = pair<ll,ll>;
void solve(){
map<ll,vector<P>> mp;
sort(x.begin(),x.end());
for(ll i = 0;i<n;i++){
mp[(x[i]%d+d)%d].push_back(P(x[i],x[i]+1));
}
vector<vector<P>> vvp;
for(auto &i:mp){
vvp.push_back(i.second);
}
for(auto &i:vvp){
for(auto &[l,r]:i){
l -= d*t;
r += d*t;
}
}
for(auto &i:vvp){
vector<P> add;
for(auto &j:i){
if(add.empty()){
add.push_back(j);
}else{
//cout<<add.back().second<<' '<<j.first<<endl;
if(add.back().second >= j.first){
add.back().second = j.second;
}else{
add.push_back(j);
}
}
}
i = add;
}
ll ans = 0;
for(auto &i:vvp){
for(auto &[l,r]:i){
ans += (r-l+d-1)/d;
}
}
cout<<ans<<endl;
}
signed main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> n >> d >> t;
x = vector<ll>(n);
for(auto &i:x)cin >> i;
solve();
}