結果
問題 | No.2248 max(C)-min(C) |
ユーザー | 👑 p-adic |
提出日時 | 2023-06-02 13:45:29 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,056 ms / 3,000 ms |
コード長 | 2,687 bytes |
コンパイル時間 | 3,359 ms |
コンパイル使用メモリ | 230,240 KB |
実行使用メモリ | 125,312 KB |
最終ジャッジ日時 | 2024-06-08 21:54:59 |
合計ジャッジ時間 | 34,073 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
12,800 KB |
testcase_01 | AC | 9 ms
12,800 KB |
testcase_02 | AC | 9 ms
12,672 KB |
testcase_03 | AC | 11 ms
13,184 KB |
testcase_04 | AC | 11 ms
13,184 KB |
testcase_05 | AC | 10 ms
12,928 KB |
testcase_06 | AC | 12 ms
13,824 KB |
testcase_07 | AC | 13 ms
13,824 KB |
testcase_08 | AC | 13 ms
13,952 KB |
testcase_09 | AC | 12 ms
13,824 KB |
testcase_10 | AC | 10 ms
12,928 KB |
testcase_11 | AC | 13 ms
13,824 KB |
testcase_12 | AC | 11 ms
13,312 KB |
testcase_13 | AC | 12 ms
13,568 KB |
testcase_14 | AC | 13 ms
13,952 KB |
testcase_15 | AC | 13 ms
13,824 KB |
testcase_16 | AC | 12 ms
13,184 KB |
testcase_17 | AC | 13 ms
13,952 KB |
testcase_18 | AC | 858 ms
110,976 KB |
testcase_19 | AC | 74 ms
25,604 KB |
testcase_20 | AC | 998 ms
125,184 KB |
testcase_21 | AC | 938 ms
119,552 KB |
testcase_22 | AC | 612 ms
87,296 KB |
testcase_23 | AC | 350 ms
60,672 KB |
testcase_24 | AC | 118 ms
31,616 KB |
testcase_25 | AC | 902 ms
114,688 KB |
testcase_26 | AC | 770 ms
103,296 KB |
testcase_27 | AC | 890 ms
113,792 KB |
testcase_28 | AC | 57 ms
22,784 KB |
testcase_29 | AC | 820 ms
106,624 KB |
testcase_30 | AC | 276 ms
50,816 KB |
testcase_31 | AC | 1,056 ms
125,312 KB |
testcase_32 | AC | 144 ms
34,432 KB |
testcase_33 | AC | 256 ms
47,872 KB |
testcase_34 | AC | 1,010 ms
125,184 KB |
testcase_35 | AC | 998 ms
125,184 KB |
testcase_36 | AC | 996 ms
125,184 KB |
testcase_37 | AC | 439 ms
71,168 KB |
testcase_38 | AC | 1,001 ms
117,632 KB |
testcase_39 | AC | 1,001 ms
117,760 KB |
testcase_40 | AC | 1,016 ms
117,632 KB |
testcase_41 | AC | 829 ms
103,168 KB |
testcase_42 | AC | 1,011 ms
117,632 KB |
testcase_43 | AC | 869 ms
106,112 KB |
testcase_44 | AC | 1,024 ms
117,760 KB |
testcase_45 | AC | 750 ms
95,488 KB |
testcase_46 | AC | 349 ms
57,344 KB |
testcase_47 | AC | 998 ms
117,760 KB |
testcase_48 | AC | 382 ms
87,808 KB |
testcase_49 | AC | 991 ms
125,184 KB |
testcase_50 | AC | 1,013 ms
125,184 KB |
testcase_51 | AC | 1,025 ms
125,184 KB |
testcase_52 | AC | 997 ms
125,184 KB |
testcase_53 | AC | 130 ms
31,488 KB |
ソースコード
#ifdef DEBUG #define _GLIBCXX_DEBUG #define CERR( ANSWER ) cerr << ANSWER << "\n"; #else #pragma GCC optimize ( "O3" ) #pragma GCC optimize( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #define CERR( ANSWER ) #endif #include <bits/stdc++.h> using namespace std; using ll = long long; #define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) #define CEXPR( LL , BOUND , VALUE ) constexpr const LL BOUND = VALUE #define CIN( LL , A ) LL A; cin >> A #define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) ) #define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) #define FOREQINV( VAR , INITIAL , FINAL ) for( TYPE_OF( INITIAL ) VAR = INITIAL ; VAR >= FINAL ; VAR -- ) #define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) #define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) #define QUIT return 0 #define COUT( ANSWER ) cout << ( ANSWER ) << "\n" #define RETURN( ANSWER ) COUT( ANSWER ); QUIT int main() { UNTIE; CEXPR( int , bound_N , 200000 ); CIN_ASSERT( N , 1 , bound_N ); CEXPR( int , bound_ABi , 1000000000 ); static set<int> AB[bound_N] = {}; map<int,set<int> > Cmin{}; FOR( i , 0 , N ){ CIN_ASSERT( Ai , 0 , bound_ABi ); assert( Ai % 2 == 0 ); AB[i].insert( Ai ); Cmin[Ai].insert( i ); } int Cmax = 0; FOR( i , 0 , N ){ CIN_ASSERT( Bi , 0 , bound_ABi ); assert( Bi % 2 == 0 ); set<int>& ABi = AB[i]; const int& Ai = *ABi.begin(); int mid = ( Ai + Bi ) / 2; ABi.insert( mid ); Cmin[mid].insert( i ); ABi.insert( Bi ); Cmin[Bi].insert( i ); Ai < Bi ? Cmax < Ai ? Cmax = Ai : Cmax : Cmax < Bi ? Cmax = Bi : Cmax; } int answer = bound_ABi; auto itr_Cmin = Cmin.begin(); while( ! Cmin.empty() ){ int temp = Cmax - itr_Cmin->first; CERR( Cmax << "-" << itr_Cmin->first << "=" << temp ); answer > temp ? answer = temp : answer; FOR_ITR( itr_Cmin->second , itr_i , end_i ){ set<int>& ABi = AB[*itr_i]; if( ABi.size() == 1 ){ RETURN( answer ); } auto itr_ABi = ABi.begin(); itr_ABi = ABi.erase( itr_ABi ); CERR( Cmax << "<" << *itr_ABi << "?" ); Cmax < *itr_ABi ? Cmax = *itr_ABi : Cmax; } itr_Cmin = Cmin.erase( itr_Cmin ); } QUIT; }