結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー 0w10w1
提出日時 2016-12-21 17:37:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 394 ms / 5,000 ms
コード長 1,438 bytes
コンパイル時間 1,620 ms
コンパイル使用メモリ 174,712 KB
実行使用メモリ 9,476 KB
最終ジャッジ日時 2023-08-21 04:04:56
合計ジャッジ時間 13,394 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 393 ms
9,232 KB
testcase_01 AC 393 ms
9,316 KB
testcase_02 AC 391 ms
9,444 KB
testcase_03 AC 375 ms
9,252 KB
testcase_04 AC 379 ms
9,352 KB
testcase_05 AC 394 ms
9,476 KB
testcase_06 AC 388 ms
8,920 KB
testcase_07 AC 391 ms
9,440 KB
testcase_08 AC 371 ms
9,020 KB
testcase_09 AC 371 ms
9,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< int, int > pii;
typedef vector< pii > vp;
typedef vector< double > vd;
typedef vector< vd > vvd;
typedef vector< string > vs;

template< class T1, class T2 >
int upmin( T1 &x, T2 v ){
  if( x > v ){
    x = v;
    return 1;
  }
  return 0;
}

template< class T1, class T2 >
int upmax( T1 &x, T2 v ){
  if( x < v ){
    x = v;
    return 1;
  }
  return 0;
}

const int INF = 0x3f3f3f3f;

const int MAXN = ( int ) 1e5;
const int MAXQ = ( int ) 1e5;

int N;
int L[ MAXN ];
int Q;
int K[ MAXQ ];

void init(){
  cin >> N;
  for( int i = 0; i < N; ++i )
    cin >> L[ i ];
  cin >> Q;
  for( int i = 0; i < Q; ++i )
    cin >> K[ i ];
}

const int MAXK = ( int ) 5e5;

double ans[ MAXK + 1 ];

void preprocess(){

  priority_queue< tuple< double, int, int > > pq;
  for( int i = 0; i < N; ++i )
    pq.emplace( 1.0 * L[ i ], i, 1 );
  for( int quantity = 1; quantity <= MAXK; ++quantity ){
    double len; int id, q; tie( len, id, q ) = pq.top(); pq.pop();
    ans[ quantity ] = len;
    pq.emplace( 1.0 * L[ id ] / ( q + 1 ), id, q + 1 );
  }
}

void solve(){
  for( int i = 0; i < Q; ++i )
    cout << fixed << setprecision( 12 ) << ans[ K[ i ] ] << endl;
}

signed main(){
  ios::sync_with_stdio( 0 );
  init();
  preprocess();
  solve();
  return 0;
}
0