結果

問題 No.2248 max(C)-min(C)
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-04 23:29:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 328 ms / 3,000 ms
コード長 1,038 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 121,712 KB
実行使用メモリ 19,116 KB
最終ジャッジ日時 2024-11-22 12:54:45
合計ジャッジ時間 12,442 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 3 ms
5,248 KB
testcase_04 AC 3 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 3 ms
5,248 KB
testcase_07 AC 3 ms
5,248 KB
testcase_08 AC 4 ms
5,248 KB
testcase_09 AC 4 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 4 ms
5,248 KB
testcase_12 AC 3 ms
5,248 KB
testcase_13 AC 4 ms
5,248 KB
testcase_14 AC 4 ms
5,248 KB
testcase_15 AC 4 ms
5,248 KB
testcase_16 AC 3 ms
5,248 KB
testcase_17 AC 4 ms
5,248 KB
testcase_18 AC 170 ms
17,400 KB
testcase_19 AC 24 ms
5,248 KB
testcase_20 AC 190 ms
18,984 KB
testcase_21 AC 181 ms
18,352 KB
testcase_22 AC 128 ms
14,888 KB
testcase_23 AC 82 ms
10,252 KB
testcase_24 AC 34 ms
6,340 KB
testcase_25 AC 172 ms
17,956 KB
testcase_26 AC 154 ms
16,672 KB
testcase_27 AC 169 ms
17,712 KB
testcase_28 AC 19 ms
5,248 KB
testcase_29 AC 159 ms
16,900 KB
testcase_30 AC 67 ms
9,176 KB
testcase_31 AC 188 ms
18,984 KB
testcase_32 AC 39 ms
6,644 KB
testcase_33 AC 60 ms
8,000 KB
testcase_34 AC 193 ms
18,980 KB
testcase_35 AC 188 ms
19,112 KB
testcase_36 AC 187 ms
19,116 KB
testcase_37 AC 99 ms
11,448 KB
testcase_38 AC 249 ms
18,984 KB
testcase_39 AC 245 ms
19,112 KB
testcase_40 AC 282 ms
18,980 KB
testcase_41 AC 220 ms
17,296 KB
testcase_42 AC 262 ms
19,112 KB
testcase_43 AC 220 ms
17,532 KB
testcase_44 AC 253 ms
18,988 KB
testcase_45 AC 202 ms
16,116 KB
testcase_46 AC 103 ms
10,060 KB
testcase_47 AC 244 ms
19,116 KB
testcase_48 AC 191 ms
19,112 KB
testcase_49 AC 321 ms
19,112 KB
testcase_50 AC 326 ms
19,112 KB
testcase_51 AC 328 ms
18,984 KB
testcase_52 AC 327 ms
19,112 KB
testcase_53 AC 47 ms
6,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_map.h:63,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/map:61,
                 from main.cpp:4:
In constructor 'constexpr std::_Head_base<_Idx, _Head, false>::_Head_base(_UHead&&) [with _UHead = int&; long unsigned int _Idx = 2; _Head = int]',
    inlined from 'constexpr std::_Tuple_impl<_Idx, _Head>::_Tuple_impl(_UHead&&) [with _UHead = int&; long unsigned int _Idx = 2; _Head = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:441:38,
    inlined from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(_UHead&&, _UTail&& ...) [with _UHead = int&; _UTail = {int&}; <template-parameter-2-3> = void; long unsigned int _Idx = 1; _Head = int; _Tail = {int}]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:292:38,
    inlined from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(_UHead&&, _UTail&& ...) [with _UHead = int&; _UTail = {int&, int&}; <template-parameter-2-3> = void; long unsigned int _Idx = 0; _Head = int; _Tail = {int, int}]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:292:38,
    inlined from 'constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {int&, int&, int&}; bool _Valid = true; typename std::enable_if<_TCC<_Valid>::__is_implicitly_constructible<_UElements ...>(), bool>::type <anonymous> = true; _Elements = {int, int, int}]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:744:54,
    inlined from 'int main()' at main.cpp:32:17:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/tuple:200:11: warning: 'u' may be used uninitialized [-Wmaybe-uninitialized]
  200 |         : _M_head_impl(std::forward<_UHead>(__h)) { }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:21:30: note: 'u' was dec

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

template<typename T> using pq = priority_queue<T, vector<T>, greater<T>>;

int main(){

    int N, mx=0, c, ans=1e9, u, v;
    cin >> N;
    vector<int> A(N), B(N);
    vector<vector<int>> C(N, vector<int>(3));
    pq<tuple<int, int, int>> que;
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++) cin >> B[i];

    for (int i=0; i<N; i++){
        if (A[i] > B[i]) swap(A[i], B[i]);
        C[i][0] = A[i]; C[i][1] = (A[i]+B[i])/2; C[i][2] = B[i];
        que.push({A[i], i, u});
        mx = max(mx, A[i]);
    }

    while(1){
        tie(c, u, v) = que.top();
        que.pop();
        ans = min(ans, mx-c);
        if (v == 2) break;
        mx = max(mx, C[u][v+1]);
        que.push({C[u][v+1], u, v+1});
    }

    cout << ans << endl;

    return 0;
}
0