結果

問題 No.135 とりあえず1次元の問題
ユーザー ytftytft
提出日時 2021-03-15 11:37:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 1,857 ms
コンパイル使用メモリ 173,832 KB
実行使用メモリ 6,224 KB
最終ジャッジ日時 2024-04-24 15:43:19
合計ジャッジ時間 3,140 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
6,100 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 RE -
testcase_22 WA -
evil01.txt AC 49 ms
5,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


template<typename type>
void vector_sort(vector<type>& v,function<int(type)> fn=[](int a){return a;}){
    auto a=[fn](type x,type y){return fn(x)>fn(y);};
    priority_queue<int,vector<int>,decltype(a)> q(a);
    for(int i=0;i<v.size();i++){
        q.push(v[i]);
    }
    for(int i=0;i<v.size();i++){
        v[i]=q.top();
        q.pop();
    }
}

template<typename type>
tuple<vector<type>,vector<int>> vector_runlength(vector<type> v){
    vector<type> element={};
    vector<int> number={};
    int consecutive=1;
    int n=v.size();
    for(int i=1;i<n;i++){
        if(v[i]==v[i-1]){
            consecutive++;
        }else{
            element.push_back(v[i-1]);
            number.push_back(consecutive);
            consecutive=1;
        }
    }
    element.push_back(v[n-1]);
    number.push_back(consecutive);
    return forward_as_tuple(element,number);
}

int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    for(int i=0;i<N;i++){
        cin>>X[i];
    }
    vector_sort(X);
    tuple<vector<int>,vector<int>> A=vector_runlength(X);
    int m=10000000;
    for(int i=0;i<N-1;i++){
        m=min(m,get<0>(A)[i+1]-get<0>(A)[i]);
    }
    cout<<m<<endl;
}
0