結果

問題 No.2248 max(C)-min(C)
ユーザー Nzt3Nzt3
提出日時 2023-03-17 23:42:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 154 ms / 3,000 ms
コード長 739 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 211,784 KB
実行使用メモリ 9,236 KB
最終ジャッジ日時 2023-10-18 16:37:07
合計ジャッジ時間 7,352 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 54 ms
8,740 KB
testcase_19 AC 8 ms
4,348 KB
testcase_20 AC 62 ms
9,236 KB
testcase_21 AC 59 ms
9,040 KB
testcase_22 AC 42 ms
7,916 KB
testcase_23 AC 27 ms
5,936 KB
testcase_24 AC 13 ms
4,544 KB
testcase_25 AC 56 ms
8,876 KB
testcase_26 AC 50 ms
8,476 KB
testcase_27 AC 56 ms
8,840 KB
testcase_28 AC 7 ms
4,348 KB
testcase_29 AC 52 ms
8,584 KB
testcase_30 AC 23 ms
5,608 KB
testcase_31 AC 61 ms
9,236 KB
testcase_32 AC 14 ms
4,640 KB
testcase_33 AC 20 ms
5,104 KB
testcase_34 AC 62 ms
9,236 KB
testcase_35 AC 62 ms
9,236 KB
testcase_36 AC 62 ms
9,236 KB
testcase_37 AC 33 ms
6,312 KB
testcase_38 AC 112 ms
9,236 KB
testcase_39 AC 113 ms
9,236 KB
testcase_40 AC 113 ms
9,236 KB
testcase_41 AC 96 ms
8,664 KB
testcase_42 AC 112 ms
9,236 KB
testcase_43 AC 96 ms
8,780 KB
testcase_44 AC 112 ms
9,236 KB
testcase_45 AC 85 ms
8,360 KB
testcase_46 AC 41 ms
5,876 KB
testcase_47 AC 113 ms
9,236 KB
testcase_48 AC 94 ms
9,236 KB
testcase_49 AC 154 ms
9,236 KB
testcase_50 AC 152 ms
9,236 KB
testcase_51 AC 151 ms
9,236 KB
testcase_52 AC 153 ms
9,236 KB
testcase_53 AC 21 ms
4,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int mod=998244353;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N),B(N);
  for(int &i:A)cin>>i;
  for(int &i:B)cin>>i;
  vector<array<int,3>>C(N);
  for(int i=0;i<N;i++){
    C[i][0]=A[i],C[i][1]=B[i],C[i][2]=(A[i]+B[i])/2;
    sort(C[i].begin(),C[i].end());
  }
  int ans=1e9,m=0;
  priority_queue<array<int,2>,vector<array<int,2>>,greater<array<int,2>>>pq;
  for(int i=0;i<N;i++){
    m=max(m,C[i][0]);
    pq.push({C[i][0],i});
  }
  while(pq.size()){
    int t=pq.top()[0],d=pq.top()[1];
    pq.pop();
    ans=min(ans,m-t);
    if(d/N==2)break;
    pq.push({C[d%N][d/N+1],d+N});
    m=max(m,C[d%N][d/N+1]);
  }
  cout<<ans<<'\n';
}
0