結果

問題 No.1767 BLUE to RED
ユーザー monnumonnu
提出日時 2021-11-26 23:27:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 3,606 ms
コンパイル使用メモリ 232,620 KB
実行使用メモリ 12,932 KB
最終ジャッジ日時 2023-09-12 05:36:31
合計ジャッジ時間 8,039 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,388 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 111 ms
7,720 KB
testcase_10 AC 134 ms
12,724 KB
testcase_11 AC 114 ms
7,696 KB
testcase_12 AC 112 ms
7,716 KB
testcase_13 AC 149 ms
12,868 KB
testcase_14 AC 212 ms
12,468 KB
testcase_15 AC 213 ms
12,044 KB
testcase_16 AC 217 ms
11,676 KB
testcase_17 AC 212 ms
12,104 KB
testcase_18 AC 209 ms
12,932 KB
testcase_19 AC 213 ms
11,296 KB
testcase_20 AC 211 ms
11,788 KB
testcase_21 AC 213 ms
11,712 KB
testcase_22 AC 214 ms
11,472 KB
testcase_23 AC 210 ms
11,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define MOD 998244353
#define MAX 1000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<ll,int>> x;
  for(int i=0;i<N;i++){
    ll A;
    cin>>A;
    x.push_back(make_pair(A,1));
  }
  for(int j=0;j<M;j++){
    ll B;
    cin>>B;
    x.push_back(make_pair(B,0));
  }
  x.push_back(make_pair(-INF,1));
  x.push_back(make_pair(2*INF,1));
  sort(x.begin(),x.end());
  ll ans=x[N+M+1].first-x[0].first;
  ll y=0;
  for(int i=0;i<=N+M;i++){
    y=max<ll>(y,x[i+1].first-x[i].first);
    if(x[i+1].second==1){
      ans-=y;
      y=0;
    }
  }
  cout<<ans<<'\n';

}
0