結果

問題 No.1884 Sequence
ユーザー nystnyst
提出日時 2022-03-25 22:51:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,025 bytes
コンパイル時間 1,295 ms
コンパイル使用メモリ 111,448 KB
実行使用メモリ 34,652 KB
最終ジャッジ日時 2024-04-22 07:38:32
合計ジャッジ時間 7,941 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 283 ms
34,524 KB
testcase_11 AC 281 ms
34,516 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 75 ms
15,616 KB
testcase_15 AC 181 ms
26,720 KB
testcase_16 WA -
testcase_17 AC 163 ms
23,304 KB
testcase_18 AC 184 ms
27,720 KB
testcase_19 AC 153 ms
23,440 KB
testcase_20 AC 159 ms
24,752 KB
testcase_21 AC 135 ms
22,484 KB
testcase_22 AC 172 ms
25,832 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 260 ms
34,520 KB
testcase_26 AC 268 ms
34,648 KB
testcase_27 AC 36 ms
6,944 KB
testcase_28 AC 36 ms
6,944 KB
testcase_29 WA -
testcase_30 AC 38 ms
6,940 KB
testcase_31 AC 102 ms
12,428 KB
testcase_32 AC 197 ms
21,336 KB
testcase_33 AC 139 ms
9,600 KB
testcase_34 AC 138 ms
9,604 KB
testcase_35 AC 46 ms
6,940 KB
testcase_36 AC 106 ms
8,396 KB
testcase_37 AC 139 ms
9,604 KB
testcase_38 AC 127 ms
9,732 KB
testcase_39 AC 59 ms
6,940 KB
testcase_40 AC 64 ms
7,272 KB
testcase_41 AC 225 ms
30,624 KB
testcase_42 AC 275 ms
30,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <fstream>
#include <cmath>
#include <stack>
#include <numeric>
#include <iomanip>
using namespace std;

int main(){
    int n;cin>>n;
    vector<long long> a(n);
    map<long long,long long> mp;
    for(int i=0;i<n;i++) {
        cin >> a[i];
    }
    vector<long long> nozero;
    sort(a.begin(),a.end(),greater<long long>());
    long long maxv = a[0];
    for(int i=0;i<n;i++) {
        if(a[i]==0) {
            continue;
        }
        nozero.push_back(a[i]);
        mp[a[i]]++;
    }
    vector<long long> diff;
    sort(nozero.begin(),nozero.end());
    if(nozero.size()!=0 && nozero.size()!=1) {
        for(int i=0;i<nozero.size()-1;i++) diff.push_back(nozero[i+1]-nozero[i]);
    }else if(nozero.size()==1){
        cout << "Yes" << endl;
        return 0;
    }else {
        cout << "Yes" << endl;
        return 0;
    }
    sort(diff.begin(),diff.end());
    //
    //for(int i=0;i<diff.size();i++) cout << diff[i] << " ";
    //cout << endl;
    //
    long long mindiff = diff[0];
    
    vector<long long> pb(n);
    pb[0] = maxv;
    int c = 0;
    for(int i=1;i<n;i++) {
        pb[i] = pb[i-1] - mindiff;
        if(pb[i]<0) {
            c++;
            break;
        }
    }
    int index = n-1;
    while(c){
        if((pb[index]+pb[index-1])%2==1){
            cout << "No"<< endl;
            return 0;
        }
        pb[n-c-1]= (pb[index]+pb[index-1])/2;
        c--;
    }


    map<long long,long long> mpb;
    for(int i=0;i<n;i++) mpb[pb[i]]++;
    //
    //for(int i=n-1;0<=i;i--) cout << pb[i] << " ";
    //cout << endl; 
    //
    for(auto x:mp){
        mpb[x.first]--;
        if(mpb[x.first]<0){
          cout << "No" << endl;
          return 0;
        } 
    }
    int diff2 = pb[1]-pb[0];
    for(int i=0;i<n-1;i++){
        if(pb[i]+diff2 != pb[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}
0