結果

問題 No.1884 Sequence
ユーザー mnmmnm
提出日時 2022-06-14 18:00:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,217 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 84,020 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 12:57:22
合計ジャッジ時間 7,943 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 150 ms
6,400 KB
testcase_11 AC 156 ms
6,400 KB
testcase_12 AC 32 ms
5,888 KB
testcase_13 AC 34 ms
6,144 KB
testcase_14 AC 32 ms
5,760 KB
testcase_15 AC 93 ms
6,400 KB
testcase_16 AC 139 ms
6,400 KB
testcase_17 AC 66 ms
6,656 KB
testcase_18 AC 92 ms
6,400 KB
testcase_19 AC 72 ms
5,888 KB
testcase_20 AC 79 ms
6,400 KB
testcase_21 AC 64 ms
6,528 KB
testcase_22 AC 86 ms
6,656 KB
testcase_23 AC 142 ms
6,656 KB
testcase_24 AC 139 ms
6,528 KB
testcase_25 AC 136 ms
6,400 KB
testcase_26 AC 141 ms
6,528 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 40 ms
6,656 KB
testcase_30 AC 40 ms
6,528 KB
testcase_31 AC 78 ms
5,760 KB
testcase_32 WA -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 AC 134 ms
6,528 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 117 ms
6,528 KB
testcase_42 AC 118 ms
6,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <bitset>

#define rep(i,n) for(i=0; i<n; ++i)
#define in(a) cin >> a
#define out(a,b) cout << a << b
using namespace std;
using lint = long long;

int main(void){
    lint i, j;
    lint p, n, m;
    in(n);
    vector<lint> a(n);
    rep(i,n)    in(a[i]);
    sort(a.begin(),a.end());
    vector<lint> dis(n-1);
    rep(i,n-1){
        if(a[i]>0&&a[i+1]>0)    dis[i]=a[i+1]-a[i];
        else    dis[i]=0;
    }
    sort(dis.begin(),dis.end());
    auto cur = lower_bound(dis.begin(),dis.end(),1);
    bool f=false;
    while(true){
        if(*cur==1||cur==dis.end()){
            f=true; break;
        }
        lint rem;
        auto it=cur+1;
        for(; it!=dis.end(); ++it) {
            rem=*it%*cur;
            if(rem!=0)  break;
        }
        if(it==dis.end()){
            f=true; break;
        }
        if(cur==dis.begin()){
            f=false; break;
        }
        cur--;
        *cur=rem;
    }
    if(f){
        auto mini=lower_bound(a.begin(),a.end(),1);
        if((a[n-1]-*mini)/ *cur>n-1)   f=false;
    }
    f? out("Yes",endl): out("No",endl);

    return 0;
}
0