結果
問題 |
No.1767 BLUE to RED
|
ユーザー |
![]() |
提出日時 | 2021-11-26 23:27:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 225 ms / 2,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 3,784 ms |
コンパイル使用メモリ | 235,052 KB |
実行使用メモリ | 11,720 KB |
最終ジャッジ日時 | 2024-06-29 18:34:59 |
合計ジャッジ時間 | 8,010 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#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'; }