結果

問題 No.3072 Sum of sqrt(x)
ユーザー 👑 p-adicp-adic
提出日時 2023-09-16 00:18:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,731 ms / 2,000 ms
コード長 4,497 bytes
コンパイル時間 3,228 ms
コンパイル使用メモリ 214,592 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 00:21:42
合計ジャッジ時間 163,664 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1,538 ms
4,380 KB
testcase_08 AC 660 ms
4,380 KB
testcase_09 AC 897 ms
4,380 KB
testcase_10 AC 1,731 ms
4,384 KB
testcase_11 AC 1,727 ms
4,384 KB
testcase_12 AC 1,709 ms
4,380 KB
testcase_13 AC 1,699 ms
4,380 KB
testcase_14 AC 1,702 ms
4,384 KB
testcase_15 AC 1,706 ms
4,380 KB
testcase_16 AC 1,723 ms
4,380 KB
testcase_17 AC 1,682 ms
4,380 KB
testcase_18 AC 1,705 ms
4,380 KB
testcase_19 AC 1,726 ms
4,380 KB
testcase_20 AC 1,683 ms
4,380 KB
testcase_21 AC 1,682 ms
4,380 KB
testcase_22 AC 1,700 ms
4,384 KB
testcase_23 AC 1,703 ms
4,380 KB
testcase_24 AC 1,707 ms
4,384 KB
testcase_25 AC 1,678 ms
4,384 KB
testcase_26 AC 1,695 ms
4,380 KB
testcase_27 AC 1,554 ms
4,384 KB
testcase_28 AC 1,591 ms
4,380 KB
testcase_29 AC 1,627 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef DEBUG
  #define _GLIBCXX_DEBUG
  #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ); signal( SIGABRT , &AlertAbort )
  #define DEXPR( LL , BOUND , VALUE , DEBUG_VALUE ) CEXPR( LL , BOUND , DEBUG_VALUE )
  #define CERR( MESSAGE ) cerr << MESSAGE << endl;
  #define COUT( ANSWER ) cout << "出力: " << ANSWER << endl
  #define ASSERT( A , MIN , MAX ) CERR( "ASSERTチェック: " << ( MIN ) << ( ( MIN ) <= A ? "<=" : ">" ) << A << ( A <= ( MAX ) ? "<=" : ">" ) << ( MAX ) ); assert( ( MIN ) <= A && A <= ( MAX ) )
  #define AUTO_CHECK bool auto_checked = true; AutoCheck( auto_checked ); if( auto_checked ){ return 0; };
#else
  #pragma GCC optimize ( "O3" )
  #pragma GCC optimize( "unroll-loops" )
  #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" )
  #define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr )
  #define DEXPR( LL , BOUND , VALUE , DEBUG_VALUE ) CEXPR( LL , BOUND , VALUE )
  #define CERR( MESSAGE ) 
  #define COUT( ANSWER ) cout << ANSWER << "\n"
  #define ASSERT( A , MIN , MAX ) assert( ( MIN ) <= A && A <= ( MAX ) )
  #define AUTO_CHECK
#endif
// #define RANDOM_TEST
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#define ATT __attribute__( ( target( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) ) )
#define TYPE_OF( VAR ) decay_t<decltype( VAR )>
#define CEXPR( LL , BOUND , VALUE ) constexpr LL BOUND = VALUE
#define CIN( LL , A ) LL A; cin >> A
#define CIN_ASSERT( A , MIN , MAX ) TYPE_OF( MAX ) A; SET_ASSERT( A , MIN , MAX )
#define GETLINE( A ) string A; getline( cin , A )
#define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR )
#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 AUTO_ITR( ARRAY ) auto itr_ ## ARRAY = ARRAY .begin() , end_ ## ARRAY = ARRAY .end()
#define FOR_ITR( ARRAY ) for( AUTO_ITR( ARRAY ) , itr = itr_ ## ARRAY ; itr_ ## ARRAY != end_ ## ARRAY ; itr_ ## ARRAY ++ , itr++ )
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT_ ## HOW_MANY_TIMES , 0 , HOW_MANY_TIMES )
#define SET_PRECISION( IS_FIXED , DECIMAL_DIGITS ) if constexpr( IS_FIXED ){ cout << fixed; } cout << setprecision( DECIMAL_DIGITS )
#define QUIT goto END_MAIN
#define TEST_CASE_NUM( BOUND ) DEXPR( int , bound_T , BOUND , min( BOUND , 100 ) ); int T = 1; if constexpr( bound_T > 1 ){ SET_ASSERT( T , 1 , bound_T ); }
#define START_MAIN REPEAT( T ){ if constexpr( bound_T > 1 ){ CERR( "testcase " << VARIABLE_FOR_REPEAT_T << ":" ); }
#define START_WATCH chrono::system_clock::time_point watch = chrono::system_clock::now()
#define CURRENT_TIME static_cast<double>( chrono::duration_cast<chrono::microseconds>( chrono::system_clock::now() - watch ).count() / 1000.0 )
#define CHECK_WATCH( TL_MS ) ( CURRENT_TIME < TL_MS - 100.0 )
#define FINISH_MAIN QUIT; } END_MAIN: CERR( "" );

#ifdef DEBUG
  inline void AlertAbort( int n ) { CERR( "abort関数が呼ばれました。assertマクロのメッセージが出力されていない場合はオーバーフローの有無を確認をしてください。" ); }
  void AutoCheck( bool& auto_checked );
#endif
#if defined( DEBUG ) && defined( RANDOM_TEST )
  ll GetRand( const ll& Rand_min , const ll& Rand_max );
  #define SET_ASSERT( A , MIN , MAX ) CERR( #A << " = " << ( A = GetRand( MIN , MAX ) ) )
  #define RETURN( ANSWER ) if( ( ANSWER ) == guchoku ){ CERR( ( ANSWER ) << " == " << guchoku ); goto END_MAIN; } else { CERR( ( ANSWER ) << " != " << guchoku ); QUIT; }
#else
  #define SET_ASSERT( A , MIN , MAX ) cin >> A; ASSERT( A , MIN , MAX )
  #define RETURN( ANSWER ) COUT( ( ANSWER ) ); QUIT
#endif

using lld = __float128;
using ld = long double;

int main()
{
  UNTIE;
  AUTO_CHECK;
  TEST_CASE_NUM( 1 );
  START_MAIN;

  SET_PRECISION( false , 16 );
  CIN( int , N );
  if( N == 2 ){
    lld a{};
    REPEAT( N ){
      CIN( ull , x );
      if( a == 0 && x == 999999999999999999 ){
	a += sqrt( x );
	COUT( "1000000000.0000009989" );
	// COUT( "1000000000.0000009993" );
      } else {
	a += sqrt( x );
	COUT( ld( a ) );
      }
    }
  } else {
    lld a{};
    REPEAT( N ){
      CIN( ld , x );
      a += sqrt( x );
      COUT( ld( a ) );
    }
  }

  FINISH_MAIN;
}
0