結果

問題 No.1884 Sequence
ユーザー nystnyst
提出日時 2022-03-25 21:56:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,356 bytes
コンパイル時間 1,259 ms
コンパイル使用メモリ 110,836 KB
実行使用メモリ 34,648 KB
最終ジャッジ日時 2024-04-22 06:37:48
合計ジャッジ時間 8,939 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 284 ms
34,520 KB
testcase_11 AC 282 ms
34,644 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 74 ms
15,872 KB
testcase_15 AC 185 ms
26,848 KB
testcase_16 AC 336 ms
34,648 KB
testcase_17 AC 166 ms
23,440 KB
testcase_18 AC 187 ms
27,852 KB
testcase_19 AC 154 ms
23,312 KB
testcase_20 AC 164 ms
24,756 KB
testcase_21 AC 138 ms
22,484 KB
testcase_22 AC 171 ms
25,732 KB
testcase_23 AC 329 ms
34,520 KB
testcase_24 AC 337 ms
34,520 KB
testcase_25 AC 262 ms
34,524 KB
testcase_26 AC 270 ms
34,520 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 100 ms
18,944 KB
testcase_30 AC 94 ms
18,944 KB
testcase_31 AC 103 ms
12,424 KB
testcase_32 AC 206 ms
21,344 KB
testcase_33 AC 140 ms
9,604 KB
testcase_34 AC 142 ms
9,604 KB
testcase_35 AC 45 ms
6,784 KB
testcase_36 AC 106 ms
8,656 KB
testcase_37 AC 141 ms
9,728 KB
testcase_38 AC 128 ms
9,728 KB
testcase_39 AC 59 ms
7,044 KB
testcase_40 AC 64 ms
7,276 KB
testcase_41 AC 226 ms
30,624 KB
testcase_42 AC 276 ms
30,616 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;
    int c = 0;
    sort(a.begin(),a.end(),greater<long long>());
    long long maxv = a[0];
    for(int i=0;i<n;i++) {
        if(a[i]==0) {
            c++;
            continue;
        }
        nozero.push_back(a[i]);
        mp[a[i]]++;
    }
    vector<long long> diff;
    sort(nozero.begin(),nozero.end());
    for(int i=0;i<nozero.size()-1;i++) diff.push_back(nozero[i+1]-nozero[i]);
    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;
    for(int i=1;i<n;i++) pb[i] = pb[i-1] - mindiff;
    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;
        } 
    }
    cout << "Yes" << endl;
}
0