結果

問題 No.33 アメーバがたくさん
ユーザー cureskolcureskol
提出日時 2022-07-08 14:22:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 951 bytes
コンパイル時間 2,746 ms
コンパイル使用メモリ 222,100 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 07:40:26
合計ジャッジ時間 3,540 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 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 1 ms
4,376 KB
testcase_10 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region template
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifdef __LOCAL
 #include <debug>
#else
 #define debug(...) void(0)
#endif

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

template<typename T>
istream& operator>>(istream&is,vector<T>&v){
  for(T&p:v)is>>p;
  return is;
}
template<typename T>
ostream& operator<<(ostream&os,const vector<T>&v){
  if(&os==&cerr)os<<"[";
  for(int i=0;i<v.size();i++){
    os<<v[i];
    if(i+1<v.size())os<<(&os==&cerr?",":" ");
  }
  if(&os==&cerr)os<<"]";
  return os;
}
#pragma endregion template

using ll=long long;
const int INF=1e9+7;

int main(){
  int n,d,t;cin>>n>>d>>t;
  map<int,vector<ll>> mp;
  REP(_,n){
    ll x;cin>>x;x+=INF;
    mp[x%d].push_back(x/d);
  }
  ll ans=0;
  for(auto&[id,ve]:mp){
    sort(ALL(ve));
    ll pre=-INF;
    for(ll p:ve){
      ans+=p+t-max(pre+1,p-t)+1;
      pre=p+t;
    }
  }
  cout<<ans<<endl;
}
0