結果

問題 No.33 アメーバがたくさん
ユーザー woodsgreenwoodsgreen
提出日時 2022-01-11 12:33:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 952 bytes
コンパイル時間 2,356 ms
コンパイル使用メモリ 200,904 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 05:46:09
合計ジャッジ時間 4,153 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int D=1e9;
int n,d,t,done[100];
long long x[100],sz,bef,res;
struct R{
    long long st,ed;
} r[100];
bool cmp(const R &a,const R &b){
    if(a.st==b.st) return a.ed<b.ed;
    return a.st<b.st;
}
int main(){
    scanf("%d%d%d",&n,&d,&t);
    for(int i=0;i<n;++i){
        scanf("%lld",&x[i]);
        x[i]+=D;
    }
    for(int k=0;k<n;++k)
        if(!done[k]){
            sz=0;
            for(int i=0;i<n;++i)
                if((x[i]-x[k])%d==0){
                    r[sz].st=x[i]/d;
                    r[sz].ed=x[i]/d+2*t;
                    sz++;
                    done[i]=1;
                }
            sort(r,r+sz,cmp);
            bef=-1;
            for(int i=0;i<sz;++i){
                bef=max(bef,r[i].st);
                res+=r[i].ed-bef+1;
                bef=r[i].ed+1;
            }
        }
    printf("%lld\n",res);
    return 0;
}
0