結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー | ytft |
提出日時 | 2021-03-15 11:19:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,806 bytes |
コンパイル時間 | 1,569 ms |
コンパイル使用メモリ | 171,524 KB |
実行使用メモリ | 9,728 KB |
最終ジャッジ日時 | 2024-04-24 15:32:07 |
合計ジャッジ時間 | 14,610 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
evil01.txt | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; template<typename type> void vector_sort(vector<type>& v,function<int(type)> fn=[](int a){return a;},int decided=0){ int range=v.size()-decided; if(range==0){ return; } int parent=(v.size()-decided-1)/2; int child=parent*2+1; int parent_depth=1; while(pow(2,parent_depth)-1<range){ parent_depth++; } parent_depth-=2; type temp; while(parent_depth>=0){ for(int i=pow(2,parent_depth)-1;i<pow(2,parent_depth+1)-1;i++){ if(i*2+1<range && fn(v[i])<fn(v[i*2+1])){ temp=v[i]; v[i]=v[i*2+1]; v[i*2+1]=temp; } if(i*2+2<range && fn(v[i])<fn(v[i*2+2])){ temp=v[i]; v[i]=v[i*2+2]; v[i*2+2]=temp; } } parent_depth--; } temp=v[0]; v[0]=v[range-1]; v[range-1]=temp; vector_sort(v,fn,decided+1); } 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; }