結果

問題 No.9 モンスターのレベル上げ
ユーザー mh72012246mh72012246
提出日時 2016-11-07 16:19:15
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 428 ms / 5,000 ms
コード長 1,374 bytes
コンパイル時間 778 ms
使用メモリ 3,576 KB
最終ジャッジ日時 2023-01-21 16:08:09
合計ジャッジ時間 5,396 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,376 KB
testcase_01 AC 1 ms
3,464 KB
testcase_02 AC 428 ms
3,428 KB
testcase_03 AC 342 ms
3,412 KB
testcase_04 AC 179 ms
3,536 KB
testcase_05 AC 118 ms
3,508 KB
testcase_06 AC 40 ms
3,396 KB
testcase_07 AC 2 ms
3,532 KB
testcase_08 AC 53 ms
3,464 KB
testcase_09 AC 414 ms
3,556 KB
testcase_10 AC 2 ms
3,524 KB
testcase_11 AC 351 ms
3,424 KB
testcase_12 AC 271 ms
3,432 KB
testcase_13 AC 214 ms
3,496 KB
testcase_14 AC 415 ms
3,576 KB
testcase_15 AC 379 ms
3,420 KB
testcase_16 AC 8 ms
3,384 KB
testcase_17 AC 241 ms
3,520 KB
testcase_18 AC 204 ms
3,416 KB
testcase_19 AC 5 ms
3,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <sstream>   // istringstream
#include <algorithm> // sort
#include <utility>   // pair
#include <cfloat>    // DBL_MAX

typedef long long ll;
using namespace std;

// const int maxN = 200000;
// bool ps[maxN-1];

int main(){
  ll N; // [1500]
  cin >> N;

  priority_queue<pair<int,int>,
                 vector<pair<int,int> >,
                 greater<pair<int,int> > > party;
  vector<int> monster(N);
  for(int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    party.push(make_pair(tmp,0));
  }
  for(int i=0; i<N; i++){
    cin >> monster[i];
  }

  // main
  int minmaxb = 2000; // > 1500
  // for from each monster begin,
  for(int i=0; i<N; i++){
    priority_queue<pair<int,int>,
                   vector<pair<int,int> >,
                   greater<pair<int,int> > > sim(party);
    // the result becomes,
    for(int j=0; j<N; j++){
      sim.push(make_pair(sim.top().first+monster[(i+j)%N]/2,
                         sim.top().second+1));
      sim.pop();
    }
    // max battle is,
    int maxb = 0;
    while(!sim.empty()){
      maxb = max(maxb, sim.top().second);
      //cout << sim.top().first<<" "<<sim.top().second<<",";
      sim.pop();
    }
    minmaxb = min(minmaxb, maxb);
  }

  cout << minmaxb << endl;

  return 0;
}
0